addition of self-spend cancel + tests (#699)

This commit is contained in:
Yeastplume
2024-02-15 10:04:18 +00:00
committed by GitHub
parent 02af39143e
commit 074fa243b5
3 changed files with 100 additions and 1 deletions
+5 -1
View File
@@ -363,8 +363,12 @@ where
return Err(Error::TransactionDoesntExist(tx_id_string));
}
let tx = tx_vec[0].clone();
debug!("cancel_tx: tx: {}", tx.tx_type);
match tx.tx_type {
TxLogEntryType::TxSent | TxLogEntryType::TxReceived | TxLogEntryType::TxReverted => {}
TxLogEntryType::TxSent
| TxLogEntryType::TxReceived
| TxLogEntryType::TxReverted
| TxLogEntryType::TxSelfSpend => {}
_ => return Err(Error::TransactionNotCancellable(tx_id_string)),
}
if tx.confirmed {
+2
View File
@@ -112,6 +112,7 @@ where
if v {
tx_entry.tx_type != TxLogEntryType::TxReceivedCancelled
&& tx_entry.tx_type != TxLogEntryType::TxSentCancelled
&& tx_entry.tx_type != TxLogEntryType::TxSelfSpendCancelled
} else {
true
}
@@ -491,6 +492,7 @@ where
TxLogEntryType::TxReceived | TxLogEntryType::TxReverted => {
tx.tx_type = TxLogEntryType::TxReceivedCancelled
}
TxLogEntryType::TxSelfSpend => tx.tx_type = TxLogEntryType::TxSelfSpendCancelled,
_ => {}
}
batch.save_tx_log_entry(tx, parent_key_id)?;