Skip to content

Commit

Permalink
Merge pull request fedimint#6313 from tvolk131/bitcoin32_internal
Browse files Browse the repository at this point in the history
chore(deps): mostly bump bitcoin to v0.32
  • Loading branch information
tvolk131 authored Nov 8, 2024
2 parents bc0f492 + d31a807 commit 9b11b56
Show file tree
Hide file tree
Showing 64 changed files with 283 additions and 568 deletions.
11 changes: 2 additions & 9 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ reqwest = { version = "0.12.9", features = [
], default-features = false }
ring = "0.17.8"
secp256k1 = { version = "0.29.0", default-features = false }
secp256k1_27 = { package = "secp256k1", version = "0.27.0", default-features = false }
semver = "1.0.23"
serde = { version = "1.0.214", features = ["derive"] }
serdect = "0.2.0"
Expand Down
3 changes: 1 addition & 2 deletions crypto/derive-secret/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ use bls12_381::Scalar;
use fedimint_core::config::FederationId;
use fedimint_core::encoding::{Decodable, Encodable};
use fedimint_core::secp256k1::{Keypair, Secp256k1, Signing};
use fedimint_core::BitcoinHash;
use hkdf::hashes::Sha512;
use hkdf::Hkdf;
use hkdf::{BitcoinHash, Hkdf};
use ring::aead;

const CHILD_TAG: &[u8; 8] = b"childkey";
Expand Down
9 changes: 6 additions & 3 deletions devimint/src/external.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ use bitcoincore_rpc::jsonrpc::error::RpcError;
use bitcoincore_rpc::RpcApi;
use cln_rpc::primitives::{Amount as ClnRpcAmount, AmountOrAny};
use cln_rpc::ClnRpc;
use fedimint_core::bitcoin_migration::bitcoin32_to_bitcoin30_sha256_hash;
use fedimint_core::bitcoin_migration::{
bitcoin30_to_bitcoin32_sha256_hash, bitcoin32_to_bitcoin30_sha256_hash,
};
use fedimint_core::encoding::Encodable;
use fedimint_core::task::jit::{JitTry, JitTryAnyhow};
use fedimint_core::task::{block_in_place, block_on, sleep, timeout};
use fedimint_core::util::write_overwrite_async;
use fedimint_core::BitcoinHash;
use fedimint_logging::LOG_DEVIMINT;
use fedimint_testing::gateway::LightningNodeType;
use futures::StreamExt;
Expand Down Expand Up @@ -812,7 +813,9 @@ impl Lnd {
.invoices_client_lock()
.await?
.subscribe_single_invoice(tonic_lnd::invoicesrpc::SubscribeSingleInvoiceRequest {
r_hash: payment_hash.to_byte_array().to_vec(),
r_hash: bitcoin30_to_bitcoin32_sha256_hash(&payment_hash)
.to_byte_array()
.to_vec(),
})
.await?
.into_inner();
Expand Down
29 changes: 9 additions & 20 deletions devimint/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ use std::{env, ffi};
use anyhow::{anyhow, bail, Context, Result};
use bitcoin::Txid;
use clap::Subcommand;
use fedimint_core::bitcoin_migration::{
bitcoin32_to_bitcoin30_script_buf, bitcoin32_to_bitcoin30_tx,
};
use fedimint_core::core::LEGACY_HARDCODED_INSTANCE_ID_WALLET;
use fedimint_core::encoding::Decodable;
use fedimint_core::envs::is_env_var_set;
Expand Down Expand Up @@ -1055,13 +1052,11 @@ pub async fn cli_tests(dev_fed: DevFed) -> Result<()> {

let tx_hex = bitcoind.poll_get_transaction(txid).await?;

let tx = bitcoin32_to_bitcoin30_tx(&bitcoin::Transaction::consensus_decode_hex(
&tx_hex,
&ModuleRegistry::default(),
)?);
assert!(tx.output.iter().any(|o| o.script_pubkey
== bitcoin32_to_bitcoin30_script_buf(&address.script_pubkey())
&& o.value == 50000));
let tx = bitcoin::Transaction::consensus_decode_hex(&tx_hex, &ModuleRegistry::default())?;
assert!(tx
.output
.iter()
.any(|o| o.script_pubkey == address.script_pubkey() && o.value.to_sat() == 50000));

let post_withdraw_walletng_balance = client.balance().await?;
let expected_wallet_balance = initial_walletng_balance - 50_000_000 - (fees_sat * 1000);
Expand Down Expand Up @@ -2000,25 +1995,19 @@ pub async fn recoverytool_test(dev_fed: DevFed) -> Result<()> {
.expect("txid should be parsable");
let tx_hex = bitcoind.poll_get_transaction(txid).await?;

let tx = bitcoin32_to_bitcoin30_tx(&bitcoin::Transaction::consensus_decode_hex(
&tx_hex,
&ModuleRegistry::default(),
)?);
let tx = bitcoin::Transaction::consensus_decode_hex(&tx_hex, &ModuleRegistry::default())?;
assert_eq!(tx.input.len(), 1);
assert_eq!(tx.output.len(), 2);

let change_output = tx
.output
.iter()
.find(|o| {
o.to_owned().script_pubkey
!= bitcoin32_to_bitcoin30_script_buf(&withdrawal_address.script_pubkey())
})
.find(|o| o.to_owned().script_pubkey != withdrawal_address.script_pubkey())
.expect("withdrawal must have change output");
assert!(fed_utxos_sats.insert(change_output.value));
assert!(fed_utxos_sats.insert(change_output.value.to_sat()));

// Remove the utxo consumed from the withdrawal tx
let total_output_sats = tx.output.iter().map(|o| o.value).sum::<u64>();
let total_output_sats = tx.output.iter().map(|o| o.value.to_sat()).sum::<u64>();
let input_sats = total_output_sats + fees_sat;
assert!(fed_utxos_sats.remove(&input_sats));

Expand Down
7 changes: 2 additions & 5 deletions fedimint-bitcoind/src/esplora.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ use std::collections::HashMap;

use anyhow::{bail, format_err};
use bitcoin::{BlockHash, Network, ScriptBuf, Transaction, Txid};
use fedimint_core::bitcoin_migration::{
bitcoin32_to_bitcoin30_block_header, bitcoin32_to_bitcoin30_partial_merkle_tree,
};
use fedimint_core::envs::BitcoinRpcConfig;
use fedimint_core::task::TaskHandle;
use fedimint_core::txoproof::TxOutProof;
Expand Down Expand Up @@ -164,8 +161,8 @@ impl IBitcoindRpc for EsploraClient {
.ok_or(format_err!("No merkle proof found"))?;

Ok(TxOutProof {
block_header: bitcoin32_to_bitcoin30_block_header(&proof.header),
merkle_proof: bitcoin32_to_bitcoin30_partial_merkle_tree(&proof.txn),
block_header: proof.header,
merkle_proof: proof.txn,
})
}

Expand Down
1 change: 0 additions & 1 deletion fedimint-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ miniscript = { workspace = true, features = ["serde"] }
parity-scale-codec = { version = "3.6.12", features = ["derive"] }
rand = { workspace = true }
secp256k1 = { workspace = true, features = ["global-context", "rand-std"] }
secp256k1_27 = { workspace = true, features = ["global-context", "rand-std"] }
serde = { workspace = true }
serde_json = { workspace = true }
serdect = { workspace = true }
Expand Down
Loading

0 comments on commit 9b11b56

Please sign in to comment.