-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docker examples #66
Docker examples #66
Conversation
Draft for doc
dcrd, dcrwallet and MVWWe need to start
Now we can start the dcrlnd, the history about Alice and BobCreate #Create "Alice"s container
docker-compose run -d --name alice dcrlnd
#Log into the "Alice" container
docker exec -it alice bash
# Generate a new backward compatible nested p2sh address for Alice:
alice$ dcrlncli -n simnet newaddress p2pkh We can keep logged in
#Send from MVW to Alice's LNWallet
docker-compose run dcrctl --wallet sendfrom deafult <alice_address> 1
#Generate a block to update the wallet balance
docker-compose run dcrctl generate 1
#Check Alice's wallet balance
alice$ dcrlncli -n simnet walletbalance Create #Create "Bob"s container
`docker-compose run -d --name bob dcrlnd`
#Log into the "Bob" container
`docker exec -it bob bash` Connect Bob node to Alice node #Get identity pubkey from Bob's node
bob$ dcrlncli -n simnet getinfo
{
"version": "0.2.0-pre+dev",
------>"identity_pubkey": "02fe9daea36c1b1bd9e8dc1f5dc9edfc887d223199f2bac99e1cf92eb8cdb654e7",
"alias": "02fe9daea36c1b1bd9e8",
"color": "#3399ff",
"num_pending_channels": 0,
"num_active_channels": 0,
"num_inactive_channels": 0,
"num_peers": 0,
"block_height": 101,
"block_hash": "0000066c30cee9bae93a05b9b0edacef1fea1443f4b43a96f5d0761a70965c18",
"best_header_timestamp": 1576527447,
"synced_to_chain": true,
"synced_to_graph": false,
"testnet": false,
"chains": [
{
"chain": "decred",
"network": "simnet"
}
],
"uris": null
}
#Connect Alice to Bob's node
alice$ dcrlncli -n simnet connect <bob_pubkey>@bob
# Check list of peers on "Alice" side:
alice$ dcrlncli -n simnet listpeers
{
"peers": [
{
"pub_key": "02fe9daea36c1b1bd9e8dc1f5dc9edfc887d223199f2bac99e1cf92eb8cdb654e7",
"address": "172.25.0.5:9735",
"bytes_sent": "139",
"bytes_recv": "139",
"atoms_sent": "0",
"atoms_recv": "0",
"inbound": false,
"ping_time": "0",
"sync_type": "ACTIVE_SYNC"
}
]
} Create the # Open the channel with "Bob":
alice$ dcrlncli -n simnet openchannel --node_key=<bob_pubkey> --local_amt=1000000
# Include funding transaction in block thereby opening the channel:
# We need six confirmations to channel active
$ docker-compose run dcrctl generate 6
# Check that channel with "Bob" was opened:
alice$ dcrlncli --n simnet listchannels
{
"channels": [
{
"active": true,
"remote_pubkey": "02fe9daea36c1b1bd9e8dc1f5dc9edfc887d223199f2bac99e1cf92eb8cdb654e7",
"channel_point": "ed19031307d1ae49b06f38587e9336dac1015be11ad59432f84af9de4d4fdef7:0",
"chan_id": "112150186164224",
"capacity": "1000000",
"local_balance": "996360",
"remote_balance": "0",
"commit_fee": "3640",
"commit_size": "328",
"fee_per_kb": "10000",
"unsettled_balance": "0",
"total_atoms_sent": "0",
"total_atoms_received": "0",
"num_updates": "0",
"pending_htlcs": [
],
"csv_delay": 288,
"private": false,
"initiator": true,
"chan_status_flags": "ChanStatusDefault",
"local_chan_reserve_atoms": "10000",
"remote_chan_reserve_atoms": "10000",
"static_remote_key": true
}
]
} Send the payment from Alice to Bob. # Add invoice on "Bob" side:
bob$ dcrlncli -n simnet addinvoice --amt=10000
{
"r_hash": "<your_random_rhash_here>",
"pay_req": "<encoded_invoice>",
"add_index": 1
}
# Send payment from "Alice" to "Bob":
alice$ dcrlncli -n simnet payinvoice <encoded_invoice>
# Check "Alice"'s channel balance
alice$ dcrlncli -n simnet channelbalance
# Check "Bob"'s channel balance
bob$ lncli -n simnet channelbalance Now we have open channel in which we sent only one payment, let's imagine that we sent lots of them and we'd now like to close the channel. Let's do it! # List the "Alice" channel and retrieve "channel_point" which represents
# the opened channel:
alice$ dcrlncli -n simnet listchannels
{
"channels": [
{
"active": true,
"remote_pubkey": "02fe9daea36c1b1bd9e8dc1f5dc9edfc887d223199f2bac99e1cf92eb8cdb654e7",
------>"channel_point": "ed19031307d1ae49b06f38587e9336dac1015be11ad59432f84af9de4d4fdef7:0",
"chan_id": "112150186164224",
"capacity": "1000000",
"local_balance": "986360",
"remote_balance": "10000",
"commit_fee": "3640",
"commit_size": "364",
"fee_per_kb": "10000",
"unsettled_balance": "0",
"total_atoms_sent": "10000",
"total_atoms_received": "0",
"num_updates": "2",
"pending_htlcs": [
],
"csv_delay": 288,
"private": false,
"initiator": true,
"chan_status_flags": "ChanStatusDefault",
"local_chan_reserve_atoms": "10000",
"remote_chan_reserve_atoms": "10000",
"static_remote_key": true
}
]
}
# Channel point consists of two numbers separated by a colon. The first one
# is "funding_txid" and the second one is "output_index":
alice$ dcrlncli -n simnet closechannel <funding_txid> <output_index>
# Include close transaction in a block thereby closing the channel:
$ docker-compose run dcrctl generate 6
# Check "Alice" on-chain balance was credited by her settled amount in the channel:
alice$ dcrlncli -n simnet walletbalance
# Check "Bob" on-chain balance was credited with the funds he received in the
# channel:
bob$ dcrlncli -n simnet walletbalance
{
"total_balance": "10000",
"confirmed_balance": "10000",
"unconfirmed_balance": "0"
} |
@matheusd and @jholdstock can you review please? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An aside, but in simnet the coinbase maturity is 16 blocks: https://github.com/decred/dcrd/blob/master/chaincfg/simnetparams.go#L167
On a superficial pass, it seems in the right track.
Given in simnet you need the MVW and in testnet you probably won't anything and will instead use the online faucet and connect to other nodes I'd split this tutorial in two documents: One for simnet (where you specify the process of setting up the MVW) and one for testnet, where you direct users to the on-chain faucet and off-chain network map or known faucet nodes.
I've run into some issues whilst testing this, going to debug with @fguisso on Matrix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worked through the issues and now this is working well! I have made some minor suggestions but otherwise LGTM, nice work
Update all docker files to work with dcrd and dcrlnd instead of btcd and lnd.
Hello guys, I've been trying to script for a few months to automate my simnet environments and also update the example with LN docker-compose.
For now I have succeeded in building a Minimum Voting Wallet (MVW), see #12 , and interacting with
dcrd
anddcrwallet
in a nice way. Just add a docker-compose up --build to get everything up and running.I'm still going to improve some things, but I've opened PR so they can give me a light and tell if it's all by default since I'm not an expert docker.
What we have so far:
You can choose wallet_seed and wallet_pass from
docker-compose.yml
or using --build-args.Thus, when docker creates the application, dcrwallet dockerfile uses two steps, one for creating the wallet, generating an address and saving that address to a volume like dcrd.conf, and the other for leaving the container clean only with what is needed. for the dcrwallet to run.
With this,
dcrd
runs with --miningaddr flag set for your wallet and you can generate blocks and init dcrwallet with ticketbuyer.Next steps:
dcrlnd
files to work with this MVWI'm using this repos to refer in how MVW works: