Skip to content

Commit

Permalink
refactor: use TxIn type from bitcoin-ffi
Browse files Browse the repository at this point in the history
  • Loading branch information
thunderbiscuit committed Oct 18, 2024
1 parent ed2aadf commit 3207943
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 33 deletions.
2 changes: 1 addition & 1 deletion bdk-ffi/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion bdk-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ bdk_wallet = { version = "=1.0.0-beta.5", features = ["all-keys", "keys-bip39",
bdk_core = { version = "0.3.0" }
bdk_esplora = { version = "0.19.0", default-features = false, features = ["std", "blocking", "blocking-https-rustls"] }
bdk_electrum = { version = "0.19.0", default-features = false, features = ["use-rustls-ring"] }
bitcoin-ffi = { git = "https://github.com/bitcoindevkit/bitcoin-ffi", tag = "v0.1.2" }
bitcoin-ffi = { git = "https://github.com/bitcoindevkit/bitcoin-ffi", ref = "165f910f560a51545f93b3eab496cc92ad210aa8" }
#bitcoin-ffi = { path = "../../bitcoin-ffi" }
#bitcoin-ffi = { git = "https://github.com/bitcoindevkit/bitcoin-ffi", tag = "v0.1.2" }

uniffi = { version = "=0.28.0" }
thiserror = "1.0.58"
Expand Down
10 changes: 4 additions & 6 deletions bdk-ffi/src/bdk.udl
Original file line number Diff line number Diff line change
Expand Up @@ -714,12 +714,7 @@ interface Psbt {
string json_serialize();
};

dictionary TxIn {
OutPoint previous_output;
Script script_sig;
u32 sequence;
sequence<sequence<u8>> witness;
};


// ------------------------------------------------------------------------
// types defined in external crate bitcoin-ffi
Expand All @@ -743,6 +738,9 @@ typedef extern Txid;
[External="bitcoin_ffi"]
typedef extern OutPoint;

[External="bitcoin_ffi"]
typedef extern TxIn;

[ExternalInterface="bitcoin_ffi"]
typedef extern FeeRateError;

Expand Down
25 changes: 1 addition & 24 deletions bdk-ffi/src/bitcoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use crate::error::{
AddressParseError, FromScriptError, PsbtError, PsbtParseError, TransactionError,
};

use bitcoin_ffi::OutPoint;
use bitcoin_ffi::Script;
use bitcoin_ffi::TxIn;

use bdk_wallet::bitcoin::address::{NetworkChecked, NetworkUnchecked};
use bdk_wallet::bitcoin::consensus::encode::serialize;
Expand All @@ -14,7 +14,6 @@ use bdk_wallet::bitcoin::Address as BdkAddress;
use bdk_wallet::bitcoin::Network;
use bdk_wallet::bitcoin::Psbt as BdkPsbt;
use bdk_wallet::bitcoin::Transaction as BdkTransaction;
use bdk_wallet::bitcoin::TxIn as BdkTxIn;
use bdk_wallet::bitcoin::TxOut as BdkTxOut;
use bdk_wallet::serde_json;

Expand Down Expand Up @@ -200,28 +199,6 @@ impl From<BdkPsbt> for Psbt {
}
}

#[derive(Debug, Clone)]
pub struct TxIn {
pub previous_output: OutPoint,
pub script_sig: Arc<Script>,
pub sequence: u32,
pub witness: Vec<Vec<u8>>,
}

impl From<&BdkTxIn> for TxIn {
fn from(tx_in: &BdkTxIn) -> Self {
TxIn {
previous_output: OutPoint {
txid: tx_in.previous_output.txid,
vout: tx_in.previous_output.vout,
},
script_sig: Arc::new(Script(tx_in.script_sig.clone())),
sequence: tx_in.sequence.0,
witness: tx_in.witness.to_vec(),
}
}
}

#[derive(Debug, Clone)]
pub struct TxOut {
pub value: u64,
Expand Down
2 changes: 1 addition & 1 deletion bdk-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ mod wallet;
use crate::bitcoin::Address;
use crate::bitcoin::Psbt;
use crate::bitcoin::Transaction;
use crate::bitcoin::TxIn;
use crate::bitcoin::TxOut;
use crate::descriptor::Descriptor;
use crate::electrum::ElectrumClient;
Expand Down Expand Up @@ -70,6 +69,7 @@ use bitcoin_ffi::FeeRate;
use bitcoin_ffi::Network;
use bitcoin_ffi::OutPoint;
use bitcoin_ffi::Script;
use bitcoin_ffi::TxIn;

use bdk_wallet::keys::bip39::WordCount;
use bdk_wallet::tx_builder::ChangeSpendPolicy;
Expand Down

0 comments on commit 3207943

Please sign in to comment.