diff options
| author | Anthony Towns <[email protected]> | 2018-06-27 17:54:32 +1000 |
|---|---|---|
| committer | Anthony Towns <[email protected]> | 2018-06-28 02:06:33 +1000 |
| commit | a3b065b51fb333d976108a1fe34b7f663fd67285 (patch) | |
| tree | 220d1003d4467010faf48e5374bbd9bf3eaa9acc /src/rpc/rawtransaction.cpp | |
| parent | Merge #13532: Log warning when deprecated network name 'tor' is used (diff) | |
| download | discoin-a3b065b51fb333d976108a1fe34b7f663fd67285.tar.xz discoin-a3b065b51fb333d976108a1fe34b7f663fd67285.zip | |
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.
Diffstat (limited to 'src/rpc/rawtransaction.cpp')
| -rw-r--r-- | src/rpc/rawtransaction.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 3b3f43ede..f14db086b 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -811,7 +811,7 @@ UniValue SignTransaction(CMutableTransaction& mtx, const UniValue& prevTxsUnival } 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")); } @@ -884,6 +884,11 @@ UniValue SignTransaction(CMutableTransaction& mtx, const UniValue& prevTxsUnival UpdateInput(txin, 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) { |