aboutsummaryrefslogtreecommitdiffstats
path: root/doc/fund-server-bitcoin-cli.md
blob: 3c5b6ef59810d600441224864120669f9570a745 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888 } /* Comment */
.highlight .err { color: #A61717; background-color: #E3D2D2 } /* Error */
.highlight .k { color: #080; font-weight: bold } /* Keyword */
.highlight .ch { color: #888 } /* Comment.Hashbang */
.highlight .cm { color: #888 } /* Comment.Multiline */
.highlight .cp { color: #C00; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888 } /* Comment.Single */
.highlight .cs { color: #C00; font-weight: bold; background-color: #FFF0F0 } /* Comment.Special */
.highlight .gd { color: #000; background-color: #FDD } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */
.highlight .gr { color: #A00 } /* Generic.Error */
.highlight .gh { color: #333 } /* Generic.Heading */
.highlight .gi { color: #000; background-color: #DFD } /* Generic.Inserted */
.highlight .go { color: #888 } /* Generic.Output */
.highlight .gp { color: #555 } /* Generic.Prompt */
.highlight .gs { fon
## Fund Coinos server (via bitcoin-cli)

Bitcoin Regtest Mode allows us to create our own Bitcoin sandbox blockchain for use in testing & development. 

In this demo/tutorial we will setup a regtest network along with wallet and some initial bitcoin.   

From the coinos-server dir on your localfilesystem (ie- after following the 'Getting Started' section of our [root README]) 

```bash

docker exec -it bitcoin bash

# get an address
bitcoin-cli -regtest -datadir=/config -rpcwallet=coinosdev getnewaddress

# mine a block to the new address 
bitcoin-cli -regtest -datadir=/config generatetoaddress 101 theaddressgneratedabove

# verify you got the reward: 
bitcoin-cli -regtest -datadir=/config -conf=./bitcoin.conf -rpcwallet=coinosdev getbalance
> 50.00000000
```

![](./img/50-bitcoin-server-balance.gif)


#### Start from scratch

To purge any existing transactions you made and to recreate all wallets including the coinos wallet (coinosdev) do (assuming coinos-server is running): 

```bash
docker-compose down
sudo rm -rf config/bitcoin 
sudo rm -rf config/lightning
sudo rm -rf config/liquid
cp -rf sampleconfig/bitcoin config
cp -rf sampleconfig/lightning config
cp -rf sampleconfig/liquid config
docker-compose up
# app may crash during re-initalization of blockchains so
# restart it again after a few moments if necessary: 
docker-compose restart app 
```


#### Creating new (Bitcoin native) wallets

Note the wallet 'coinosdev' is created apart of the initial docker build for our Coinos Bitcoin server.  
To create a new wallet (ie- as an alternate or one for yourself) do: 

```bash
bitcoin-cli -regtest -datadir=/config -conf=./bitcoin.conf createwallet me
> # new wallet created in /config/regtest/wallets
```
and then specify `-rpcwallet=me` (or wallet name of your choice)


#### further reading

On why to generate 101 blocks and some general info on Regtest Mode: 

https://developer.bitcoin.org/examples/testing.html


[root README]:https://github.com/coinos/coinos-server