From 0493d57b2e413a7e3497764a13784588d8b98653 Mon Sep 17 00:00:00 2001 From: nymkappa Date: Mon, 13 Jun 2022 11:28:34 +0200 Subject: [PATCH 1/2] Added regtest notes to backend README --- backend/README.md | 55 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/backend/README.md b/backend/README.md index 31872b962..7f6b63f96 100644 --- a/backend/README.md +++ b/backend/README.md @@ -159,3 +159,58 @@ nodemon src/index.ts --ignore cache/ --ignore pools.json ``` `nodemon` should be in npm's global binary folder. If needed, you can determine where that is with `npm -g bin`. + +### Regtest cheatsheets + +* Useful link https://gist.github.com/System-Glitch/cb4e87bf1ae3fec9925725bb3ebe223a + +* Run bitcoind for regtest + ``` + bitcoind -regtest -rpcport=8332 + ``` + +* If it's the first time, create a new wallet + ``` + bitcoin-cli -regtest -rpcport=8332 createwallet test + ``` + +* If it's not the first time, load the wallet. This command may take a while if you have lot of utxos + ``` + bitcoin-cli -regtest -rpcport=8332 loadwallet test + ``` + +* Get a new address + ``` + address=$(./src/bitcoin-cli -regtest -rpcport=8332 getnewaddress) + ``` + +* Mine blocks to the previously generated new address, you need at least 101 blocks before being able to spend. This will take some time to execute (~1 min) + ``` + bitcoin-cli -regtest -rpcport=8332 generatetoaddress 101 $address + ``` + +* Send 0.1 BTC at 5 sat/vB to another address + ``` + ./src/bitcoin-cli -named -regtest -rpcport=8332 sendtoaddress address=$(./src/bitcoin-cli -regtest -rpcport=8332 getnewaddress) amount=0.1 fee_rate=5 + ``` + +* See more example of `sendtoaddress` + ``` + ./src/bitcoin-cli sendtoaddress # will print the help + ``` + +* Mini script to generate txs with random fx rate (between 1 to 100 sat/vB). It's slow so don't expect to use this to test mempool spam, except if you let it run for a long time, or maybe with multiple regtest node connected to each other. + ``` + #!/bin/bash + address=$(./src/bitcoin-cli -regtest -rpcport=8332 getnewaddress) + for i in {1..1000000} + do + ./src/bitcoin-cli -regtest -rpcport=8332 -named sendtoaddress address=$address amount=0.01 fee_rate=$(jot -r 1 1 100) + done + ``` + +* Generate block at regular interval (every 10 sec in this example) + ``` + watch -n 10 "./src/bitcoin-cli -regtest -rpcport=8332 generatetoaddress 1 $address" + ``` + From 109de73691ee86064e261a66b460fd33ac0910b5 Mon Sep 17 00:00:00 2001 From: wiz Date: Tue, 14 Jun 2022 08:31:48 +0900 Subject: [PATCH 2/2] Fix typo in backend/README.md --- backend/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/README.md b/backend/README.md index 7f6b63f96..b65001182 100644 --- a/backend/README.md +++ b/backend/README.md @@ -199,7 +199,7 @@ nodemon src/index.ts --ignore cache/ --ignore pools.json ./src/bitcoin-cli sendtoaddress # will print the help ``` -* Mini script to generate txs with random fx rate (between 1 to 100 sat/vB). It's slow so don't expect to use this to test mempool spam, except if you let it run for a long time, or maybe with multiple regtest node connected to each other. +* Mini script to generate transactions with random TX fee-rate (between 1 to 100 sat/vB). It's slow so don't expect to use this to test mempool spam, except if you let it run for a long time, or maybe with multiple regtest node connected to each other. ``` #!/bin/bash address=$(./src/bitcoin-cli -regtest -rpcport=8332 getnewaddress)