salvatoshi on Nostr: If you often use regtest, you often need to manually mine blocks to test things. If ...
If you often use regtest, you often need to manually mine blocks to test things.
If you're on linux, add this to ~/.bashrc:
```
mine() {
if [ "$#" -eq 0 ]; then
bitcoin-cli -regtest -generate 1
else
bitcoin-cli -regtest -generate "$1"
fi
}
alias mine=mine
```
Now you can write:
```
$ mine
```
to mine a block, or:
```
$ mine 100
```
to mine 100 blocks and make your Liana timelocks expire.
Another useful alias for .bashrc:
```
alias lastblock='bitcoin-cli -regtest getblock $(bitcoin-cli -regtest getbestblockhash) 2'
```
So you can just write 'lastblock' on the terminal to see all the transactions in the last block.
Please reply below with your best regtest aliases and scripts.
Published at
2024-10-04 04:23:58Event JSON
{
"id": "9a4278a9ffad7d641a3ab9e9591bd02a70f266ffc2ceb3bc454c0bd20d999f52",
"pubkey": "a789a409ff78d377294f1a5d3e4b294e80ade7118cc5670951e6ec35eaa7564c",
"created_at": 1728015838,
"kind": 1,
"tags": [],
"content": "If you often use regtest, you often need to manually mine blocks to test things.\n\nIf you're on linux, add this to ~/.bashrc:\n\n```\nmine() {\n if [ \"$#\" -eq 0 ]; then\n bitcoin-cli -regtest -generate 1\n else\n bitcoin-cli -regtest -generate \"$1\"\n fi\n}\n\nalias mine=mine\n```\n\nNow you can write:\n\n```\n $ mine\n```\n\nto mine a block, or:\n\n```\n $ mine 100\n```\n\nto mine 100 blocks and make your Liana timelocks expire.\n\n\nAnother useful alias for .bashrc:\n\n```\nalias lastblock='bitcoin-cli -regtest getblock $(bitcoin-cli -regtest getbestblockhash) 2'\n```\n\nSo you can just write 'lastblock' on the terminal to see all the transactions in the last block.\n\nPlease reply below with your best regtest aliases and scripts.",
"sig": "ebe37d03d304eacab510c79c8e576107a77c9e27e4371e269b7bf05bbfc0860ed25f47e418aca57f62c343e79dc57e9c100a787c7ac1ad1bd769a58f09b95551"
}