Skip to content

Commit 0f8e095

Browse files
committed
Merge #11288: More user-friendly error message when partially signing
df10edf More user-friendly error message when partially signing (MeshCollider) Pull request description: When partially signing a transaction using `signrawtransaction`, if the wallet doesn't have access to a key, it will output a scary error message `"error": "Operation not valid with the current stack size"`, yet it will partially sign the transaction anyway. This puts a lot of users off, because they don't realise the signing actually succeeded for some inputs. This catches that specific error when signing, and outputs a friendlier message which says `Unable to sign input, invalid stack size (possibly missing key)`. This is the best way I could think of to fix the issue, but please let me know if you come up with a better way to do it :) Fixes bitcoin/bitcoin#9988 Tree-SHA512: 65e1d4a49caa4202e1357b0b3f42329d76456c7b4286d63232226e03267809027b0c44e0faaa1da8b86c9ad677e3a3d655698a24fc870d6a661203c9f56ef95b
2 parents 67879b7 + df10edf commit 0f8e095

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/rpc/rawtransaction.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,12 @@ UniValue signrawtransaction(const JSONRPCRequest& request)
873873

874874
ScriptError serror = SCRIPT_ERR_OK;
875875
if (!VerifyScript(txin.scriptSig, prevPubKey, &txin.scriptWitness, STANDARD_SCRIPT_VERIFY_FLAGS, TransactionSignatureChecker(&txConst, i, amount), &serror)) {
876-
TxInErrorToJSON(txin, vErrors, ScriptErrorString(serror));
876+
if (serror == SCRIPT_ERR_INVALID_STACK_OPERATION) {
877+
// Unable to sign input and verification failed (possible attempt to partially sign).
878+
TxInErrorToJSON(txin, vErrors, "Unable to sign input, invalid stack size (possibly missing key)");
879+
} else {
880+
TxInErrorToJSON(txin, vErrors, ScriptErrorString(serror));
881+
}
877882
}
878883
}
879884
bool fComplete = vErrors.empty();

0 commit comments

Comments
 (0)