[Contracts] Cancel self-spend TX Pt. 2 (#703)

* add tests + legacy self send cancel

* add missing file
This commit is contained in:
Yeastplume 2024-02-23 09:24:47 +00:00 committed by GitHub
parent f94a0a4a08
commit 6f226ea3e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -359,10 +359,10 @@ where
Some(&parent_key_id), Some(&parent_key_id),
false, false,
)?; )?;
if tx_vec.len() != 1 { if tx_vec.len() == 0 {
return Err(Error::TransactionDoesntExist(tx_id_string)); return Err(Error::TransactionDoesntExist(tx_id_string));
} }
let tx = tx_vec[0].clone(); for tx in tx_vec {
debug!("cancel_tx: tx: {}", tx.tx_type); debug!("cancel_tx: tx: {}", tx.tx_type);
match tx.tx_type { match tx.tx_type {
TxLogEntryType::TxSent TxLogEntryType::TxSent
@ -384,6 +384,7 @@ where
)?; )?;
let outputs = res.iter().map(|m| m.output.clone()).collect(); let outputs = res.iter().map(|m| m.output.clone()).collect();
updater::cancel_tx_and_outputs(wallet, keychain_mask, tx, outputs, parent_key_id)?; updater::cancel_tx_and_outputs(wallet, keychain_mask, tx, outputs, parent_key_id)?;
}
Ok(()) Ok(())
} }