Skip to content
This repository has been archived by the owner on May 11, 2023. It is now read-only.

Latest commit

 

History

History
128 lines (87 loc) · 3.5 KB

quickstart.md

File metadata and controls

128 lines (87 loc) · 3.5 KB

Quickstart

Installation

You must first download and install Go if you don't have it already.

git clone [email protected]:luno/moonbeam.git
cd moonbeam
source ./vars.sh
go get github.com/btcsuite/btcutil
go get github.com/btcsuite/btcrpcclient
go install github.com/luno/moonbeam/cmd/mbclient
go install github.com/luno/moonbeam/cmd/mbserver

Client Guide

The reference client is a standalone command-line program and doesn't require direct access to a bitcoin daemon. It stores its state in a file called mbclient-state.{mainnet,testnet3}.json. This file includes a private key so should be kept safe and be backed-up.

Initiate the channel

First we need to initiate a channel opening to a remote server. In this case, https://bitcoinmoonbeam.org:

./bin/mbclient create bitcoinmoonbeam.org <refundaddr>

refundaddr is your own wallet address where the balance of coins will be sent when the channel is eventually closed. Note that bitcoinmoonbeam.org is running on testnet, so this must be a regular Bitcoin testnet address.

The funding address and channel ID are printed if successful.

To see the channel info, you can run:

./bin/mbclient list -a

To see the channel info on the server, visit https://bitcoinmoonbeam.org

Fund the channel

Now you need to send some coins to the funding address. You can send any amount larger than the channel fee. This amount will be the maximum channel capacity. You can send it from any wallet.

You must wait for the transaction to confirm before proceeding. Once the transaction has confirmed run:

./bin/mbclient fund <id> <txid> <vout> <amount_in_satoshi>
  • id is the ID of the channel, you can find it by running bin/mbclient list -a
  • txid is the ID of the funding Bitcoin transaction
  • vout denotes the output of the transaction that contains the channel funding address, e.g. 0 for the first output
  • amount_in_satoshi is the number of satoshis (1 satoshi = 0.00000001 bitcoin) to send

If successful, the channel is now open. To see your open channels, run:

./bin/mbclient list

To get more info about this particular channel, run:

./bin/mbclient show <id>

Send payments

Now that the channel is open, you can send payments:

./bin/mbclient send [email protected] 1000

This will send 1000 Satoshi to [email protected].

You can see the payments on the server at: https://bitcoinmoonbeam.org

Close the channel

Once you're done, you can close the channel:

./bin/mbclient close <id>

This will print the closure transaction. The server should submit it to the network, but you can broadcast it yourself too.

Server Guide

The reference server requires access to a bitcoin daemon via JSON-RPC. It stores its stage in a file called mbserver-state.{mainnet,testnet3}.json. You can configure the server through flags.

To start the server:

./bin/mbserver --destination=<refundaddr> --xprivkey=<your_xprivkey> --auth_token=<random_secret>

You can then view the server status by visting https://127.0.0.1:3211. By default, a self-signed SSL certificate is used, which you'll have to bypass in your browser in order to view the page.

The available configuration flags can be found by running

./bin/mbserver --help

To create a channel to your test server, run:

./bin/mbclient create https://127.0.0.1:3211/moonbeamrpc <refundaddr>