From 7167dc9b2ce40a1d5b5bf2a0042c0b331a9fb164 Mon Sep 17 00:00:00 2001 From: Daira Hopwood Date: Mon, 16 Sep 2019 13:04:27 +0100 Subject: [PATCH 1/2] Test setting an expiry height of 0. Signed-off-by: Daira Hopwood --- qa/rpc-tests/signrawtransactions.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 From 3e37152bf5492664708ebfc32c14cb7dab04c928 Mon Sep 17 00:00:00 2001 From: Daira Hopwood Date: Mon, 16 Sep 2019 13:47:30 +0100 Subject: [PATCH 2/2] Fix setting an expiry height of 0. fixes #4132 Signed-off-by: Daira Hopwood --- src/rpc/rawtransaction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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));