Merge bitcoindevkit/bdk#1177: Upgrade bitcoin/miniscript dependencies

984c758f96 Upgrade miniscript/bitcoin dependency (Tobin C. Harding)

Pull request description:

  Upgrade:

  - bitcoin to v0.31.0
  - miniscript to v11.0.0

  Fix: #1196

ACKs for top commit:
  ValuedMammal:
    ACK 984c758f96
  notmandatory:
    ACK 984c758f96
  oleonardolima:
    ACK 984c758f96
  storopoli:
    ACK 984c758f96

Tree-SHA512: d64d530e93cc36688ba07d3677d5c1689b61f246f05d08092bbf86ddbba8a5ec49648e6825b950ef17729dc064da50d50b793475a288862a0461976876807170
This commit is contained in:
Steve Myers
2024-04-12 10:48:48 -05:00
49 changed files with 556 additions and 519 deletions

View File

@@ -70,7 +70,7 @@ macro_rules! changeset {
#[allow(unused)]
pub fn new_tx(lt: u32) -> bitcoin::Transaction {
bitcoin::Transaction {
version: 0x00,
version: bitcoin::transaction::Version::non_standard(0x00),
lock_time: bitcoin::absolute::LockTime::from_consensus(lt),
input: vec![],
output: vec![],

View File

@@ -3,8 +3,8 @@ use std::collections::HashMap;
use bdk_chain::{tx_graph::TxGraph, Anchor, SpkTxOutIndex};
use bitcoin::{
locktime::absolute::LockTime, secp256k1::Secp256k1, OutPoint, ScriptBuf, Sequence, Transaction,
TxIn, TxOut, Txid, Witness,
locktime::absolute::LockTime, secp256k1::Secp256k1, transaction, Amount, OutPoint, ScriptBuf,
Sequence, Transaction, TxIn, TxOut, Txid, Witness,
};
use miniscript::Descriptor;
@@ -68,7 +68,7 @@ pub fn init_graph<'a, A: Anchor + Clone + 'a>(
for (bogus_txin_vout, tx_tmp) in tx_templates.into_iter().enumerate() {
let tx = Transaction {
version: 0,
version: transaction::Version::non_standard(0),
lock_time: LockTime::ZERO,
input: tx_tmp
.inputs
@@ -111,11 +111,11 @@ pub fn init_graph<'a, A: Anchor + Clone + 'a>(
.iter()
.map(|output| match &output.spk_index {
None => TxOut {
value: output.value,
value: Amount::from_sat(output.value),
script_pubkey: ScriptBuf::new(),
},
Some(index) => TxOut {
value: output.value,
value: Amount::from_sat(output.value),
script_pubkey: spk_index.spk_at_index(index).unwrap().to_owned(),
},
})

View File

@@ -9,7 +9,9 @@ use bdk_chain::{
local_chain::LocalChain,
tx_graph, ChainPosition, ConfirmationHeightAnchor,
};
use bitcoin::{secp256k1::Secp256k1, OutPoint, Script, ScriptBuf, Transaction, TxIn, TxOut};
use bitcoin::{
secp256k1::Secp256k1, Amount, OutPoint, Script, ScriptBuf, Transaction, TxIn, TxOut,
};
use miniscript::Descriptor;
/// Ensure [`IndexedTxGraph::insert_relevant_txs`] can successfully index transactions NOT presented
@@ -35,11 +37,11 @@ fn insert_relevant_txs() {
let tx_a = Transaction {
output: vec![
TxOut {
value: 10_000,
value: Amount::from_sat(10_000),
script_pubkey: spk_0,
},
TxOut {
value: 20_000,
value: Amount::from_sat(20_000),
script_pubkey: spk_1,
},
],
@@ -154,7 +156,7 @@ fn test_list_owned_txouts() {
..Default::default()
}],
output: vec![TxOut {
value: 70000,
value: Amount::from_sat(70000),
script_pubkey: trusted_spks[0].to_owned(),
}],
..common::new_tx(0)
@@ -163,7 +165,7 @@ fn test_list_owned_txouts() {
// tx2 is an incoming transaction received at untrusted keychain at block 1.
let tx2 = Transaction {
output: vec![TxOut {
value: 30000,
value: Amount::from_sat(30000),
script_pubkey: untrusted_spks[0].to_owned(),
}],
..common::new_tx(0)
@@ -176,7 +178,7 @@ fn test_list_owned_txouts() {
..Default::default()
}],
output: vec![TxOut {
value: 10000,
value: Amount::from_sat(10000),
script_pubkey: trusted_spks[1].to_owned(),
}],
..common::new_tx(0)
@@ -185,7 +187,7 @@ fn test_list_owned_txouts() {
// tx4 is an external transaction receiving at untrusted keychain, unconfirmed.
let tx4 = Transaction {
output: vec![TxOut {
value: 20000,
value: Amount::from_sat(20000),
script_pubkey: untrusted_spks[1].to_owned(),
}],
..common::new_tx(0)
@@ -194,7 +196,7 @@ fn test_list_owned_txouts() {
// tx5 is spending tx3 and receiving change at trusted keychain, unconfirmed.
let tx5 = Transaction {
output: vec![TxOut {
value: 15000,
value: Amount::from_sat(15000),
script_pubkey: trusted_spks[2].to_owned(),
}],
..common::new_tx(0)

View File

@@ -9,7 +9,7 @@ use bdk_chain::{
Append,
};
use bitcoin::{secp256k1::Secp256k1, OutPoint, ScriptBuf, Transaction, TxOut};
use bitcoin::{secp256k1::Secp256k1, Amount, OutPoint, ScriptBuf, Transaction, TxOut};
use miniscript::{Descriptor, DescriptorPublicKey};
#[derive(Clone, Debug, PartialEq, Eq, Ord, PartialOrd)]
@@ -176,14 +176,14 @@ fn test_lookahead() {
.at_derivation_index(external_index)
.unwrap()
.script_pubkey(),
value: 10_000,
value: Amount::from_sat(10_000),
},
TxOut {
script_pubkey: internal_desc
.at_derivation_index(internal_index)
.unwrap()
.script_pubkey(),
value: 10_000,
value: Amount::from_sat(10_000),
},
],
..common::new_tx(external_index)
@@ -238,7 +238,7 @@ fn test_scan_with_lookahead() {
let op = OutPoint::new(h!("fake tx"), spk_i);
let txout = TxOut {
script_pubkey: spk.clone(),
value: 0,
value: Amount::ZERO,
};
let changeset = txout_index.index_txout(op, &txout);
@@ -264,7 +264,7 @@ fn test_scan_with_lookahead() {
let op = OutPoint::new(h!("fake tx"), 41);
let txout = TxOut {
script_pubkey: spk_41,
value: 0,
value: Amount::ZERO,
};
let changeset = txout_index.index_txout(op, &txout);
assert!(changeset.is_empty());

View File

@@ -1,5 +1,5 @@
use bdk_chain::{indexed_tx_graph::Indexer, SpkTxOutIndex};
use bitcoin::{absolute, OutPoint, ScriptBuf, Transaction, TxIn, TxOut};
use bitcoin::{absolute, transaction, Amount, OutPoint, ScriptBuf, Transaction, TxIn, TxOut};
#[test]
fn spk_txout_sent_and_received() {
@@ -11,11 +11,11 @@ fn spk_txout_sent_and_received() {
index.insert_spk(1, spk2.clone());
let tx1 = Transaction {
version: 0x02,
version: transaction::Version::TWO,
lock_time: absolute::LockTime::ZERO,
input: vec![],
output: vec![TxOut {
value: 42_000,
value: Amount::from_sat(42_000),
script_pubkey: spk1.clone(),
}],
};
@@ -30,7 +30,7 @@ fn spk_txout_sent_and_received() {
);
let tx2 = Transaction {
version: 0x1,
version: transaction::Version::ONE,
lock_time: absolute::LockTime::ZERO,
input: vec![TxIn {
previous_output: OutPoint {
@@ -41,12 +41,12 @@ fn spk_txout_sent_and_received() {
}],
output: vec![
TxOut {
value: 20_000,
value: Amount::from_sat(20_000),
script_pubkey: spk2,
},
TxOut {
script_pubkey: spk1,
value: 30_000,
value: Amount::from_sat(30_000),
},
],
};
@@ -73,11 +73,11 @@ fn mark_used() {
assert!(spk_index.is_used(&1));
let tx1 = Transaction {
version: 0x02,
version: transaction::Version::TWO,
lock_time: absolute::LockTime::ZERO,
input: vec![],
output: vec![TxOut {
value: 42_000,
value: Amount::from_sat(42_000),
script_pubkey: spk1,
}],
};

View File

@@ -8,7 +8,8 @@ use bdk_chain::{
Anchor, Append, BlockId, ChainOracle, ChainPosition, ConfirmationHeightAnchor,
};
use bitcoin::{
absolute, hashes::Hash, BlockHash, OutPoint, ScriptBuf, Transaction, TxIn, TxOut, Txid,
absolute, hashes::Hash, transaction, Amount, BlockHash, OutPoint, ScriptBuf, Transaction, TxIn,
TxOut, Txid,
};
use common::*;
use core::iter;
@@ -23,14 +24,14 @@ fn insert_txouts() {
(
OutPoint::new(h!("tx1"), 1),
TxOut {
value: 10_000,
value: Amount::from_sat(10_000),
script_pubkey: ScriptBuf::new(),
},
),
(
OutPoint::new(h!("tx1"), 2),
TxOut {
value: 20_000,
value: Amount::from_sat(20_000),
script_pubkey: ScriptBuf::new(),
},
),
@@ -40,21 +41,21 @@ fn insert_txouts() {
let update_ops = [(
OutPoint::new(h!("tx2"), 0),
TxOut {
value: 20_000,
value: Amount::from_sat(20_000),
script_pubkey: ScriptBuf::new(),
},
)];
// One full transaction to be included in the update
let update_txs = Transaction {
version: 0x01,
version: transaction::Version::ONE,
lock_time: absolute::LockTime::ZERO,
input: vec![TxIn {
previous_output: OutPoint::null(),
..Default::default()
}],
output: vec![TxOut {
value: 30_000,
value: Amount::from_sat(30_000),
script_pubkey: ScriptBuf::new(),
}],
};
@@ -164,14 +165,14 @@ fn insert_txouts() {
(
1u32,
&TxOut {
value: 10_000,
value: Amount::from_sat(10_000),
script_pubkey: ScriptBuf::new(),
}
),
(
2u32,
&TxOut {
value: 20_000,
value: Amount::from_sat(20_000),
script_pubkey: ScriptBuf::new(),
}
)
@@ -184,7 +185,7 @@ fn insert_txouts() {
[(
0u32,
&TxOut {
value: 30_000,
value: Amount::from_sat(30_000),
script_pubkey: ScriptBuf::new()
}
)]
@@ -206,7 +207,7 @@ fn insert_txouts() {
#[test]
fn insert_tx_graph_doesnt_count_coinbase_as_spent() {
let tx = Transaction {
version: 0x01,
version: transaction::Version::ONE,
lock_time: absolute::LockTime::ZERO,
input: vec![TxIn {
previous_output: OutPoint::null(),
@@ -225,10 +226,10 @@ fn insert_tx_graph_doesnt_count_coinbase_as_spent() {
#[test]
fn insert_tx_graph_keeps_track_of_spend() {
let tx1 = Transaction {
version: 0x01,
version: transaction::Version::ONE,
lock_time: absolute::LockTime::ZERO,
input: vec![],
output: vec![TxOut::default()],
output: vec![TxOut::NULL],
};
let op = OutPoint {
@@ -237,7 +238,7 @@ fn insert_tx_graph_keeps_track_of_spend() {
};
let tx2 = Transaction {
version: 0x01,
version: transaction::Version::ONE,
lock_time: absolute::LockTime::ZERO,
input: vec![TxIn {
previous_output: op,
@@ -266,13 +267,13 @@ fn insert_tx_graph_keeps_track_of_spend() {
#[test]
fn insert_tx_can_retrieve_full_tx_from_graph() {
let tx = Transaction {
version: 0x01,
version: transaction::Version::ONE,
lock_time: absolute::LockTime::ZERO,
input: vec![TxIn {
previous_output: OutPoint::null(),
..Default::default()
}],
output: vec![TxOut::default()],
output: vec![TxOut::NULL],
};
let mut graph = TxGraph::<()>::default();
@@ -287,12 +288,12 @@ fn insert_tx_can_retrieve_full_tx_from_graph() {
fn insert_tx_displaces_txouts() {
let mut tx_graph = TxGraph::<()>::default();
let tx = Transaction {
version: 0x01,
version: transaction::Version::ONE,
lock_time: absolute::LockTime::ZERO,
input: vec![],
output: vec![TxOut {
value: 42_000,
script_pubkey: ScriptBuf::default(),
value: Amount::from_sat(42_000),
script_pubkey: ScriptBuf::new(),
}],
};
@@ -302,7 +303,7 @@ fn insert_tx_displaces_txouts() {
vout: 0,
},
TxOut {
value: 1_337_000,
value: Amount::from_sat(1_337_000),
script_pubkey: ScriptBuf::default(),
},
);
@@ -315,8 +316,8 @@ fn insert_tx_displaces_txouts() {
vout: 0,
},
TxOut {
value: 1_000_000_000,
script_pubkey: ScriptBuf::default(),
value: Amount::from_sat(1_000_000_000),
script_pubkey: ScriptBuf::new(),
},
);
@@ -330,7 +331,7 @@ fn insert_tx_displaces_txouts() {
})
.unwrap()
.value,
42_000
Amount::from_sat(42_000)
);
assert_eq!(
tx_graph.get_txout(OutPoint {
@@ -345,12 +346,12 @@ fn insert_tx_displaces_txouts() {
fn insert_txout_does_not_displace_tx() {
let mut tx_graph = TxGraph::<()>::default();
let tx = Transaction {
version: 0x01,
version: transaction::Version::ONE,
lock_time: absolute::LockTime::ZERO,
input: vec![],
output: vec![TxOut {
value: 42_000,
script_pubkey: ScriptBuf::default(),
value: Amount::from_sat(42_000),
script_pubkey: ScriptBuf::new(),
}],
};
@@ -362,8 +363,8 @@ fn insert_txout_does_not_displace_tx() {
vout: 0,
},
TxOut {
value: 1_337_000,
script_pubkey: ScriptBuf::default(),
value: Amount::from_sat(1_337_000),
script_pubkey: ScriptBuf::new(),
},
);
@@ -373,8 +374,8 @@ fn insert_txout_does_not_displace_tx() {
vout: 0,
},
TxOut {
value: 1_000_000_000,
script_pubkey: ScriptBuf::default(),
value: Amount::from_sat(1_000_000_000),
script_pubkey: ScriptBuf::new(),
},
);
@@ -386,7 +387,7 @@ fn insert_txout_does_not_displace_tx() {
})
.unwrap()
.value,
42_000
Amount::from_sat(42_000)
);
assert_eq!(
tx_graph.get_txout(OutPoint {
@@ -401,21 +402,21 @@ fn insert_txout_does_not_displace_tx() {
fn test_calculate_fee() {
let mut graph = TxGraph::<()>::default();
let intx1 = Transaction {
version: 0x01,
version: transaction::Version::ONE,
lock_time: absolute::LockTime::ZERO,
input: vec![],
output: vec![TxOut {
value: 100,
..Default::default()
value: Amount::from_sat(100),
script_pubkey: ScriptBuf::new(),
}],
};
let intx2 = Transaction {
version: 0x02,
version: transaction::Version::TWO,
lock_time: absolute::LockTime::ZERO,
input: vec![],
output: vec![TxOut {
value: 200,
..Default::default()
value: Amount::from_sat(200),
script_pubkey: ScriptBuf::new(),
}],
};
@@ -425,8 +426,8 @@ fn test_calculate_fee() {
vout: 0,
},
TxOut {
value: 300,
..Default::default()
value: Amount::from_sat(300),
script_pubkey: ScriptBuf::new(),
},
);
@@ -435,7 +436,7 @@ fn test_calculate_fee() {
let _ = graph.insert_txout(intxout1.0, intxout1.1);
let mut tx = Transaction {
version: 0x01,
version: transaction::Version::ONE,
lock_time: absolute::LockTime::ZERO,
input: vec![
TxIn {
@@ -458,8 +459,8 @@ fn test_calculate_fee() {
},
],
output: vec![TxOut {
value: 500,
..Default::default()
value: Amount::from_sat(500),
script_pubkey: ScriptBuf::new(),
}],
};
@@ -491,13 +492,13 @@ fn test_calculate_fee() {
#[test]
fn test_calculate_fee_on_coinbase() {
let tx = Transaction {
version: 0x01,
version: transaction::Version::ONE,
lock_time: absolute::LockTime::ZERO,
input: vec![TxIn {
previous_output: OutPoint::null(),
..Default::default()
}],
output: vec![TxOut::default()],
output: vec![TxOut::NULL],
};
let graph = TxGraph::<()>::default();
@@ -533,7 +534,7 @@ fn test_walk_ancestors() {
previous_output: OutPoint::new(h!("op0"), 0),
..TxIn::default()
}],
output: vec![TxOut::default(), TxOut::default()],
output: vec![TxOut::NULL, TxOut::NULL],
..common::new_tx(0)
};
@@ -543,7 +544,7 @@ fn test_walk_ancestors() {
previous_output: OutPoint::new(tx_a0.txid(), 0),
..TxIn::default()
}],
output: vec![TxOut::default(), TxOut::default()],
output: vec![TxOut::NULL, TxOut::NULL],
..common::new_tx(0)
};
@@ -553,7 +554,7 @@ fn test_walk_ancestors() {
previous_output: OutPoint::new(tx_a0.txid(), 1),
..TxIn::default()
}],
output: vec![TxOut::default()],
output: vec![TxOut::NULL],
..common::new_tx(0)
};
@@ -562,7 +563,7 @@ fn test_walk_ancestors() {
previous_output: OutPoint::new(h!("op1"), 0),
..TxIn::default()
}],
output: vec![TxOut::default()],
output: vec![TxOut::NULL],
..common::new_tx(0)
};
@@ -572,7 +573,7 @@ fn test_walk_ancestors() {
previous_output: OutPoint::new(tx_b0.txid(), 0),
..TxIn::default()
}],
output: vec![TxOut::default()],
output: vec![TxOut::NULL],
..common::new_tx(0)
};
@@ -582,7 +583,7 @@ fn test_walk_ancestors() {
previous_output: OutPoint::new(tx_b0.txid(), 1),
..TxIn::default()
}],
output: vec![TxOut::default()],
output: vec![TxOut::NULL],
..common::new_tx(0)
};
@@ -598,7 +599,7 @@ fn test_walk_ancestors() {
..TxIn::default()
},
],
output: vec![TxOut::default()],
output: vec![TxOut::NULL],
..common::new_tx(0)
};
@@ -607,7 +608,7 @@ fn test_walk_ancestors() {
previous_output: OutPoint::new(h!("op2"), 0),
..TxIn::default()
}],
output: vec![TxOut::default()],
output: vec![TxOut::NULL],
..common::new_tx(0)
};
@@ -617,7 +618,7 @@ fn test_walk_ancestors() {
previous_output: OutPoint::new(tx_c1.txid(), 0),
..TxIn::default()
}],
output: vec![TxOut::default()],
output: vec![TxOut::NULL],
..common::new_tx(0)
};
@@ -633,7 +634,7 @@ fn test_walk_ancestors() {
..TxIn::default()
},
],
output: vec![TxOut::default()],
output: vec![TxOut::NULL],
..common::new_tx(0)
};
@@ -643,7 +644,7 @@ fn test_walk_ancestors() {
previous_output: OutPoint::new(tx_d1.txid(), 0),
..TxIn::default()
}],
output: vec![TxOut::default()],
output: vec![TxOut::NULL],
..common::new_tx(0)
};
@@ -726,7 +727,7 @@ fn test_conflicting_descendants() {
previous_output,
..TxIn::default()
}],
output: vec![TxOut::default()],
output: vec![TxOut::NULL],
..common::new_tx(0)
};
@@ -736,7 +737,7 @@ fn test_conflicting_descendants() {
previous_output,
..TxIn::default()
}],
output: vec![TxOut::default(), TxOut::default()],
output: vec![TxOut::NULL, TxOut::NULL],
..common::new_tx(1)
};
@@ -746,7 +747,7 @@ fn test_conflicting_descendants() {
previous_output: OutPoint::new(tx_a.txid(), 0),
..TxIn::default()
}],
output: vec![TxOut::default()],
output: vec![TxOut::NULL],
..common::new_tx(2)
};
@@ -768,7 +769,7 @@ fn test_conflicting_descendants() {
#[test]
fn test_descendants_no_repeat() {
let tx_a = Transaction {
output: vec![TxOut::default(), TxOut::default(), TxOut::default()],
output: vec![TxOut::NULL, TxOut::NULL, TxOut::NULL],
..common::new_tx(0)
};
@@ -778,7 +779,7 @@ fn test_descendants_no_repeat() {
previous_output: OutPoint::new(tx_a.txid(), vout),
..TxIn::default()
}],
output: vec![TxOut::default()],
output: vec![TxOut::NULL],
..common::new_tx(1)
})
.collect::<Vec<_>>();
@@ -789,7 +790,7 @@ fn test_descendants_no_repeat() {
previous_output: OutPoint::new(txs_b[vout as usize].txid(), vout),
..TxIn::default()
}],
output: vec![TxOut::default()],
output: vec![TxOut::NULL],
..common::new_tx(2)
})
.collect::<Vec<_>>();
@@ -805,7 +806,7 @@ fn test_descendants_no_repeat() {
..TxIn::default()
},
],
output: vec![TxOut::default()],
output: vec![TxOut::NULL],
..common::new_tx(3)
};
@@ -814,7 +815,7 @@ fn test_descendants_no_repeat() {
previous_output: OutPoint::new(tx_d.txid(), 0),
..TxIn::default()
}],
output: vec![TxOut::default()],
output: vec![TxOut::NULL],
..common::new_tx(4)
};
@@ -824,7 +825,7 @@ fn test_descendants_no_repeat() {
previous_output: OutPoint::new(h!("tx_does_not_exist"), v),
..TxIn::default()
}],
output: vec![TxOut::default()],
output: vec![TxOut::NULL],
..common::new_tx(v)
})
.collect::<Vec<_>>();
@@ -871,11 +872,11 @@ fn test_chain_spends() {
input: vec![],
output: vec![
TxOut {
value: 10_000,
value: Amount::from_sat(10_000),
script_pubkey: ScriptBuf::new(),
},
TxOut {
value: 20_000,
value: Amount::from_sat(20_000),
script_pubkey: ScriptBuf::new(),
},
],
@@ -890,11 +891,11 @@ fn test_chain_spends() {
}],
output: vec![
TxOut {
value: 5_000,
value: Amount::from_sat(5_000),
script_pubkey: ScriptBuf::new(),
},
TxOut {
value: 5_000,
value: Amount::from_sat(5_000),
script_pubkey: ScriptBuf::new(),
},
],
@@ -909,11 +910,11 @@ fn test_chain_spends() {
}],
output: vec![
TxOut {
value: 10_000,
value: Amount::from_sat(10_000),
script_pubkey: ScriptBuf::new(),
},
TxOut {
value: 10_000,
value: Amount::from_sat(10_000),
script_pubkey: ScriptBuf::new(),
},
],