Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge #1178:
LocalChain
with hardwired genesis block
f1b112e docs(bitcoind_rpc): update docs for `Emitter::new` (志宇) 9a250ba chore: make clippy happy (志宇) 79b84be feat(bdk): changeset's `Append` impl checks that network is consistent (志宇) 06a956a feat!: change `load_from_persistence` to return an option (志宇) c3265e2 test(bdk): add tests for wallet constructor methods (志宇) 96f1d94 test(file_store): add construction method tests (志宇) 1886dc4 chore(examples): use `Wallet::new_or_load` method where appropriate (志宇) 24994a3 feat(file_store)!: have separate methods for creating and opening Store (志宇) d294e2e feat(wallet)!: add `new_or_load` methods (志宇) 7c6cbc4 chore(file_store): rm empty test file (志宇) 6cf3963 feat(bdk)!: have separate methods for creating and loading `Wallet` (志宇) 7d5f31f feat(chain, file_store): add `is_empty` method to `PersistBackend` trait (志宇) 5998a22 feat!: `LocalChain` with hardwired genesis checkpoint (志宇) Pull request description: closes #1079 closes #1107 ### Description Many methods of `TxGraph` require a `chain_tip: BlockId` input to use against a `ChainOracle` implementation. This is used to ask the `ChainOracle` implementation whether a certain block exists in the chain identified by the `chain_tip`. This guarantees that the `TxGraph` methods will return a consistent history of transactions. However, the `ChainOracle` trait's `get_chain_tip` method returns an option of `BlockId`. It becomes unclear what to do when `get_chain_tip` returns `None`. This PR changes the `ChainOracle::get_chain_tip` method to always return a `BlockId` (no `Option`). `LocalChain` now hardwires the genesis block in order to implement `ChainOracle`. `bdk::Wallet` and `bdk_file_store::Store` are changed to have separate constructor methods for initializing a fresh instance and recovering a previous instance from persistence. ### Notes to the reviewers ### Changelog notice - Changed `ChainOracle::get_chain_tip` method to return a `BlockId` instead of an `Option` of a `BlockId`. - Refactored `LocalChain` so that the genesis `BlockId` is hardwired. This way, the `ChainOracle::get_chain_tip` implementation can always return a tip. - Add `is_empty` method to `PersistBackend`. This returns true when there is no data in the persistence. - Changed `Wallet::new` to initialize a fresh wallet only. - Added `Wallet::load` to restore an instance of a wallet. - Replaced `Store::new` with separate methods to create/open the database file. ### 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 Top commit has no ACKs. Tree-SHA512: 31b75fb53cc451f1fce7e409f1112c43973db7e8b5b31640e01e5b52089683b60320565427d6ea0478ff4c8680dbdb9272fdab08aef69d30f257da52e731e1a3
- Loading branch information