Skip to content

Commit a31e125

Browse files
committed
fixup! refactor: change BlindTransaction to return more detailed error information
1 parent 8938a0e commit a31e125

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/wallet/spend.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1445,6 +1445,10 @@ static bool CreateTransactionInternal(
14451445
assert(info.status == BlindStatus::SUCCESS || (info.status == BlindStatus::ERR_SINGLE_ATTEMPT_WITH_NO_INPUT_BLINDS && blind_details->num_to_blind == 0));
14461446
if (info.num_blinded != blind_details->num_to_blind) {
14471447
auto message = strprintf("Unable to blind transaction: Number to blind: %d. Number blinded: %d.", blind_details->num_to_blind, info.num_blinded);
1448+
auto num_inputs = result->GetInputSet().size();
1449+
if (num_inputs > 256) {
1450+
message = strprintf("Unable to blind transaction. Only 256 inputs can be blinded at once. Transaction has %d inputs.", num_inputs);
1451+
}
14481452
error = Untranslated(message);
14491453
return false;
14501454
}
@@ -1651,8 +1655,12 @@ static bool CreateTransactionInternal(
16511655
assert(info.status == BlindStatus::SUCCESS || (info.status == BlindStatus::ERR_SINGLE_ATTEMPT_WITH_NO_INPUT_BLINDS && blind_details->num_to_blind == 0));
16521656
if (info.num_blinded != blind_details->num_to_blind) {
16531657
auto status = BlindStatusString(info.status);
1654-
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);
16551658
auto message = strprintf("Unable to blind transaction: %s Number of blinded outputs: %d.", status, info.num_blinded);
1659+
auto num_inputs = result->GetInputSet().size();
1660+
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);
1661+
if (num_inputs > 256) {
1662+
message = strprintf("Unable to blind transaction. Only 256 inputs can be blinded at once. Transaction has %d inputs.", num_inputs);
1663+
}
16561664
error = Untranslated(message);
16571665
return false;
16581666
}

test/functional/rpc_fundrawtransaction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ def test_surjectionproof_many_inputs(self):
12871287
# ...and try to send them all in one transaction
12881288
# This should fail but we should not see an assertion failure.
12891289
rawtx = recipient.createrawtransaction([], [{wallet.getnewaddress(): 49.99}])
1290-
assert_raises_rpc_error(-4, "Unable to blind transaction: Number to blind: 2. Number blinded: 0.", recipient.fundrawtransaction, rawtx)
1290+
assert_raises_rpc_error(-4, "Unable to blind transaction. Only 256 inputs can be blinded at once. Transaction has 500 inputs.", recipient.fundrawtransaction, rawtx)
12911291

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

0 commit comments

Comments
 (0)