Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update rust-miniscript (and thereby rust-bitcoin) to latest version #565

Merged
merged 5 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 37 additions & 14 deletions Cargo.lock

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

5 changes: 1 addition & 4 deletions 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 Expand Up @@ -54,9 +54,6 @@ jsonrpc = "0.12"
# Used for daemonization
libc = { version = "0.2", optional = true }

# Used for PSBTs
base64 = "0.13"

# Used for generating mnemonics
getrandom = "0.2"

Expand Down
4 changes: 2 additions & 2 deletions gui/Cargo.lock

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

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>,
}
23 changes: 16 additions & 7 deletions src/bitcoin/poller/looper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,28 @@ 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) {
let UTxO {
outpoint,
amount,
address,
..
} = utxo;
// 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 address.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 All @@ -52,9 +64,6 @@ fn update_coins(

// Now record this coin as a newly received one.
if !curr_coins.contains_key(&utxo.outpoint) {
let UTxO {
outpoint, amount, ..
} = utxo;
let coin = Coin {
outpoint,
amount,
Expand All @@ -71,7 +80,7 @@ fn update_coins(
log::error!(
"Could not get derivation index for coin '{}' (address: '{}')",
&utxo.outpoint,
&utxo.address
&address
);
}
}
Expand Down
Loading