Auto merge of #4134 - daira:fix-disable-expiry, r=Eirik0

Fix the use of 0 as expiryheight in createrawtransaction, to disable expiry

fixes #4132
This commit is contained in:
Homu 2019-09-26 12:47:13 -07:00
commit 8770f88663
2 changed files with 3 additions and 2 deletions

View File

@ -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

View File

@ -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));