From 53e1056c8e00693e0b0af41972312c141a87712c Mon Sep 17 00:00:00 2001 From: Lucas Soriano del Pino Date: Wed, 8 Sep 2021 13:35:23 +1000 Subject: [PATCH] Do not hard-code network in library --- cfd_protocol/src/lib.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/cfd_protocol/src/lib.rs b/cfd_protocol/src/lib.rs index b63147c..6ad0b2f 100644 --- a/cfd_protocol/src/lib.rs +++ b/cfd_protocol/src/lib.rs @@ -4,7 +4,7 @@ use bdk::bitcoin::hashes::*; use bdk::bitcoin::util::bip143::SigHashCache; use bdk::bitcoin::util::psbt::{Global, PartiallySignedTransaction}; use bdk::bitcoin::{ - Address, Amount, Network, OutPoint, PublicKey, SigHash, SigHashType, Transaction, TxIn, TxOut, + Address, Amount, OutPoint, PublicKey, SigHash, SigHashType, Transaction, TxIn, TxOut, }; use bdk::database::BatchDatabase; use bdk::descriptor::Descriptor; @@ -692,10 +692,7 @@ impl CommitTransaction { let output = TxOut { value: lock_tx_amount, - script_pubkey: descriptor - .address(Network::Regtest) - .expect("can derive address from descriptor") - .script_pubkey(), + script_pubkey: descriptor.script_pubkey(), }; let mut inner = Transaction { @@ -802,10 +799,7 @@ impl LockTransaction { let lock_output = TxOut { value: amount.as_sat(), - script_pubkey: lock_descriptor - .address(Network::Regtest) - .expect("can derive address from descriptor") - .script_pubkey(), + script_pubkey: lock_descriptor.script_pubkey(), }; let lock_tx = Transaction { @@ -884,6 +878,8 @@ impl SigHashExt for SigHash { #[cfg(test)] mod tests { use super::*; + + use bdk::bitcoin::Network; use std::str::FromStr; // TODO add proptest for this