Skip to content

Commit dbb143a

Browse files
committed
Merge #294: feat(utxo-locking)!: Add commands to lock, unlock and list locked UTXOs
7c2dfac feat(utxo-locking): Limit locking to known utxos (Vihiga Tyonum) 90270f7 fix(bip322): Re-enable bip322 feature (Vihiga Tyonum) aba6c66 feat(utxo-locking): Add tests for utxo locking (Vihiga Tyonum) d3dde30 fix(bip322): disable bip322 feature (Vihiga Tyonum) 242d4da feat(utxo-locking): Add wallet locking commands (Vihiga Tyonum) 205d46c feat(cbf): Update bdk_kyoto to v0.17.0 (Vihiga Tyonum) d89a08d feat(wallet-3.1.0): Update Wallet to v3.1.0 (Vihiga Tyonum) cbee8a0 fix(proxy_opts): add saving and reading proxy_opts (Vihiga Tyonum) eec81e2 ref(verbose): Dropped `verbose` flag from tests (Vihiga Tyonum) dfeb580 test(online): Add test transaction full cycle (Vihiga Tyonum) ae0c32a test: Add integration tests for offline wallet ops (Vihiga Tyonum) b8761bc test: Add wallets, descriptor, compile & config (Vihiga Tyonum) 38a709f test: Add helper fns & integration tests for key (Vihiga Tyonum) 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 --> This PR updates the Wallet API to v3.1.0 and adds wallet subcommands to lock and unlock UTXOs. Locked outpoints are excluded from coin selection, and the lock state is stored in the wallet. It also updates the `bdk_redb` to v0.2.0 and `bdk_kyoto` to v0.17.0. Fixes #293 and builds upon #289 and #278 ### 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 --> ## Changelog notice <!-- Notice the release manager should include in the release tag message changelog --> <!-- See https://keepachangelog.com/en/1.0.0/ for examples --> - Update bdk_wallet to v3.1.0 - Add wallet `lock_utxo` command - Add wallet `unlock_utxo` command - Add wallet `locked_uxtos` command - Update bdk_redb to v0.2.0 - Update bdk_kyoto to v0.17.0 - Replace `Network` enum with `NetworkKind` - Replace `include_output_redeem_witness_script` with `add_global_xpubs` in TxBuilder - Replace `submit_package` with `broadcast_random` for broadcasting transactions in KyotoClient ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk-cli/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` Top commit has no ACKs. Tree-SHA512: df9291a93f2231408981d5a90b6164a75e6ca4b6c73e5638fe1c18323ea2be1c1b485bddc86efbfc64620087238df19dcb5274272a1ea27cd8b5dac0f08e6b6b
2 parents 9b58a1a + 7c2dfac commit dbb143a

13 files changed

Lines changed: 282 additions & 101 deletions

File tree

Cargo.lock

Lines changed: 66 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ readme = "README.md"
1212
license = "MIT"
1313

1414
[dependencies]
15-
bdk_wallet = { version = "2.4.0", features = ["rusqlite", "keys-bip39", "compiler", "std"] }
15+
bdk_wallet = { version = "3.1.0", features = ["rusqlite", "keys-bip39", "compiler", "std"] }
1616
clap = { version = "4.6", features = ["derive","env"] }
1717
clap_complete = "4.6"
1818
dirs = { version = "6.0.0" }
@@ -32,14 +32,14 @@ tap = "1.0.1"
3232
bdk_bitcoind_rpc = { version = "0.22.0", features = ["std"], optional = true }
3333
bdk_electrum = { version = "0.24.0", optional = true }
3434
bdk_esplora = { version = "0.22.2", features = ["async-https", "tokio"], optional = true }
35-
bdk_kyoto = { version = "0.15.4", optional = true }
36-
bdk_redb = { version = "0.1.1", optional = true }
35+
bdk_kyoto = { version = "0.17.0", optional = true }
36+
bdk_redb = { version = "0.2.0", optional = true }
3737
bdk_sp = { version = "0.1.0", optional = true, git = "https://github.com/bitcoindevkit/bdk-sp", tag = "v0.1.0" }
3838
shlex = { version = "1.3.0", optional = true }
3939
payjoin = { version = "0.25.0", features = ["v1", "v2", "io", "_test-utils"], optional = true}
4040
reqwest = { version = "0.13.2", default-features = false, features = ["rustls"], optional = true }
4141
url = { version = "2.5.8", optional = true }
42-
bdk_bip322 = { version = "0.1.0", optional = true }
42+
bdk_message_signer = { version = "0.2.0", optional = true }
4343
bitcoin-payment-instructions = { version = "0.7.0", optional = true}
4444

4545
[features]
@@ -61,7 +61,7 @@ dns_payment = ["bitcoin-payment-instructions"]
6161

6262
# Internal features
6363
_payjoin-dependencies = ["payjoin", "reqwest", "url", "sqlite"]
64-
bip322 = ["bdk_bip322"]
64+
bip322 = ["bdk_message_signer"]
6565

6666
# Use this to consensus verify transactions at sync time
6767
verify = []
@@ -74,7 +74,6 @@ compiler = []
7474
silent-payments = ["dep:bdk_sp"]
7575

7676
[dev-dependencies]
77-
claims = "0.8.0"
7877
predicates = "3.0"
7978
tempfile = "3.8"
8079
assert_cmd = "2.2.2"

src/client.rs

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ use {
2323
};
2424

2525
#[cfg(feature = "cbf")]
26-
use {
27-
crate::utils::trace_logger,
28-
bdk_kyoto::{BuilderExt, LightClient},
29-
};
26+
use {crate::utils::trace_logger, bdk_kyoto::BuilderExt};
3027

3128
#[cfg(any(
3229
feature = "electrum",
@@ -101,14 +98,10 @@ impl BlockchainClient {
10198
#[cfg(feature = "cbf")]
10299
Self::KyotoClient { client } => {
103100
let txid = tx.compute_txid();
104-
let wtxid = client
105-
.requester
106-
.broadcast_random(tx.clone())
107-
.await
108-
.map_err(|_| {
109-
tracing::warn!("Broadcast was unsuccessful");
110-
Error::Generic("Transaction broadcast timed out after 30 seconds".into())
111-
})?;
101+
let wtxid = client.requester.submit_package(tx).await.map_err(|_| {
102+
tracing::warn!("Broadcast was unsuccessful");
103+
Error::Generic("Transaction broadcast timed out after 30 seconds".into())
104+
})?;
112105
tracing::info!("Successfully broadcast WTXID: {wtxid}");
113106
Ok(txid)
114107
}
@@ -205,7 +198,8 @@ impl BlockchainClient {
205198
#[cfg(feature = "cbf")]
206199
pub struct KyotoClientHandle {
207200
pub requester: bdk_kyoto::Requester,
208-
pub update_subscriber: tokio::sync::Mutex<bdk_kyoto::UpdateSubscriber>,
201+
pub update_subscriber:
202+
tokio::sync::Mutex<bdk_kyoto::UpdateSubscriber<bdk_kyoto::wallets::Single>>,
209203
}
210204

211205
#[cfg(any(
@@ -267,21 +261,16 @@ pub(crate) fn new_blockchain_client(
267261
.data_dir(&_datadir)
268262
.build_with_wallet(_wallet, scan_type)?;
269263

270-
let LightClient {
271-
requester,
272-
info_subscriber,
273-
warning_subscriber,
274-
update_subscriber,
275-
node,
276-
} = light_client;
264+
let (client, logging, update_subscriber) = light_client.subscribe();
265+
// `start()` spawns the node's run loop on a tokio task internally.
266+
let requester = client.start().requester();
277267

278268
let subscriber = tracing_subscriber::FmtSubscriber::new();
279269
let _ = tracing::subscriber::set_global_default(subscriber);
280270

281-
tokio::task::spawn(async move { node.run().await });
282-
tokio::task::spawn(
283-
async move { trace_logger(info_subscriber, warning_subscriber).await },
284-
);
271+
tokio::task::spawn(async move {
272+
trace_logger(logging.info_subscriber, logging.warning_subscriber).await
273+
});
285274

286275
BlockchainClient::KyotoClient {
287276
client: Box::new(KyotoClientHandle {

0 commit comments

Comments
 (0)