Skip to content

Commit

Permalink
[RPC] More user-friendly error message when partially signing
Browse files Browse the repository at this point in the history
- see Bitcoin pull request: bitcoin/bitcoin#11288
  • Loading branch information
AmirAbrams committed Nov 22, 2019
1 parent cfec40a commit 41c999c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/rpc/rawtransaction.cpp
Expand Up @@ -841,14 +841,19 @@ UniValue signrawtransaction(const JSONRPCRequest& request)
SignSignature(keystore, prevPubKey, mergedTx, i, nHashType);

// ... and merge in other signatures:
BOOST_FOREACH (const CMutableTransaction& txv, txVariants) {
for (const CMutableTransaction& txv : txVariants) {
if (txv.vin.size() > i) {
txin.scriptSig = CombineSignatures(prevPubKey, txConst, i, txin.scriptSig, txv.vin[i].scriptSig);
}
}
ScriptError serror = SCRIPT_ERR_OK;
if (!VerifyScript(txin.scriptSig, prevPubKey, STANDARD_SCRIPT_VERIFY_FLAGS, TransactionSignatureChecker(&txConst, i), &serror)) {
TxInErrorToJSON(txin, vErrors, ScriptErrorString(serror));
if (serror == SCRIPT_ERR_INVALID_STACK_OPERATION) {
// Unable to sign input and verification failed (possible attempt to partially sign).
TxInErrorToJSON(txin, vErrors, "Unable to sign input, invalid stack size (possibly missing key)");
} else {
TxInErrorToJSON(txin, vErrors, ScriptErrorString(serror));
}
}
}
bool fComplete = vErrors.empty();
Expand Down

0 comments on commit 41c999c

Please sign in to comment.