mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-10-12 05:20:53 -04:00
Merge #209
209: Upgrade to bdk 0.4 r=thomaseizinger a=thomaseizinger Effectively, this also means: - Upgrading to rust-bitcoin 0.26 - Upgrading to miniscript 5 - Upgrading monero to 0.10 - Upgrading curve25519-dalek to 3 - Upgrading bitcoin-harness to rust-bitcoin 0.26 (https://github.com/coblox/bitcoin-harness-rs/pull/21) - Upgrade `ecdsa_fun` to latest version - Replace `cross_curve_dleq` with `sigma_fun` (to avoid an upgrade dance on that library) I refrained from specifying `rev`s in the Cargo.toml because we have a lock-file anyway. This should allow us to update those dependencies easier in the future by just running `cargo update -p <dependency>`. Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
This commit is contained in:
commit
81228c9d5b
20 changed files with 306 additions and 268 deletions
|
@ -5,7 +5,7 @@ use crate::bitcoin::{
|
|||
use ::bitcoin::{util::bip143::SigHashCache, OutPoint, SigHash, SigHashType, TxIn, TxOut, Txid};
|
||||
use anyhow::Result;
|
||||
use ecdsa_fun::Signature;
|
||||
use miniscript::{Descriptor, NullCtx};
|
||||
use miniscript::{Descriptor, DescriptorTrait};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{collections::HashMap, ops::Add};
|
||||
|
||||
|
@ -78,7 +78,7 @@ impl TxCancel {
|
|||
|
||||
let tx_out = TxOut {
|
||||
value: tx_lock.lock_amount().as_sat() - TX_FEE,
|
||||
script_pubkey: cancel_output_descriptor.script_pubkey(NullCtx),
|
||||
script_pubkey: cancel_output_descriptor.script_pubkey(),
|
||||
};
|
||||
|
||||
let transaction = Transaction {
|
||||
|
@ -90,7 +90,7 @@ impl TxCancel {
|
|||
|
||||
let digest = SigHashCache::new(&transaction).signature_hash(
|
||||
0, // Only one input: lock_input (lock transaction)
|
||||
&tx_lock.output_descriptor.witness_script(NullCtx),
|
||||
&tx_lock.output_descriptor.script_code(),
|
||||
tx_lock.lock_amount().as_sat(),
|
||||
SigHashType::All,
|
||||
);
|
||||
|
@ -146,7 +146,7 @@ impl TxCancel {
|
|||
let mut tx_cancel = self.inner;
|
||||
tx_lock
|
||||
.output_descriptor
|
||||
.satisfy(&mut tx_cancel.input[0], satisfier, NullCtx)?;
|
||||
.satisfy(&mut tx_cancel.input[0], satisfier)?;
|
||||
|
||||
Ok(tx_cancel)
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ use crate::bitcoin::{
|
|||
};
|
||||
use ::bitcoin::{util::psbt::PartiallySignedTransaction, OutPoint, TxIn, TxOut, Txid};
|
||||
use anyhow::Result;
|
||||
use miniscript::{Descriptor, NullCtx};
|
||||
use miniscript::{Descriptor, DescriptorTrait};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
|
@ -20,7 +20,7 @@ impl TxLock {
|
|||
{
|
||||
let lock_output_descriptor = build_shared_output_descriptor(A.0, B.0);
|
||||
let address = lock_output_descriptor
|
||||
.address(wallet.get_network().await, NullCtx)
|
||||
.address(wallet.get_network().await)
|
||||
.expect("can derive address from descriptor");
|
||||
|
||||
let psbt = wallet.build_tx_lock_psbt(address, amount).await?;
|
||||
|
@ -54,9 +54,7 @@ impl TxLock {
|
|||
.extract_tx()
|
||||
.output
|
||||
.iter()
|
||||
.position(|output| {
|
||||
output.script_pubkey == self.output_descriptor.script_pubkey(NullCtx)
|
||||
})
|
||||
.position(|output| output.script_pubkey == self.output_descriptor.script_pubkey())
|
||||
.expect("transaction contains lock output")
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ use crate::bitcoin::{Address, PublicKey, PunishTimelock, Transaction, TxCancel};
|
|||
use ::bitcoin::{util::bip143::SigHashCache, SigHash, SigHashType};
|
||||
use anyhow::Result;
|
||||
use ecdsa_fun::Signature;
|
||||
use miniscript::NullCtx;
|
||||
use miniscript::DescriptorTrait;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -21,7 +21,7 @@ impl TxPunish {
|
|||
|
||||
let digest = SigHashCache::new(&tx_punish).signature_hash(
|
||||
0, // Only one input: cancel transaction
|
||||
&tx_cancel.output_descriptor.witness_script(NullCtx),
|
||||
&tx_cancel.output_descriptor.script_code(),
|
||||
tx_cancel.amount().as_sat(),
|
||||
SigHashType::All,
|
||||
);
|
||||
|
@ -64,7 +64,7 @@ impl TxPunish {
|
|||
let mut tx_punish = self.inner;
|
||||
tx_cancel
|
||||
.output_descriptor
|
||||
.satisfy(&mut tx_punish.input[0], satisfier, NullCtx)?;
|
||||
.satisfy(&mut tx_punish.input[0], satisfier)?;
|
||||
|
||||
Ok(tx_punish)
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::bitcoin::{
|
|||
use ::bitcoin::{util::bip143::SigHashCache, SigHash, SigHashType, Txid};
|
||||
use anyhow::{bail, Context, Result};
|
||||
use ecdsa_fun::Signature;
|
||||
use miniscript::NullCtx;
|
||||
use miniscript::DescriptorTrait;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
@ -22,7 +22,7 @@ impl TxRedeem {
|
|||
|
||||
let digest = SigHashCache::new(&tx_redeem).signature_hash(
|
||||
0, // Only one input: lock_input (lock transaction)
|
||||
&tx_lock.output_descriptor.witness_script(NullCtx),
|
||||
&tx_lock.output_descriptor.script_code(),
|
||||
tx_lock.lock_amount().as_sat(),
|
||||
SigHashType::All,
|
||||
);
|
||||
|
@ -69,7 +69,7 @@ impl TxRedeem {
|
|||
let mut tx_redeem = self.inner;
|
||||
tx_lock
|
||||
.output_descriptor
|
||||
.satisfy(&mut tx_redeem.input[0], satisfier, NullCtx)?;
|
||||
.satisfy(&mut tx_redeem.input[0], satisfier)?;
|
||||
|
||||
Ok(tx_redeem)
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::bitcoin::{
|
|||
use ::bitcoin::{util::bip143::SigHashCache, SigHash, SigHashType, Txid};
|
||||
use anyhow::{bail, Context, Result};
|
||||
use ecdsa_fun::Signature;
|
||||
use miniscript::NullCtx;
|
||||
use miniscript::DescriptorTrait;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -20,7 +20,7 @@ impl TxRefund {
|
|||
|
||||
let digest = SigHashCache::new(&tx_punish).signature_hash(
|
||||
0, // Only one input: cancel transaction
|
||||
&tx_cancel.output_descriptor.witness_script(NullCtx),
|
||||
&tx_cancel.output_descriptor.script_code(),
|
||||
tx_cancel.amount().as_sat(),
|
||||
SigHashType::All,
|
||||
);
|
||||
|
@ -67,7 +67,7 @@ impl TxRefund {
|
|||
let mut tx_refund = self.inner;
|
||||
tx_cancel
|
||||
.output_descriptor
|
||||
.satisfy(&mut tx_refund.input[0], satisfier, NullCtx)?;
|
||||
.satisfy(&mut tx_refund.input[0], satisfier)?;
|
||||
|
||||
Ok(tx_refund)
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ use crate::{
|
|||
use ::bitcoin::{util::psbt::PartiallySignedTransaction, Txid};
|
||||
use anyhow::{anyhow, bail, Context, Result};
|
||||
use async_trait::async_trait;
|
||||
use backoff::{backoff::Constant as ConstantBackoff, tokio::retry};
|
||||
use backoff::{backoff::Constant as ConstantBackoff, future::retry};
|
||||
use bdk::{
|
||||
blockchain::{noop_progress, Blockchain, ElectrumBlockchain},
|
||||
electrum_client::{self, Client, ElectrumApi},
|
||||
|
@ -125,14 +125,12 @@ impl BuildTxLockPsbt for Wallet {
|
|||
output_amount: Amount,
|
||||
) -> Result<PartiallySignedTransaction> {
|
||||
tracing::debug!("building tx lock");
|
||||
let (psbt, _details) = self.inner.lock().await.create_tx(
|
||||
bdk::TxBuilder::with_recipients(vec![(
|
||||
output_address.script_pubkey(),
|
||||
output_amount.as_sat(),
|
||||
)])
|
||||
// todo: get actual fee
|
||||
.fee_rate(FeeRate::from_sat_per_vb(5.0)),
|
||||
)?;
|
||||
let wallet = self.inner.lock().await;
|
||||
|
||||
let mut tx_builder = wallet.build_tx();
|
||||
tx_builder.add_recipient(output_address.script_pubkey(), output_amount.as_sat());
|
||||
tx_builder.fee_rate(FeeRate::from_sat_per_vb(5.0)); // todo: get actual fee
|
||||
let (psbt, _details) = tx_builder.finish()?;
|
||||
tracing::debug!("tx lock built");
|
||||
Ok(psbt)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue