Changeset View
Changeset View
Standalone View
Standalone View
test/functional/wallet_basic.py
Show First 20 Lines • Show All 145 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# create both transactions | # create both transactions | ||||
txns_to_send = [] | txns_to_send = [] | ||||
for utxo in node0utxos: | for utxo in node0utxos: | ||||
inputs = [] | inputs = [] | ||||
outputs = {} | outputs = {} | ||||
inputs.append({"txid": utxo["txid"], "vout": utxo["vout"]}) | inputs.append({"txid": utxo["txid"], "vout": utxo["vout"]}) | ||||
outputs[self.nodes[2].getnewaddress("from1")] = utxo["amount"] - 3 | outputs[self.nodes[2].getnewaddress("from1")] = utxo["amount"] - 3 | ||||
raw_tx = self.nodes[0].createrawtransaction(inputs, outputs) | raw_tx = self.nodes[0].createrawtransaction(inputs, outputs) | ||||
txns_to_send.append(self.nodes[0].signrawtransaction(raw_tx)) | txns_to_send.append( | ||||
self.nodes[0].signrawtransactionwithwallet(raw_tx)) | |||||
# Have node 1 (miner) send the transactions | # Have node 1 (miner) send the transactions | ||||
self.nodes[1].sendrawtransaction(txns_to_send[0]["hex"], True) | self.nodes[1].sendrawtransaction(txns_to_send[0]["hex"], True) | ||||
self.nodes[1].sendrawtransaction(txns_to_send[1]["hex"], True) | self.nodes[1].sendrawtransaction(txns_to_send[1]["hex"], True) | ||||
# Have node1 mine a block to confirm transactions: | # Have node1 mine a block to confirm transactions: | ||||
self.nodes[1].generate(1) | self.nodes[1].generate(1) | ||||
self.sync_all([self.nodes[0:3]]) | self.sync_all([self.nodes[0:3]]) | ||||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
usp = self.nodes[1].listunspent() | usp = self.nodes[1].listunspent() | ||||
inputs = [{"txid": usp[0]['txid'], "vout":usp[0]['vout']}] | inputs = [{"txid": usp[0]['txid'], "vout":usp[0]['vout']}] | ||||
outputs = {self.nodes[1].getnewaddress(): 49.998, | outputs = {self.nodes[1].getnewaddress(): 49.998, | ||||
self.nodes[0].getnewaddress(): 11.11} | self.nodes[0].getnewaddress(): 11.11} | ||||
rawTx = self.nodes[1].createrawtransaction(inputs, outputs).replace( | rawTx = self.nodes[1].createrawtransaction(inputs, outputs).replace( | ||||
"c0833842", "00000000") # replace 11.11 with 0.0 (int32) | "c0833842", "00000000") # replace 11.11 with 0.0 (int32) | ||||
decRawTx = self.nodes[1].decoderawtransaction(rawTx) | decRawTx = self.nodes[1].decoderawtransaction(rawTx) | ||||
signedRawTx = self.nodes[1].signrawtransaction(rawTx) | signedRawTx = self.nodes[1].signrawtransactionwithwallet(rawTx) | ||||
decRawTx = self.nodes[1].decoderawtransaction(signedRawTx['hex']) | decRawTx = self.nodes[1].decoderawtransaction(signedRawTx['hex']) | ||||
zeroValueTxid = decRawTx['txid'] | zeroValueTxid = decRawTx['txid'] | ||||
self.nodes[1].sendrawtransaction(signedRawTx['hex']) | self.nodes[1].sendrawtransaction(signedRawTx['hex']) | ||||
self.sync_all() | self.sync_all() | ||||
self.nodes[1].generate(1) # mine a block | self.nodes[1].generate(1) # mine a block | ||||
self.sync_all() | self.sync_all() | ||||
▲ Show 20 Lines • Show All 171 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
), self.nodes[0].getnewaddress()] | ), self.nodes[0].getnewaddress()] | ||||
singletxid = self.nodes[0].sendtoaddress( | singletxid = self.nodes[0].sendtoaddress( | ||||
chain_addrs[0], self.nodes[0].getbalance(), "", "", True) | chain_addrs[0], self.nodes[0].getbalance(), "", "", True) | ||||
self.nodes[0].generate(1) | self.nodes[0].generate(1) | ||||
node0_balance = self.nodes[0].getbalance() | node0_balance = self.nodes[0].getbalance() | ||||
# Split into two chains | # Split into two chains | ||||
rawtx = self.nodes[0].createrawtransaction([{"txid": singletxid, "vout": 0}], { | rawtx = self.nodes[0].createrawtransaction([{"txid": singletxid, "vout": 0}], { | ||||
chain_addrs[0]: node0_balance / 2 - Decimal('0.01'), chain_addrs[1]: node0_balance / 2 - Decimal('0.01')}) | chain_addrs[0]: node0_balance / 2 - Decimal('0.01'), chain_addrs[1]: node0_balance / 2 - Decimal('0.01')}) | ||||
signedtx = self.nodes[0].signrawtransaction(rawtx) | signedtx = self.nodes[0].signrawtransactionwithwallet(rawtx) | ||||
singletxid = self.nodes[0].sendrawtransaction(signedtx["hex"]) | singletxid = self.nodes[0].sendrawtransaction(signedtx["hex"]) | ||||
self.nodes[0].generate(1) | self.nodes[0].generate(1) | ||||
# Make a long chain of unconfirmed payments without hitting mempool limit | # Make a long chain of unconfirmed payments without hitting mempool limit | ||||
# Each tx we make leaves only one output of change on a chain 1 longer | # Each tx we make leaves only one output of change on a chain 1 longer | ||||
# Since the amount to send is always much less than the outputs, we only ever need one output | # Since the amount to send is always much less than the outputs, we only ever need one output | ||||
# So we should be able to generate exactly chainlimit txs for each original output | # So we should be able to generate exactly chainlimit txs for each original output | ||||
sending_addr = self.nodes[1].getnewaddress() | sending_addr = self.nodes[1].getnewaddress() | ||||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |