8a98e69e788dd79d030798465fbc0dec044d86f1 Add rpc wallet creation example (rajarshimaitra)
Pull request description:
### Description
As mentioned in https://github.com/bitcoindevkit/bitcoindevkit.org/issues/83#issuecomment-1005190174 it would be helpful
to have wallet creation example code in the `example` directory.
This is an attempt to create the most simplistic bdk wallet with a RPC backend and demonstrate receiving, creating, signing
and broadcasting transaction.
The code is a refinement of the RPC tutorial https://bitcoindevkit.org/blog/bitcoin-core-rpc-demo/ with more elaborate doc comments.
### Notes to the reviewers
To automate the background RPC process `electrsd` is used which is already a `dev-dependency` of bdk.
### Checklists
#### All Submissions:
* [x] I've signed all my commits
* [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
* [x] I ran `cargo fmt` and `cargo clippy` before committing
ACKs for top commit:
notmandatory:
tACK 8a98e69e788dd79d030798465fbc0dec044d86f1
Tree-SHA512: f00c1ce57ef91c3d3ab2ce08af3571c41bbe98f18f705c61ba4217c2f8061196e5eaf6122742293cd6fa16939bbbfacd0f8506cd4151b55f19a05325fd94a74a
1803f5ea8a7a2f8f9ebdfa520baad91f84bd6ba0 Update `electrsd` to v0.15 (Alekos Filini)
Pull request description:
<!-- You can erase any parts of this template not applicable to your Pull Request. -->
### Description
PR RCasatta/electrsd#33 has been merged and the new changes released as part of `v0.15.0`: the PR allows setting an env variable (`ELECTRSD_EXE`) to use a custom electrsd binary, which can be useful when the one that is downloaded automatically doesn't work for whatever reason.
### Checklists
#### All Submissions:
* [x] I've signed all my commits
* [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
* [x] I ran `cargo fmt` and `cargo clippy` before committing
#### New Features:
* [ ] I've added tests for the new feature
* [ ] I've added docs for the new feature
* [ ] I've updated `CHANGELOG.md`
#### Bugfixes:
* [ ] This pull request breaks the existing API
* [ ] I've added tests to reproduce the issue which are now passing
* [ ] I'm linking the issue being fixed by this PR
ACKs for top commit:
LLFourn:
ACK 1803f5e
notmandatory:
ACK 1803f5ea8a7a2f8f9ebdfa520baad91f84bd6ba0
Tree-SHA512: 01d84763a5acf3aa1686b91ba7cb0c7ec3a0ca6c7b9bac29aa74a72f54ed31c476b7a8b0f8c6c8a8ccf530ad8a19e90e144ac4cacbe436699ef9e319b5732f1c
52bc63e48f5d16cb03c8a58f7b0bd07cbb058dde Fix pre-segwit inputs with esplora (LLFourn)
Pull request description:
Unexpectedly pre-segwit inputs have an empty JSON witness field in esplora.
Fixes#570
* [x] I've added tests to reproduce the issue which are now passing
* [x] I'm linking the issue being fixed by this PR
ACKs for top commit:
notmandatory:
ACK 52bc63e48f5d16cb03c8a58f7b0bd07cbb058dde
afilini:
ACK 52bc63e48f5d16cb03c8a58f7b0bd07cbb058dde
Tree-SHA512: 1da82aeb2739111e1a516d94c79fe7d7c7879526a8cd780dcd63ff5ae9ccb1bed4eb20e5c575a45e37b6d1818d63ce6d3812e7b9ae34ebb02bc190a47b9750f8
f2f0efc0b3367abf40e33b84fc577fb11f625b04 Never delete spent utxos from the database (Daniela Brozzoni)
Pull request description:
<!-- You can erase any parts of this template not applicable to your Pull Request. -->
### Description
A `is_spent` field is added to LocalUtxo; when a txo is spent we set
this field to true instead of deleting the entire utxo from the
database.
This allows us to create txs double-spending txs already in blockchain.
Listunspent won't return spent in mempool utxos, effectively excluding them from the coin selection and balance calculation
Fixes#414
### Checklists
#### All Submissions:
* [x] I've signed all my commits
* [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
* [x] I ran `cargo fmt` and `cargo clippy` before committing
#### New Features:
* [x] I've added tests for the new feature
* [x] I've updated `CHANGELOG.md`
* [x] I'm linking the issue being fixed by this PR
ACKs for top commit:
afilini:
Re-ACK f2f0efc
Tree-SHA512: 7984b69c56b3b12746c2301072d637dea1346730aa132f1ea67c5bd8bf685bd557fc7cbdc2fc1185e63c71db07d36cd979514921b2c83c55737cd4b96102377e
A `is_spent` field is added to LocalUtxo; when a txo is spent we set
this field to true instead of deleting the entire utxo from the
database.
This allows us to create txs double-spending txs already in blockchain.
Listunspent won't return spent utxos, effectively excluding them from the
coin selection and balance calculation
0cc4700bd67be84bb5cb0814bf5c8aa9fc3f3cdc Fix typo in CHANGELOG and doc in wallet/mod.rs (Steve Myers)
660faab1e20defe86a7baf132e52928f538b9cbb Fix typo in CHANGELOG (LLFourn)
45767fcaf7c65d5020f99fdc35c147acd6e8d037 Remove max_addresses sync param (LLFourn)
fbb50ad1c886a9cb716146fa823558d7d655c7b7 apply doc suggestions from @notmandatory (Lloyd Fournier)
035307ef54ebc330b1760bbdd17bdab3b167cfeb [rpc] Filter out unrelated transactions (LLFourn)
c0e75fc1a8560cdacf705ff60ef8833befd8280c Split get_tx into its own trait (LLFourn)
dcd90f8b61287164dae60f039848d3605eab8616 Restore but depreciate new_offline (LLFourn)
410a51355bb47dbf3401cbe6f19546255c6721e0 Add SyncOptions as the second argument to Wallet::sync (LLFourn)
326bfe82a89eaa79acf90c34442234c7e53e1caf Remove Blockchain from wallet (LLFourn)
Pull request description:
While trying to finish #490 I thought that it'd be better to try the idea of getting rid of a lot of the async macros and just having tow different traits for sync and async stuff. While trying to do that I felt that this needed to be done first.
The goal of this change is to decouple the wallet from the blockchain trait. A wallet is something that keeps track of UTXOs and transactions (and can sign things). The only reason it should need to talk to the blockchain is if doing a `sync`. So we remove all superfluous calls to the blockchain and precisely define the requirements for the blockchain to be used to sync with two new traits: `WalletSync` and `GetHeight`.
1. Stop requesting height when wallet is created
2. `new_offline` is just `new` now.
3. a `WalletSync + GetHeight` is now the first argument to `sync`.
4. `SyncOptions` replaces the existing options to `sync` and allows for less friction when making breaking changes in the fuutre (no more noop_progress!).
5. We `Box` the `Progress` now to avoid type parameters
6. broadcast has been removed from `Wallet`. You just use the blockchain directly to broadcast now.
### Notes to the reviewers
This needs #502 before it can be merged but can reviewed now.
Be on the look up for stale documentation from this change.
Our doc build looks broken because of ureq or something.
### Checklists
#### All Submissions:
* [x] I've signed all my commits
* [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
* [x] I ran `cargo fmt` and `cargo clippy` before committing
* [x] I've updated `CHANGELOG.md`
Top commit has no ACKs.
Tree-SHA512: a8f3e21e45359be642b1f30d4ac1ba74785439e1b770dbeab0a5a4b8aab1eef4bb6b855aea4382e289257bc890fa713ca832a8b6c9655f7a59e96d412b4da3e6
edf2f0ce06d27a1434202b79306cd1e998b5614c refactor wallet address caching into its own public method for offline wallet use (a5an0)
Pull request description:
### Description
Currently, the only way to ensure that a wallet's internal database has addresses loaded and cached is through `Wallet::sync`: that function generates and caches up to a number of addresses if they aren't already in the database, and then uses the wallet's blockchain client to sync those addresses. If you are using an offline wallet, there is no mechanism to ensure that the database has addresses loaded. This is a problem for usecases like an offline wallet being used as a multisig signer and wanting to validate change addresses as `Wallet::is_mine` will only work properly if the owned-address is loaded in the database.
This PR takes the address caching functionality out of `Wallet::sync` and puts it in a new public method that is available to offline wallets. `Wallet::sync` uses this method internally.
### Checklists
#### All Submissions:
* [X] I've signed all my commits
* [X] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
* [X] I ran `cargo fmt` and `cargo clippy` before committing
* [X] I've added docs for the new feature
* [X] I've updated `CHANGELOG.md`
Top commit has no ACKs.
Tree-SHA512: 8ddc58d71457163bb20ff663ac508feb4e77000688161b63841a94db30b3f29f60f35fa2467bd99546123148873e3aed11e2f13ae6cbceda6605b83c227d9079
022256c91ac7a4d9324a1a7925394a948feec808 Fix comment on peek_address (Lloyd Fournier)
00f0901bac805360695d0c492df8fa809918863e Add API for internal addresses (LLFourn)
Pull request description:
There are good reasons for applications to need to get internal
addresses too. For example creating a transactions that splits an output
into several smaller ones.
### Checklists
#### All Submissions:
* [x] I've signed all my commits
* [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
* [x] I ran `cargo fmt` and `cargo clippy` before committing
#### New Features:
* [x] I've added tests for the new feature
* [x] I've added docs for the new feature
* [x] I've updated `CHANGELOG.md`
ACKs for top commit:
notmandatory:
ACK 022256c91ac7a4d9324a1a7925394a948feec808
Tree-SHA512: 0ead6669c9974332708ae6cba1a5be69cd4b3b6c7a21896efdce178d4406265ba072e1cf02d1913178d0a551f3b276d99b75676c632833964f87484e262a61b1
For some reason while doing the "remove blockchain from wallet PR" I
changed the tests around in what I thought was a benign way. But it
meant (apparently) that both parties "test_sync_double_receive" were
using the same "blockchain". This meant that when the blockchain was RPC
they both imported their addresses to it and got each other's results
when syncing. This bugged out the sync and this commit fixes that.
Although somewhat convenient to have, coupling the Wallet with
the blockchain trait causes development friction and complexity.
What if sometimes the wallet is "offline" (no access to the blockchain)
but sometimes its online?
The only thing the Wallet needs the blockchain for is to sync.
But not all applications will even use the sync method and the sync
method doesn't require the full blockchain functionality.
So we instead pass the blockchain in when we want to sync.
- To further reduce the coupling with blockchain I removed the get_height call from `new` and just use the height of the
last sync in the database.
- I split up the blockchain trait a bit into subtraits.
There are good reasons for applications to need to get internal
addresses too. For example creating a transactions that splits an output
into several smaller ones.
1999d97aeb3d97ee24a9b59a2f1453a26943b595 Remove `verify` flag from `TransactionDetails` via new MIGRATIONS (Steve Myers)
0195bc0636d9a58013f0cbc3781d213b0cfc1509 Update CHANGELOG (rajarshimaitra)
1d7ea89d8a792013212b1d269895b02fe3b410bd Refactor sync time verification (rajarshimaitra)
b05ee78c7335f7e3a1593dc4ff7686e6f72ff5c0 Remove verifcation flag from compact_filters (rajarshimaitra)
53c30b0479c74dde17cd27f8eac7f540e492067d Add verification tests in CI (rajarshimaitra)
6a09075d1a87509e9117eab727132efdf8ea6e1d Remove verify flag from sqlite DB (rajarshimaitra)
61a95d0d15b9944e8b5d13db64ef6ffd9a8d6e29 Update changelog (rajarshimaitra)
08f312a82f889f6bf5dfedfaa565ac2cb59683ae Remove `verify` flag from `TransactionDetails` (rajarshimaitra)
acbf0ae08e0732579652aece9bc48169351884cf Add sync verification for `esplora` (rajarshimaitra)
4761155707a819c4db437e71a36621a027d5302a Add sync verification in `electrum` (rajarshimaitra)
98a3b3282a0ff59bbdf900adc765f6912d1975c1 Remove sync verification (rajarshimaitra)
Pull request description:
<!-- You can erase any parts of this template not applicable to your Pull Request. -->
### Description
As discussed in https://github.com/bitcoindevkit/bdk/issues/498 and also in team call,
- default verification from wallet sync is removed
- `verify_tx` refactored as an wallet API
- in `sync` verification added for electrum and esplora backends, gated by `verify` flag.
- `verify` flag is removed from `TransactionDetails`.
### Notes to the reviewers
I haven't looked into `comapct_filters` to see how verification can fit there, but that will probably be required in future.
### Checklists
#### All Submissions:
* [x] I've signed all my commits
* [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
* [x] I ran `cargo fmt` and `cargo clippy` before committing
#### Wallet API change:
* [x] I've updated `CHANGELOG.md`
Top commit has no ACKs.
Tree-SHA512: 72e307008a137468d96d5c2a6ec804b18fa52363606f3c978208ae5dc22973a7f0aa37488e9bb98dde88409a12d59cc5f00c675d2d408e57e661bf6210bee67b
bfd0d13779003f11fa099a0b665052c18ce6e500 [blockchain] Fix `sent` calculation in the RPC backend (Daniela Brozzoni)
128c37595c5cfeacdb8e999da5795a9aa28ad67b [tests] Pass tx inputs to the testutils macro (Daniela Brozzoni)
Pull request description:
<!-- You can erase any parts of this template not applicable to your Pull Request. -->
### Description
<!-- Describe the purpose of this PR, what's being adding and/or fixed -->
### Notes to the reviewers
<!-- In this section you can include notes directed to the reviewers, like explaining why some parts
of the PR were done in a specific way -->
### Checklists
#### All Submissions:
* [x] I've signed all my commits
* [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
* [x] I ran `cargo fmt` and `cargo clippy` before committing
#### Bugfixes:
* [x] I've added tests to reproduce the issue which are now passing
ACKs for top commit:
afilini:
ACK bfd0d13779003f11fa099a0b665052c18ce6e500
Tree-SHA512: 1c214819c5dc1f1c30b1c6ef18a44a3013d587651890b26aecfc5203d128173fd91497337186bbee6934f77d3cfe1686e67b83ca6fe6e47b4c1d4b1dbcc656ee
We used to consider a tx input as ours if we had the
tx that creates it in the database.
This commit actually checks if an input is ours before adding
its value to the `sent` field.
b04bb590f385db349f8dc70cc169674b530c4205 Pin tokio version to ~1.14 (Steve Myers)
Pull request description:
### Description
The `tokio` project recently changed their MSRV to `1.49.0`. This PR will pin the `tokio` dependency version to `~1.14` which is prior to their MSRV increase.
### Notes to the reviewers
The LDK team took this approach for their `tokio` dev-dependency, see https://github.com/lightningdevkit/rust-lightning/pull/1315.
As long as `tokio` backports bug fixes to`1.14.x` releases this should be safe. If we need any new features we can revisit this decision.
### Checklists
#### All Submissions:
* [x] I've signed all my commits
* [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
* [x] I ran `cargo fmt` and `cargo clippy` before committing
#### New Features:
* [ ] I've updated `CHANGELOG.md`
ACKs for top commit:
LLFourn:
ACK b04bb590f385db349f8dc70cc169674b530c4205
Tree-SHA512: a44d61e0d644900837b5a99e0f2b9e5706cf9932f7430c3a2c8adbff37c82e4a6a545849fe031da748fcd8c8a70f5266d6974c5b6634b50af5eae148b9a26635
b6fe01c4668b1b6737e5e24ae2282f0f55da39cd Implement XKeyUtils on InnerXKey (Gianluca Acerbis)
Pull request description:
Closes#395
<!-- You can erase any parts of this template not applicable to your Pull Request. -->
### Description
<!-- Describe the purpose of this PR, what's being adding and/or fixed -->
### Notes to the reviewers
<!-- In this section you can include notes directed to the reviewers, like explaining why some parts
of the PR were done in a specific way -->
### Checklists
#### All Submissions:
* [x] I've signed all my commits
* [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
* [x] I ran `cargo fmt` and `cargo clippy` before committing
#### New Features:
* [ ] I've added tests for the new feature
* [ ] I've added docs for the new feature
* [ ] I've updated `CHANGELOG.md`
#### Bugfixes:
* [ ] This pull request breaks the existing API
* [ ] I've added tests to reproduce the issue which are now passing
* [x] I'm linking the issue being fixed by this PR
ACKs for top commit:
danielabrozzoni:
ACK b6fe01c4668b1b6737e5e24ae2282f0f55da39cd - the code looks good to me, I tested locally and all tests pass
notmandatory:
ACK b6fe01c4668b1b6737e5e24ae2282f0f55da39cd
Tree-SHA512: 00a3ed9532a0589ac4be55a7d0c6ac5251f03f716adb2086eb934d9a9b04bcb7fd95aaeba38b68c5c90876644ce53ac5e39a912a4096e789887342f8727ae434