mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-10-13 05:50:57 -04:00
Remove Tx
arguments from add_signatures
functions
The only reason we need this argument is because we need to access the output descriptor. We can save that one ahead of time at when we construct the type.
This commit is contained in:
parent
0f8fbd087f
commit
6c38d66864
9 changed files with 28 additions and 31 deletions
|
@ -58,6 +58,7 @@ pub struct TxCancel {
|
|||
inner: Transaction,
|
||||
digest: SigHash,
|
||||
pub(in crate::bitcoin) output_descriptor: Descriptor<::bitcoin::PublicKey>,
|
||||
lock_output_descriptor: Descriptor<::bitcoin::PublicKey>,
|
||||
}
|
||||
|
||||
impl TxCancel {
|
||||
|
@ -99,6 +100,7 @@ impl TxCancel {
|
|||
inner: transaction,
|
||||
digest,
|
||||
output_descriptor: cancel_output_descriptor,
|
||||
lock_output_descriptor: tx_lock.output_descriptor.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,7 +122,6 @@ impl TxCancel {
|
|||
|
||||
pub fn add_signatures(
|
||||
self,
|
||||
tx_lock: &TxLock,
|
||||
(A, sig_a): (PublicKey, Signature),
|
||||
(B, sig_b): (PublicKey, Signature),
|
||||
) -> Result<Transaction> {
|
||||
|
@ -144,8 +145,7 @@ impl TxCancel {
|
|||
};
|
||||
|
||||
let mut tx_cancel = self.inner;
|
||||
tx_lock
|
||||
.output_descriptor
|
||||
self.lock_output_descriptor
|
||||
.satisfy(&mut tx_cancel.input[0], satisfier)?;
|
||||
|
||||
Ok(tx_cancel)
|
||||
|
|
|
@ -2,13 +2,14 @@ use crate::bitcoin::{Address, PublicKey, PunishTimelock, Transaction, TxCancel};
|
|||
use ::bitcoin::{util::bip143::SigHashCache, SigHash, SigHashType};
|
||||
use anyhow::Result;
|
||||
use ecdsa_fun::Signature;
|
||||
use miniscript::DescriptorTrait;
|
||||
use miniscript::{Descriptor, DescriptorTrait};
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct TxPunish {
|
||||
inner: Transaction,
|
||||
digest: SigHash,
|
||||
cancel_output_descriptor: Descriptor<::bitcoin::PublicKey>,
|
||||
}
|
||||
|
||||
impl TxPunish {
|
||||
|
@ -29,6 +30,7 @@ impl TxPunish {
|
|||
Self {
|
||||
inner: tx_punish,
|
||||
digest,
|
||||
cancel_output_descriptor: tx_cancel.output_descriptor.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,7 +40,6 @@ impl TxPunish {
|
|||
|
||||
pub fn add_signatures(
|
||||
self,
|
||||
tx_cancel: &TxCancel,
|
||||
(A, sig_a): (PublicKey, Signature),
|
||||
(B, sig_b): (PublicKey, Signature),
|
||||
) -> Result<Transaction> {
|
||||
|
@ -62,8 +63,7 @@ impl TxPunish {
|
|||
};
|
||||
|
||||
let mut tx_punish = self.inner;
|
||||
tx_cancel
|
||||
.output_descriptor
|
||||
self.cancel_output_descriptor
|
||||
.satisfy(&mut tx_punish.input[0], satisfier)?;
|
||||
|
||||
Ok(tx_punish)
|
||||
|
|
|
@ -5,13 +5,14 @@ use crate::bitcoin::{
|
|||
use ::bitcoin::{util::bip143::SigHashCache, SigHash, SigHashType, Txid};
|
||||
use anyhow::{bail, Context, Result};
|
||||
use ecdsa_fun::Signature;
|
||||
use miniscript::DescriptorTrait;
|
||||
use miniscript::{Descriptor, DescriptorTrait};
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct TxRedeem {
|
||||
inner: Transaction,
|
||||
digest: SigHash,
|
||||
lock_output_descriptor: Descriptor<::bitcoin::PublicKey>,
|
||||
}
|
||||
|
||||
impl TxRedeem {
|
||||
|
@ -30,6 +31,7 @@ impl TxRedeem {
|
|||
Self {
|
||||
inner: tx_redeem,
|
||||
digest,
|
||||
lock_output_descriptor: tx_lock.output_descriptor.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,7 +45,6 @@ impl TxRedeem {
|
|||
|
||||
pub fn add_signatures(
|
||||
self,
|
||||
tx_lock: &TxLock,
|
||||
(A, sig_a): (PublicKey, Signature),
|
||||
(B, sig_b): (PublicKey, Signature),
|
||||
) -> Result<Transaction> {
|
||||
|
@ -67,8 +68,7 @@ impl TxRedeem {
|
|||
};
|
||||
|
||||
let mut tx_redeem = self.inner;
|
||||
tx_lock
|
||||
.output_descriptor
|
||||
self.lock_output_descriptor
|
||||
.satisfy(&mut tx_redeem.input[0], satisfier)?;
|
||||
|
||||
Ok(tx_redeem)
|
||||
|
|
|
@ -5,13 +5,14 @@ use crate::bitcoin::{
|
|||
use ::bitcoin::{util::bip143::SigHashCache, SigHash, SigHashType, Txid};
|
||||
use anyhow::{bail, Context, Result};
|
||||
use ecdsa_fun::Signature;
|
||||
use miniscript::DescriptorTrait;
|
||||
use miniscript::{Descriptor, DescriptorTrait};
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct TxRefund {
|
||||
inner: Transaction,
|
||||
digest: SigHash,
|
||||
cancel_output_descriptor: Descriptor<::bitcoin::PublicKey>,
|
||||
}
|
||||
|
||||
impl TxRefund {
|
||||
|
@ -28,6 +29,7 @@ impl TxRefund {
|
|||
Self {
|
||||
inner: tx_punish,
|
||||
digest,
|
||||
cancel_output_descriptor: tx_cancel.output_descriptor.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,7 +43,6 @@ impl TxRefund {
|
|||
|
||||
pub fn add_signatures(
|
||||
self,
|
||||
tx_cancel: &TxCancel,
|
||||
(A, sig_a): (PublicKey, Signature),
|
||||
(B, sig_b): (PublicKey, Signature),
|
||||
) -> Result<Transaction> {
|
||||
|
@ -65,8 +66,7 @@ impl TxRefund {
|
|||
};
|
||||
|
||||
let mut tx_refund = self.inner;
|
||||
tx_cancel
|
||||
.output_descriptor
|
||||
self.cancel_output_descriptor
|
||||
.satisfy(&mut tx_refund.input[0], satisfier)?;
|
||||
|
||||
Ok(tx_refund)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue