[bug] prevent freezed utxos being accidentally unlocked
This commit is contained in:
parent
8b2af9b937
commit
00821af9a7
@ -265,6 +265,8 @@ fn commit_new_transaction(
|
|||||||
.ok_or(Error::msg("Wallet not initialized"))?
|
.ok_or(Error::msg("Wallet not initialized"))?
|
||||||
.get_wallet()?;
|
.get_wallet()?;
|
||||||
|
|
||||||
|
let commitment_payload = Vec::from(state_to_commit.state_id);
|
||||||
|
|
||||||
let mut recipients = vec![];
|
let mut recipients = vec![];
|
||||||
recipients.push(Recipient {
|
recipients.push(Recipient {
|
||||||
address: sp_wallet.get_client().get_receiving_address(),
|
address: sp_wallet.get_client().get_receiving_address(),
|
||||||
@ -294,16 +296,12 @@ fn commit_new_transaction(
|
|||||||
let mut freezed_utxos = lock_freezed_utxos()?;
|
let mut freezed_utxos = lock_freezed_utxos()?;
|
||||||
|
|
||||||
let next_commited_in = updated_process.get_process_tip()?;
|
let next_commited_in = updated_process.get_process_tip()?;
|
||||||
let mandatory_input = if let Some(next_outpoint) = freezed_utxos.take(&next_commited_in) {
|
if !freezed_utxos.contains(&next_commited_in) {
|
||||||
next_outpoint
|
|
||||||
} else {
|
|
||||||
return Err(Error::msg(format!("Missing next commitment outpoint for process {}", updated_process.get_process_id()?)));
|
return Err(Error::msg(format!("Missing next commitment outpoint for process {}", updated_process.get_process_id()?)));
|
||||||
};
|
};
|
||||||
|
|
||||||
let commitment_payload = Vec::from_hex(state_to_commit.state_id.clone())?;
|
|
||||||
|
|
||||||
let psbt = create_transaction(
|
let psbt = create_transaction(
|
||||||
vec![mandatory_input],
|
vec![next_commited_in],
|
||||||
&freezed_utxos,
|
&freezed_utxos,
|
||||||
&sp_wallet,
|
&sp_wallet,
|
||||||
recipients,
|
recipients,
|
||||||
@ -318,6 +316,7 @@ fn commit_new_transaction(
|
|||||||
let commited_in = OutPoint::new(txid, 0);
|
let commited_in = OutPoint::new(txid, 0);
|
||||||
|
|
||||||
freezed_utxos.insert(commited_in);
|
freezed_utxos.insert(commited_in);
|
||||||
|
freezed_utxos.remove(&next_commited_in);
|
||||||
updated_process.remove_all_concurrent_states()?;
|
updated_process.remove_all_concurrent_states()?;
|
||||||
updated_process.insert_concurrent_state(state_to_commit)?;
|
updated_process.insert_concurrent_state(state_to_commit)?;
|
||||||
updated_process.update_states_tip(commited_in)?;
|
updated_process.update_states_tip(commited_in)?;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user