diff --git a/qa/rpc-tests/signrawtransactions.py b/qa/rpc-tests/signrawtransactions.py index e6eff05ed..622b18bf5 100755 --- a/qa/rpc-tests/signrawtransactions.py +++ b/qa/rpc-tests/signrawtransactions.py @@ -38,7 +38,8 @@ class SignRawTransactionsTest(BitcoinTestFramework): outputs = {'tmJXomn8fhYy3AFqDEteifjHRMUdKtBuTGM': 0.1} - rawTx = self.nodes[0].createrawtransaction(inputs, outputs) + # Also test setting an expiry height of 0. + rawTx = self.nodes[0].createrawtransaction(inputs, outputs, 0, 0) rawTxSigned = self.nodes[0].signrawtransaction(rawTx, inputs, privKeys) # 1) The transaction has a complete set of signatures diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 7d20f1017..4b6140f4c 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -543,7 +543,7 @@ UniValue createrawtransaction(const UniValue& params, bool fHelp) throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid parameter, expiryheight must be nonnegative and less than %d.", TX_EXPIRY_HEIGHT_THRESHOLD)); } // DoS mitigation: reject transactions expiring soon - if (nextBlockHeight + TX_EXPIRING_SOON_THRESHOLD > nExpiryHeight) { + if (nExpiryHeight != 0 && nextBlockHeight + TX_EXPIRING_SOON_THRESHOLD > nExpiryHeight) { throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid parameter, expiryheight should be at least %d to avoid transaction expiring soon", nextBlockHeight + TX_EXPIRING_SOON_THRESHOLD));