Changeset View
Changeset View
Standalone View
Standalone View
test/functional/rpc_rawtransaction.py
Show First 20 Lines • Show All 199 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
{'txid': txid, 'vout': 9}], outputs=multidict([(address, 99), (address2, 99), ('data', '99')]))))) | {'txid': txid, 'vout': 9}], outputs=multidict([(address, 99), (address2, 99), ('data', '99')]))))) | ||||
assert_equal(len(tx.vout), 3) | assert_equal(len(tx.vout), 3) | ||||
assert_equal( | assert_equal( | ||||
tx.serialize().hex(), | tx.serialize().hex(), | ||||
self.nodes[2].createrawtransaction(inputs=[{'txid': txid, 'vout': 9}], outputs=[ | self.nodes[2].createrawtransaction(inputs=[{'txid': txid, 'vout': 9}], outputs=[ | ||||
{address: 99}, {address2: 99}, {'data': '99'}]), | {address: 99}, {address2: 99}, {'data': '99'}]), | ||||
) | ) | ||||
for type in ["legacy"]: | |||||
addr = self.nodes[0].getnewaddress("", type) | |||||
addrinfo = self.nodes[0].getaddressinfo(addr) | |||||
pubkey = addrinfo["scriptPubKey"] | |||||
self.log.info( | |||||
'sendrawtransaction with missing prevtx info ({})'.format(type)) | |||||
# Test `signrawtransactionwithwallet` 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].signrawtransactionwithwallet(rawtx, [prevtx]) | |||||
assert succ["complete"] | |||||
assert_raises_rpc_error(-8, "Missing amount", self.nodes[0].signrawtransactionwithwallet, rawtx, [ | |||||
{ | |||||
"txid": txid, | |||||
"scriptPubKey": pubkey, | |||||
"vout": 3, | |||||
} | |||||
]) | |||||
assert_raises_rpc_error(-3, "Missing vout", self.nodes[0].signrawtransactionwithwallet, rawtx, [ | |||||
{ | |||||
"txid": txid, | |||||
"scriptPubKey": pubkey, | |||||
"amount": 1, | |||||
} | |||||
]) | |||||
assert_raises_rpc_error(-3, "Missing txid", self.nodes[0].signrawtransactionwithwallet, rawtx, [ | |||||
{ | |||||
"scriptPubKey": pubkey, | |||||
"vout": 3, | |||||
"amount": 1, | |||||
} | |||||
]) | |||||
assert_raises_rpc_error(-3, "Missing scriptPubKey", self.nodes[0].signrawtransactionwithwallet, rawtx, [ | |||||
{ | |||||
"txid": txid, | |||||
"vout": 3, | |||||
"amount": 1 | |||||
} | |||||
]) | |||||
######################################### | |||||
# sendrawtransaction with missing input # | |||||
######################################### | |||||
self.log.info('sendrawtransaction with missing input') | self.log.info('sendrawtransaction with missing input') | ||||
# won't exists | # won't exists | ||||
inputs = [ | inputs = [ | ||||
{'txid': "1d1d4e24ed99057e84c3f80fd8fbec79ed9e1acee37da269356ecea000000000", 'vout': 1}] | {'txid': "1d1d4e24ed99057e84c3f80fd8fbec79ed9e1acee37da269356ecea000000000", 'vout': 1}] | ||||
outputs = {self.nodes[0].getnewaddress(): 4.998} | outputs = {self.nodes[0].getnewaddress(): 4.998} | ||||
rawtx = self.nodes[2].createrawtransaction(inputs, outputs) | rawtx = self.nodes[2].createrawtransaction(inputs, outputs) | ||||
rawtx = pad_raw_tx(rawtx) | rawtx = pad_raw_tx(rawtx) | ||||
rawtx = self.nodes[2].signrawtransactionwithwallet(rawtx) | rawtx = self.nodes[2].signrawtransactionwithwallet(rawtx) | ||||
▲ Show 20 Lines • Show All 418 Lines • Show Last 20 Lines |