Ejemplo n.º 1
0
print("2b. Sending half to e2 (address %s)." % addr)
txid2 = e1.sendtoaddress(addr, 10500000, "", "", False)
e1.generatetoaddress(1, e1.getnewaddress())
assert len(e1.listunspent()) == 1  # change output, but no coinbase
e1.generatetoaddress(99, e1.getnewaddress())
assert len(e1.listunspent(
)) == 2  # change output, and coinbase with fees from first transaction
e1.generatetoaddress(1, e1.getnewaddress())
assert len(e1.listunspent()) == 3  # ...and fees from the second transaction
sync_all([e1, e2])
assert len(e2.listunspent()) == 1

# Funds should now be evenly split between the two wallets. e2 directly
# received 10500000, while e1 has the remainder, less fees (because it
# created the transactions), plus fees (because it created the blocks).
assert e1.getbalance() == e2.getbalance()
assert e1.listunspent() != e2.listunspent()

# 2c. Self-send this half to e2 again
addr = e2.getnewaddress()
print("2c. Self-sending this half to e2 (address %s)." % addr)
txid3 = e2.sendtoaddress(addr, 10500000, "", "", True)
sync_all([e1, e2])
e1.generatetoaddress(101, e1.getnewaddress())
sync_all([e1, e2])

# New e1 has slightly more coins than e2, because it received the fees
# from the last transaction
assert len(e1.listunspent()) == 4
assert len(e2.listunspent()) == 1
assert e1.getbalance()['bitcoin'] > e2.getbalance()['bitcoin']
Ejemplo n.º 2
0
alice.sendmany("", { alice.getnewaddress(): 10000 for x in range(0, 10) })
alice.sendtoaddress(carol.getnewaddress(), 100000)
alice.generatetoaddress(1, alice.getnewaddress())

# 1c. Issue 1000 units of a new asset. No reissuance tokens. Send them
#     all to the second node.
issue = alice.issueasset(1000, 0)
alice.sendtoaddress(address=carol.getnewaddress(), amount=1000, assetlabel=issue["asset"])
alice.generatetoaddress(1, alice.getnewaddress())
sync_all([alice, carol])

# 1d. Move the coins around on each wallet so that they do not share
#     any wallet transaction. (Otherwise they may fill in each others'
#     UTXO data, which is harmless but makes the tutorial harder to
#     follow.)
alice.sendtoaddress(alice.getnewaddress(), alice.getbalance()["bitcoin"], "", "", True)
carol.sendtoaddress(carol.getnewaddress(), carol.getbalance()["bitcoin"], "", "", True)
carol.sendtoaddress(address=carol.getnewaddress(), amount=1000, assetlabel=issue["asset"])
sync_all([alice, carol])
alice.generatetoaddress(1, alice.getnewaddress())
sync_all([alice, carol])

# Define some variables and continue..
asset_ALT = issue["asset"]
asset_BTC = alice.dumpassetlabels()["bitcoin"]

assert len(alice.listunspent()) > 0
assert len(carol.listunspent()) > 0

## 2. Construct a swap transaction in PSET format
#