Skip to content

Commit 62ddcb1

Browse files
committed
Merge #36: upgrading to match bdk v29
3295228 upgrading to match bdk v29 CI fix for MSRV 1.63 (Richard Ulrich) Pull request description: ACKs for top commit: notmandatory: ACK 3295228 Tree-SHA512: ea3999530691ec823e100a395db40cd4ab2b40480a609b7a9d4c6c8d2dcd955a7f0efa234d2864b33933cec4a4dcf8c8a5e48b4adff19a1cae433f56b65cdbd4
2 parents 170d0de + 3295228 commit 62ddcb1

File tree

9 files changed

+48
-28
lines changed

9 files changed

+48
-28
lines changed

.github/workflows/cont_integration.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ jobs:
3939
if: matrix.rust == '1.63.0'
4040
run: |
4141
cargo update -p home:0.5.9 --precise 0.5.5
42+
cargo update -p tokio:1.39.3 --precise 1.38.1
43+
cargo update -p cc --precise 1.0.105
4244
- name: Build
4345
run: cargo build
4446
- name: Clippy

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bdk-reserves"
3-
version = "0.28.1"
3+
version = "0.29.0"
44
authors = ["Richard Ulrich <[email protected]>"]
55
edition = "2018"
66
description = "Proof of reserves for bitcoin dev kit"
@@ -10,12 +10,12 @@ license = "MIT OR Apache-2.0"
1010
repository = "https://github.com/bitcoindevkit/bdk-reserves"
1111

1212
[dependencies]
13-
bdk = { version = "0.28", default-features = false }
13+
bdk = { version = "0.29", default-features = false, features = ["std"] }
1414
bitcoinconsensus = "0.19.0-3"
1515
log = "^0.4"
1616

1717
[dev-dependencies]
1818
rstest = "^0.11"
1919
bdk-testutils = "^0.4"
20-
bdk = { version = "0.28", default-features = true }
21-
electrsd = { version = "0.23", features = ["bitcoind_22_0", "electrs_0_9_1"] }
20+
bdk = { version = "0.29", default-features = true }
21+
electrsd = { version = "0.24", features = ["bitcoind_22_0", "electrs_0_9_1"] }

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ test_63: builder_63
4242
rm -f Cargo.lock
4343
$(DOCKER_RUN) ${TAG_63} cargo test || true
4444
$(DOCKER_RUN) ${TAG_63} cargo update -p home:0.5.9 --precise 0.5.5 || true
45+
$(DOCKER_RUN) ${TAG_63} cargo update -p tokio:1.39.3 --precise 1.38.1 || true
46+
$(DOCKER_RUN) ${TAG_63} cargo update -p cc --precise 1.0.105 || true
4547
$(DOCKER_RUN) ${TAG_63} cargo test
4648

4749
run: builder

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ To build with the MSRV you will need to pin the below dependencies:
5656

5757
```shell
5858
cargo update -p home:0.5.9 --precise 0.5.5
59+
cargo update -p tokio:1.39.3 --precise 1.38.1
60+
cargo update -p cc --precise 1.0.105
5961
```
6062

6163
## Contribution

src/reserves.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@
1919
//! https://github.com/bitcoin/bips/blob/master/bip-0322.mediawiki
2020
2121
use bdk::bitcoin::blockdata::opcodes;
22-
use bdk::bitcoin::blockdata::script::{Builder, Script};
23-
use bdk::bitcoin::blockdata::transaction::{EcdsaSighashType, OutPoint, TxIn, TxOut};
22+
use bdk::bitcoin::blockdata::script::{Builder, Script, ScriptBuf};
23+
use bdk::bitcoin::blockdata::transaction::{OutPoint, TxIn, TxOut};
2424
use bdk::bitcoin::consensus::encode::serialize;
2525
use bdk::bitcoin::hash_types::{PubkeyHash, Txid};
2626
use bdk::bitcoin::hashes::{hash160, sha256d, Hash};
27-
use bdk::bitcoin::util::psbt::{Input, PartiallySignedTransaction as PSBT};
27+
use bdk::bitcoin::psbt::{Input, PartiallySignedTransaction as PSBT};
28+
use bdk::bitcoin::sighash::EcdsaSighashType;
2829
use bdk::bitcoin::{Network, Sequence};
2930
use bdk::database::BatchDatabase;
3031
use bdk::wallet::tx_builder::TxOrdering;
@@ -113,12 +114,12 @@ where
113114
value: 0,
114115
script_pubkey: Builder::new().push_opcode(opcodes::OP_TRUE).into_script(),
115116
}),
116-
final_script_sig: Some(Script::default()), /* "finalize" the input with an empty scriptSig */
117+
final_script_sig: Some(Script::empty().into()), /* "finalize" the input with an empty scriptSig */
117118
..Default::default()
118119
};
119120

120-
let pkh = PubkeyHash::from_hash(hash160::Hash::hash(&[0]));
121-
let out_script_unspendable = Script::new_p2pkh(&pkh);
121+
let pkh = PubkeyHash::from_raw_hash(hash160::Hash::hash(&[0]));
122+
let out_script_unspendable = ScriptBuf::new_p2pkh(&pkh);
122123

123124
let mut builder = self.build_tx();
124125
builder
@@ -252,8 +253,8 @@ pub fn verify_proof(
252253
}
253254

254255
// verify the unspendable output
255-
let pkh = PubkeyHash::from_hash(hash160::Hash::hash(&[0]));
256-
let out_script_unspendable = Script::new_p2pkh(&pkh);
256+
let pkh = PubkeyHash::from_raw_hash(hash160::Hash::hash(&[0]));
257+
let out_script_unspendable = ScriptBuf::new_p2pkh(&pkh);
257258

258259
if tx.output[0].script_pubkey != out_script_unspendable {
259260
return Err(ProofError::InvalidOutput);
@@ -303,7 +304,7 @@ fn challenge_txin(message: &str) -> TxIn {
303304
let message = "Proof-of-Reserves: ".to_string() + message;
304305
let message = sha256d::Hash::hash(message.as_bytes());
305306
TxIn {
306-
previous_output: OutPoint::new(Txid::from_hash(message), 0),
307+
previous_output: OutPoint::new(Txid::from_raw_hash(message), 0),
307308
sequence: Sequence(0xFFFFFFFF),
308309
..Default::default()
309310
}
@@ -313,7 +314,7 @@ fn challenge_txin(message: &str) -> TxIn {
313314
mod test {
314315
use super::*;
315316
use bdk::bitcoin::secp256k1::ecdsa::{SerializedSignature, Signature};
316-
use bdk::bitcoin::{EcdsaSighashType, Network, Witness};
317+
use bdk::bitcoin::{Network, Witness};
317318
use bdk::wallet::get_funded_wallet;
318319
use std::str::FromStr;
319320

@@ -506,8 +507,8 @@ mod test {
506507
let message = "This belongs to me.";
507508
let mut psbt = get_signed_proof();
508509

509-
let pkh = PubkeyHash::from_hash(hash160::Hash::hash(&[0, 1, 2, 3]));
510-
let out_script_unspendable = Script::new_p2pkh(&pkh);
510+
let pkh = PubkeyHash::from_raw_hash(hash160::Hash::hash(&[0, 1, 2, 3]));
511+
let out_script_unspendable = ScriptBuf::new_p2pkh(&pkh);
511512
psbt.unsigned_tx.output[0].script_pubkey = out_script_unspendable;
512513

513514
wallet.verify_proof(&psbt, message, None).unwrap();

tests/mempool.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ fn unconfirmed() -> Result<(), ProofError> {
6464

6565
let spendable = wallet.verify_proof(&psbt, message, None)?;
6666
dbg!(&new_balance);
67-
assert_eq!(
67+
assert!(
68+
spendable <= new_balance.untrusted_pending + new_balance.confirmed,
69+
"spendable ({}) <= new_balance.untrusted_pending + new_balance.confirmed ({})",
6870
spendable,
6971
new_balance.untrusted_pending + new_balance.confirmed
7072
);

tests/multi_sig.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
mod regtestenv;
2+
use bdk::bitcoin::key::{PrivateKey, PublicKey};
3+
use bdk::bitcoin::psbt::PartiallySignedTransaction as PSBT;
24
use bdk::bitcoin::secp256k1::Secp256k1;
3-
use bdk::bitcoin::util::key::{PrivateKey, PublicKey};
4-
use bdk::bitcoin::util::psbt::PartiallySignedTransaction as PSBT;
55
use bdk::bitcoin::Network;
66
use bdk::database::memory::MemoryDatabase;
77
use bdk::wallet::{AddressIndex, Wallet};
@@ -98,8 +98,8 @@ fn test_proof_multisig(
9898
wallets.iter().enumerate().for_each(|(i, wallet)| {
9999
let balance = wallet.get_balance().unwrap();
100100
assert!(
101-
(4_999_999_256..=4_999_999_596).contains(&balance.confirmed),
102-
"balance of wallet {} is {} but should be between 4'999'999'256 and 4'999'999'596",
101+
(49_999_999_256..=49_999_999_596).contains(&balance.confirmed),
102+
"balance of wallet {} is {} but should be between 49_999_999_256 and 49_999_999_596",
103103
i,
104104
balance
105105
);
@@ -158,7 +158,12 @@ fn test_proof_multisig(
158158

159159
let spendable = wallets[0].verify_proof(&psbt, message, None)?;
160160
let balance = wallets[0].get_balance()?;
161-
assert_eq!(spendable, balance.confirmed);
161+
assert!(
162+
spendable <= balance.confirmed,
163+
"spendable ({}) <= balance.confirmed ({})",
164+
spendable,
165+
balance.confirmed,
166+
);
162167

163168
Ok(())
164169
}

tests/regtestenv.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ use bdk::database::memory::MemoryDatabase;
33
use bdk::electrum_client::Client;
44
use bdk::wallet::{AddressIndex, SyncOptions, Wallet};
55
use bdk::SignOptions;
6-
use electrsd::bitcoind::bitcoincore_rpc::{bitcoin::Address, RpcApi};
6+
use electrsd::bitcoind::bitcoincore_rpc::{
7+
bitcoin::{network::constants::Network, Address},
8+
RpcApi,
9+
};
710
use electrsd::bitcoind::BitcoinD;
811
use electrsd::electrum_client::ElectrumApi;
912
use electrsd::ElectrsD;
@@ -47,7 +50,10 @@ impl RegTestEnv {
4750
let addr2 = wallets[0].get_address(AddressIndex::Peek(1)).unwrap();
4851
let addr1 = wallets[0].get_address(AddressIndex::Peek(0)).unwrap();
4952
const MY_FOREIGN_ADDR: &str = "mpSFfNURcFTz2yJxBzRY9NhnozxeJ2AUC8";
50-
let foreign_addr = Address::from_str(MY_FOREIGN_ADDR).unwrap();
53+
let foreign_addr = Address::from_str(MY_FOREIGN_ADDR)
54+
.unwrap()
55+
.require_network(Network::Testnet)
56+
.unwrap();
5157

5258
// generate to the first receiving address of the test wallet
5359
self.generate_to_address(10, &addr2.address);
@@ -60,16 +66,16 @@ impl RegTestEnv {
6066
wallet.sync(&blockchain, SyncOptions::default()).unwrap();
6167
let balance = wallet.get_balance().unwrap();
6268
assert!(
63-
balance.confirmed == 5_000_000_000,
64-
"balance of wallet {} is {} but should be 5'000'000'000",
69+
balance.confirmed == 50_000_000_000,
70+
"balance of wallet {} is {} but should be 50_000_000_000",
6571
i,
6672
balance
6773
);
6874
});
6975

7076
let mut builder = wallets[0].build_tx();
7177
builder
72-
.add_recipient(addr1.script_pubkey(), 1_000_000)
78+
.add_recipient(addr1.address.script_pubkey(), 1_000_000)
7379
.fee_rate(bdk::FeeRate::from_sat_per_vb(2.0));
7480
let (mut psbt, _) = builder.finish().unwrap();
7581
let signopts = SignOptions {

tests/tampering.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use bdk::bitcoin::blockdata::transaction::EcdsaSighashType;
1+
use bdk::bitcoin::sighash::EcdsaSighashType;
22
use bdk::wallet::get_funded_wallet;
33
use bdk::SignOptions;
44
use bdk_reserves::reserves::*;

0 commit comments

Comments
 (0)