Avoid coredump if witness index does not exist

This commit is contained in:
Duke
2025-08-22 07:34:11 -04:00
parent fb7d669f14
commit 34829af017

View File

@@ -428,16 +428,14 @@ bool AsyncRPCOperation_sendmany::main_impl() {
// Add Sapling spends
for (size_t i = 0; i < saplingNoteInputs_.size(); i++) {
//LOCK2(cs_main, pwalletMain->cs_wallet);
//TODO: avoid coredump here if this index does not exist
if (!witnesses[i]) {
if (!witnesses.at(i)) {
throw JSONRPCError(RPC_WALLET_ERROR,
strprintf( "Missing witness for Sapling note at outpoint %s", std::get<0>(saplingNoteInputs_[i]).ToString())
);
}
if(fZdebug)
LogPrintf("%s: Adding Sapling spend\n", __func__);
assert(builder_.AddSaplingSpend(expsk, std::get<1>(saplingNoteInputs_[i]), anchor, witnesses[i].get()));
}