Open shohu opened 6 years ago
testcode
##################################################
# test a fundrawtransaction using only watchonly #
##################################################
inputs = []
outputs = {self.nodes[2].getnewaddress() : watchonly_amount / 2}
rawtx = self.nodes[3].createrawtransaction(inputs, outputs)
result = self.nodes[3].fundrawtransaction(rawtx, {'includeWatching': True })
res_dec = self.nodes[0].decoderawtransaction(result["hex"])
assert_equal(len(res_dec["vin"]), 1)
assert_equal(res_dec["vin"][0]["txid"], watchonly_txid) ### Error was occured !!!
{
'vsize': 119,
'locktime': 0,
'txid': '34fc43c2455a2ea695cbd35e3d7d6821fd8e54453fa4db55e9f683049ba5b3b4',
'vin': [
{'txid': 'e78e46dc30c97d7cb87ea7b14e82d2e1baf662b69d4b44a3cd1da9b88bbff8bc',
'scriptSig': {'hex': '', 'asm': ''},
'sequence': 4294967294,
'vout': 1
}
],
'vout': [
{
'value': Decimal('99.99999774'),
'scriptPubKey': {
'hex': '76a91498bf0ffe328db1f65dc321f0b9fb97b1d9204db488ac',
'type': 'pubkeyhash',
'reqSigs': 1,
'asm': 'OP_DUP OP_HASH160 98bf0ffe328db1f65dc321f0b9fb97b1d9204db4 OP_EQUALVERIFY OP_CHECKSIG',
'addresses': ['muSbtTxQubg3DGiGKgzDyJMozubbjyM6Wq']
},
'n': 0
},
{
'value': Decimal('100.00000000'),
'scriptPubKey': {
'hex': '76a9143d24a10a776a6b61bd08aace783750c7234ccdb688ac',
'type': 'pubkeyhash',
'reqSigs': 1,
'asm': 'OP_DUP OP_HASH160 3d24a10a776a6b61bd08aace783750c7234ccdb6 OP_EQUALVERIFY OP_CHECKSIG',
'addresses': ['mm6FPneQEieumLT5PYZzyk89JCoEEx2hz4']
},
'n': 1
}
],
'size': 119,
'hash': '34fc43c2455a2ea695cbd35e3d7d6821fd8e54453fa4db55e9f683049ba5b3b4',
'version': 2
}
{
'vsize': 119,
'locktime': 0,
'txid': '2f45af55f265ce2dba167769762c5af2cefa24a9b087804866015b32c0070a81',
'vin': [
{
'vout': 1,
'txid': '89eed113243cdb065504560d1c1d63734b3780f7b780f65d674ce5240541123a',
'scriptSig': {'asm': '', 'hex': ''},
'sequence': 4294967294
}
],
'vout': [
{
'value': Decimal('100.00000000'),
'scriptPubKey': {
'reqSigs': 1,
'type': 'pubkeyhash',
'asm': 'OP_DUP OP_HASH160 105e89b5c2650af5b4f584f279cfabf556d4a1ba OP_EQUALVERIFY OP_CHECKSIG',
'hex': '76a914105e89b5c2650af5b4f584f279cfabf556d4a1ba88ac',
'addresses': ['mh1WMjWpCwjZgcbU7EAgpHnFs7drofWsAj']
},
'n': 0
},
{
'value': Decimal('99.99999774'),
'scriptPubKey': {
'reqSigs': 1,
'type': 'pubkeyhash',
'asm': 'OP_DUP OP_HASH160 f7c258206975d6d9ce84a6cfe18aa4ec55599e51 OP_EQUALVERIFY OP_CHECKSIG',
'hex': '76a914f7c258206975d6d9ce84a6cfe18aa4ec55599e5188ac',
'addresses': ['n46z1iByWrP1UQsCJHirMBBY8Gu7DAH6kZ']
},
'n': 1
}
],
'size': 119,
'hash': '2f45af55f265ce2dba167769762c5af2cefa24a9b087804866015b32c0070a81',
'version': 2,
}
(Pdb) p self.nodes[3].listunspent()
[{'vout': 1, 'txid': 'e9bb2c4a5689e563d5b3e5952530ff138b4bc9d670fe1b5ffd3b175dbfbf32fa', 'safe': True, 'confirmations': 9, 'solvable': True, 'account': '', 'scriptPubKey': '76a914b518a9dfb052b57e2add868888c334380eb523fc88ac', 'spendable': True, 'address': 'mx2W9RuNBcqDfbkkiBVDz2xrdpDqME2UHs', 'amount': Decimal('88000.00000000')}]
(Pdb) p res_dec["vin"][0]["txid"]
'e9bb2c4a5689e563d5b3e5952530ff138b4bc9d670fe1b5ffd3b175dbfbf32fa'
(Pdb) p self.nodes[3].listunspent()
[
{
'safe': True,
'address': 'mtPpE9NU5jJTdPC1tw3FMbT5hajydsaFtq',
'txid': '0b1126949fd80ca9c3c340c0f175759e6138fa87f69128f2ee44712a97672114',
'scriptPubKey': '76a9148d3ffd37ed701dca3d01d838223a68aa0ce2063c88ac',
'spendable': True,
'solvable': True,
'vout': 1,
'account': '',
'confirmations': 1,
'amount': Decimal('88000.00000000')
},
{
'safe': True,
'address': 'mqqa5XEU53vmSgRUwbNF8YDS7guukrTJrc',
'txid': '07c547514e7457db02012a9fe9175b5f598e78598b73d1076b9624943745874d',
'scriptPubKey': '76a91471369db6e356fe90de72f3a40880e3e637624bd388ac',
'spendable': False,
'solvable': True,
'vout': 0,
'account': '',
'confirmations': 1,
'amount': Decimal('88000.00000000')
}
]
(Pdb) p watchonly_txid
'07c547514e7457db02012a9fe9175b5f598e78598b73d1076b9624943745874d'
(Pdb) p self.nodes[3].listunspent()
[
{
'safe': True,
'address': 'mtPpE9NU5jJTdPC1tw3FMbT5hajydsaFtq',
'txid': '0b1126949fd80ca9c3c340c0f175759e6138fa87f69128f2ee44712a97672114',
'scriptPubKey': '76a9148d3ffd37ed701dca3d01d838223a68aa0ce2063c88ac',
'spendable': True,
'solvable': True,
'vout': 1,
'account': '',
'confirmations': 9,
'amount': Decimal('88000.00000000')
}
]
iが19回でlistunspentの数が1つになった
(Pdb) p self.nodes[3].listunspent()
[{'safe': True, 'vout': 1, 'scriptPubKey': '76a914799991b122c02ef6c86ab07d80f58e3880b8187188ac', 'confirmations': 5, 'account': '', 'solvable': True, 'spendable': True, 'address': 'mrbv2S97tYViDLixQ7h7a2r5UJtjd2usqt', 'txid': '88188c589955ba648568edf9b239db2a2fbf688faff2af58581067a136144c5b', 'amount': Decimal('88000.00000000')}, {'safe': True, 'vout': 1, 'scriptPubKey': '76a914bba215c157cb41c63b998277c615a9181976eb1088ac', 'confirmations': 5, 'account': '', 'solvable': True, 'spendable': False, 'address': 'mxd4pnfwG7e5WKvPyB39S4pVmWndjUW6hs', 'txid': '0b680ba07daa50863997fe23467b792480c89e7319e41580bbcc9dbfc04f117f', 'amount': Decimal('88000.00000000')}]
(Pdb) n
> /c0ban/test/functional/fundrawtransaction.py(515)run_test()
-> self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01)
(Pdb)
> /c0ban/test/functional/fundrawtransaction.py(514)run_test()
-> for i in range(0,20):
(Pdb) p self.nodes[3].listunspent()
[{'safe': True, 'vout': 1, 'scriptPubKey': '76a914799991b122c02ef6c86ab07d80f58e3880b8187188ac', 'confirmations': 5, 'account': '', 'solvable': True, 'spendable': True, 'address': 'mrbv2S97tYViDLixQ7h7a2r5UJtjd2usqt', 'txid': '88188c589955ba648568edf9b239db2a2fbf688faff2af58581067a136144c5b', 'amount': Decimal('88000.00000000')}]
(Pdb) p i
19
👍
# test/functional/fundrawtransaction.py
2018-03-23 05:46:21.502000 TestFramework (INFO): Initializing test directory /tmp/test9gm7kv7v
2018-03-23 05:46:54.617000 TestFramework (INFO): Stopping nodes
2018-03-23 05:46:56.777000 TestFramework (INFO): Cleaning up
2018-03-23 05:46:56.782000 TestFramework (INFO): Tests successful