Skip to content

Commit

Permalink
TMP: update rust-miniscript
Browse files Browse the repository at this point in the history
  • Loading branch information
darosior committed Jul 12, 2023
1 parent 3bea691 commit 3fe53e6
Show file tree
Hide file tree
Showing 18 changed files with 251 additions and 191 deletions.
46 changes: 35 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ daemon = ["libc"]

[dependencies]
# For managing transactions (it re-exports the bitcoin crate)
miniscript = { git = "https://github.com/darosior/rust-miniscript", branch = "multipath_descriptors_on_9.0", features = ["serde", "compiler"] }
miniscript = { version = "10.0", features = ["serde", "compiler", "base64"] }

# Don't reinvent the wheel
dirs = "5.0"
Expand Down
5 changes: 3 additions & 2 deletions src/bitcoin/d/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use jsonrpc::{
};

use miniscript::{
bitcoin::{self, hashes::hex::FromHex},
bitcoin::{self, address, hashes::hex::FromHex},
descriptor,
};

Expand Down Expand Up @@ -651,6 +651,7 @@ impl BitcoinD {
bitcoin::Network::Testnet => "test",
bitcoin::Network::Regtest => "regtest",
bitcoin::Network::Signet => "signet",
_ => "Unknown network, undefined at the time of writing",
};
if bitcoind_net != bip70_net {
return Err(BitcoindError::NetworkMismatch(
Expand Down Expand Up @@ -1072,7 +1073,7 @@ pub struct LSBlockEntry {
pub outpoint: bitcoin::OutPoint,
pub amount: bitcoin::Amount,
pub block_height: Option<i32>,
pub address: bitcoin::Address,
pub address: bitcoin::Address<address::NetworkUnchecked>,
pub parent_descs: Vec<descriptor::Descriptor<descriptor::DescriptorPublicKey>>,
}

Expand Down
4 changes: 2 additions & 2 deletions src/bitcoin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{

use std::{fmt, sync};

use miniscript::bitcoin;
use miniscript::bitcoin::{self, address};

/// Information about a block
#[derive(Debug, Clone, Eq, PartialEq, Copy)]
Expand Down Expand Up @@ -408,5 +408,5 @@ pub struct UTxO {
pub outpoint: bitcoin::OutPoint,
pub amount: bitcoin::Amount,
pub block_height: Option<i32>,
pub address: bitcoin::Address,
pub address: bitcoin::Address<address::NetworkUnchecked>,
}
14 changes: 10 additions & 4 deletions src/bitcoin/poller/looper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,22 @@ fn update_coins(
descs: &[descriptors::SinglePathLianaDesc],
secp: &secp256k1::Secp256k1<secp256k1::VerifyOnly>,
) -> UpdatedCoins {
let network = db_conn.network();
let curr_coins = db_conn.coins(CoinType::All);
log::debug!("Current coins: {:?}", curr_coins);

// Start by fetching newly received coins.
let mut received = Vec::new();
for utxo in bit.received_coins(previous_tip, descs) {
// We can only really treat them if we know the derivation index that was used.
if let Some((derivation_index, is_change)) =
db_conn.derivation_index_by_address(&utxo.address)
{
let address = match utxo.address.clone().require_network(network) {
Ok(addr) => addr,
Err(e) => {
log::error!("Invalid network for address: {}", e);
continue;
}
};
if let Some((derivation_index, is_change)) = db_conn.derivation_index_by_address(&address) {
// First of if we are receiving coins that are beyond our next derivation index,
// adjust it.
if derivation_index > db_conn.receive_index() {
Expand Down Expand Up @@ -71,7 +77,7 @@ fn update_coins(
log::error!(
"Could not get derivation index for coin '{}' (address: '{}')",
&utxo.outpoint,
&utxo.address
&address
);
}
}
Expand Down
Loading

0 comments on commit 3fe53e6

Please sign in to comment.