Commit 6b1816a
committed
Merge #1: The new
c806d5e chore(ci): Make `pin-msrv.sh` exec (志宇)
22ebcfe refactor: Rename `InputStatus` to `TxStatus` (志宇)
0e4a4a6 fix(finalizer): return true if already finalized in `finalize_input` (valued mammal)
ad78206 feat: Add `Selector::select_with_algorithm` (valued mammal)
866f881 feat!: Improve error handling (valued mammal)
1124439 ci: fix typo in rust.yml (valued mammal)
60fa9aa chore: Add examples directory (valued mammal)
386bdae ci: update for rust 1.63.0 (valued mammal)
9bdd0b1 feat!: Remove `bdk_chain` dependency (志宇)
4250de1 feat!: More progress (志宇)
3a5a67e feat!: Replace `PsbtUpdater` and `Builder` with `create_psbt` method (志宇)
Pull request description:
## Rationale
There were many problems with the design of the old `TxBuilder` currently residing in `bdk_wallet`.
* **No separation of concerns** - All options are crammed into a single `TxParams` struct.
* Some combinations of parameters are hard to reason about, or may even create invalid transactions.
* It's difficult to maintain. Adding new features tends to exacerbate the issue by introducing even more variants.
* **No planning module** - The planning module can help pick the best spending branch just by specifying available assets.
* **Inaccurate weight calculations** - Coin selection does not currently account for varints of inputs/outputs.
* "Policies" are applied to all transactions, irrelevant of which inputs were actually chosen.
* Cannot accurately determine when relatively-locked outputs are spendable.
* **The "no breaking changes" constraint** This made it difficult to introduce new features to the existing codebase without introducing more footguns.
* **Coupled to wallet** - Limits flexibility.
Rewriting the `TxBuilder` and decoupling it from `bdk_wallet` allows us to:
* Make it usable independently of `bdk_wallet`.
* Fix all the problems mentioned above cleanly.
* Avoid waiting for `bdk_wallet v2.0` to ship these fixes/improvements.
## Proposed Repository Layout
I propose turning this repo into a Cargo workspace, containing the following crates:
* `bdk_tx_core` - This will contain the core `Input`, `InputGroup` types (and maybe more). Both `bdk_chain` and `bdk_wallet` would only need to output these types to interoperate with the rest of the tx-building crates. These types are expected to be relatively stable, with most changes being non-breaking.
* `bdk_tx` - Handles the coin selection + psbt creation/signing/finalization. @nymius suggested splitting coin selection into its own crate, but I'm not fully convinced that's necessary (for now).
* `bdk_coin_select` - It would be convenient to move this crate into the workspace for easier development.
* `bdk_coin_control` - Contains `CoinControl`. This is the only crate in the workspace that depends on `bdk_chain` and `bdk_core`. It handles canonicalization and ensures the caller does not provide a bad set of input candidates (cc. @stevenroose).
## Where to Start Reviewing?
Start with `tests/synopsis.rs` - For now, it's more of an example than a test.
It includes:
* A basic create-transaction example.
* A more involved (but well-commented) cancel-transaction example.
These examples demonstrate how the various types in the library interact across the different stages of transaction building.
## How can I help?
The main architecture/flow is complete.
However, there are still a whole bunch of TODOs scattered over the codebase and should be done before merging. These TODOs be summarized as follows (these should be done before merging):
- [x] Fix up error types. Some methods return `Option`s when they should return custom error enums with variants. It is helpful to know why something failed.
- [x] Documentation. Things should be better documented. evanlinjin#4
- [x] Examples. The `tests/synopsis.rs` should be moves to a `examples` folder. The `Wallet` type should be contained in `examples/common/mod.rs` so that it can be shared across examples. evanlinjin#5
- [x] Update README.
This is enough to get a merge and get users to start using/testing.
To help:
* Review the codebase.
* Add PRs addressing various TODO comments. The PRs should be made to my fork (`evanlinjin/bdk-tx`).
## How long would it take for this to be stable?
Without any hold-backs, and multiple contributors, I think 2 months is a reasonable time.
ACKs for top commit:
evanlinjin:
self-ACK c806d5e
Tree-SHA512: a37fdd2683ed1967912ef2f2828d40a0939d956d8b4372591fcfa3e8e5d458bf478706345ae988d5966efcbf557f1396e4bb8f6f98c0dedc891b5cb790c97e77TxBuilder
File tree
18 files changed
+2999
-1390
lines changed- .github/workflows
- ci
- examples
- src
- tests
18 files changed
+2999
-1390
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
| 17 | + | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
25 | 28 | | |
26 | 29 | | |
27 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | | - | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
19 | 22 | | |
20 | 23 | | |
21 | 24 | | |
22 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
| 11 | + | |
11 | 12 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | 13 | | |
31 | 14 | | |
32 | 15 | | |
| |||
36 | 19 | | |
37 | 20 | | |
38 | 21 | | |
| 22 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
0 commit comments