Skip to content

Commit

Permalink
Update example_cli to rust-bitcoin 0.30.0
Browse files Browse the repository at this point in the history
  • Loading branch information
danielabrozzoni committed Aug 3, 2023
1 parent 468d2a0 commit 2949bdc
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions example-crates/example_cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::{cmp::Reverse, collections::HashMap, path::PathBuf, sync::Mutex, time::

use bdk_chain::{
bitcoin::{
psbt::Prevouts, secp256k1::Secp256k1, util::sighash::SighashCache, Address, LockTime,
absolute, address, psbt::Prevouts, secp256k1::Secp256k1, sighash::SighashCache, Address,
Network, Sequence, Transaction, TxIn, TxOut,
},
indexed_tx_graph::{IndexedAdditions, IndexedTxGraph},
Expand Down Expand Up @@ -70,7 +70,7 @@ pub enum Commands<S: clap::Subcommand> {
/// Send coins to an address.
Send {
value: u64,
address: Address,
address: Address<address::NetworkUnchecked>,
#[clap(short, default_value = "bnb")]
coin_select: CoinSelectionAlgo,
},
Expand Down Expand Up @@ -457,15 +457,16 @@ where
additions.append(change_additions);

// Clone to drop the immutable reference.
let change_script = change_script.clone();
let change_script = change_script.into();

let change_plan = bdk_tmp_plan::plan_satisfaction(
&graph
.index
.keychains()
.get(&internal_keychain)
.expect("must exist")
.at_derivation_index(change_index),
.at_derivation_index(change_index)
.expect("change_index can't be hardened"),
&assets,
)
.expect("failed to obtain change plan");
Expand Down Expand Up @@ -520,9 +521,8 @@ where
// tip as the `lock_time` for anti-fee-sniping purposes
lock_time: chain
.get_chain_tip()?
.and_then(|block_id| LockTime::from_height(block_id.height).ok())
.unwrap_or(LockTime::ZERO)
.into(),
.and_then(|block_id| absolute::LockTime::from_height(block_id.height).ok())
.unwrap_or(absolute::LockTime::ZERO),
input: selected_txos
.iter()
.map(|(_, utxo)| TxIn {
Expand Down Expand Up @@ -625,7 +625,8 @@ pub fn planned_utxos<A: Anchor, O: ChainOracle, K: Clone + bdk_tmp_plan::CanDeri
.keychains()
.get(&k)
.expect("keychain must exist")
.at_derivation_index(i);
.at_derivation_index(i)
.expect("i can't be hardened");
let plan = bdk_tmp_plan::plan_satisfaction(&desc, assets)?;
Some(Ok((plan, full_txo)))
},
Expand Down Expand Up @@ -668,6 +669,7 @@ where
coin_select,
} => {
let chain = &*chain.lock().unwrap();
let address = address.require_network(network)?;
run_send_cmd(
graph,
db,
Expand Down

0 comments on commit 2949bdc

Please sign in to comment.