]> Untitled Git - bitcoindevkit.org/commitdiff
add article headings and make heading consistent
authorrajarshimaitra <rajarshi149@gmail.com>
Sun, 26 Jun 2022 11:59:52 +0000 (17:29 +0530)
committerrajarshimaitra <rajarshi149@gmail.com>
Mon, 22 Aug 2022 12:33:54 +0000 (18:03 +0530)
This adds `## Introduction` heading to all tutorial articles and
makes heading sizes consistent across all tutorials..

docs/tutorials/Bitcoin_Core_RPC_Demo.md
docs/tutorials/compact_filters_demo.md
docs/tutorials/descriptor_based_paper_wallet.md
docs/tutorials/descriptors_in_the_wild.md
docs/tutorials/hidden-power-of-bitcoin.md
docs/tutorials/spending_policy_demo.md

index cff2d6fdfec235983a2b2ef57f9db19353510c60..c34c0aa6769f82f1757f3c8c288ea6592707c96e 100644 (file)
@@ -9,7 +9,7 @@ hidden: true
 draft: false
 ---
 
-### Introduction
+## Introduction
 BDK wallet developer library can be used to easily deploy wallets with various kinds of blockchain backend support, like [`electrum`](https://github.com/romanz/electrs), [`esplora`](https://github.com/Blockstream/esplora), `compact-filters` ([BIP157](https://github.com/bitcoin/bips/blob/master/bip-0157.mediawiki)) etc. With the latest release of BDK [`v0.10.0`](https://github.com/bitcoindevkit/bdk/releases/tag/v0.10.0), BDK now supports Bitcoin Core as a blockchain backend. BDK talks with Bitcoin Core using rust-bitcoin's [bitcoincore-rpc](https://github.com/rust-bitcoin/rust-bitcoincore-rpc) library.
 
 This allows wallet devs to quickly deploy their wallet that can talk to a bitcoin full node (home raspi nodes) out of the box. Wallet devs don't need to worry about connecting to a full node with correct RPC calls, all of that is handled by BDK under the hood. All they need is to identify the full node's RPC IP address and the correct RPC credentials.
@@ -18,7 +18,7 @@ In this tutorial we will see how to write a very simplistic wallet code that can
 
 Unlike other tutorials, we will not use `bdk-cli` tools, but instead write rust code directly using `BDK` devkit. In the end we will end up with our own simple bitcoin wallet.
 
-### Prerequisite
+## Prerequisite
 To run with this tutorial you would need to have a bitcoin core node running in regtest mode. Get the bitcoin core binary either from the [bitcoin core repo](https://bitcoincore.org/bin/bitcoin-core-0.21.1/) or [build from source](https://github.com/bitcoin/bitcoin/blob/v0.21.1/doc/build-unix.md).
 
 Then configure the node with a following `bitcoin.conf` file
@@ -33,7 +33,7 @@ rpcpassword=password
 
 Apart from that, you would need to install rust in your system. Grab the installation one-liner from [here](https://www.rust-lang.org/tools/install). 
 
-### Setting Up
+## Setting Up
 Create a new cargo binary repository.
 ```shell
 mkdir ~/tutorial
@@ -80,7 +80,7 @@ edition = "2018"
 [dependencies]
 ```
 
-### Setting dependencies
+## Setting dependencies
 Once the rust binary is compiled and running, we now need to specify the dependencies we need to work on our library.
 
 Remember that BDK provides almost everything we would need to build a wallet out of the box. So we don't need any more dependencies apart from BDK. We will use another small rust crate called [`dirs_next`](https://crates.io/crates/dirs-next) to find our home directory and store wallet files in a subfolder there.
@@ -131,7 +131,7 @@ use std::str::FromStr;
 ```
 With this we are now ready to add our wallet code.
 
-### Getting Descriptors
+## Getting Descriptors
 
 BDK is a descriptor based wallet library. That means when we specify our wallet key-chain we need to tell BDK about it in the format of a descriptor. You can read up on descriptors more [here](https://bitcoindevkit.org/descriptors/). A descriptor string looks like this
 `"wpkh([b8b575c2/84'/1'/0'/0]tprv8icWtRzy9CWgFxpGMLSdAeE4wWyz39XGc6SwykeTo13tYm14JkVVQAf7jz8WDDarCgNJrG3aEPJEqchDWeJdiaWpS3FwbLB9SzsN57V7qxB/*)"`.
@@ -209,7 +209,7 @@ chng: "wpkh([89df6a67/84'/1'/0'/1]tprv8iSRXyLtTKJNCECQxBJ19cgx2ueS7mC7GNq7VqTWY3
 ```
 Voila! Now we have nice descriptors strings handy to use for our BDK wallet construction.
 
-### Talking to Bitcoin Core Programmatically
+## Talking to Bitcoin Core Programmatically
 Like all other tutorials we will use two wallets to send coins back and forth. A Bitcoin Core wallet accessible via `bitcoin-cli` command line tools, and a BDK wallet maintained by BDK library.    
 
 But unlike other tutorials, we won't be using `bitcoin-cli` to talk to the Core wallet (we can, but let's spice things up). Instead, we will use the `bitcoin-rpc` library, to talk with our core node listening at `127.0.0.1:18443`, from inside our main function. This will allow us to write code, that will handle both the core and BDK wallet, from inside of the same function, and we won't have to switch terminals!
@@ -257,7 +257,7 @@ GetBlockchainInfoResult {
 ```
 Thats it. Now we can programmatically talk to our core node.
 
-### Get some balance in core wallet.
+## Get some balance in core wallet.
 We have told our rpc client that we would use a wallet named `test`. But currently, our core node doesn't have such a wallet. So let's create the wallet and fund it with some test coins.
 ```rust
 fn main() {
@@ -288,7 +288,7 @@ core balance: Amount(50.00000000 BTC)
 ```
 Great! We now have 50 regtest BTC to play with.
 
-### Setup the BDK wallet
+## Setup the BDK wallet
 Now that we are done setting up the core wallet. The last remaining step is to setup the BDK wallet. For this we will use the previous descriptor generation function and write code as below.
 
 **Note**: You might want to comment out the previous code in `main()`, as running them again will create more coins in core, which isn't an issue, but might be confusing.
@@ -366,7 +366,7 @@ cargo run
 bdk address: bcrt1q9vkmujggvzs0rd4z6069v3v0jucje7ua7ap308
 ```
 
-### Sending Sats Around
+## Sending Sats Around
 
 Now that we have covered all the groundwork, we have all we need to send coins back and forth between core and BDK wallet.
 
@@ -637,7 +637,7 @@ fn get_descriptors() -> (String, String) {
 }
 ```
 
-### Conclusion
+## Conclusion
 In this tutorial we saw some very basic BDK wallet functionality with a bitcoin core backend as the source and sync of blockchain data. This is just tip of the iceberg of BDK capabilities. BDK allows flexibility in all the dimensions of a bitcoin wallet, that is key chain, blockchain backend and database management. With all that power, we just implemented a trustless, non-custodial, private bitcoin wallet, backed by a bitcoin full node, with less than 200 lines of code (including lots of comments).
 
 BDK thus allows wallet devs, to only focus on stuff that they care about, writing wallet logic. All the backend stuff like blockchain, key management, and databases are abstracted away under the hood.
index 417957bffed920e5d190be89a20b2e62c5fd6018..a425f3674b924a0b5561067c52f8cf5045de713a 100644 (file)
@@ -9,7 +9,7 @@ tags: ["tutorial", "BDK", "bdk-cli", "compact_filters", "BIP157", "Neutrino"]
 
 ## Introduction
 
-#### Compact Filters:
+### Compact Filters:
 Compact filters are the latest specification of Bitcoin SPV node implementation as per [BIP157](https://github.com/bitcoin/bips/blob/master/bip-0157.mediawiki) and [BIP158](https://github.com/bitcoin/bips/blob/master/bip-0158.mediawiki). Such light clients were envisioned by Satoshi himself in  his original white paper, but due to lack of robust privacy and trust guarantees using conventional [bloomfilters](https://github.com/bitcoin/bips/blob/master/bip-0037.mediawiki), these type of nodes never got popular.
 
 Enters [BIP157](https://github.com/bitcoin/bips/blob/master/bip-0157.mediawiki), which described a new type of filters for Bitcoin Blockchain data, known as `compact_filters`. The [Neutrino](https://github.com/lightninglabs/neutrino) project pioneered the use of compact filter based light client nodes for using with Lightning Network wallets. Using compact filters, a light-node can talk to one or more full nodes, and fetch relevant information from the blockchain, with much more robust privacy and security guarantees than previously possible. Compact filter based nodes are best suitable to be used with mobile wallets, to create more trustless mobile applications on Bitcoin. Any wallet application that needs to have an "eye on the blockchain" has an use for such light clients.
@@ -20,7 +20,7 @@ Example of such `compact_filters` wallets in wild is [Breeze](https://github.com
 
 Bitcoin core supports serving `BIP157` type filters from `v0.21.0`.
 
-#### BDK and Compact filters
+### BDK and Compact filters
 BDK is a bitcoin wallet development library that can be used to create bitcoin wallets with custom `Database` and `Blockchain` backends. BDK is a [descriptor](https://bitcoindevkit.org/descriptors/) based wallet, i.e. the wallet keychain is described by a set of descriptors.
 
 Using BDK one can instantiate wallets of various kinds as per requirement. BDK abstracts away all the heavy lifting works, and allow wallet devs to concentrate on logic that they care about, i.e. writing wallet codes. For more detailed documentation on BDK capabilities check these [blog](https://bitcoindevkit.org/blog/2020/12/hello-world/), [bog](https://bitcoindevkit.org/blog/2020/11/descriptors-in-the-wild/) and [docs](https://docs.rs/bdk/).
@@ -36,7 +36,7 @@ BDK also supports [BIP158](https://github.com/bitcoin/bips/blob/master/bip-0158.
 
 This capability can be unlocked by compiling BDK with the `compact_filters` feature. Once enabled, BDK will be able to create wallets with the `compact_filters` type `Blockchain` backend. (The default backend is electrum server)
 
-#### bdk-cli
+### bdk-cli
 `bdk-cli` is a lightweight [REPL](https://codewith.mu/en/tutorials/1.0/repl) wrapper over the BDK library to facilitate quick and easy demonstration of BDK capabilities in command-line. Wallet devs can use this tool to quickly try out different possibilities with BDK.
 
 In this tutorial, We will use `bdk-cli` to demonstrate some basic wallet functionalities using `compact_filters` backend.
@@ -64,7 +64,7 @@ Following things are required to start with the tutorial.
 
 If you already have these two setup and working, you can skip this and jump to the [Tutorial](#tutorial) section.
 
-#### Install and run `bitcoind`
+### Install and run `bitcoind`
 You can definitely do it with your own `bitcoind` installation. `BIP157` support has been included in Bitcoin Core `v0.21.0`. So anything above that will work.
 
 You also need to ensure proper configuration settings for signalling `compact_filters` support.
@@ -102,7 +102,7 @@ For ease of testing, the BDK project hosts docker images that can be used to spa
   ```
   In the output, the `version` should show `210000`. `localservicesnames` should contain `"COMPACT_FILTERS"`. If you see this, then Bitcoin Core is correctly configured.
 
-#### Install and run bdk-cli
+### Install and run bdk-cli
 - Install `bdk-cli` with `compact_filters` feature
 
   ```shell
index a587a365da2b81a8a859ecc75fc6cbeea02a6ba4..4ac324506717de8e513f6d5202cd94a7a77dad3a 100644 (file)
@@ -8,6 +8,8 @@ date: "2021-03-30"
 tags: ["guide", "descriptor", "paper wallets"]
 ---
 
+## Introduction
+
 In this post, we will use the [Rusty Paper Wallet] tool to create a multi-owned descriptor-based paper wallet. We will use [bdk] via the [bdk-cli] tool to test our descriptor and to be able to sweep the funds from our paper wallet to a new address.
 
 ## About paper wallets
index 06306f5c083815fcaa499208d19364ace70a4a10..0efbc3af45b2ecfcd62e304d59003bcd05e8b720 100644 (file)
@@ -7,6 +7,8 @@ date: "2020-11-18"
 tags: ["guide", "descriptor"]
 ---
 
+## Introduction
+
 I have tried to setup a 2 of 2 multi signature infrastructure with two
 different wallets, which know nothing about each other, but are compliant with
 two very important protocols: [Output Descriptors] and [Partially Signed
index 0119e25f83697170e001d0404dd825a77f697359..5088fa866c283d2d1f455fde19cebbabb463a85e 100644 (file)
@@ -10,12 +10,14 @@ hidden: true
 draft: false
 ---
 
+## Introduction
+
 To send people BTC - we simply scan a QR Code *(or paste an address)*, enter some amount and *whoosh* - sent!
 Users might think, just like traditional currency, we can only exchange money using Bitcoin.
 As it so happens, the underlying technology Bitcoin supports specify outputs not as addresses, but as programming scripts.
 This opens us to a world of possibilities using Bitcoin.
 
-### Script
+## Script
 
 Bitcoin supports [Script](https://en.bitcoin.it/wiki/Script), a **stack-based** lightweight programming language.
 Any script written in **Script** *(pun intended)* contains `OP_*` codes and raw byte arrays that Bitcoin Full Nodes understand and process.
@@ -35,14 +37,14 @@ scriptPubKey: OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG
 scriptSig: <sig> <pubKey>
 ```
 
-##### Examples of things achievable using Bitcoin Script:
+#### Examples of things achievable using Bitcoin Script:
 
 1. `Pay Someone (p2pkh/p2wpkh)` - A specific public key must sign to spend the coins.
 2. `Escrow (2-of-3-multisig)` - Two parties need to sign together to spend the coins.
 3. `Vault (locked)` - A specific key will not be able to spend the coins until a timeout but another master key will always be able to spend them.
 4. `HTLC` - The receiver needs disclose a secret before a timeout, else the coins are transferred back to the payee.
 
-##### Motivation for Policies
+#### Motivation for Policies
 
 Unfortunately, due to its low-level and unusual stack-based nature, Script is pretty hard to reason about and use.
 Despite being around since Bitcoin's creation, writing and understanding Script is not trivial.
@@ -52,7 +54,7 @@ When writing a script, we would want to know that if the logic we wrote is **cor
 The community wanted an easy alternative way of writing Script that would create the most optimized Script code.
 This gave rise to **Miniscript**.
 
-### Miniscript
+## Miniscript
 
 [Miniscript](http://bitcoin.sipa.be/miniscript/) tackles the above problems head-on.
 It is an expressive way to create policies on Bitcoin Scripts in a structured and simple fashion.
@@ -67,7 +69,7 @@ Miniscript compiler compiles a **spending policy** down to Miniscript.
 It doesn't contain any signature, it's mainly a combinator language for designing spending conditions.
 You can try out the compiler online by using [this link](http://bitcoin.sipa.be/miniscript/#:~:text=Policy%20to%20Miniscript%20compiler).
 
-##### Fragments
+#### Fragments
 
 Here are some fragments which can be combined to create powerful expressions.
 
@@ -81,7 +83,7 @@ Here are some fragments which can be combined to create powerful expressions.
 Bitcoin Script allows us to use another alternate stack. The combinator functions use this second stack to evaluate expressions of `thresh`, `and`, `aor` and `or`.
 The complete Miniscript Reference can be found [here](http://bitcoin.sipa.be/miniscript/#:~:text=Miniscript%20reference).
 
-##### Example Policies
+#### Example Policies
 
 Here are the Miniscript Policies for the examples we looked at earlier. 
 Note `A`, `B`, `C` are placeholders for keys *(`xpub`/`xprv`)* involved in the tx.
@@ -113,7 +115,7 @@ The Miniscript Policy Compiler is written in Rust and is present in [this reposi
 In this blog, we will later use the same using [bitcoindevkit/bdk](https://github.com/bitcoindevkit/bdk), a lightweight descriptor-based wallet library
 with a [cli](https://github.com/bitcoindevkit/bdk-cli). 
 
-### Descriptors
+## Descriptors
 
 The Bitcoin scriptpubkey supports various schemes like P2PKH, P2SH, P2WPKH, P2TR (Segwit v1) etc.
 A Descriptor is a simple "description" of what scriptpubkey to be used for a given policy.
@@ -166,20 +168,20 @@ Of course we cannot use `pk(multi(...))`, `pkh(multi(...))` or `wpkh(multi(...))
 For example a descriptor like `wsh(multi(2, PKA, PKB, PKC))` describes a P2WSH type address created by a `2-of-3` multisig
 script using `PKA`, `PKB` and `PKC` pubkeys.
 
-### Where it all comes together...
+## Where it all comes together...
 
 In this section, we are going to make a descriptor-based wallet and derive addresses from `bitcoin-cli` and then use `bdk-cli` to confirm that the addresses generated for descriptor wallets are deterministic for a given descriptor.
 
 We will also try to create a vault miniscript policy and push funds to the vault with a lock time of 2 months. 
 During this time, we will try to break our vault and see our transactions failing.
 
-##### Tools and Armor
+#### Tools and Armor
 
 - [docker](https://docs.docker.com/engine/install/)
 - [bdk-cli](https://github.com/bitcoindevkit/bdk-cli)
 - [miniscriptc](https://bitcoindevkit.org/bdk-cli/compiler/#installation)
 
-##### Setting Up
+#### Setting Up
 
 We require `bitcoind` to run in `regtest` mode. Use the following config file, or any other config
 that you are familiar with.
@@ -198,7 +200,7 @@ rpcpassword=password
 bitcoind
 ```
 
-#### Keys and Generating Addresses
+### Keys and Generating Addresses
 
 Quick installation for `bdk-cli` and `miniscriptc`:
 ```bash
@@ -262,7 +264,7 @@ Notes:
 
 Note that both `bdk-cli` and `bitcoin-cli` produced the exact same addresses. So now we have definitive proof that descriptors can make wallets portable. That single string will be able to make any wallet generate the same set of addresses and hence they can sync and broadcast transactions in the same manner!
 
-#### Making a MultiSig Descriptor for Funds
+### Making a MultiSig Descriptor for Funds
 
 In the real-life, most of us hold two kinds of savings accounts - one to store huge funds saved throughout our lifetime *(probably without internet banking functionalities)* 
 and another for regular expenses.
@@ -418,7 +420,7 @@ one wallet know whats the next address to create without talking to other wallet
 If all the wallet shares the correct descriptor string they will always create the exact sequence of addresses and
 by passing around PSBTs they would know how to sign them, without talking to each other. This solves a major problem of multisig interoperability. And BDK makes this process as seamless as possible.
 
-### Retention Bonus - Smart Contract with Bitcoin
+## Retention Bonus - Smart Contract with Bitcoin
 
 Let us consider that a company wants to give its employees a retention bonus for two months.
 If an employee stays with that company for over 2 months, the employee would get 1 BTC as a reward.
@@ -563,7 +565,7 @@ So this time it worked, because we have simulated 2 months passing by generating
 and Employe wallet gets updated.
 Hence, we saw that we can generate some smart contracts using Bitcoin.
 
-### Inspirations
+## Inspirations
 
 1. [Descriptors from Bitcoin Core](https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md)
 1. [Miniscript](http://bitcoin.sipa.be/miniscript)
index 7fd77c283da35802ae70cd9c693ca2f9b606372e..3e9b3cec76be065ab9d5fc5f2aa5f923bc5f929d 100644 (file)
@@ -8,6 +8,8 @@ date: "2021-02-23"
 tags: ["guide", "descriptor"]
 ---
 
+## Introduction
+
 In this post we will use the [bdk-cli](https://github.com/bitcoindevkit/bdk-cli) tool to demonstrate how to use the [bdk](https://github.com/bitcoindevkit/bdk) library to:
 
 1. generate *testnet* public and private keys
@@ -322,7 +324,7 @@ bdk-cli wallet -w alice -d $ALICE_DESCRIPTOR get_balance
 }
 ```
 
-### DONE!
+#### DONE!
 
 ## Policy B. Two signatures after a relative time lock
 
@@ -435,6 +437,6 @@ bdk-cli wallet -w alice -d $ALICE_DESCRIPTOR get_balance
 }
 ```
 
-### Done again!
+#### Done again!
 
 In this demo we showed how to receive and spend bitcoin using two different descriptor wallet policies using the `bdk` library and `bdk-cli` wallet tool.