Clean up locks if z_sendmany is cancelled

This commit is contained in:
Duke
2025-05-30 08:22:31 -04:00
parent b43a4f2653
commit 88143a87fc

View File

@@ -131,8 +131,13 @@ AsyncRPCOperation_sendmany::~AsyncRPCOperation_sendmany() {
}
void AsyncRPCOperation_sendmany::main() {
if (isCancelled())
// clean up locks if we are cancelled
if (isCancelled()) {
unlock_utxos();
unlock_notes();
return;
}
set_state(OperationStatus::EXECUTING);
start_execution_clock();
@@ -797,6 +802,7 @@ void AsyncRPCOperation_sendmany::unlock_utxos() {
// Lock input notes
void AsyncRPCOperation_sendmany::lock_notes() {
LOCK2(cs_main, pwalletMain->cs_wallet);
fprintf(stderr,"%s: found %d notes to lock\n", z_sapling_inputs_.count() );
for (auto note : z_sapling_inputs_) {
pwalletMain->LockNote(note.op);
}
@@ -805,6 +811,7 @@ void AsyncRPCOperation_sendmany::lock_notes() {
// Unlock input notes
void AsyncRPCOperation_sendmany::unlock_notes() {
LOCK2(cs_main, pwalletMain->cs_wallet);
fprintf(stderr,"%s: found %d notes to unlock\n", z_sapling_inputs_.count() );
for (auto note : z_sapling_inputs_) {
pwalletMain->UnlockNote(note.op);
}