Browse Source

Do not hard-code network in library

state-machine
Lucas Soriano del Pino 3 years ago
parent
commit
53e1056c8e
No known key found for this signature in database GPG Key ID: EE611E973A1530E7
  1. 14
      cfd_protocol/src/lib.rs

14
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

Loading…
Cancel
Save