Skip to content

Commit c0b1706

Browse files
committed
Merge #19568: Wallet should not override signing errors
e7448d6 wallet: Don't override signing errors (Fabian Jahr) Pull request description: While reviewing #17204 I noticed that the errors in `input_errors` from `::SignTransaction` where being overridden by `CWallet::SignTransaction`. For example, a Script related error led to incomplete signature data which led to `CWallet::SignTransaction` reporting that keys were missing, which was a less precise error than the original one. Additionally, the error `"Input not found or already spent"` is [duplicated in `sign.cpp`](https://github.com/bitcoin/bitcoin/blob/c7b4968552c704f1e2e9a046911e1207f5af5fe0/src/script/sign.cpp#L481), so the error here is redundant at the moment. So technically the whole error block could be removed, I think. However, this code is affected by the ongoing work on the wallet so there might be a reason why these errors are here. But even if there is a reason to keep them, I don't think existing, potentially more precise errors should be overridden here unless we want to hide them from the users. I am looking for feedback if this is a work in progress state where these errors could be more useful in the future or if they can be removed. On testing: even though [the errors in `CWallet` are covered](https://marcofalke.github.io/btc_cov/total.coverage/src/wallet/wallet.cpp.gcov.html), all tests still pass after removing them. I am not sure if there is a desire to cover these specific error messages, tests in `test/functional/rpc_signrawtransaction.py` seem to aim for a more generic approach. ACKs for top commit: achow101: ACK e7448d6 meshcollider: Code review ACK e7448d6 Tree-SHA512: 3e2bc11d05379d2aef87b093a383d1b044787efc70e35955b2f8ecd028b6acef02f386180566af6a1a63193635f5d685466e2f6141c96326c49ffc5c81ca3e23
2 parents 31760bb + e7448d6 commit c0b1706

File tree

1 file changed

+0
-17
lines changed

1 file changed

+0
-17
lines changed

src/wallet/wallet.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2486,23 +2486,6 @@ bool CWallet::SignTransaction(CMutableTransaction& tx, const std::map<COutPoint,
24862486
}
24872487

24882488
// At this point, one input was not fully signed otherwise we would have exited already
2489-
// Find that input and figure out what went wrong.
2490-
for (unsigned int i = 0; i < tx.vin.size(); i++) {
2491-
// Get the prevout
2492-
CTxIn& txin = tx.vin[i];
2493-
auto coin = coins.find(txin.prevout);
2494-
if (coin == coins.end() || coin->second.IsSpent()) {
2495-
input_errors[i] = "Input not found or already spent";
2496-
continue;
2497-
}
2498-
2499-
// Check if this input is complete
2500-
SignatureData sigdata = DataFromTransaction(tx, i, coin->second.out);
2501-
if (!sigdata.complete) {
2502-
input_errors[i] = "Unable to sign input, missing keys";
2503-
continue;
2504-
}
2505-
}
25062489
return false;
25072490
}
25082491

0 commit comments

Comments
 (0)