Wait until after find_unspent_notes() to lock notes in z_sendmany
This commit is contained in:
@@ -120,11 +120,6 @@ AsyncRPCOperation_sendmany::AsyncRPCOperation_sendmany(
|
|||||||
LogPrint("zrpc", "%s: z_sendmany initialized\n", getId());
|
LogPrint("zrpc", "%s: z_sendmany initialized\n", getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lock UTXOs
|
|
||||||
lock_utxos();
|
|
||||||
// Lock shielded input notes
|
|
||||||
lock_notes();
|
|
||||||
LogPrint("zrpc", "%s: z_sendmany input notes locked\n", getId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AsyncRPCOperation_sendmany::~AsyncRPCOperation_sendmany() {
|
AsyncRPCOperation_sendmany::~AsyncRPCOperation_sendmany() {
|
||||||
@@ -240,6 +235,15 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
|||||||
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Insufficient funds, no unspent notes found for zaddr from address.");
|
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Insufficient funds, no unspent notes found for zaddr from address.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Now that find_unspent_notes() has run, we now know which
|
||||||
|
// notes need to be locked
|
||||||
|
|
||||||
|
// Lock UTXOs
|
||||||
|
lock_utxos();
|
||||||
|
// Lock shielded input notes
|
||||||
|
lock_notes();
|
||||||
|
LogPrint("zrpc", "%s: z_sendmany input notes locked\n", getId());
|
||||||
|
|
||||||
CAmount t_inputs_total = 0;
|
CAmount t_inputs_total = 0;
|
||||||
for (SendManyInputUTXO & t : t_inputs_) {
|
for (SendManyInputUTXO & t : t_inputs_) {
|
||||||
t_inputs_total += std::get<2>(t);
|
t_inputs_total += std::get<2>(t);
|
||||||
@@ -802,7 +806,7 @@ void AsyncRPCOperation_sendmany::unlock_utxos() {
|
|||||||
// Lock input notes
|
// Lock input notes
|
||||||
void AsyncRPCOperation_sendmany::lock_notes() {
|
void AsyncRPCOperation_sendmany::lock_notes() {
|
||||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||||
fprintf(stderr,"%s: found %d notes to lock\n", z_sapling_inputs_.count() );
|
fprintf(stderr,"%s: found %lu notes to lock\n", __func__, z_sapling_inputs_.size() );
|
||||||
for (auto note : z_sapling_inputs_) {
|
for (auto note : z_sapling_inputs_) {
|
||||||
pwalletMain->LockNote(note.op);
|
pwalletMain->LockNote(note.op);
|
||||||
}
|
}
|
||||||
@@ -811,7 +815,7 @@ void AsyncRPCOperation_sendmany::lock_notes() {
|
|||||||
// Unlock input notes
|
// Unlock input notes
|
||||||
void AsyncRPCOperation_sendmany::unlock_notes() {
|
void AsyncRPCOperation_sendmany::unlock_notes() {
|
||||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||||
fprintf(stderr,"%s: found %d notes to unlock\n", z_sapling_inputs_.count() );
|
fprintf(stderr,"%s: found %lu notes to unlock\n", __func__, z_sapling_inputs_.size() );
|
||||||
for (auto note : z_sapling_inputs_) {
|
for (auto note : z_sapling_inputs_) {
|
||||||
pwalletMain->UnlockNote(note.op);
|
pwalletMain->UnlockNote(note.op);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user