Пример #1
0
# in a single OP_TRUE output. All Elements wallets recognize OP_TRUE outputs as their
# own (this differs from Bitcoin), so the 21M bitcoins are immediately available for
# use. This can be disabled by setting `anyonecanspend_aremine=0` in the daemon config.
#
# This is useful for testing basic functionality and for blockchains that have no peg,
# since every blockchain needs a default "policy asset". This policy asset is used
# for transaction fees (which are required for anti-DoS purposes). Also, asset
# issuances require some pre-existing asset, since they consume inputs for entropy.
#
# To separate the policy asset (used for fees) from the peg asset, use the `-policyasset`
# configuration value.
#
# In Elements there is no block subsidy. In a production sidechain, `initialfreecoins`
# will likely be set to zero, necessitating peg-in functionality to get a policy asset.

e1.createwallet("wallet1")
e2.createwallet("wallet2")

# Because of https://github.com/ElementsProject/elements/issues/956 we need to run
# `rescanblockchain` after creating the wallets to detect the `TRUE` outputs
assert e1["initialfreecoins"] == "2100000000000000"
assert e1.getwalletinfo()['balance'] == {'bitcoin': 0}
e1.rescanblockchain()
e2.rescanblockchain()
assert e1.getwalletinfo()['balance'] == {'bitcoin': 21000000}
assert e2.getwalletinfo()['balance'] == {'bitcoin': 21000000}
# All the initial coins coins are in one UTXO
assert len(e1.listunspent()) == 1
# ...and both nodes think they own it. This is a common situation when
# using near-empty test chains, so be aware of it.
assert e1.listunspent() == e2.listunspent()
Пример #2
0
    "contrib/assets_tutorial/elements2.conf",
    not args.no_cleanup,
)

## 1. Start nodes
print ("1. Start nodes and setup scenario")

# 1a. Turn on both nodes. Disable -validatepegin as we will just swap the
#     initialcoins asset with a newly issued asset. Using the peg would
#     be an inessential distraction.
#
alice.start(["-validatepegin=0"])
carol.start(["-validatepegin=0"])
alice.connect_to(carol)
carol.connect_to(alice)
alice.createwallet("wallet")
carol.createwallet("wallet")
alice.rescanblockchain()

# 1b. Split the initial coins so that both sides have some (but Alice has more)
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])