Skip to content

Commit

Permalink
fixup! refactor: change BlindTransaction to return more detailed erro…
Browse files Browse the repository at this point in the history
…r information
  • Loading branch information
delta1 committed Nov 27, 2023
1 parent 8938a0e commit a31e125
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/wallet/spend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1445,6 +1445,10 @@ static bool CreateTransactionInternal(
assert(info.status == BlindStatus::SUCCESS || (info.status == BlindStatus::ERR_SINGLE_ATTEMPT_WITH_NO_INPUT_BLINDS && blind_details->num_to_blind == 0));
if (info.num_blinded != blind_details->num_to_blind) {
auto message = strprintf("Unable to blind transaction: Number to blind: %d. Number blinded: %d.", blind_details->num_to_blind, info.num_blinded);
auto num_inputs = result->GetInputSet().size();
if (num_inputs > 256) {
message = strprintf("Unable to blind transaction. Only 256 inputs can be blinded at once. Transaction has %d inputs.", num_inputs);
}
error = Untranslated(message);
return false;
}
Expand Down Expand Up @@ -1651,8 +1655,12 @@ static bool CreateTransactionInternal(
assert(info.status == BlindStatus::SUCCESS || (info.status == BlindStatus::ERR_SINGLE_ATTEMPT_WITH_NO_INPUT_BLINDS && blind_details->num_to_blind == 0));
if (info.num_blinded != blind_details->num_to_blind) {
auto status = BlindStatusString(info.status);
wallet.WalletLogPrintf("ERROR: tried to blind %d outputs but only blinded %d. Blind status: %s\n", (int)blind_details->num_to_blind, info.num_blinded, status);
auto message = strprintf("Unable to blind transaction: %s Number of blinded outputs: %d.", status, info.num_blinded);
auto num_inputs = result->GetInputSet().size();
wallet.WalletLogPrintf("ERROR: tried to blind %d outputs but only blinded %d. Number of inputs: %d. Blind status: %s\n", (int)blind_details->num_to_blind, info.num_blinded, num_inputs, status);
if (num_inputs > 256) {
message = strprintf("Unable to blind transaction. Only 256 inputs can be blinded at once. Transaction has %d inputs.", num_inputs);
}
error = Untranslated(message);
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion test/functional/rpc_fundrawtransaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -1287,7 +1287,7 @@ def test_surjectionproof_many_inputs(self):
# ...and try to send them all in one transaction
# This should fail but we should not see an assertion failure.
rawtx = recipient.createrawtransaction([], [{wallet.getnewaddress(): 49.99}])
assert_raises_rpc_error(-4, "Unable to blind transaction: Number to blind: 2. Number blinded: 0.", recipient.fundrawtransaction, rawtx)
assert_raises_rpc_error(-4, "Unable to blind transaction. Only 256 inputs can be blinded at once. Transaction has 500 inputs.", recipient.fundrawtransaction, rawtx)

# Try to send them across two transactions. This should succeed.
rawtx = recipient.createrawtransaction([], [{wallet.getnewaddress(): 24.99}])
Expand Down

0 comments on commit a31e125

Please sign in to comment.