Skip to content

Commit

Permalink
Merge #11: Update bdk dependency to 0.22
Browse files Browse the repository at this point in the history
1bf97ec Add cargo update step to CI Build and Test (Steve Myers)
e08ea81 Update bdk dependency to 0.22 (Steve Myers)

Pull request description:

  This update also required recalculating the PSBT proofs due to BDK removing partial signatures, see bitcoindevkit/bdk-cli#118 (review).

  Once this PR is merged I'll publish a new `bdk-reserves` release version `0.22.0`.

Top commit has no ACKs.

Tree-SHA512: 972e51e9ab8dbbff869ce1b8916abf7781e3b30ac671bb719e82d8803b8c56aa3cff723762d2c771cb17bc6d71296bff7c9fee93312316d1162d18f99f35fbee
  • Loading branch information
notmandatory committed Sep 8, 2022
2 parents d4f078e + 1bf97ec commit 6f742ff
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/cont_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ jobs:
run: rustup component add clippy
- name: Update toolchain
run: rustup update
- name: Update Cargo.lock
run: cargo update
- name: Build
run: cargo build
- name: Clippy
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bdk-reserves"
version = "0.20.0"
version = "0.22.0"
authors = ["Richard Ulrich <richard.ulrich@seba.swiss>"]
edition = "2018"
description = "Proof of reserves for bitcoin dev kit"
Expand All @@ -10,11 +10,11 @@ license = "MIT OR Apache-2.0"
repository = "https://github.com/weareseba/bdk-reserves"

[dependencies]
bdk = { version = "0.20", default-features = false }
bdk = { version = "0.22", default-features = false }
bitcoinconsensus = "0.19.0-3"
log = "^0.4"

[dev-dependencies]
rstest = "^0.11"
bdk-testutils = "^0.4"
bdk = { version = "0.20", default-features = true }
bdk = { version = "0.22", default-features = true }
4 changes: 2 additions & 2 deletions src/reserves.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ mod test {
let psbt = wallet.create_proof(message).unwrap();
let psbt_ser = serialize(&psbt);
let psbt_b64 = base64::encode(&psbt_ser);
let expected = r#"cHNidP8BAH4BAAAAAmw1RvG4UzfnSafpx62EPTyha6VslP0Er7n3TxjEpeBeAAAAAAD/////FcB9C8LQwqAoYxGcM/YLhUt3XZIQUmFAlaJlBjVmFO8AAAAAAP////8BUMMAAAAAAAAZdqkUn3/QltN+0sDj9/DPySS+70/862iIrAAAAAAAAQEKAAAAAAAAAAABUQEHAAABAR9QwwAAAAAAABYAFOzlJlcQU9qGRUyeBmd56vnRUC5qAAA="#;
let expected = r#"cHNidP8BAH4BAAAAAmw1RvG4UzfnSafpx62EPTyha6VslP0Er7n3TxjEpeBeAAAAAAD/////2johM0znoXIXT1lg+ySrvGrtq1IGXPJzpfi/emkV9iIAAAAAAP////8BUMMAAAAAAAAZdqkUn3/QltN+0sDj9/DPySS+70/862iIrAAAAAAAAQEKAAAAAAAAAAABUQEHAAABAR9QwwAAAAAAABYAFOzlJlcQU9qGRUyeBmd56vnRUC5qAAA="#;
assert_eq!(psbt_b64, expected);
}

Expand All @@ -373,7 +373,7 @@ mod test {
}

fn get_signed_proof() -> PSBT {
let psbt = "cHNidP8BAH4BAAAAAmw1RvG4UzfnSafpx62EPTyha6VslP0Er7n3TxjEpeBeAAAAAAD/////FcB9C8LQwqAoYxGcM/YLhUt3XZIQUmFAlaJlBjVmFO8AAAAAAP////8BUMMAAAAAAAAZdqkUn3/QltN+0sDj9/DPySS+70/862iIrAAAAAAAAQEKAAAAAAAAAAABUQEHAAABAR9QwwAAAAAAABYAFOzlJlcQU9qGRUyeBmd56vnRUC5qIgIDKwVYB4vsOGlKhJM9ZZMD4lddrn6RaFkRRUEVv9ZEh+NHMEQCICY1Ikn5FTh1KYCpJz7VHyybI1xIcwdtRzOSzmIn6L7RAiBPEOj74R91LZJot3HQ0QbR2zqJnXQG8iL/s7YSBpSOfwEBBwABCGsCRzBEAiAmNSJJ+RU4dSmAqSc+1R8smyNcSHMHbUczks5iJ+i+0QIgTxDo++EfdS2SaLdx0NEG0ds6iZ10BvIi/7O2EgaUjn8BIQMrBVgHi+w4aUqEkz1lkwPiV12ufpFoWRFFQRW/1kSH4wAA";
let psbt = "cHNidP8BAH4BAAAAAmw1RvG4UzfnSafpx62EPTyha6VslP0Er7n3TxjEpeBeAAAAAAD/////2johM0znoXIXT1lg+ySrvGrtq1IGXPJzpfi/emkV9iIAAAAAAP////8BUMMAAAAAAAAZdqkUn3/QltN+0sDj9/DPySS+70/862iIrAAAAAAAAQEKAAAAAAAAAAABUQEHAAABAR9QwwAAAAAAABYAFOzlJlcQU9qGRUyeBmd56vnRUC5qAQcAAQhrAkcwRAIgDSE4PQ57JDiZ7otGkTqz35bi/e1pexYaYKWaveuvRd4CIFzVB4sAmgtdEVz2vHzs1iXc9iRKJ+KQOQb+C2DtPyvzASEDKwVYB4vsOGlKhJM9ZZMD4lddrn6RaFkRRUEVv9ZEh+MAAA==";
let psbt = base64::decode(&psbt).unwrap();
deserialize(&psbt).unwrap()
}
Expand Down
20 changes: 16 additions & 4 deletions tests/mempool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ fn unconfirmed() -> Result<(), ProofError> {
)?;

let balance = wallet.get_balance()?;
assert!(balance > 10_000, "insufficient balance: {}", balance);
assert!(
balance.confirmed > 10_000,
"insufficient balance: {}",
balance.confirmed
);
let addr = wallet.get_address(AddressIndex::New).unwrap();
assert_eq!(
addr.to_string(),
Expand Down Expand Up @@ -58,7 +62,11 @@ fn unconfirmed() -> Result<(), ProofError> {
assert!(finalized);

let spendable = wallet.verify_proof(&psbt, message, None)?;
assert_eq!(spendable, new_balance);
dbg!(&new_balance);
assert_eq!(
spendable,
new_balance.untrusted_pending + new_balance.confirmed
);

Ok(())
}
Expand All @@ -73,7 +81,11 @@ fn confirmed() {
.unwrap();

let balance = wallet.get_balance().unwrap();
assert!(balance > 10_000, "insufficient balance: {}", balance);
assert!(
balance.confirmed > 10_000,
"insufficient balance: {}",
balance
);
let addr = wallet.get_address(AddressIndex::New).unwrap();
assert_eq!(
addr.to_string(),
Expand Down Expand Up @@ -109,5 +121,5 @@ fn confirmed() {
let spendable = wallet
.verify_proof(&psbt, message, Some(max_confirmation_height))
.unwrap();
assert_eq!(spendable, new_balance);
assert_eq!(spendable, new_balance.confirmed);
}
4 changes: 2 additions & 2 deletions tests/multi_sig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ fn test_proof_multisig(
);
let balance = wallet1.get_balance()?;
assert!(
(410000..=420000).contains(&balance),
(410000..=420000).contains(&balance.confirmed),
"balance is {} but should be between 410000 and 420000",
balance
);
Expand Down Expand Up @@ -158,7 +158,7 @@ fn test_proof_multisig(
assert!(finalized);

let spendable = wallet1.verify_proof(&psbt, message, None)?;
assert_eq!(spendable, balance);
assert_eq!(spendable, balance.confirmed);

Ok(())
}
2 changes: 1 addition & 1 deletion tests/single_sig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn test_proof(#[case] descriptor: &'static str) -> Result<(), ProofError> {
assert!(finalized);

let spendable = wallet.verify_proof(&psbt, message, None)?;
assert_eq!(spendable, balance);
assert_eq!(spendable, balance.confirmed);

Ok(())
}
2 changes: 1 addition & 1 deletion tests/tampering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn tampered_proof_message() {
let spendable = wallet
.verify_proof(&psbt_alice, message_alice, None)
.unwrap();
assert_eq!(spendable, balance);
assert_eq!(spendable, balance.confirmed);

// change the message
let message_bob = "This belongs to Bob.";
Expand Down

0 comments on commit 6f742ff

Please sign in to comment.