Update example_cli to rust-bitcoin 0.30.0

This commit is contained in:
Daniela Brozzoni 2023-06-26 12:18:43 +02:00
parent 468d2a0a3b
commit 2949bdc7b8
No known key found for this signature in database
GPG Key ID: 7DE4F1FDCED0AB87

View File

@ -7,7 +7,7 @@ use std::{cmp::Reverse, collections::HashMap, path::PathBuf, sync::Mutex, time::
use bdk_chain::{ use bdk_chain::{
bitcoin::{ bitcoin::{
psbt::Prevouts, secp256k1::Secp256k1, util::sighash::SighashCache, Address, LockTime, absolute, address, psbt::Prevouts, secp256k1::Secp256k1, sighash::SighashCache, Address,
Network, Sequence, Transaction, TxIn, TxOut, Network, Sequence, Transaction, TxIn, TxOut,
}, },
indexed_tx_graph::{IndexedAdditions, IndexedTxGraph}, indexed_tx_graph::{IndexedAdditions, IndexedTxGraph},
@ -70,7 +70,7 @@ pub enum Commands<S: clap::Subcommand> {
/// Send coins to an address. /// Send coins to an address.
Send { Send {
value: u64, value: u64,
address: Address, address: Address<address::NetworkUnchecked>,
#[clap(short, default_value = "bnb")] #[clap(short, default_value = "bnb")]
coin_select: CoinSelectionAlgo, coin_select: CoinSelectionAlgo,
}, },
@ -457,7 +457,7 @@ where
additions.append(change_additions); additions.append(change_additions);
// Clone to drop the immutable reference. // 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( let change_plan = bdk_tmp_plan::plan_satisfaction(
&graph &graph
@ -465,7 +465,8 @@ where
.keychains() .keychains()
.get(&internal_keychain) .get(&internal_keychain)
.expect("must exist") .expect("must exist")
.at_derivation_index(change_index), .at_derivation_index(change_index)
.expect("change_index can't be hardened"),
&assets, &assets,
) )
.expect("failed to obtain change plan"); .expect("failed to obtain change plan");
@ -520,9 +521,8 @@ where
// tip as the `lock_time` for anti-fee-sniping purposes // tip as the `lock_time` for anti-fee-sniping purposes
lock_time: chain lock_time: chain
.get_chain_tip()? .get_chain_tip()?
.and_then(|block_id| LockTime::from_height(block_id.height).ok()) .and_then(|block_id| absolute::LockTime::from_height(block_id.height).ok())
.unwrap_or(LockTime::ZERO) .unwrap_or(absolute::LockTime::ZERO),
.into(),
input: selected_txos input: selected_txos
.iter() .iter()
.map(|(_, utxo)| TxIn { .map(|(_, utxo)| TxIn {
@ -625,7 +625,8 @@ pub fn planned_utxos<A: Anchor, O: ChainOracle, K: Clone + bdk_tmp_plan::CanDeri
.keychains() .keychains()
.get(&k) .get(&k)
.expect("keychain must exist") .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)?; let plan = bdk_tmp_plan::plan_satisfaction(&desc, assets)?;
Some(Ok((plan, full_txo))) Some(Ok((plan, full_txo)))
}, },
@ -668,6 +669,7 @@ where
coin_select, coin_select,
} => { } => {
let chain = &*chain.lock().unwrap(); let chain = &*chain.lock().unwrap();
let address = address.require_network(network)?;
run_send_cmd( run_send_cmd(
graph, graph,
db, db,