aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Sanders <gsanders87@gmail.com>2018-08-14 21:52:16 -0400
committerWladimir J. van der Laan <laanwj@gmail.com>2018-08-21 09:44:52 +0200
commit82e2b9cb25d62f709d443e8e9fb5d174eb29eab0 (patch)
treed4437660e46535735eae02b41049e5c497de40fb
parent65e7a8b97f84beaa41a2a06e2d318614d6ece686 (diff)
downloadbitcoin-82e2b9cb25d62f709d443e8e9fb5d174eb29eab0.tar.xz
QA: add basic walletcreatefunded optional arg test
Github-Pull: #13968 Rebased-From: 1f0c4282e961baea85d5f74d7493bd7459784391 Tree-SHA512: 1f8b10629a314f623d589801ef2e62724de2cd82a0e523e0ab25a285f92b76a3b31304c1c0418b1b611ec3ca0016016d1e6af410ac81a78449b875c4f89a46d7
-rwxr-xr-xtest/functional/rpc_psbt.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/functional/rpc_psbt.py b/test/functional/rpc_psbt.py
index 99c4131d61..f847a01e59 100755
--- a/test/functional/rpc_psbt.py
+++ b/test/functional/rpc_psbt.py
@@ -11,6 +11,8 @@ from test_framework.util import assert_equal, assert_raises_rpc_error, find_outp
import json
import os
+MAX_BIP125_RBF_SEQUENCE = 0xfffffffd
+
# Create one-input, one-output, no-fee transaction:
class PSBTTest(BitcoinTestFramework):
@@ -135,6 +137,33 @@ class PSBTTest(BitcoinTestFramework):
self.nodes[0].generate(6)
self.sync_all()
+ # Test additional args in walletcreatepsbt
+ # Make sure both pre-included and funded inputs
+ # have the correct sequence numbers based on
+ # replaceable arg
+ block_height = self.nodes[0].getblockcount()
+ unspent = self.nodes[0].listunspent()[0]
+ psbtx_info = self.nodes[0].walletcreatefundedpsbt([{"txid":unspent["txid"], "vout":unspent["vout"]}], [{self.nodes[2].getnewaddress():unspent["amount"]+1}], block_height+2, {"replaceable":True})
+ decoded_psbt = self.nodes[0].decodepsbt(psbtx_info["psbt"])
+ for tx_in in decoded_psbt["tx"]["vin"]:
+ assert_equal(tx_in["sequence"], MAX_BIP125_RBF_SEQUENCE)
+ assert_equal(decoded_psbt["tx"]["locktime"], block_height+2)
+
+ # Same construction with only locktime set
+ psbtx_info = self.nodes[0].walletcreatefundedpsbt([{"txid":unspent["txid"], "vout":unspent["vout"]}], [{self.nodes[2].getnewaddress():unspent["amount"]+1}], block_height)
+ decoded_psbt = self.nodes[0].decodepsbt(psbtx_info["psbt"])
+ for tx_in in decoded_psbt["tx"]["vin"]:
+ assert tx_in["sequence"] > MAX_BIP125_RBF_SEQUENCE
+ assert_equal(decoded_psbt["tx"]["locktime"], block_height)
+
+ # Same construction without optional arguments
+ psbtx_info = self.nodes[0].walletcreatefundedpsbt([{"txid":unspent["txid"], "vout":unspent["vout"]}], [{self.nodes[2].getnewaddress():unspent["amount"]+1}])
+ decoded_psbt = self.nodes[0].decodepsbt(psbtx_info["psbt"])
+ for tx_in in decoded_psbt["tx"]["vin"]:
+ assert tx_in["sequence"] > MAX_BIP125_RBF_SEQUENCE
+ assert_equal(decoded_psbt["tx"]["locktime"], 0)
+
+
# BIP 174 Test Vectors
# Check that unknown values are just passed through