Skip to content

Commit

Permalink
Merge #565: Update rust-miniscript (and thereby rust-bitcoin) to …
Browse files Browse the repository at this point in the history
…latest version

a19f2c1 daemon: drop the base64 dependency (Antoine Poinsot)
96e4cb5 Update proc-macro2 to fix a nightly compilation bug (Antoine Poinsot)
b9753b4 descriptors: update the satisfaction size estimation (Antoine Poinsot)
0ac4d80 commands: fix two clippy lints (Antoine Poinsot)
e280109 lianad: update rust-miniscript (and rust-bitcoin) dependencies (Antoine Poinsot)

Pull request description:

  It was a big chunk, especially in making sure we don't introduce any silent bug with all the upstream recent code movements.

  Also, we no longer depend on my custom `rust-miniscript` branch! 🎉

ACKs for top commit:
  darosior:
    Self-ACK a19f2c1.

Tree-SHA512: 7b785551b51bd247c233cac8a44148d25832be729772e2987d6e276643d9f781feb5016e81f2914845a2c93542f57ce861d06b31ba6c455f75cf93681fb98805
  • Loading branch information
darosior committed Jul 13, 2023
2 parents 3bea691 + a19f2c1 commit 12a3d50
Show file tree
Hide file tree
Showing 20 changed files with 304 additions and 231 deletions.
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

0 comments on commit 12a3d50

Please sign in to comment.