Skip to content

Commit db6c428

Browse files
authored
Merge pull request #37 from AminaBank/feature/burner
removing the obsolete network parameter, and adding a test for the bu…
2 parents 62ddcb1 + 082a300 commit db6c428

File tree

4 files changed

+40
-8
lines changed

4 files changed

+40
-8
lines changed

.github/workflows/cont_integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ 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
42+
cargo update -p tokio:1.40.0 --precise 1.38.1
4343
cargo update -p cc --precise 1.0.105
4444
- name: Build
4545
run: cargo build

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM rust:1.69-bookworm
1+
FROM rust:1.70-bookworm
22
ARG http_proxy
33
ENV http_proxy=$http_proxy
44
ENV https_proxy=$http_proxy

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ 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
45+
$(DOCKER_RUN) ${TAG_63} cargo update -p tokio:1.40.0 --precise 1.38.1 || true
4646
$(DOCKER_RUN) ${TAG_63} cargo update -p cc --precise 1.0.105 || true
4747
$(DOCKER_RUN) ${TAG_63} cargo test
4848

src/reserves.rs

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use bdk::bitcoin::hash_types::{PubkeyHash, Txid};
2626
use bdk::bitcoin::hashes::{hash160, sha256d, Hash};
2727
use bdk::bitcoin::psbt::{Input, PartiallySignedTransaction as PSBT};
2828
use bdk::bitcoin::sighash::EcdsaSighashType;
29-
use bdk::bitcoin::{Network, Sequence};
29+
use bdk::bitcoin::Sequence;
3030
use bdk::database::BatchDatabase;
3131
use bdk::wallet::tx_builder::TxOrdering;
3232
use bdk::wallet::Wallet;
@@ -173,7 +173,7 @@ where
173173
.map(|(utxo, _)| (utxo.outpoint, utxo.txout.clone()))
174174
.collect();
175175

176-
verify_proof(psbt, message, outpoints, self.network())
176+
verify_proof(psbt, message, outpoints)
177177
}
178178
}
179179

@@ -188,7 +188,6 @@ pub fn verify_proof(
188188
psbt: &PSBT,
189189
message: &str,
190190
outpoints: Vec<(OutPoint, TxOut)>,
191-
_network: Network,
192191
) -> Result<u64, ProofError> {
193192
let tx = psbt.clone().extract_tx();
194193

@@ -314,7 +313,7 @@ fn challenge_txin(message: &str) -> TxIn {
314313
mod test {
315314
use super::*;
316315
use bdk::bitcoin::secp256k1::ecdsa::{SerializedSignature, Signature};
317-
use bdk::bitcoin::{Network, Witness};
316+
use bdk::bitcoin::{Address, Network, Witness};
318317
use bdk::wallet::get_funded_wallet;
319318
use std::str::FromStr;
320319

@@ -406,7 +405,7 @@ mod test {
406405
.iter()
407406
.map(|utxo| (utxo.outpoint, utxo.txout.clone()))
408407
.collect();
409-
let spendable = verify_proof(&psbt, message, outpoints, Network::Testnet).unwrap();
408+
let spendable = verify_proof(&psbt, message, outpoints).unwrap();
410409

411410
assert_eq!(spendable, 50_000);
412411
}
@@ -498,6 +497,39 @@ mod test {
498497
wallet.verify_proof(&psbt, message, None).unwrap();
499498
}
500499

500+
#[test]
501+
fn burner_output() {
502+
let psbt = get_signed_proof();
503+
504+
let pkh = PubkeyHash::from_raw_hash(hash160::Hash::hash(&[0]));
505+
let out_script_unspendable = ScriptBuf::new_p2pkh(&pkh);
506+
assert_eq!(
507+
psbt.unsigned_tx.output[0].script_pubkey,
508+
out_script_unspendable
509+
);
510+
511+
let addr_unspendable = Address::new(
512+
Network::Bitcoin,
513+
bdk::bitcoin::address::Payload::PubkeyHash(pkh),
514+
);
515+
assert_eq!(
516+
addr_unspendable.to_string(),
517+
"1FYMZEHnszCHKTBdFZ2DLrUuk3dGwYKQxh"
518+
);
519+
// https://mempool.space/de/address/1FYMZEHnszCHKTBdFZ2DLrUuk3dGwYKQxh
520+
// https://bitcoin.stackexchange.com/questions/65969/invalid-public-key-was-spent-how-was-this-possible
521+
522+
let addr_unspendable_testnet = Address::new(
523+
Network::Testnet,
524+
bdk::bitcoin::address::Payload::PubkeyHash(pkh),
525+
);
526+
assert_eq!(
527+
addr_unspendable_testnet.to_string(),
528+
"mv4JrHNmh1dY6ZfEy7zbAmhEc3Dyr8ULqX"
529+
);
530+
// this address can be discovered in the transaction in https://ulrichard.ch/blog/?p=2566
531+
}
532+
501533
#[test]
502534
#[should_panic(expected = "InvalidOutput")]
503535
fn invalid_output() {

0 commit comments

Comments
 (0)