mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-16 13:01:19 +02:00
update assets tutorial to support new peg-in format
This commit is contained in:
parent
6e8e6b2de8
commit
3ba146d872
2 changed files with 12 additions and 35 deletions
|
|
@ -46,7 +46,6 @@ def sync_all(e1, e2):
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
## Preparations
|
## Preparations
|
||||||
|
|
||||||
# Make data directories for each daemon
|
# Make data directories for each daemon
|
||||||
|
|
@ -91,20 +90,19 @@ time.sleep(3)
|
||||||
# Alternatively, you can set validatepegin=0 in their configs and not
|
# Alternatively, you can set validatepegin=0 in their configs and not
|
||||||
# run the bitcoin node, but it is necessary for fully validating the two way peg.
|
# run the bitcoin node, but it is necessary for fully validating the two way peg.
|
||||||
|
|
||||||
# At beginning "immature balance" holds all funds until genesis is mature
|
# Regtest chain starts with 21M bitcoins as OP_TRUE which the wallet
|
||||||
# Regtest chain starts with 21M elements coins as OP_TRUE which the wallet
|
# understands. This is useful for testing basic functionality and for
|
||||||
# understands. This is useful for testing basic functionality.
|
# blockchains that have no pegging functionality. "Policy" coins are required
|
||||||
# In Elements there is no block subsidy. All 21M output value in a mainnet
|
# for anti-DoS purposes as well as asset issuance, which consumes inputs for entropy.
|
||||||
# pegged sidechain are locked for pegging.
|
# In Elements there is no block subsidy. In a production sidechain it can
|
||||||
|
# be configured to start with no outputs, necessitating peg-in functionality
|
||||||
|
# for asset issuance.
|
||||||
e1.getwalletinfo()
|
e1.getwalletinfo()
|
||||||
|
|
||||||
# In regtest mining "target" is OP_TRUE since we have not set `-signblockscript` argument
|
# In regtest mining "target" is OP_TRUE since we have not set `-signblockscript` argument
|
||||||
# Generate simply works.
|
# Generate simply works.
|
||||||
e1.generate(101)
|
e1.generate(101)
|
||||||
sync_all(e1, e2)
|
sync_all(e1, e2)
|
||||||
# Now we have 21M OP_TRUE value in each Elements wallet.
|
|
||||||
e1.getwalletinfo()
|
|
||||||
e2.getwalletinfo()
|
|
||||||
|
|
||||||
######## WALLET ###########
|
######## WALLET ###########
|
||||||
|
|
||||||
|
|
@ -419,12 +417,6 @@ e1.generate(101)
|
||||||
bitcoin.generate(101)
|
bitcoin.generate(101)
|
||||||
sync_all(e1, e2)
|
sync_all(e1, e2)
|
||||||
|
|
||||||
# We have to lock up some of the funds first. Regtest(what we're running) has all funds as OP_TRUE
|
|
||||||
# but this is not the case in testnet/production. Doesn't matter where we send it
|
|
||||||
# inside Bitcoin, this is just a hack to lock some funds up.
|
|
||||||
# We can immediately grab this output from the mempool on subsequent steps
|
|
||||||
e1.sendtomainchain(bitcoin.getnewaddress(), 50)
|
|
||||||
|
|
||||||
# Now we can actually start pegging in. Examine the pegin address fields
|
# Now we can actually start pegging in. Examine the pegin address fields
|
||||||
e1.getpeginaddress()
|
e1.getpeginaddress()
|
||||||
# Changes each time as it's a new sidechain address as well as new "tweak" for the watchmen keys
|
# Changes each time as it's a new sidechain address as well as new "tweak" for the watchmen keys
|
||||||
|
|
@ -448,7 +440,7 @@ proof = bitcoin.gettxoutproof([txid])
|
||||||
raw = bitcoin.getrawtransaction(txid)
|
raw = bitcoin.getrawtransaction(txid)
|
||||||
|
|
||||||
# Attempt claim!
|
# Attempt claim!
|
||||||
claimtxid = e1.claimpegin(raw, proof, addrs["sidechain_address"])
|
claimtxid = e1.claimpegin(raw, proof, addrs["witness_program"])
|
||||||
sync_all(e1, e2)
|
sync_all(e1, e2)
|
||||||
|
|
||||||
# Other node should accept to mempool and mine
|
# Other node should accept to mempool and mine
|
||||||
|
|
|
||||||
|
|
@ -39,18 +39,11 @@ e2-dae
|
||||||
# run the bitcoin node, but it is necessary for the two way peg parts of
|
# run the bitcoin node, but it is necessary for the two way peg parts of
|
||||||
# this tutorial.
|
# this tutorial.
|
||||||
|
|
||||||
# Prime the chain, see "immature balance" holds all funds until genesis is mature
|
# We have 21M OP_TRUE value in each wallet
|
||||||
e1-cli getwalletinfo
|
# This is useful for testing and non-sidechain applications of Elements
|
||||||
|
|
||||||
# Mining for now is OP_TRUE
|
|
||||||
e1-cli generate 101
|
|
||||||
|
|
||||||
# Now we have 21M OP_TRUE value
|
|
||||||
e1-cli getwalletinfo
|
e1-cli getwalletinfo
|
||||||
e2-cli getwalletinfo
|
e2-cli getwalletinfo
|
||||||
|
|
||||||
# Primed and ready
|
|
||||||
|
|
||||||
######## WALLET ###########
|
######## WALLET ###########
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -311,19 +304,11 @@ e2-dae $FEDPEGARG
|
||||||
e1-cli generate 101
|
e1-cli generate 101
|
||||||
b-cli generate 101
|
b-cli generate 101
|
||||||
|
|
||||||
# We have to lock up some of the funds first. Regtest(what we're running) has all funds as OP_TRUE
|
|
||||||
# but this is not the case in testnet/production. Doesn't matter where we send it
|
|
||||||
# inside Bitcoin, this is just a hack to lock some funds up.
|
|
||||||
e1-cli sendtomainchain $(b-cli getnewaddress) 50
|
|
||||||
|
|
||||||
# Mature the pegout
|
|
||||||
e1-cli generate 101
|
|
||||||
|
|
||||||
# Now we can actually start pegging in. Examine the pegin address fields
|
# Now we can actually start pegging in. Examine the pegin address fields
|
||||||
e1-cli getpeginaddress
|
e1-cli getpeginaddress
|
||||||
# Changes each time as it's a new sidechain address as well as new "tweak" for the watchmen keys
|
# Changes each time as it's a new sidechain address as well as new "tweak" for the watchmen keys
|
||||||
# mainchain_address : where you send your bitcoin from Bitcoin network
|
# mainchain_address : where you send your bitcoin from Bitcoin network
|
||||||
# sidechain_address : where the bitcoin will end up on the sidechain after pegging in
|
# witness_program: what script will have to be satisfied to spent the peg-in input
|
||||||
|
|
||||||
# Each call of this takes the pubkeys defined in the config file, adds a random number to them
|
# Each call of this takes the pubkeys defined in the config file, adds a random number to them
|
||||||
# that is essetially the hash of the sidechain_address and other information,
|
# that is essetially the hash of the sidechain_address and other information,
|
||||||
|
|
@ -335,7 +320,7 @@ e1-cli getpeginaddress
|
||||||
ADDRS=$(e1-cli getpeginaddress)
|
ADDRS=$(e1-cli getpeginaddress)
|
||||||
|
|
||||||
MAINCHAIN=$(echo $ADDRS | python3 -c "import sys, json; print(json.load(sys.stdin)['mainchain_address'])")
|
MAINCHAIN=$(echo $ADDRS | python3 -c "import sys, json; print(json.load(sys.stdin)['mainchain_address'])")
|
||||||
SIDECHAIN=$(echo $ADDRS | python3 -c "import sys, json; print(json.load(sys.stdin)['sidechain_address'])")
|
SIDECHAIN=$(echo $ADDRS | python3 -c "import sys, json; print(json.load(sys.stdin)['witness_program'])")
|
||||||
|
|
||||||
#Send funds to unique watchmen P2SH address
|
#Send funds to unique watchmen P2SH address
|
||||||
TXID=$(b-cli sendtoaddress $MAINCHAIN 1)
|
TXID=$(b-cli sendtoaddress $MAINCHAIN 1)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue