Skip to content

Commit e19a63f

Browse files
authored
Merge pull request #5 from rajarshimaitra/bdk-update
update to bdk v0.19.0
2 parents f4acda3 + 3210861 commit e19a63f

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ license = "MIT OR Apache-2.0"
1010
repository = "https://github.com/weareseba/bdk-reserves"
1111

1212
[dependencies]
13-
bdk = { version = "^0.18", default-features = false }
13+
bdk = { version = "0.19", default-features = false }
1414
bitcoinconsensus = "0.19.0-3"
1515
base64 = "^0.11"
1616
log = "^0.4"
1717

1818
[dev-dependencies]
1919
rstest = "^0.11"
2020
bdk-testutils = "^0.4"
21-
bdk = { version = "^0.18", default-features = true }
21+
bdk = { version = "0.19", default-features = true }

src/reserves.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
2121
use bdk::bitcoin::blockdata::opcodes;
2222
use bdk::bitcoin::blockdata::script::{Builder, Script};
23-
use bdk::bitcoin::blockdata::transaction::{OutPoint, SigHashType, TxIn, TxOut};
23+
use bdk::bitcoin::blockdata::transaction::{EcdsaSighashType, 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};
@@ -232,7 +232,7 @@ pub fn verify_proof(
232232

233233
// Verify the SIGHASH
234234
if let Some((i, _psbt_in)) = psbt.inputs.iter().enumerate().find(|(_i, psbt_in)| {
235-
psbt_in.sighash_type.is_some() && psbt_in.sighash_type != Some(SigHashType::All)
235+
psbt_in.sighash_type.is_some() && psbt_in.sighash_type != Some(EcdsaSighashType::All.into())
236236
}) {
237237
return Err(ProofError::UnsupportedSighashType(i));
238238
}
@@ -446,7 +446,7 @@ mod test {
446446

447447
let message = "This belongs to me.";
448448
let mut psbt = get_signed_proof();
449-
psbt.global.unsigned_tx.input.truncate(1);
449+
psbt.unsigned_tx.input.truncate(1);
450450
psbt.inputs.truncate(1);
451451

452452
wallet.verify_proof(&psbt, message, None).unwrap();
@@ -460,7 +460,7 @@ mod test {
460460

461461
let message = "This belongs to me.";
462462
let mut psbt = get_signed_proof();
463-
psbt.global.unsigned_tx.output.clear();
463+
psbt.unsigned_tx.output.clear();
464464
psbt.inputs.clear();
465465

466466
wallet.verify_proof(&psbt, message, None).unwrap();
@@ -488,7 +488,7 @@ mod test {
488488

489489
let message = "This belongs to me.";
490490
let mut psbt = get_signed_proof();
491-
psbt.inputs[1].sighash_type = Some(SigHashType::SinglePlusAnyoneCanPay);
491+
psbt.inputs[1].sighash_type = Some(EcdsaSighashType::SinglePlusAnyoneCanPay.into());
492492

493493
wallet.verify_proof(&psbt, message, None).unwrap();
494494
}
@@ -508,7 +508,7 @@ mod test {
508508
network: Network::Testnet,
509509
}
510510
.script_pubkey();
511-
psbt.global.unsigned_tx.output[0].script_pubkey = out_script_unspendable;
511+
psbt.unsigned_tx.output[0].script_pubkey = out_script_unspendable;
512512

513513
wallet.verify_proof(&psbt, message, None).unwrap();
514514
}
@@ -521,7 +521,7 @@ mod test {
521521

522522
let message = "This belongs to me.";
523523
let mut psbt = get_signed_proof();
524-
psbt.global.unsigned_tx.output[0].value = 123;
524+
psbt.unsigned_tx.output[0].value = 123;
525525

526526
wallet.verify_proof(&psbt, message, None).unwrap();
527527
}

tests/tampering.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use bdk::bitcoin::blockdata::transaction::SigHashType;
1+
use bdk::bitcoin::blockdata::transaction::EcdsaSighashType;
22
use bdk::wallet::get_funded_wallet;
33
use bdk::SignOptions;
44
use bdk_reserves::reserves::*;
@@ -27,8 +27,7 @@ fn tampered_proof_message() {
2727
// change the message
2828
let message_bob = "This belongs to Bob.";
2929
let psbt_bob = wallet.create_proof(message_bob).unwrap();
30-
psbt_alice.global.unsigned_tx.input[0].previous_output =
31-
psbt_bob.global.unsigned_tx.input[0].previous_output;
30+
psbt_alice.unsigned_tx.input[0].previous_output = psbt_bob.unsigned_tx.input[0].previous_output;
3231
psbt_alice.inputs[0].witness_utxo = psbt_bob.inputs[0].witness_utxo.clone();
3332

3433
let res_alice = wallet.verify_proof(&psbt_alice, message_alice, None);
@@ -55,7 +54,7 @@ fn tampered_proof_sighash_tx() {
5554
};
5655

5756
// set an unsupported sighash
58-
psbt.inputs[1].sighash_type = Some(SigHashType::Single);
57+
psbt.inputs[1].sighash_type = Some(EcdsaSighashType::Single.into());
5958

6059
let _finalized = wallet.sign(&mut psbt, signopt).unwrap();
6160

@@ -78,7 +77,7 @@ fn tampered_proof_miner_fee() {
7877
};
7978

8079
// reduce the output value to grant a miner fee
81-
psbt.global.unsigned_tx.output[0].value -= 100;
80+
psbt.unsigned_tx.output[0].value -= 100;
8281

8382
let _finalized = wallet.sign(&mut psbt, signopt).unwrap();
8483

0 commit comments

Comments
 (0)