Lock zins inside z_sendmany async operation

This commit is contained in:
Duke
2025-05-18 14:47:43 -04:00
parent d18e246a92
commit bd730cb927
2 changed files with 51 additions and 0 deletions

View File

@@ -119,6 +119,11 @@ AsyncRPCOperation_sendmany::AsyncRPCOperation_sendmany(
} else {
LogPrint("zrpc", "%s: z_sendmany initialized\n", getId());
}
// Lock UTXOs
//lock_utxos();
// Lock shielded input notes
lock_notes();
}
AsyncRPCOperation_sendmany::~AsyncRPCOperation_sendmany() {
@@ -185,6 +190,9 @@ void AsyncRPCOperation_sendmany::main() {
s += strprintf(", error=%s)\n", getErrorMessage());
}
LogPrintf("%s",s);
//unlock_utxos(); // clean up
unlock_notes(); // clean up
}
// Notes:
@@ -781,3 +789,41 @@ UniValue AsyncRPCOperation_sendmany::getStatus() const {
obj.push_back(Pair("params", contextinfo_ ));
return obj;
}
/* TODO: support locking taddr utxo inputs
// Lock input utxos
void AsyncRPCOperation_sendmany::lock_utxos() {
LOCK2(cs_main, pwalletMain->cs_wallet);
for (auto utxo : t_inputs_) {
COutPoint outpt(utxo.txid, utxo.vout);
pwalletMain->LockCoin(outpt);
}
}
// Unlock input utxos
void AsyncRPCOperation_sendmany::unlock_utxos() {
LOCK2(cs_main, pwalletMain->cs_wallet);
for (auto utxo : t_inputs_) {
COutPoint outpt(utxo.txid, utxo.vout);
pwalletMain->UnlockCoin(outpt);
}
}
*/
// Lock input notes
void AsyncRPCOperation_sendmany::lock_notes() {
LOCK2(cs_main, pwalletMain->cs_wallet);
for (auto note : z_sapling_inputs_) {
pwalletMain->LockNote(note.op);
}
}
// Unlock input notes
void AsyncRPCOperation_sendmany::unlock_notes() {
LOCK2(cs_main, pwalletMain->cs_wallet);
for (auto note : z_sapling_inputs_) {
pwalletMain->UnlockNote(note.op);
}
}

View File

@@ -112,6 +112,11 @@ private:
bool main_impl();
void sign_send_raw_transaction(UniValue obj); // throws exception if there was an error
void lock_utxos();
void unlock_utxos();
void lock_notes();
void unlock_notes();
};