Changeset View
Changeset View
Standalone View
Standalone View
test/functional/rawtransactions.py
Show First 20 Lines • Show All 137 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
self.nodes[2].sendrawtransaction(rawTxSigned['hex']) | self.nodes[2].sendrawtransaction(rawTxSigned['hex']) | ||||
rawTx = self.nodes[0].decoderawtransaction(rawTxSigned['hex']) | rawTx = self.nodes[0].decoderawtransaction(rawTxSigned['hex']) | ||||
self.sync_all() | self.sync_all() | ||||
self.nodes[0].generate(1) | self.nodes[0].generate(1) | ||||
self.sync_all() | self.sync_all() | ||||
assert_equal(self.nodes[0].getbalance(), bal + Decimal( | assert_equal(self.nodes[0].getbalance(), bal + Decimal( | ||||
'50.00000000') + Decimal('2.19000000')) # block reward + tx | '50.00000000') + Decimal('2.19000000')) # block reward + tx | ||||
# 2of2 test for combining transactions | |||||
bal = self.nodes[2].getbalance() | |||||
addr1 = self.nodes[1].getnewaddress() | |||||
addr2 = self.nodes[2].getnewaddress() | |||||
addr1Obj = self.nodes[1].validateaddress(addr1) | |||||
addr2Obj = self.nodes[2].validateaddress(addr2) | |||||
self.nodes[1].addmultisigaddress( | |||||
2, [addr1Obj['pubkey'], addr2Obj['pubkey']]) | |||||
mSigObj = self.nodes[2].addmultisigaddress( | |||||
2, [addr1Obj['pubkey'], addr2Obj['pubkey']]) | |||||
mSigObjValid = self.nodes[2].validateaddress(mSigObj) | |||||
txId = self.nodes[0].sendtoaddress(mSigObj, 2.2) | |||||
decTx = self.nodes[0].gettransaction(txId) | |||||
rawTx2 = self.nodes[0].decoderawtransaction(decTx['hex']) | |||||
self.sync_all() | |||||
self.nodes[0].generate(1) | |||||
self.sync_all() | |||||
# the funds of a 2of2 multisig tx should not be marked as spendable | |||||
assert_equal(self.nodes[2].getbalance(), bal) | |||||
txDetails = self.nodes[0].gettransaction(txId, True) | |||||
rawTx2 = self.nodes[0].decoderawtransaction(txDetails['hex']) | |||||
vout = False | |||||
for outpoint in rawTx2['vout']: | |||||
if outpoint['value'] == Decimal('2.20000000'): | |||||
vout = outpoint | |||||
break | |||||
bal = self.nodes[0].getbalance() | |||||
inputs = [{"txid": txId, "vout": vout['n'], "scriptPubKey": vout['scriptPubKey'] | |||||
['hex'], "redeemScript": mSigObjValid['hex'], "amount": vout['value']}] | |||||
outputs = {self.nodes[0].getnewaddress(): 2.19} | |||||
rawTx2 = self.nodes[2].createrawtransaction(inputs, outputs) | |||||
rawTxPartialSigned1 = self.nodes[1].signrawtransaction(rawTx2, inputs) | |||||
self.log.info(rawTxPartialSigned1) | |||||
# node1 only has one key, can't comp. sign the tx | |||||
assert_equal(rawTxPartialSigned['complete'], False) | |||||
rawTxPartialSigned2 = self.nodes[2].signrawtransaction(rawTx2, inputs) | |||||
self.log.info(rawTxPartialSigned2) | |||||
# node2 only has one key, can't comp. sign the tx | |||||
assert_equal(rawTxPartialSigned2['complete'], False) | |||||
rawTxComb = self.nodes[2].combinerawtransaction( | |||||
[rawTxPartialSigned1['hex'], rawTxPartialSigned2['hex']]) | |||||
self.log.info(rawTxComb) | |||||
self.nodes[2].sendrawtransaction(rawTxComb) | |||||
rawTx2 = self.nodes[0].decoderawtransaction(rawTxComb) | |||||
self.sync_all() | |||||
self.nodes[0].generate(1) | |||||
self.sync_all() | |||||
assert_equal(self.nodes[0].getbalance( | |||||
), bal+Decimal('50.00000000')+Decimal('2.19000000')) # block reward + tx | |||||
# getrawtransaction tests | # getrawtransaction tests | ||||
# 1. valid parameters - only supply txid | # 1. valid parameters - only supply txid | ||||
txHash = rawTx["hash"] | txHash = rawTx["hash"] | ||||
assert_equal( | assert_equal( | ||||
self.nodes[0].getrawtransaction(txHash), rawTxSigned['hex']) | self.nodes[0].getrawtransaction(txHash), rawTxSigned['hex']) | ||||
# 2. valid parameters - supply txid and 0 for non-verbose | # 2. valid parameters - supply txid and 0 for non-verbose | ||||
assert_equal( | assert_equal( | ||||
▲ Show 20 Lines • Show All 70 Lines • Show Last 20 Lines |