[ci] Fix clippy warnings, enable clippy checks
This commit is contained in:
parent
6402fd07c2
commit
aea9abff8a
4
.github/workflows/cont_integration.yml
vendored
4
.github/workflows/cont_integration.yml
vendored
@ -24,10 +24,11 @@ jobs:
|
|||||||
include:
|
include:
|
||||||
- rust: stable
|
- rust: stable
|
||||||
features: default
|
features: default
|
||||||
clippy: false
|
clippy: true
|
||||||
test: true
|
test: true
|
||||||
- rust: 1.45.0
|
- rust: 1.45.0
|
||||||
features: default
|
features: default
|
||||||
|
clippy: true
|
||||||
test: true
|
test: true
|
||||||
- rust: nightly
|
- rust: nightly
|
||||||
features: test-md-docs
|
features: test-md-docs
|
||||||
@ -55,6 +56,7 @@ jobs:
|
|||||||
profile: minimal
|
profile: minimal
|
||||||
toolchain: ${{ matrix.rust }}
|
toolchain: ${{ matrix.rust }}
|
||||||
override: true
|
override: true
|
||||||
|
components: clippy
|
||||||
- name: build
|
- name: build
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
|
@ -221,7 +221,11 @@ pub fn log_progress() -> LogProgress {
|
|||||||
|
|
||||||
impl Progress for LogProgress {
|
impl Progress for LogProgress {
|
||||||
fn update(&self, progress: f32, message: Option<String>) -> Result<(), Error> {
|
fn update(&self, progress: f32, message: Option<String>) -> Result<(), Error> {
|
||||||
log::info!("Sync {:.3}%: `{}`", progress, message.unwrap_or("".into()));
|
log::info!(
|
||||||
|
"Sync {:.3}%: `{}`",
|
||||||
|
progress,
|
||||||
|
message.unwrap_or_else(|| "".into())
|
||||||
|
);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -314,7 +314,7 @@ impl Database for Tree {
|
|||||||
let is_internal = serde_json::from_value(val["i"].take())?;
|
let is_internal = serde_json::from_value(val["i"].take())?;
|
||||||
|
|
||||||
Ok(UTXO {
|
Ok(UTXO {
|
||||||
outpoint: outpoint.clone(),
|
outpoint: *outpoint,
|
||||||
txout,
|
txout,
|
||||||
is_internal,
|
is_internal,
|
||||||
})
|
})
|
||||||
|
@ -77,7 +77,7 @@ impl MapKey<'_> {
|
|||||||
|
|
||||||
fn serialize_content(&self) -> Vec<u8> {
|
fn serialize_content(&self) -> Vec<u8> {
|
||||||
match self {
|
match self {
|
||||||
MapKey::Path((_, Some(child))) => u32::from(*child).to_be_bytes().to_vec(),
|
MapKey::Path((_, Some(child))) => child.to_be_bytes().to_vec(),
|
||||||
MapKey::Script(Some(s)) => serialize(*s),
|
MapKey::Script(Some(s)) => serialize(*s),
|
||||||
MapKey::UTXO(Some(s)) => serialize(*s),
|
MapKey::UTXO(Some(s)) => serialize(*s),
|
||||||
MapKey::RawTx(Some(s)) => serialize(*s),
|
MapKey::RawTx(Some(s)) => serialize(*s),
|
||||||
@ -94,8 +94,8 @@ impl MapKey<'_> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn after(key: &Vec<u8>) -> Vec<u8> {
|
fn after(key: &[u8]) -> Vec<u8> {
|
||||||
let mut key = key.clone();
|
let mut key = key.to_owned();
|
||||||
let mut idx = key.len();
|
let mut idx = key.len();
|
||||||
while idx > 0 {
|
while idx > 0 {
|
||||||
if key[idx - 1] == 0xFF {
|
if key[idx - 1] == 0xFF {
|
||||||
@ -233,7 +233,7 @@ impl BatchOperations for MemoryDatabase {
|
|||||||
Some(b) => {
|
Some(b) => {
|
||||||
let (txout, is_internal) = b.downcast_ref().cloned().unwrap();
|
let (txout, is_internal) = b.downcast_ref().cloned().unwrap();
|
||||||
Ok(Some(UTXO {
|
Ok(Some(UTXO {
|
||||||
outpoint: outpoint.clone(),
|
outpoint: *outpoint,
|
||||||
txout,
|
txout,
|
||||||
is_internal,
|
is_internal,
|
||||||
}))
|
}))
|
||||||
@ -387,7 +387,7 @@ impl Database for MemoryDatabase {
|
|||||||
Ok(self.map.get(&key).map(|b| {
|
Ok(self.map.get(&key).map(|b| {
|
||||||
let (txout, is_internal) = b.downcast_ref().cloned().unwrap();
|
let (txout, is_internal) = b.downcast_ref().cloned().unwrap();
|
||||||
UTXO {
|
UTXO {
|
||||||
outpoint: outpoint.clone(),
|
outpoint: *outpoint,
|
||||||
txout,
|
txout,
|
||||||
is_internal,
|
is_internal,
|
||||||
}
|
}
|
||||||
@ -424,9 +424,9 @@ impl Database for MemoryDatabase {
|
|||||||
let key = MapKey::LastIndex(script_type).as_map_key();
|
let key = MapKey::LastIndex(script_type).as_map_key();
|
||||||
let value = self
|
let value = self
|
||||||
.map
|
.map
|
||||||
.entry(key.clone())
|
.entry(key)
|
||||||
.and_modify(|x| *x.downcast_mut::<u32>().unwrap() += 1)
|
.and_modify(|x| *x.downcast_mut::<u32>().unwrap() += 1)
|
||||||
.or_insert(Box::<u32>::new(0))
|
.or_insert_with(|| Box::<u32>::new(0))
|
||||||
.downcast_mut()
|
.downcast_mut()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@ -445,8 +445,8 @@ impl BatchDatabase for MemoryDatabase {
|
|||||||
for key in batch.deleted_keys {
|
for key in batch.deleted_keys {
|
||||||
self.map.remove(&key);
|
self.map.remove(&key);
|
||||||
}
|
}
|
||||||
|
self.map.append(&mut batch.map);
|
||||||
Ok(self.map.append(&mut batch.map))
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ pub(crate) trait DatabaseUtils: Database {
|
|||||||
self.get_raw_tx(&outpoint.txid)?
|
self.get_raw_tx(&outpoint.txid)?
|
||||||
.map(|previous_tx| {
|
.map(|previous_tx| {
|
||||||
if outpoint.vout as usize >= previous_tx.output.len() {
|
if outpoint.vout as usize >= previous_tx.output.len() {
|
||||||
Err(Error::InvalidOutpoint(outpoint.clone()))
|
Err(Error::InvalidOutpoint(*outpoint))
|
||||||
} else {
|
} else {
|
||||||
Ok(previous_tx.output[outpoint.vout as usize].clone())
|
Ok(previous_tx.output[outpoint.vout as usize].clone())
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ impl From<crate::keys::KeyError> for Error {
|
|||||||
match key_error {
|
match key_error {
|
||||||
crate::keys::KeyError::Miniscript(inner) => Error::Miniscript(inner),
|
crate::keys::KeyError::Miniscript(inner) => Error::Miniscript(inner),
|
||||||
crate::keys::KeyError::BIP32(inner) => Error::BIP32(inner),
|
crate::keys::KeyError::BIP32(inner) => Error::BIP32(inner),
|
||||||
e @ _ => Error::Key(e),
|
e => Error::Key(e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,8 +78,8 @@ impl ToWalletDescriptor for &str {
|
|||||||
self,
|
self,
|
||||||
network: Network,
|
network: Network,
|
||||||
) -> Result<(ExtendedDescriptor, KeyMap), KeyError> {
|
) -> Result<(ExtendedDescriptor, KeyMap), KeyError> {
|
||||||
let descriptor = if self.contains("#") {
|
let descriptor = if self.contains('#') {
|
||||||
let parts: Vec<&str> = self.splitn(2, "#").collect();
|
let parts: Vec<&str> = self.splitn(2, '#').collect();
|
||||||
if !get_checksum(parts[0])
|
if !get_checksum(parts[0])
|
||||||
.ok()
|
.ok()
|
||||||
.map(|computed| computed == parts[1])
|
.map(|computed| computed == parts[1])
|
||||||
@ -171,7 +171,7 @@ impl ToWalletDescriptor for (ExtendedDescriptor, KeyMap, ValidNetworks) {
|
|||||||
|
|
||||||
DescriptorPublicKey::XPub(xpub)
|
DescriptorPublicKey::XPub(xpub)
|
||||||
}
|
}
|
||||||
other @ _ => other.clone(),
|
other => other.clone(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(pk)
|
Ok(pk)
|
||||||
@ -201,19 +201,19 @@ pub(crate) trait XKeyUtils {
|
|||||||
|
|
||||||
impl<K: InnerXKey> XKeyUtils for DescriptorXKey<K> {
|
impl<K: InnerXKey> XKeyUtils for DescriptorXKey<K> {
|
||||||
fn full_path(&self, append: &[ChildNumber]) -> DerivationPath {
|
fn full_path(&self, append: &[ChildNumber]) -> DerivationPath {
|
||||||
let full_path = match &self.source {
|
let full_path = match self.source {
|
||||||
&Some((_, ref path)) => path
|
Some((_, ref path)) => path
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.chain(self.derivation_path.into_iter())
|
.chain(self.derivation_path.into_iter())
|
||||||
.cloned()
|
.cloned()
|
||||||
.collect(),
|
.collect(),
|
||||||
&None => self.derivation_path.clone(),
|
None => self.derivation_path.clone(),
|
||||||
};
|
};
|
||||||
|
|
||||||
if self.is_wildcard {
|
if self.is_wildcard {
|
||||||
full_path
|
full_path
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.chain(append.into_iter())
|
.chain(append.iter())
|
||||||
.cloned()
|
.cloned()
|
||||||
.collect()
|
.collect()
|
||||||
} else {
|
} else {
|
||||||
@ -222,9 +222,9 @@ impl<K: InnerXKey> XKeyUtils for DescriptorXKey<K> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn root_fingerprint(&self) -> Fingerprint {
|
fn root_fingerprint(&self) -> Fingerprint {
|
||||||
match &self.source {
|
match self.source {
|
||||||
&Some((fingerprint, _)) => fingerprint.clone(),
|
Some((fingerprint, _)) => fingerprint,
|
||||||
&None => self.xkey.xkey_fingerprint(),
|
None => self.xkey.xkey_fingerprint(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
//! # Ok::<(), bdk::Error>(())
|
//! # Ok::<(), bdk::Error>(())
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
use std::cmp::max;
|
use std::cmp::{max, Ordering};
|
||||||
use std::collections::{BTreeMap, HashSet, VecDeque};
|
use std::collections::{BTreeMap, HashSet, VecDeque};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
@ -155,7 +155,7 @@ impl SatisfiableItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn combinations(vec: &Vec<usize>, size: usize) -> Vec<Vec<usize>> {
|
fn combinations(vec: &[usize], size: usize) -> Vec<Vec<usize>> {
|
||||||
assert!(vec.len() >= size);
|
assert!(vec.len() >= size);
|
||||||
|
|
||||||
let mut answer = Vec::new();
|
let mut answer = Vec::new();
|
||||||
@ -344,8 +344,8 @@ impl Satisfaction {
|
|||||||
.map(|i| {
|
.map(|i| {
|
||||||
conditions
|
conditions
|
||||||
.get(i)
|
.get(i)
|
||||||
.and_then(|set| Some(set.clone().into_iter().collect()))
|
.map(|set| set.clone().into_iter().collect())
|
||||||
.unwrap_or(vec![])
|
.unwrap_or_default()
|
||||||
})
|
})
|
||||||
.collect())
|
.collect())
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@ -525,7 +525,7 @@ impl Policy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn make_multisig(
|
fn make_multisig(
|
||||||
keys: &Vec<DescriptorPublicKey>,
|
keys: &[DescriptorPublicKey],
|
||||||
signers: Arc<SignersContainer<DescriptorPublicKey>>,
|
signers: Arc<SignersContainer<DescriptorPublicKey>>,
|
||||||
threshold: usize,
|
threshold: usize,
|
||||||
) -> Result<Option<Policy>, PolicyError> {
|
) -> Result<Option<Policy>, PolicyError> {
|
||||||
@ -542,7 +542,7 @@ impl Policy {
|
|||||||
conditions: Default::default(),
|
conditions: Default::default(),
|
||||||
};
|
};
|
||||||
for (index, key) in keys.iter().enumerate() {
|
for (index, key) in keys.iter().enumerate() {
|
||||||
if let Some(_) = signers.find(signer_id(key)) {
|
if signers.find(signer_id(key)).is_some() {
|
||||||
contribution.add(
|
contribution.add(
|
||||||
&Satisfaction::Complete {
|
&Satisfaction::Complete {
|
||||||
condition: Default::default(),
|
condition: Default::default(),
|
||||||
@ -582,7 +582,7 @@ impl Policy {
|
|||||||
// if items.len() == threshold, selected can be omitted and we take all of them by default
|
// if items.len() == threshold, selected can be omitted and we take all of them by default
|
||||||
let default = match &self.item {
|
let default = match &self.item {
|
||||||
SatisfiableItem::Thresh { items, threshold } if items.len() == *threshold => {
|
SatisfiableItem::Thresh { items, threshold } if items.len() == *threshold => {
|
||||||
(0..*threshold).into_iter().collect()
|
(0..*threshold).collect()
|
||||||
}
|
}
|
||||||
_ => vec![],
|
_ => vec![],
|
||||||
};
|
};
|
||||||
@ -608,10 +608,14 @@ impl Policy {
|
|||||||
// if we have something, make sure we have enough items. note that the user can set
|
// if we have something, make sure we have enough items. note that the user can set
|
||||||
// an empty value for this step in case of n-of-n, because `selected` is set to all
|
// an empty value for this step in case of n-of-n, because `selected` is set to all
|
||||||
// the elements above
|
// the elements above
|
||||||
if selected.len() < *threshold {
|
match selected.len().cmp(threshold) {
|
||||||
return Err(PolicyError::NotEnoughItemsSelected(self.id.clone()));
|
Ordering::Less => {
|
||||||
} else if selected.len() > *threshold {
|
return Err(PolicyError::NotEnoughItemsSelected(self.id.clone()))
|
||||||
return Err(PolicyError::TooManyItemsSelected(self.id.clone()));
|
}
|
||||||
|
Ordering::Greater => {
|
||||||
|
return Err(PolicyError::TooManyItemsSelected(self.id.clone()))
|
||||||
|
}
|
||||||
|
Ordering::Equal => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
// check the selected items, see if there are conflicting requirements
|
// check the selected items, see if there are conflicting requirements
|
||||||
@ -676,7 +680,7 @@ fn signature_key(
|
|||||||
) -> Policy {
|
) -> Policy {
|
||||||
let mut policy: Policy = SatisfiableItem::Signature(PKOrF::from_key_hash(*key_hash)).into();
|
let mut policy: Policy = SatisfiableItem::Signature(PKOrF::from_key_hash(*key_hash)).into();
|
||||||
|
|
||||||
if let Some(_) = signers.find(SignerId::PkHash(*key_hash)) {
|
if signers.find(SignerId::PkHash(*key_hash)).is_some() {
|
||||||
policy.contribution = Satisfaction::Complete {
|
policy.contribution = Satisfaction::Complete {
|
||||||
condition: Default::default(),
|
condition: Default::default(),
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ impl From<crate::keys::KeyError> for Error {
|
|||||||
crate::keys::KeyError::Miniscript(inner) => Error::Miniscript(inner),
|
crate::keys::KeyError::Miniscript(inner) => Error::Miniscript(inner),
|
||||||
crate::keys::KeyError::BIP32(inner) => Error::BIP32(inner),
|
crate::keys::KeyError::BIP32(inner) => Error::BIP32(inner),
|
||||||
crate::keys::KeyError::InvalidChecksum => Error::ChecksumMismatch,
|
crate::keys::KeyError::InvalidChecksum => Error::ChecksumMismatch,
|
||||||
e @ _ => Error::Key(e),
|
e => Error::Key(e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -562,12 +562,12 @@ pub mod test {
|
|||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
const test_entropy: [u8; 32] = [0xAA; 32];
|
const TEST_ENTROPY: [u8; 32] = [0xAA; 32];
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_keys_generate_xprv() {
|
fn test_keys_generate_xprv() {
|
||||||
let generated_xprv: GeneratedKey<_, miniscript::Segwitv0> =
|
let generated_xprv: GeneratedKey<_, miniscript::Segwitv0> =
|
||||||
bip32::ExtendedPrivKey::generate_with_entropy((), test_entropy).unwrap();
|
bip32::ExtendedPrivKey::generate_with_entropy((), TEST_ENTROPY).unwrap();
|
||||||
|
|
||||||
assert_eq!(generated_xprv.valid_networks, any_network());
|
assert_eq!(generated_xprv.valid_networks, any_network());
|
||||||
assert_eq!(generated_xprv.to_string(), "xprv9s21ZrQH143K4Xr1cJyqTvuL2FWR8eicgY9boWqMBv8MDVUZ65AXHnzBrK1nyomu6wdcabRgmGTaAKawvhAno1V5FowGpTLVx3jxzE5uk3Q");
|
assert_eq!(generated_xprv.to_string(), "xprv9s21ZrQH143K4Xr1cJyqTvuL2FWR8eicgY9boWqMBv8MDVUZ65AXHnzBrK1nyomu6wdcabRgmGTaAKawvhAno1V5FowGpTLVx3jxzE5uk3Q");
|
||||||
|
@ -42,7 +42,7 @@ extern crate async_trait;
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate bdk_macros;
|
extern crate bdk_macros;
|
||||||
|
|
||||||
#[cfg(any(test, feature = "compact_filters"))]
|
#[cfg(feature = "compact_filters")]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
|
|
||||||
|
@ -39,8 +39,8 @@ pub enum ScriptType {
|
|||||||
impl ScriptType {
|
impl ScriptType {
|
||||||
pub fn as_byte(&self) -> u8 {
|
pub fn as_byte(&self) -> u8 {
|
||||||
match self {
|
match self {
|
||||||
ScriptType::External => 'e' as u8,
|
ScriptType::External => b'e',
|
||||||
ScriptType::Internal => 'i' as u8,
|
ScriptType::Internal => b'i',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -605,9 +605,7 @@ where
|
|||||||
available_utxos,
|
available_utxos,
|
||||||
use_all_utxos,
|
use_all_utxos,
|
||||||
new_feerate,
|
new_feerate,
|
||||||
fee_difference
|
fee_difference.saturating_sub(removed_change_output.value),
|
||||||
.checked_sub(removed_change_output.value)
|
|
||||||
.unwrap_or(0),
|
|
||||||
input_witness_weight,
|
input_witness_weight,
|
||||||
0.0,
|
0.0,
|
||||||
)?;
|
)?;
|
||||||
@ -620,7 +618,7 @@ where
|
|||||||
// copy the n_sequence from the inputs that were already in the transaction
|
// copy the n_sequence from the inputs that were already in the transaction
|
||||||
txin.iter_mut()
|
txin.iter_mut()
|
||||||
.for_each(|i| i.sequence = tx.input[0].sequence);
|
.for_each(|i| i.sequence = tx.input[0].sequence);
|
||||||
tx.input.extend_from_slice(&mut txin);
|
tx.input.extend_from_slice(&txin);
|
||||||
|
|
||||||
details.sent += selected_amount;
|
details.sent += selected_amount;
|
||||||
selected_amount
|
selected_amount
|
||||||
@ -666,7 +664,7 @@ where
|
|||||||
.iter()
|
.iter()
|
||||||
.map(|txin| {
|
.map(|txin| {
|
||||||
Ok((
|
Ok((
|
||||||
txin.previous_output.clone(),
|
txin.previous_output,
|
||||||
self.database
|
self.database
|
||||||
.borrow()
|
.borrow()
|
||||||
.get_previous_output(&txin.previous_output)?,
|
.get_previous_output(&txin.previous_output)?,
|
||||||
@ -765,7 +763,7 @@ where
|
|||||||
.database
|
.database
|
||||||
.borrow()
|
.borrow()
|
||||||
.get_tx(&input.previous_output.txid, false)?
|
.get_tx(&input.previous_output.txid, false)?
|
||||||
.and_then(|tx| Some(tx.height.unwrap_or(std::u32::MAX)));
|
.map(|tx| tx.height.unwrap_or(std::u32::MAX));
|
||||||
let current_height = assume_height.or(self.current_height);
|
let current_height = assume_height.or(self.current_height);
|
||||||
|
|
||||||
debug!(
|
debug!(
|
||||||
@ -833,15 +831,13 @@ where
|
|||||||
&self,
|
&self,
|
||||||
script_type: ScriptType,
|
script_type: ScriptType,
|
||||||
) -> (&ExtendedDescriptor, ScriptType) {
|
) -> (&ExtendedDescriptor, ScriptType) {
|
||||||
let desc = match script_type {
|
match script_type {
|
||||||
ScriptType::Internal if self.change_descriptor.is_some() => (
|
ScriptType::Internal if self.change_descriptor.is_some() => (
|
||||||
self.change_descriptor.as_ref().unwrap(),
|
self.change_descriptor.as_ref().unwrap(),
|
||||||
ScriptType::Internal,
|
ScriptType::Internal,
|
||||||
),
|
),
|
||||||
_ => (&self.descriptor, ScriptType::External),
|
_ => (&self.descriptor, ScriptType::External),
|
||||||
};
|
}
|
||||||
|
|
||||||
desc
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_descriptor_for_txout(&self, txout: &TxOut) -> Result<Option<ExtendedDescriptor>, Error> {
|
fn get_descriptor_for_txout(&self, txout: &TxOut) -> Result<Option<ExtendedDescriptor>, Error> {
|
||||||
@ -941,7 +937,7 @@ where
|
|||||||
) -> Result<(Vec<UTXO>, bool), Error> {
|
) -> Result<(Vec<UTXO>, bool), Error> {
|
||||||
let unspendable_set = match unspendable {
|
let unspendable_set = match unspendable {
|
||||||
None => HashSet::new(),
|
None => HashSet::new(),
|
||||||
Some(vec) => vec.into_iter().collect(),
|
Some(vec) => vec.iter().collect(),
|
||||||
};
|
};
|
||||||
|
|
||||||
match utxo {
|
match utxo {
|
||||||
@ -1131,10 +1127,7 @@ where
|
|||||||
if self
|
if self
|
||||||
.database
|
.database
|
||||||
.borrow()
|
.borrow()
|
||||||
.get_script_pubkey_from_path(
|
.get_script_pubkey_from_path(ScriptType::Internal, max_address.saturating_sub(1))?
|
||||||
ScriptType::Internal,
|
|
||||||
max_address.checked_sub(1).unwrap_or(0),
|
|
||||||
)?
|
|
||||||
.is_none()
|
.is_none()
|
||||||
{
|
{
|
||||||
run_setup = true;
|
run_setup = true;
|
||||||
|
@ -205,7 +205,7 @@ impl Signer for DescriptorXKey<ExtendedPrivKey> {
|
|||||||
.hd_keypaths
|
.hd_keypaths
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|(pk, &(fingerprint, ref path))| {
|
.filter_map(|(pk, &(fingerprint, ref path))| {
|
||||||
if self.matches(fingerprint.clone(), &path).is_some() {
|
if self.matches(fingerprint, &path).is_some() {
|
||||||
Some((pk, path))
|
Some((pk, path))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
@ -284,7 +284,7 @@ impl Signer for PrivateKey {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn descriptor_secret_key(&self) -> Option<DescriptorSecretKey> {
|
fn descriptor_secret_key(&self) -> Option<DescriptorSecretKey> {
|
||||||
Some(DescriptorSecretKey::PrivKey(self.clone()))
|
Some(DescriptorSecretKey::PrivKey(*self))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,7 +407,7 @@ impl<Pk: MiniscriptKey> SignersContainer<Pk> {
|
|||||||
Included(&(id, SignerOrdering(usize::MAX)).into()),
|
Included(&(id, SignerOrdering(usize::MAX)).into()),
|
||||||
))
|
))
|
||||||
.map(|(_, v)| v)
|
.map(|(_, v)| v)
|
||||||
.nth(0)
|
.next()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -431,9 +431,9 @@ impl ComputeSighash for Legacy {
|
|||||||
let tx_input = &psbt.global.unsigned_tx.input[input_index];
|
let tx_input = &psbt.global.unsigned_tx.input[input_index];
|
||||||
|
|
||||||
let sighash = psbt_input.sighash_type.ok_or(SignerError::MissingSighash)?;
|
let sighash = psbt_input.sighash_type.ok_or(SignerError::MissingSighash)?;
|
||||||
let script = match &psbt_input.redeem_script {
|
let script = match psbt_input.redeem_script {
|
||||||
&Some(ref redeem_script) => redeem_script.clone(),
|
Some(ref redeem_script) => redeem_script.clone(),
|
||||||
&None => {
|
None => {
|
||||||
let non_witness_utxo = psbt_input
|
let non_witness_utxo = psbt_input
|
||||||
.non_witness_utxo
|
.non_witness_utxo
|
||||||
.as_ref()
|
.as_ref()
|
||||||
@ -485,9 +485,9 @@ impl ComputeSighash for Segwitv0 {
|
|||||||
.ok_or(SignerError::MissingNonWitnessUtxo)?;
|
.ok_or(SignerError::MissingNonWitnessUtxo)?;
|
||||||
let value = witness_utxo.value;
|
let value = witness_utxo.value;
|
||||||
|
|
||||||
let script = match &psbt_input.witness_script {
|
let script = match psbt_input.witness_script {
|
||||||
&Some(ref witness_script) => witness_script.clone(),
|
Some(ref witness_script) => witness_script.clone(),
|
||||||
&None => {
|
None => {
|
||||||
if witness_utxo.script_pubkey.is_v0_p2wpkh() {
|
if witness_utxo.script_pubkey.is_v0_p2wpkh() {
|
||||||
p2wpkh_script_code(&witness_utxo.script_pubkey)
|
p2wpkh_script_code(&witness_utxo.script_pubkey)
|
||||||
} else if psbt_input
|
} else if psbt_input
|
||||||
|
@ -24,8 +24,6 @@
|
|||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate serde_json;
|
extern crate serde_json;
|
||||||
#[macro_use]
|
|
||||||
extern crate serial_test;
|
|
||||||
|
|
||||||
pub use serial_test::serial;
|
pub use serial_test::serial;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user