Commit Graph
100 Commits
Author SHA1 Message Date
LLFourn 53fa35096f refactor(electrum)!: put the tx cache in electrum
Previously there was a tx cache that you passed in as part of the sync
request. This seems bad and the example show'd that you should copy all
your transactions from the transaction graph into the sync request every
time you sync'd. If you forgot to do this then you would always download everything.

Instead just do a plain old simple cache inside the electrum client.
This way at least you only download transactions once. You can
pre-populate the cache with a method also and I did this in the examples.
2024-06-04 12:23:01 +08:00
LLFourn fac228337c feat(chain)!: make KeychainTxOutIndex more range based
`KeychainTxOutIndex` should try and avoid "all" kind of queries.
There may be subranges of interest. If the user wants "all" they can
just query "..".
2024-04-18 15:31:14 +08:00
LLFourn 13ab5a835d chore(chain): Improve TxGraph::ChangeSet docs 2024-02-10 09:13:08 +11:00
LLFourn ae00e1ee7b fix(chain): tx_graph::ChangeSet::is_empty 2024-02-09 20:03:57 +11:00
LLFourn adc95137ac fix(chain)! Re-order fields in anchors so Ord DWIM 2024-02-09 13:48:19 +11:00
LLFourn 216648bcfd chore(esplora): Clarify consistency guarantees 2024-01-30 13:57:06 +11:00
LLFourn 66dc34e75a refactor(file_store): Use BufReader but simplify 2024-01-23 11:41:00 +08:00
LLFourn e6433fb2c1 feat(persist): Add stage_and_commit to Persist
In the example_cli we were not always committing (seemingly by mistake).
This then caused all the examples to have to compensate by manually
committing.
2024-01-19 11:28:56 +11:00
LLFourn 0bee46e75b fix(store): Remove lifetime
Remove gratuitous use of lifetimes in the main persistence struct
2024-01-19 11:28:56 +11:00
LLFourn a4f28c079e chore: improve LocalChain::apply_header_connected_to doc 2024-01-16 10:29:49 +11:00
LLFourn c9467dcbb2 chore: improve documentation of lookahead 2023-12-29 16:40:48 +11:00
LLFourn 5e79b81a6a fix: Remove dependency on unnecessary bdk_chain features 2023-10-04 10:52:12 +11:00
LLFourn 4104206980 feat: impl Append for lots of tuples 2023-09-05 07:53:50 +08:00
LLFourn f41cc1cb37 fix: s/index_tx_graph/indexed_tx_graph/g 2023-08-31 13:07:19 +02:00
LLFourn a78967e51b [example-cli] simplify new address logic 2023-06-04 03:32:18 +08:00
LLFourn 2fcf9c4adb Make async esplora futures Send 2023-03-10 12:19:54 +11:00
LLFourn a38f63359d Make bdk_file_store use bincode v1 2023-03-03 17:44:10 +01:00
LLFourn b5559767db Rename the stub wallet examples 2023-03-02 10:56:38 +01:00
LLFourn 2e82cd8c04 Use tempfile for file_store tests 2023-03-02 10:56:37 +01:00
LLFourn c069b0fb41 Move everything else over 🎉
This completes the move of things from https://github.com/LLFourn/bdk_core_staging
2023-03-02 10:56:36 +01:00
LLFourn f2188f9dcd Make lib.rs's docs be the README.md
Also flesh out README a bit
2023-03-02 10:56:32 +01:00
LLFourn 94a084aafd Fix doc links 2023-03-02 10:56:30 +01:00
LLFourn 9edbdf54c9 [ci] Fix feature flags 2023-03-02 10:56:29 +01:00
LLFourn 20e45b7af0 Add back test-hardware-signer feature 2023-03-02 10:56:28 +01:00
LLFourn 6d05598407 Remove test-readme-examples
we shouldn't have a feature flag for this it should always be done.
2023-03-02 10:56:27 +01:00
LLFourn b60820a7b5 Remove authors.workspace because older cargo don't like 2023-03-02 10:56:26 +01:00
LLFourn 22bec6d363 Delete unused errors 2023-03-02 10:56:25 +01:00
LLFourn 8a6de3aa2d Convert to workspace 2023-03-02 10:56:22 +01:00
LLFourn fdfc9b9ede Delete unused things 2023-03-02 10:55:15 +01:00
LLFourn e1eb0253cf Make doctests work 2023-03-02 10:55:14 +01:00
LLFourn 3baf9721ec Use bdk_chain Balance
instead of bdk's one
2023-03-02 10:55:13 +01:00
LLFourn b310a7afdd Add Wallet::cancel_tx
To allow you to re-use change addresses from transactions that get cancelled.
2023-03-02 10:55:12 +01:00
LLFourn 5985706c1a Add wallet persistence 2023-03-02 10:55:11 +01:00
LLFourn 57538e53e4 Move tests to /tests
To stop my rust-anlayzer from killing me
2023-03-02 10:55:10 +01:00
LLFourn a40da9ba6c Make bdk no_std 2023-03-02 10:55:09 +01:00
LLFourn aab2b12f7a bdk_core integration initial commit 🔥
We prepare the BDK repo for a major restructuring.

- database modules removed
- blockchain module removed
- minimal API changes.
- Many macros removed.
- no longer applicable examples removed.
- Much conditional compilation removed. Can compile with --all-features.
- delete verify module
2023-03-02 10:55:07 +01:00
LLFourn e9bbb8724f Fix wallet export rescan height
It would return the latest transaction height rather than the earliest :S
2022-10-26 12:35:21 +08:00
LLFourn 559cfc4373 Fix pre-segwit inputs with esplora 2022-03-17 10:37:03 -05:00
LLFourn 52bc63e48f Fix pre-segwit inputs with esplora 2022-03-16 10:39:53 +11:00
LLFourn 660faab1e2 Fix typo in CHANGELOG 2022-03-08 14:00:29 +11:00
LLFourn 45767fcaf7 Remove max_addresses sync param
You can do this with ensure_addresses_cached if you really want to.
2022-03-07 10:44:41 +11:00
LLFourn d03aa85108 Merge branch 'master' into remove-blockchain-from-wallet 2022-03-03 13:13:45 +11:00
LLFourn 035307ef54 [rpc] Filter out unrelated transactions
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.
2022-02-24 20:39:00 +11:00
LLFourn c0e75fc1a8 Split get_tx into its own trait
to make supporting verify_tx easier
2022-02-24 20:39:00 +11:00
LLFourn dcd90f8b61 Restore but depreciate new_offline 2022-02-24 20:39:00 +11:00
LLFourn 410a51355b Add SyncOptions as the second argument to Wallet::sync
The current options are awkward and it would be good if we could
introduce more in the future without breaking changes.
2022-02-24 20:39:00 +11:00
LLFourn 326bfe82a8 Remove Blockchain from wallet
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.
2022-02-24 20:39:00 +11:00
LLFourn 00f0901bac Add API for internal addresses
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.
2022-02-23 09:28:08 +11:00
LLFourn a630685a0a Merge branch 'master' into sync_pipeline 2021-11-23 12:53:40 +11:00
LLFourn 9c5770831d Make stop_gap a parameter to EsploraBlockchainConfig::new 2021-11-10 09:07:36 +11:00
LLFourn 0f0a01a742 s/vin/vout/ 2021-11-10 09:07:36 +11:00
LLFourn 1a64fd9c95 Delete src/blockchain/utils.rs 2021-11-10 09:07:36 +11:00
LLFourn d3779fac73 Fix comments 2021-11-10 09:07:36 +11:00
LLFourn d39401162f Less intermediary data states in sync
Use BTrees to store ordered sets rather than HashSets -> VecDequeue
2021-11-10 09:07:36 +11:00
LLFourn dfb63d389b s/observed_txs/finished_txs/g 2021-11-10 09:07:36 +11:00
LLFourn 188d9a4a8b Make variable names consistent 2021-11-10 09:07:36 +11:00
LLFourn 5eadf5ccf9 Add some logging to script_sync 2021-11-10 09:07:36 +11:00
LLFourn aaad560a91 Always get up to chunk_size heights to request headers for 2021-11-10 09:07:36 +11:00
LLFourn e7c13575c8 Don't request conftime during tx request 2021-11-10 09:07:36 +11:00
LLFourn 808d7d8463 Update changelog 2021-11-10 09:07:34 +11:00
LLFourn 732166fcb6 Fix feerate calculation for esplora 2021-11-10 09:06:49 +11:00
LLFourn 3f5cb6997f Invert dependencies in electrum sync
Blockchain calls sync logic rather than the other way around.
Sync logic is captured in script_sync.rs.
2021-11-10 09:06:49 +11:00
LLFourn c601ae3271 [fix-build] Fix version of zeroize_derive to 1.1.0 2021-09-22 11:01:37 +10:00
LLFourn 7597645ed6 Replace set_single_recipient with drain_to
What set_single_recipient does turns out to be useful with multiple
recipients.
Effectively, set_single_recipient was simply creating a change
output that was arbitrarily required to be the only output.
But what if you want to send excess funds to one address but still have
additional recipients who receive a fixed value?
Generalizing this to `drain_to` simplifies the logic and removes several
error cases while also allowing new use cases.

"maintain_single_recipient" is also replaced with "allow_shrinking"
which has more general semantics.
2021-07-12 16:38:42 +10:00
LLFourn 618e0d3700 Replace set_single_recipient with drain_to
What set_single_recipient does turns out to be useful with multiple
recipients.
Effectively, set_single_recipient was simply creating a change
output that was arbitrarily required to be the only output.
But what if you want to send excess funds to one address but still have
additional recipients who receive a fixed value?
Generalizing this to `drain_to` simplifies the logic and removes several
error cases while also allowing new use cases.

"maintain_single_recipient" is also replaced with "allow_shrinking"
which has more general semantics.
2021-07-12 16:21:53 +10:00
LLFourn ea8488b2a7 Initialize env_logger at start of blockchain tests 2021-05-21 13:21:59 +10:00
LLFourn d2a981efee run_blockchain_tests.sh improvements 2021-05-21 13:21:41 +10:00
LLFourn 4c92daf517 Uppercase 'Test' so that github can see what's up
It is expecting something named 'Test electrum'
2021-05-20 14:33:02 +10:00
LLFourn aba2a05d83 Add script for running the blockchain tests locally 2021-05-19 16:45:48 +10:00
LLFourn 5b194c268d Fix clippy warnings inside testutils macro
Now that it's inside the main repo clippy is having a go at me.
2021-05-19 16:45:48 +10:00
LLFourn 00bdf08f2a Remove testutils feature so doctests worka again
I wanted to only conditionally compile testutils but it's needed in
doctests which we can't conditionally compile for:

https://github.com/rust-lang/rust/issues/67295
2021-05-19 16:45:48 +10:00
LLFourn 38b0470b14 Move blockchain related stuff to blockchain_tests 2021-05-19 16:45:48 +10:00
LLFourn d60c5003bf Merge testutils crate into the main crate
This avoids having to keep the apis in sync between the macros and the
main project.
2021-05-19 16:45:48 +10:00
LLFourn fcae5adabd Run blockchain tests on esplora
They were only being run on electrum before.
2021-05-19 15:47:44 +10:00
LLFourn 465ef6e674 Roll blockchain tests proc macro into normal macro
This means one less crate in the repo. Had to do a Default on TestClient
to satisfy clippy.
2021-05-18 20:02:33 +10:00
LLFourn 5a0c150ff9 Make wallet methods take &mut psbt
Rather than consuming it because that is unergonomic.
2021-04-28 15:34:25 +10:00
LLFourn 882a9c27cc Use tagged serialization for blockchain config
also make the config types Clone and PartialEq
2021-04-03 15:30:49 +11:00
LLFourn ac7c1bd97b Clean up add_foreign_utxo tests a bit
Noticed some suboptimal things while reviewing myself.
2021-02-26 13:33:52 +11:00
LLFourn d9a102afa9 Improve docs of satisfaction_weight 2021-02-26 13:33:52 +11:00
LLFourn 1fbfeabd77 Added add_foreign_utxo
To allow adding UTXOs external to the current wallet.
The caller must provide the psbt::Input so we can create a coherent PSBT
at the end and so this is compatible with existing PSBT workflows.

Main changes:

- There are now two types of UTXOs, local and foreign reflected in a
`Utxo` enum.
- `WeightedUtxo` now captures floating `(Utxo, usize)` tuples
- `CoinSelectionResult` now has methods on it for distinguishing between
local amount included vs total.
2021-02-26 13:33:52 +11:00
LLFourn 9a918f285d Make TxBuilder actually Clone
it derived Clone but in practice it was never clone because some of the
parameters were not Clone.
2021-02-26 13:33:52 +11:00
LLFourn a7183f34ef s/UTXO/LocalUtxo/g
Since this struct has a "keychain" it is not a general "UTXO" but a
local wallet UTXO.
2021-02-26 13:33:52 +11:00
LLFourn 6689384c8a Merge branch 'master' into make_txbuilder_take_ref_to_wallet 2021-01-30 13:12:13 +11:00
LLFourn 35a61f5759 Fix whitespace and curse emacs 2021-01-30 13:05:23 +11:00
LLFourn d0ffd5606a Fix CHANGELOG to mention s/utxos/add_utxos/ 2021-01-30 12:58:05 +11:00
LLFourn dbf8cf7674 Make maintain_single_recipient return a Result
preferable to panicking.
2021-01-29 12:33:07 +11:00
LLFourn ff10aa5ceb Add "add_utxos" method on TxBuilder
To replace the previously existing ".utxos"
2021-01-22 15:08:31 +11:00
LLFourn 21d382315a Remove not very useful comment
Thanks @tcharding.
2021-01-22 15:08:30 +11:00
LLFourn 6fe3be0243 Derive Clone + Debug for TxBuilder
And make Wallet Debug while I'm at it.
2021-01-22 15:08:30 +11:00
LLFourn 10fcba9439 Revert back to Vec to hold utxos in builder
Due to brain malfunction I made utxos into a BTree. This made a test
pass but is incorrect. The test itself was incorrect as per comment in

https://github.com/bitcoindevkit/bdk/pull/258#issuecomment-758370380

So I (1) reverted utxos back to a Vec, (2) fixed the test and expanded
the comment in the test.
2021-01-22 15:08:30 +11:00
LLFourn 890d6191a1 Remove Option trickery from TxBuilder API
see: https://github.com/bitcoindevkit/bdk/pull/258#issuecomment-754685962
2021-01-22 15:08:30 +11:00
LLFourn 735db02850 Assert that .finish() hasn't been called already in coin_selection 2021-01-22 14:33:37 +11:00
LLFourn 7bf46c7d71 Add comment explaining why params and coin_selection are Options 2021-01-22 14:33:37 +11:00
LLFourn 8319b32466 Fix wrong doc links 2021-01-22 14:33:37 +11:00
LLFourn 0faca43744 Make testutils dependency path relative 2021-01-22 14:33:37 +11:00
LLFourn 6f66de3d16 Update Changelog for Tx creation overhaul 2021-01-22 14:33:37 +11:00
LLFourn 5fb7fdffe1 [wallet] Use doctest_wallet!() to remove some no_runs from doctests
...and improve the fee bumping example while trying to make it
no_run (but failed).
2021-01-22 14:33:37 +11:00
LLFourn 7553b905c4 [wallet] Overhaul TxBuilder internals and externals
Fixes #251

TxBuilders are now not created directly but are created through the
wallet with `build_tx` and `build_fee_bump`.
The advantages of this realised in this commit are:

1. Normal tx creation and fee bumping use the code internally. The only
difference between normal tx and fee bump is how the builder is created.
2. The TxBuilder now has a refernce to the wallet and can therefore
lookup things as methods are called on it. `add_utxo` now uses this to
look up UTXO deta when it is called (rather than having to do it and
possibly error later on).

To support these changes `get_utxo` and `get_descriptor_for_keychain`
public methods have been added to Wallet. I could have kept them
pub(crate) but they seem like fine APIs to have publicly.
2021-01-22 14:33:37 +11:00
LLFourn f74f17e227 Change "received_tx" into "populate_test_db" macro
A `[cfg(test)]` function is not as helpful as a macro since it can't be
called in the context of a doctest.

Also adds doctest_wallet macro which can be used to create a wallet in a
doctest.
2021-01-22 14:23:36 +11:00
LLFourn 0c9c0716a4 [wallet] Fix details.fees being wrong when change is dust 2020-12-29 16:36:35 +11:00