aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Towns <aj@erisian.com.au>2018-06-27 17:54:32 +1000
committerLuke Dashjr <luke-jr+git@utopios.org>2018-07-29 20:26:45 +0000
commit1825e37075aa7885930cb48c5452ba3e8952b78a (patch)
treebbca238953ec9c475d758dfa326fae7b3c8a3e46
parent9d9c4185fadaf243bb97c226e2fef16b65299699 (diff)
Error on missing amount in signrawtransaction*
Signatures using segregated witness commit to the amount being spent, so that value must be passed into signrawtransactionwithkey and signrawtransactionwithwallet. This ensures an error is issued if that doesn't happen, rather than just assuming the value is 0 and producing a signature that is almost certainly invalid. Github-Pull: #13547 Rebased-From: a3b065b51fb333d976108a1fe34b7f663fd67285
-rw-r--r--src/rpc/rawtransaction.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp
index 82399e1567..3fbea1ff71 100644
--- a/src/rpc/rawtransaction.cpp
+++ b/src/rpc/rawtransaction.cpp
@@ -820,7 +820,7 @@ UniValue signrawtransaction(const JSONRPCRequest& request)
}
Coin newcoin;
newcoin.out.scriptPubKey = scriptPubKey;
- newcoin.out.nValue = 0;
+ newcoin.out.nValue = MAX_MONEY;
if (prevOut.exists("amount")) {
newcoin.out.nValue = AmountFromValue(find_value(prevOut, "amount"));
}
@@ -898,6 +898,11 @@ UniValue signrawtransaction(const JSONRPCRequest& request)
UpdateTransaction(mtx, i, sigdata);
+ // amount must be specified for valid segwit signature
+ if (amount == MAX_MONEY && !txin.scriptWitness.IsNull()) {
+ throw JSONRPCError(RPC_TYPE_ERROR, strprintf("Missing amount for %s", coin.out.ToString()));
+ }
+
ScriptError serror = SCRIPT_ERR_OK;
if (!VerifyScript(txin.scriptSig, prevPubKey, &txin.scriptWitness, STANDARD_SCRIPT_VERIFY_FLAGS, TransactionSignatureChecker(&txConst, i, amount), &serror)) {
if (serror == SCRIPT_ERR_INVALID_STACK_OPERATION) {