Skip to content

Commit 2949bdc

Browse files
Update example_cli to rust-bitcoin 0.30.0
1 parent 468d2a0 commit 2949bdc

File tree

1 file changed

+10
-8
lines changed
  • example-crates/example_cli/src

1 file changed

+10
-8
lines changed

example-crates/example_cli/src/lib.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::{cmp::Reverse, collections::HashMap, path::PathBuf, sync::Mutex, time::
77

88
use bdk_chain::{
99
bitcoin::{
10-
psbt::Prevouts, secp256k1::Secp256k1, util::sighash::SighashCache, Address, LockTime,
10+
absolute, address, psbt::Prevouts, secp256k1::Secp256k1, sighash::SighashCache, Address,
1111
Network, Sequence, Transaction, TxIn, TxOut,
1212
},
1313
indexed_tx_graph::{IndexedAdditions, IndexedTxGraph},
@@ -70,7 +70,7 @@ pub enum Commands<S: clap::Subcommand> {
7070
/// Send coins to an address.
7171
Send {
7272
value: u64,
73-
address: Address,
73+
address: Address<address::NetworkUnchecked>,
7474
#[clap(short, default_value = "bnb")]
7575
coin_select: CoinSelectionAlgo,
7676
},
@@ -457,15 +457,16 @@ where
457457
additions.append(change_additions);
458458

459459
// Clone to drop the immutable reference.
460-
let change_script = change_script.clone();
460+
let change_script = change_script.into();
461461

462462
let change_plan = bdk_tmp_plan::plan_satisfaction(
463463
&graph
464464
.index
465465
.keychains()
466466
.get(&internal_keychain)
467467
.expect("must exist")
468-
.at_derivation_index(change_index),
468+
.at_derivation_index(change_index)
469+
.expect("change_index can't be hardened"),
469470
&assets,
470471
)
471472
.expect("failed to obtain change plan");
@@ -520,9 +521,8 @@ where
520521
// tip as the `lock_time` for anti-fee-sniping purposes
521522
lock_time: chain
522523
.get_chain_tip()?
523-
.and_then(|block_id| LockTime::from_height(block_id.height).ok())
524-
.unwrap_or(LockTime::ZERO)
525-
.into(),
524+
.and_then(|block_id| absolute::LockTime::from_height(block_id.height).ok())
525+
.unwrap_or(absolute::LockTime::ZERO),
526526
input: selected_txos
527527
.iter()
528528
.map(|(_, utxo)| TxIn {
@@ -625,7 +625,8 @@ pub fn planned_utxos<A: Anchor, O: ChainOracle, K: Clone + bdk_tmp_plan::CanDeri
625625
.keychains()
626626
.get(&k)
627627
.expect("keychain must exist")
628-
.at_derivation_index(i);
628+
.at_derivation_index(i)
629+
.expect("i can't be hardened");
629630
let plan = bdk_tmp_plan::plan_satisfaction(&desc, assets)?;
630631
Some(Ok((plan, full_txo)))
631632
},
@@ -668,6 +669,7 @@ where
668669
coin_select,
669670
} => {
670671
let chain = &*chain.lock().unwrap();
672+
let address = address.require_network(network)?;
671673
run_send_cmd(
672674
graph,
673675
db,

0 commit comments

Comments
 (0)