You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/cookbook/bindings/starter-example.md
+53-2Lines changed: 53 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ So you want to build a bitcoin wallet using BDK. Great! Here is the rough outlin
16
16
17
17
This page provides a starter example showcasing how BDK can be used to create, sync, and manage a wallet using an Esplora client as a blockchain data source. Familiarity with this example will help you work through the more advanced pages in this section.
18
18
19
-
You can find [working code examples](https://github.com/bitcoindevkit/book-of-bdk/tree/master/examples) of this example in two programming languages: [Swift](https://github.com/bitcoindevkit/book-of-bdk/tree/master/examples/swift) and [Kotlin](https://github.com/bitcoindevkit/book-of-bdk/tree/master/examples/kotlin). (Note: some additional language bindings are available for BDK, see [3rd Party Bindings](../getting-started/3rd-party-bindings.md)).
19
+
You can find [working code examples](https://github.com/bitcoindevkit/book-of-bdk/tree/master/examples) of this example in three programming languages: [Swift](https://github.com/bitcoindevkit/book-of-bdk/tree/master/examples/swift), [Kotlin](https://github.com/bitcoindevkit/book-of-bdk/tree/master/examples/kotlin) and [Python](https://github.com/bitcoindevkit/book-of-bdk/tree/master/examples/python). (Note: some additional language bindings are available for BDK, see [3rd Party Bindings](../getting-started/3rd-party-bindings.md)).
20
20
21
21
!!!tip
22
22
To complete this example from top to bottom, you'll need to create new descriptors and replace the ones provided. Once you do so, you'll run the example twice; on first run the wallet will not have any balance and will exit with an address to send funds to. Once that's done, you can run the example again and the wallet will be able to perform the later steps, namely creating and broadcasting a new transaction.
@@ -35,12 +35,21 @@ You can find [working code examples](https://github.com/bitcoindevkit/book-of-bd
@@ -63,6 +72,12 @@ You can find [working code examples](https://github.com/bitcoindevkit/book-of-bd
63
72
}
64
73
```
65
74
75
+
=== "Python"
76
+
77
+
```text title="requirements.txt"
78
+
bdkpython==2.2.0
79
+
```
80
+
66
81
## Use descriptors
67
82
68
83
To create a wallet using BDK, we need some <ahref="https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md"target="_blank">descriptors</a> for our wallet. This example uses public descriptors (meaning they cannot be used to sign transactions) on Signet. Step 7 and below will fail unless you replace those public descriptors with private ones of your own and fund them using Signet coins through a faucet. Refer to the [Creating Descriptors](./keys-descriptors/descriptors.md) page for information on how to generate your own private descriptors.
@@ -82,6 +97,12 @@ To create a wallet using BDK, we need some <a href="https://github.com/bitcoin/b
These are taproot descriptors (`tr()`) using public keys on Signet (`tpub`) as described in <ahref="https://github.com/bitcoin/bips/blob/master/bip-0086.mediawiki"target="_blank">BIP86</a>. The first descriptor is an HD wallet with a path for generating addresses to give out externally for payments. The second one is used by the wallet to generate addresses to pay ourselves change when sending payments (remember that <ahref="https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch06_transactions.adoc#outpoint"target="_blank">UTXOs</a> must be spent in full, so you often need to make change).
86
107
87
108
## Create or load a wallet
@@ -100,6 +121,12 @@ Next let's load up our wallet.
In cases where you are using new descriptors that do not have a balance yet, the example will request a new address from the wallet and print it out so you can fund the wallet. Remember that this example uses Signet coins!
120
153
121
154
=== "Swift"
@@ -130,6 +163,12 @@ In cases where you are using new descriptors that do not have a balance yet, the
For this step you'll need a wallet built with private keys, funded with some Signet satoshis. You can find a faucet [here](https://signet25.bublina.eu.org/) to get some coins.
@@ -148,6 +187,12 @@ Let's prepare to send a transaction. The two core choices here are where to send
0 commit comments