aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2018-08-08 10:19:28 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2018-08-08 12:29:30 +0200
commitb64f02fcfad4768f5761da463c09089ab6ec27ed (patch)
tree27ecae08f8ace1a5f72ed475f48581495587ad8e /test
parent6518bcd56ca7362afdce3f8ea9adf95662c92f2d (diff)
parent212ef1f9547e27295a94eaa9d5ae552d858e2d9f (diff)
Merge #13796: [0.16] Make signrawtransaction give an error when amount is needed but missing
212ef1f9547e27295a94eaa9d5ae552d858e2d9f [tests] Check signrawtransaction* errors on missing prevtx info (Anthony Towns) 1825e37075aa7885930cb48c5452ba3e8952b78a Error on missing amount in signrawtransaction* (Anthony Towns) Pull request description: Backport of #13547 to 0.16 Tree-SHA512: 7a660023b6948632a1f949443c18fa45add75ec8c36df1ebbaccd181dd1560c1bef460f061f8dab36b6a5df295eb4967effaa2cf55ea06b41d8f7562842a39ec
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/rpc_rawtransaction.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/test/functional/rpc_rawtransaction.py b/test/functional/rpc_rawtransaction.py
index c2ca7c70b8..a60d15756d 100755
--- a/test/functional/rpc_rawtransaction.py
+++ b/test/functional/rpc_rawtransaction.py
@@ -98,6 +98,57 @@ class RawTransactionsTest(BitcoinTestFramework):
# Test `createrawtransaction` invalid `replaceable`
assert_raises_rpc_error(-3, "Expected type bool", self.nodes[0].createrawtransaction, [], {}, 0, 'foo')
+ for type in ["bech32", "p2sh-segwit", "legacy"]:
+ addr = self.nodes[0].getnewaddress("", type)
+ addrinfo = self.nodes[0].validateaddress(addr)
+ pubkey = addrinfo["scriptPubKey"]
+
+ self.log.info('sendrawtransaction with missing prevtx info (%s)' %(type))
+
+ # Test `signrawtransaction` invalid `prevtxs`
+ inputs = [ {'txid' : txid, 'vout' : 3, 'sequence' : 1000}]
+ outputs = { self.nodes[0].getnewaddress() : 1 }
+ rawtx = self.nodes[0].createrawtransaction(inputs, outputs)
+
+ prevtx = dict(txid=txid, scriptPubKey=pubkey, vout=3, amount=1)
+ succ = self.nodes[0].signrawtransaction(rawtx, [prevtx])
+ assert succ["complete"]
+ if type == "legacy":
+ del prevtx["amount"]
+ succ = self.nodes[0].signrawtransaction(rawtx, [prevtx])
+ assert succ["complete"]
+
+ if type != "legacy":
+ assert_raises_rpc_error(-3, "Missing amount", self.nodes[0].signrawtransaction, rawtx, [
+ {
+ "txid": txid,
+ "scriptPubKey": pubkey,
+ "vout": 3,
+ }
+ ])
+
+ assert_raises_rpc_error(-3, "Missing vout", self.nodes[0].signrawtransaction, rawtx, [
+ {
+ "txid": txid,
+ "scriptPubKey": pubkey,
+ "amount": 1,
+ }
+ ])
+ assert_raises_rpc_error(-3, "Missing txid", self.nodes[0].signrawtransaction, rawtx, [
+ {
+ "scriptPubKey": pubkey,
+ "vout": 3,
+ "amount": 1,
+ }
+ ])
+ assert_raises_rpc_error(-3, "Missing scriptPubKey", self.nodes[0].signrawtransaction, rawtx, [
+ {
+ "txid": txid,
+ "vout": 3,
+ "amount": 1
+ }
+ ])
+
#########################################
# sendrawtransaction with missing input #
#########################################