Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from Sep 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion qa/rpc-tests/signrawtransactions.py
Expand Up @@ -38,7 +38,8 @@ def successful_signing_test(self):

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
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/rawtransaction.cpp
Expand Up @@ -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));
Expand Down