deps(bdk): bump bitcoin to 0.32.0, miniscript to 12.0.0

deps(chain): bump `bitcoin` to `0.32.0`, miniscript to `12.0.0`

fix(chain): use `minimal_non_dust()` instead of `dust_value()`

fix(chain): use `compute_txid()` instead of `txid`

deps(testenv): bump `electrsd` to `0.28.0`

deps(electrum): bump `electrum-client` to `0.20.0`

fix(electrum): use `compute_txid()` instead of `txid`

deps(esplora): bump `esplora-client` to `0.8.0`

deps(bitcoind_rpc): bump `bitcoin` to `0.32.0`, `bitcoincore-rpc` to
`0.19.0`

fix(bitcoind_rpc): use `compute_txid()` instead of `txid`

fix(nursery/tmp_plan): use proper `sighash` errors, and fix the expected
`Signature` fields

fix(sqlite): use `compute_txid()` instead of `txid`

deps(hwi): bump `hwi` to `0.9.0`

deps(wallet): bump `bitcoin` to `0.32.0`, miniscript to `12.0.0`

fix(wallet): use `compute_txid()` and `minimal_non_dust()`

- update to use `compute_txid()` instead of deprecated `txid()`
- update to use `minimal_non_dust()` instead of `dust_value()`
- remove unused `bitcoin::hex::FromHex`.

fix(wallet): uses `.into` conversion on `Network` for `NetworkKind`

- uses `.into()` when appropriate, otherwise use the explicit
  `NetworkKind`, and it's `.is_mainnet()` method.

fix(wallet): add P2wpkh, Taproot, InputsIndex errors to `SignerError`

fix(wallet): fields on taproot, and ecdsa `Signature` structure

fix(wallet/wallet): convert `Weight` to `usize` for now

- converts the `bitcoin-units::Weight` type to `usize` with help of
  `to_wu()` method.
- it should be updated/refactored in the future to handle the `Weight`
  type throughout the code instead of current `usize`, only converting
  it for now.
- allows the usage of deprecated `is_provably_unspendable()`, needs
  further discussion if suggested `is_op_return` is suitable.
- update the expect field to `signature`, as it was renamed from `sig`.

fix(wallet/wallet): use `is_op_return` instead of
`is_provably_unspendable`

fix(wallet/wallet): use `relative::Locktime` instead of `Sequence`

fix(wallet/descriptor): use `ParsePublicKeyError`

fix(wallet/descriptor): use `.into()` to convert from `AbsLockTime` and
`RelLockTime` to `absolute::LockTime` and `relative::LockTime`

fix(wallet/wallet): use `Message::from_digest()` instead of relying on
deprecated `ThirtyTwoByteHash` trait.

fix(wallet/descriptor+wallet): expect `Threshold` type, and handle it
internally

fix(wallet/wallet): remove `0x` prefix from expected `TxId` display

fix(examples): use `compute_txid()` instead of `txid`

fix(ci): remove usage of `bitcoin/no-std` feature

- remove comment: `# The `no-std` feature it's implied when the `std` feature is disabled.`
This commit is contained in:
Leonardo Lima
2024-05-22 18:34:30 -03:00
parent 473ef9714f
commit 2a4564097b
41 changed files with 480 additions and 302 deletions

View File

@@ -130,11 +130,11 @@ fn insert_txouts() {
// Mark it as confirmed.
assert_eq!(
graph.insert_anchor(update_txs.txid(), conf_anchor),
graph.insert_anchor(update_txs.compute_txid(), conf_anchor),
ChangeSet {
txs: [].into(),
txouts: [].into(),
anchors: [(conf_anchor, update_txs.txid())].into(),
anchors: [(conf_anchor, update_txs.compute_txid())].into(),
last_seen: [].into()
}
);
@@ -149,7 +149,11 @@ fn insert_txouts() {
ChangeSet {
txs: [Arc::new(update_txs.clone())].into(),
txouts: update_ops.clone().into(),
anchors: [(conf_anchor, update_txs.txid()), (unconf_anchor, h!("tx2"))].into(),
anchors: [
(conf_anchor, update_txs.compute_txid()),
(unconf_anchor, h!("tx2"))
]
.into(),
last_seen: [(h!("tx2"), 1000000)].into()
}
);
@@ -183,7 +187,9 @@ fn insert_txouts() {
);
assert_eq!(
graph.tx_outputs(update_txs.txid()).expect("should exists"),
graph
.tx_outputs(update_txs.compute_txid())
.expect("should exists"),
[(
0u32,
&TxOut {
@@ -200,7 +206,11 @@ fn insert_txouts() {
ChangeSet {
txs: [Arc::new(update_txs.clone())].into(),
txouts: update_ops.into_iter().chain(original_ops).collect(),
anchors: [(conf_anchor, update_txs.txid()), (unconf_anchor, h!("tx2"))].into(),
anchors: [
(conf_anchor, update_txs.compute_txid()),
(unconf_anchor, h!("tx2"))
]
.into(),
last_seen: [(h!("tx2"), 1000000)].into()
}
);
@@ -235,7 +245,7 @@ fn insert_tx_graph_keeps_track_of_spend() {
};
let op = OutPoint {
txid: tx1.txid(),
txid: tx1.compute_txid(),
vout: 0,
};
@@ -261,7 +271,7 @@ fn insert_tx_graph_keeps_track_of_spend() {
assert_eq!(
graph1.outspends(op),
&iter::once(tx2.txid()).collect::<HashSet<_>>()
&iter::once(tx2.compute_txid()).collect::<HashSet<_>>()
);
assert_eq!(graph2.outspends(op), graph1.outspends(op));
}
@@ -281,7 +291,9 @@ fn insert_tx_can_retrieve_full_tx_from_graph() {
let mut graph = TxGraph::<()>::default();
let _ = graph.insert_tx(tx.clone());
assert_eq!(
graph.get_tx(tx.txid()).map(|tx| tx.as_ref().clone()),
graph
.get_tx(tx.compute_txid())
.map(|tx| tx.as_ref().clone()),
Some(tx)
);
}
@@ -301,7 +313,7 @@ fn insert_tx_displaces_txouts() {
let changeset = tx_graph.insert_txout(
OutPoint {
txid: tx.txid(),
txid: tx.compute_txid(),
vout: 0,
},
TxOut {
@@ -314,7 +326,7 @@ fn insert_tx_displaces_txouts() {
let _ = tx_graph.insert_txout(
OutPoint {
txid: tx.txid(),
txid: tx.compute_txid(),
vout: 0,
},
TxOut {
@@ -328,7 +340,7 @@ fn insert_tx_displaces_txouts() {
assert_eq!(
tx_graph
.get_txout(OutPoint {
txid: tx.txid(),
txid: tx.compute_txid(),
vout: 0
})
.unwrap()
@@ -337,7 +349,7 @@ fn insert_tx_displaces_txouts() {
);
assert_eq!(
tx_graph.get_txout(OutPoint {
txid: tx.txid(),
txid: tx.compute_txid(),
vout: 1
}),
None
@@ -361,7 +373,7 @@ fn insert_txout_does_not_displace_tx() {
let _ = tx_graph.insert_txout(
OutPoint {
txid: tx.txid(),
txid: tx.compute_txid(),
vout: 0,
},
TxOut {
@@ -372,7 +384,7 @@ fn insert_txout_does_not_displace_tx() {
let _ = tx_graph.insert_txout(
OutPoint {
txid: tx.txid(),
txid: tx.compute_txid(),
vout: 0,
},
TxOut {
@@ -384,7 +396,7 @@ fn insert_txout_does_not_displace_tx() {
assert_eq!(
tx_graph
.get_txout(OutPoint {
txid: tx.txid(),
txid: tx.compute_txid(),
vout: 0
})
.unwrap()
@@ -393,7 +405,7 @@ fn insert_txout_does_not_displace_tx() {
);
assert_eq!(
tx_graph.get_txout(OutPoint {
txid: tx.txid(),
txid: tx.compute_txid(),
vout: 1
}),
None
@@ -443,14 +455,14 @@ fn test_calculate_fee() {
input: vec![
TxIn {
previous_output: OutPoint {
txid: intx1.txid(),
txid: intx1.compute_txid(),
vout: 0,
},
..Default::default()
},
TxIn {
previous_output: OutPoint {
txid: intx2.txid(),
txid: intx2.compute_txid(),
vout: 0,
},
..Default::default()
@@ -543,7 +555,7 @@ fn test_walk_ancestors() {
// tx_b0 spends tx_a0
let tx_b0 = Transaction {
input: vec![TxIn {
previous_output: OutPoint::new(tx_a0.txid(), 0),
previous_output: OutPoint::new(tx_a0.compute_txid(), 0),
..TxIn::default()
}],
output: vec![TxOut::NULL, TxOut::NULL],
@@ -553,7 +565,7 @@ fn test_walk_ancestors() {
// tx_b1 spends tx_a0
let tx_b1 = Transaction {
input: vec![TxIn {
previous_output: OutPoint::new(tx_a0.txid(), 1),
previous_output: OutPoint::new(tx_a0.compute_txid(), 1),
..TxIn::default()
}],
output: vec![TxOut::NULL],
@@ -572,7 +584,7 @@ fn test_walk_ancestors() {
// tx_c0 spends tx_b0
let tx_c0 = Transaction {
input: vec![TxIn {
previous_output: OutPoint::new(tx_b0.txid(), 0),
previous_output: OutPoint::new(tx_b0.compute_txid(), 0),
..TxIn::default()
}],
output: vec![TxOut::NULL],
@@ -582,7 +594,7 @@ fn test_walk_ancestors() {
// tx_c1 spends tx_b0
let tx_c1 = Transaction {
input: vec![TxIn {
previous_output: OutPoint::new(tx_b0.txid(), 1),
previous_output: OutPoint::new(tx_b0.compute_txid(), 1),
..TxIn::default()
}],
output: vec![TxOut::NULL],
@@ -593,11 +605,11 @@ fn test_walk_ancestors() {
let tx_c2 = Transaction {
input: vec![
TxIn {
previous_output: OutPoint::new(tx_b1.txid(), 0),
previous_output: OutPoint::new(tx_b1.compute_txid(), 0),
..TxIn::default()
},
TxIn {
previous_output: OutPoint::new(tx_b2.txid(), 0),
previous_output: OutPoint::new(tx_b2.compute_txid(), 0),
..TxIn::default()
},
],
@@ -617,7 +629,7 @@ fn test_walk_ancestors() {
// tx_d0 spends tx_c1
let tx_d0 = Transaction {
input: vec![TxIn {
previous_output: OutPoint::new(tx_c1.txid(), 0),
previous_output: OutPoint::new(tx_c1.compute_txid(), 0),
..TxIn::default()
}],
output: vec![TxOut::NULL],
@@ -628,11 +640,11 @@ fn test_walk_ancestors() {
let tx_d1 = Transaction {
input: vec![
TxIn {
previous_output: OutPoint::new(tx_c2.txid(), 0),
previous_output: OutPoint::new(tx_c2.compute_txid(), 0),
..TxIn::default()
},
TxIn {
previous_output: OutPoint::new(tx_c3.txid(), 0),
previous_output: OutPoint::new(tx_c3.compute_txid(), 0),
..TxIn::default()
},
],
@@ -643,7 +655,7 @@ fn test_walk_ancestors() {
// tx_e0 spends tx_d1
let tx_e0 = Transaction {
input: vec![TxIn {
previous_output: OutPoint::new(tx_d1.txid(), 0),
previous_output: OutPoint::new(tx_d1.compute_txid(), 0),
..TxIn::default()
}],
output: vec![TxOut::NULL],
@@ -665,7 +677,7 @@ fn test_walk_ancestors() {
]);
[&tx_a0, &tx_b1].iter().for_each(|&tx| {
let changeset = graph.insert_anchor(tx.txid(), tip.block_id());
let changeset = graph.insert_anchor(tx.compute_txid(), tip.block_id());
assert!(!changeset.is_empty());
});
@@ -682,7 +694,7 @@ fn test_walk_ancestors() {
// Only traverse unconfirmed ancestors of tx_e0 this time
graph
.walk_ancestors(tx_e0.clone(), |depth, tx| {
let tx_node = graph.get_tx_node(tx.txid())?;
let tx_node = graph.get_tx_node(tx.compute_txid())?;
for block in tx_node.anchors {
match local_chain.is_block_in_chain(block.anchor_block(), tip.block_id()) {
Ok(Some(true)) => return None,
@@ -746,15 +758,15 @@ fn test_conflicting_descendants() {
// tx_b spends tx_a
let tx_b = Transaction {
input: vec![TxIn {
previous_output: OutPoint::new(tx_a.txid(), 0),
previous_output: OutPoint::new(tx_a.compute_txid(), 0),
..TxIn::default()
}],
output: vec![TxOut::NULL],
..common::new_tx(2)
};
let txid_a = tx_a.txid();
let txid_b = tx_b.txid();
let txid_a = tx_a.compute_txid();
let txid_b = tx_b.compute_txid();
let mut graph = TxGraph::<()>::default();
let _ = graph.insert_tx(tx_a);
@@ -778,7 +790,7 @@ fn test_descendants_no_repeat() {
let txs_b = (0..3)
.map(|vout| Transaction {
input: vec![TxIn {
previous_output: OutPoint::new(tx_a.txid(), vout),
previous_output: OutPoint::new(tx_a.compute_txid(), vout),
..TxIn::default()
}],
output: vec![TxOut::NULL],
@@ -789,7 +801,7 @@ fn test_descendants_no_repeat() {
let txs_c = (0..2)
.map(|vout| Transaction {
input: vec![TxIn {
previous_output: OutPoint::new(txs_b[vout as usize].txid(), vout),
previous_output: OutPoint::new(txs_b[vout as usize].compute_txid(), vout),
..TxIn::default()
}],
output: vec![TxOut::NULL],
@@ -800,11 +812,11 @@ fn test_descendants_no_repeat() {
let tx_d = Transaction {
input: vec![
TxIn {
previous_output: OutPoint::new(txs_c[0].txid(), 0),
previous_output: OutPoint::new(txs_c[0].compute_txid(), 0),
..TxIn::default()
},
TxIn {
previous_output: OutPoint::new(txs_c[1].txid(), 0),
previous_output: OutPoint::new(txs_c[1].compute_txid(), 0),
..TxIn::default()
},
],
@@ -814,7 +826,7 @@ fn test_descendants_no_repeat() {
let tx_e = Transaction {
input: vec![TxIn {
previous_output: OutPoint::new(tx_d.txid(), 0),
previous_output: OutPoint::new(tx_d.compute_txid(), 0),
..TxIn::default()
}],
output: vec![TxOut::NULL],
@@ -848,11 +860,11 @@ fn test_descendants_no_repeat() {
.chain(core::iter::once(&tx_e))
{
let _ = graph.insert_tx(tx.clone());
expected_txids.push(tx.txid());
expected_txids.push(tx.compute_txid());
}
let descendants = graph
.walk_descendants(tx_a.txid(), |_, txid| Some(txid))
.walk_descendants(tx_a.compute_txid(), |_, txid| Some(txid))
.collect::<Vec<_>>();
assert_eq!(descendants, expected_txids);
@@ -888,7 +900,7 @@ fn test_chain_spends() {
// The first confirmed transaction spends vout: 0. And is confirmed at block 98.
let tx_1 = Transaction {
input: vec![TxIn {
previous_output: OutPoint::new(tx_0.txid(), 0),
previous_output: OutPoint::new(tx_0.compute_txid(), 0),
..TxIn::default()
}],
output: vec![
@@ -907,7 +919,7 @@ fn test_chain_spends() {
// The second transactions spends vout:1, and is unconfirmed.
let tx_2 = Transaction {
input: vec![TxIn {
previous_output: OutPoint::new(tx_0.txid(), 1),
previous_output: OutPoint::new(tx_0.compute_txid(), 1),
..TxIn::default()
}],
output: vec![
@@ -931,7 +943,7 @@ fn test_chain_spends() {
for (ht, tx) in [(95, &tx_0), (98, &tx_1)] {
let _ = graph.insert_anchor(
tx.txid(),
tx.compute_txid(),
ConfirmationHeightAnchor {
anchor_block: tip.block_id(),
confirmation_height: ht,
@@ -941,19 +953,23 @@ fn test_chain_spends() {
// Assert that confirmed spends are returned correctly.
assert_eq!(
graph.get_chain_spend(&local_chain, tip.block_id(), OutPoint::new(tx_0.txid(), 0)),
graph.get_chain_spend(
&local_chain,
tip.block_id(),
OutPoint::new(tx_0.compute_txid(), 0)
),
Some((
ChainPosition::Confirmed(&ConfirmationHeightAnchor {
anchor_block: tip.block_id(),
confirmation_height: 98
}),
tx_1.txid(),
tx_1.compute_txid(),
)),
);
// Check if chain position is returned correctly.
assert_eq!(
graph.get_chain_position(&local_chain, tip.block_id(), tx_0.txid()),
graph.get_chain_position(&local_chain, tip.block_id(), tx_0.compute_txid()),
// Some(ObservedAs::Confirmed(&local_chain.get_block(95).expect("block expected"))),
Some(ChainPosition::Confirmed(&ConfirmationHeightAnchor {
anchor_block: tip.block_id(),
@@ -963,25 +979,33 @@ fn test_chain_spends() {
// Even if unconfirmed tx has a last_seen of 0, it can still be part of a chain spend.
assert_eq!(
graph.get_chain_spend(&local_chain, tip.block_id(), OutPoint::new(tx_0.txid(), 1)),
Some((ChainPosition::Unconfirmed(0), tx_2.txid())),
graph.get_chain_spend(
&local_chain,
tip.block_id(),
OutPoint::new(tx_0.compute_txid(), 1)
),
Some((ChainPosition::Unconfirmed(0), tx_2.compute_txid())),
);
// Mark the unconfirmed as seen and check correct ObservedAs status is returned.
let _ = graph.insert_seen_at(tx_2.txid(), 1234567);
let _ = graph.insert_seen_at(tx_2.compute_txid(), 1234567);
// Check chain spend returned correctly.
assert_eq!(
graph
.get_chain_spend(&local_chain, tip.block_id(), OutPoint::new(tx_0.txid(), 1))
.get_chain_spend(
&local_chain,
tip.block_id(),
OutPoint::new(tx_0.compute_txid(), 1)
)
.unwrap(),
(ChainPosition::Unconfirmed(1234567), tx_2.txid())
(ChainPosition::Unconfirmed(1234567), tx_2.compute_txid())
);
// A conflicting transaction that conflicts with tx_1.
let tx_1_conflict = Transaction {
input: vec![TxIn {
previous_output: OutPoint::new(tx_0.txid(), 0),
previous_output: OutPoint::new(tx_0.compute_txid(), 0),
..Default::default()
}],
..common::new_tx(0)
@@ -990,13 +1014,13 @@ fn test_chain_spends() {
// Because this tx conflicts with an already confirmed transaction, chain position should return none.
assert!(graph
.get_chain_position(&local_chain, tip.block_id(), tx_1_conflict.txid())
.get_chain_position(&local_chain, tip.block_id(), tx_1_conflict.compute_txid())
.is_none());
// Another conflicting tx that conflicts with tx_2.
let tx_2_conflict = Transaction {
input: vec![TxIn {
previous_output: OutPoint::new(tx_0.txid(), 1),
previous_output: OutPoint::new(tx_0.compute_txid(), 1),
..Default::default()
}],
..common::new_tx(0)
@@ -1004,12 +1028,12 @@ fn test_chain_spends() {
// Insert in graph and mark it as seen.
let _ = graph.insert_tx(tx_2_conflict.clone());
let _ = graph.insert_seen_at(tx_2_conflict.txid(), 1234568);
let _ = graph.insert_seen_at(tx_2_conflict.compute_txid(), 1234568);
// This should return a valid observation with correct last seen.
assert_eq!(
graph
.get_chain_position(&local_chain, tip.block_id(), tx_2_conflict.txid())
.get_chain_position(&local_chain, tip.block_id(), tx_2_conflict.compute_txid())
.expect("position expected"),
ChainPosition::Unconfirmed(1234568)
);
@@ -1017,14 +1041,21 @@ fn test_chain_spends() {
// Chain_spend now catches the new transaction as the spend.
assert_eq!(
graph
.get_chain_spend(&local_chain, tip.block_id(), OutPoint::new(tx_0.txid(), 1))
.get_chain_spend(
&local_chain,
tip.block_id(),
OutPoint::new(tx_0.compute_txid(), 1)
)
.expect("expect observation"),
(ChainPosition::Unconfirmed(1234568), tx_2_conflict.txid())
(
ChainPosition::Unconfirmed(1234568),
tx_2_conflict.compute_txid()
)
);
// Chain position of the `tx_2` is now none, as it is older than `tx_2_conflict`
assert!(graph
.get_chain_position(&local_chain, tip.block_id(), tx_2.txid())
.get_chain_position(&local_chain, tip.block_id(), tx_2.compute_txid())
.is_none());
}
@@ -1065,7 +1096,7 @@ fn test_changeset_last_seen_append() {
fn update_last_seen_unconfirmed() {
let mut graph = TxGraph::<()>::default();
let tx = new_tx(0);
let txid = tx.txid();
let txid = tx.compute_txid();
// insert a new tx
// initially we have a last_seen of 0, and no anchors