Upgrade miniscript/bitcoin dependency
Upgrade: - bitcoin to v0.31.0 - miniscript to v11.0.0 Note: The bitcoin upgrade includes improvements to the `Transaction::weight()` function, it appears those guys did good, we no longer need to add the 2 additional weight units "just in case".
This commit is contained in:
@@ -96,7 +96,7 @@ impl CoinSelectorOpt {
|
||||
) -> Self {
|
||||
let mut tx = Transaction {
|
||||
input: vec![],
|
||||
version: 1,
|
||||
version: transaction::Version::ONE,
|
||||
lock_time: absolute::LockTime::ZERO,
|
||||
output: txouts.to_vec(),
|
||||
};
|
||||
@@ -112,7 +112,7 @@ impl CoinSelectorOpt {
|
||||
target_value: if txouts.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(txouts.iter().map(|txout| txout.value).sum())
|
||||
Some(txouts.iter().map(|txout| txout.value.to_sat()).sum())
|
||||
},
|
||||
..Self::from_weights(
|
||||
base_weight.to_wu() as u32,
|
||||
|
||||
@@ -12,7 +12,7 @@ use bdk_chain::{
|
||||
bitcoin,
|
||||
collections::{BTreeSet, HashMap},
|
||||
};
|
||||
use bitcoin::{absolute, Transaction, TxOut};
|
||||
use bitcoin::{absolute, transaction, Transaction, TxOut};
|
||||
use core::fmt::{Debug, Display};
|
||||
|
||||
mod coin_selector;
|
||||
@@ -29,5 +29,5 @@ pub const TXIN_BASE_WEIGHT: u32 = (32 + 4 + 4) * 4;
|
||||
// Shamelessly copied from
|
||||
// https://github.com/rust-bitcoin/rust-miniscript/blob/d5615acda1a7fdc4041a11c1736af139b8c7ebe8/src/util.rs#L8
|
||||
pub(crate) fn varint_size(v: usize) -> u32 {
|
||||
bitcoin::VarInt(v as u64).len() as u32
|
||||
bitcoin::VarInt(v as u64).size() as u32
|
||||
}
|
||||
|
||||
@@ -17,14 +17,13 @@
|
||||
use bdk_chain::{bitcoin, collections::*, miniscript};
|
||||
use bitcoin::{
|
||||
absolute,
|
||||
address::WitnessVersion,
|
||||
bip32::{DerivationPath, Fingerprint, KeySource},
|
||||
blockdata::transaction::Sequence,
|
||||
ecdsa,
|
||||
hashes::{hash160, ripemd160, sha256},
|
||||
secp256k1::Secp256k1,
|
||||
taproot::{self, LeafVersion, TapLeafHash},
|
||||
ScriptBuf, TxIn, Witness,
|
||||
ScriptBuf, TxIn, Witness, WitnessVersion,
|
||||
};
|
||||
use miniscript::{
|
||||
descriptor::{InnerXKey, Tr},
|
||||
@@ -32,7 +31,7 @@ use miniscript::{
|
||||
};
|
||||
|
||||
pub(crate) fn varint_len(v: usize) -> usize {
|
||||
bitcoin::VarInt(v as u64).len() as usize
|
||||
bitcoin::VarInt(v as u64).size() as usize
|
||||
}
|
||||
|
||||
mod plan_impls;
|
||||
|
||||
@@ -3,12 +3,11 @@ use core::ops::Deref;
|
||||
|
||||
use bitcoin::{
|
||||
bip32,
|
||||
hashes::{hash160, ripemd160, sha256},
|
||||
hashes::{hash160, ripemd160, sha256, Hash},
|
||||
key::XOnlyPublicKey,
|
||||
psbt::Prevouts,
|
||||
secp256k1::{KeyPair, Message, PublicKey, Signing, Verification},
|
||||
secp256k1::{Keypair, Message, PublicKey, Signing, Verification},
|
||||
sighash,
|
||||
sighash::{EcdsaSighashType, SighashCache, TapSighashType},
|
||||
sighash::{EcdsaSighashType, Prevouts, SighashCache, TapSighashType},
|
||||
taproot, Transaction, TxOut,
|
||||
};
|
||||
|
||||
@@ -163,11 +162,11 @@ impl RequiredSignatures<DescriptorPublicKey> {
|
||||
|
||||
let tweak =
|
||||
taproot::TapTweakHash::from_key_and_tweak(x_only_pubkey, merkle_root.clone());
|
||||
let keypair = KeyPair::from_secret_key(&secp, &secret_key.clone())
|
||||
let keypair = Keypair::from_secret_key(&secp, &secret_key.clone())
|
||||
.add_xonly_tweak(&secp, &tweak.to_scalar())
|
||||
.unwrap();
|
||||
|
||||
let msg = Message::from_slice(sighash.as_ref()).expect("Sighashes are 32 bytes");
|
||||
let msg = Message::from_digest(sighash.to_byte_array());
|
||||
let sig = secp.sign_schnorr_no_aux_rand(&msg, &keypair);
|
||||
|
||||
let bitcoin_sig = taproot::Signature {
|
||||
@@ -209,9 +208,8 @@ impl RequiredSignatures<DescriptorPublicKey> {
|
||||
todo!();
|
||||
}
|
||||
};
|
||||
let keypair = KeyPair::from_secret_key(&secp, &secret_key.clone());
|
||||
let msg =
|
||||
Message::from_slice(sighash.as_ref()).expect("Sighashes are 32 bytes");
|
||||
let keypair = Keypair::from_secret_key(&secp, &secret_key.clone());
|
||||
let msg = Message::from_digest(sighash.to_byte_array());
|
||||
let sig = secp.sign_schnorr_no_aux_rand(&msg, &keypair);
|
||||
let bitcoin_sig = taproot::Signature {
|
||||
sig,
|
||||
|
||||
Reference in New Issue
Block a user