Skip to content

Commit cba69e6

Browse files
Clean up of From traits implementations
1 parent 35d8fb3 commit cba69e6

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

bdk-ffi/src/lib.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ use crate::keys::{DescriptorPublicKey, DescriptorSecretKey, Mnemonic};
1515
use crate::psbt::PartiallySignedTransaction;
1616
use crate::wallet::{BumpFeeTxBuilder, TxBuilder, Wallet};
1717
use bdk::bitcoin::blockdata::script::Script as BdkScript;
18+
use bdk::bitcoin::blockdata::transaction::TxIn as BdkTxIn;
19+
use bdk::bitcoin::blockdata::transaction::TxOut as BdkTxOut;
1820
use bdk::bitcoin::consensus::Decodable;
1921
use bdk::bitcoin::psbt::serialize::Serialize;
2022
use bdk::bitcoin::{
@@ -25,6 +27,7 @@ use bdk::database::any::{SledDbConfiguration, SqliteDbConfiguration};
2527
use bdk::keys::bip39::WordCount;
2628
use bdk::wallet::AddressIndex as BdkAddressIndex;
2729
use bdk::wallet::AddressInfo as BdkAddressInfo;
30+
use bdk::LocalUtxo as BdkLocalUtxo;
2831
use bdk::{Balance as BdkBalance, BlockTime, Error as BdkError, FeeRate, KeychainKind};
2932
use std::convert::From;
3033
use std::fmt;
@@ -49,7 +52,7 @@ pub struct AddressInfo {
4952
}
5053

5154
impl From<BdkAddressInfo> for AddressInfo {
52-
fn from(x: bdk::wallet::AddressInfo) -> AddressInfo {
55+
fn from(x: bdk::wallet::AddressInfo) -> Self {
5356
AddressInfo {
5457
index: x.index,
5558
address: x.address.to_string(),
@@ -85,7 +88,7 @@ pub enum AddressIndex {
8588
}
8689

8790
impl From<AddressIndex> for BdkAddressIndex {
88-
fn from(x: AddressIndex) -> BdkAddressIndex {
91+
fn from(x: AddressIndex) -> Self {
8992
match x {
9093
AddressIndex::New => BdkAddressIndex::New,
9194
AddressIndex::LastUnused => BdkAddressIndex::LastUnused,
@@ -143,7 +146,7 @@ pub struct OutPoint {
143146
}
144147

145148
impl From<&OutPoint> for BdkOutPoint {
146-
fn from(x: &OutPoint) -> BdkOutPoint {
149+
fn from(x: &OutPoint) -> Self {
147150
BdkOutPoint {
148151
txid: Txid::from_str(&x.txid).unwrap(),
149152
vout: x.vout,
@@ -188,8 +191,8 @@ pub struct TxOut {
188191
script_pubkey: Arc<Script>,
189192
}
190193

191-
impl From<&bdk::bitcoin::blockdata::transaction::TxOut> for TxOut {
192-
fn from(x: &bdk::bitcoin::blockdata::transaction::TxOut) -> Self {
194+
impl From<&BdkTxOut> for TxOut {
195+
fn from(x: &BdkTxOut) -> Self {
193196
TxOut {
194197
value: x.value,
195198
script_pubkey: Arc::new(Script {
@@ -206,8 +209,8 @@ pub struct LocalUtxo {
206209
is_spent: bool,
207210
}
208211

209-
impl From<bdk::LocalUtxo> for LocalUtxo {
210-
fn from(local_utxo: bdk::LocalUtxo) -> Self {
212+
impl From<BdkLocalUtxo> for LocalUtxo {
213+
fn from(local_utxo: BdkLocalUtxo) -> Self {
211214
LocalUtxo {
212215
outpoint: OutPoint {
213216
txid: local_utxo.outpoint.txid.to_string(),
@@ -216,7 +219,7 @@ impl From<bdk::LocalUtxo> for LocalUtxo {
216219
txout: TxOut {
217220
value: local_utxo.txout.value,
218221
script_pubkey: Arc::new(Script {
219-
script: local_utxo.txout.script_pubkey.clone(),
222+
script: local_utxo.txout.script_pubkey,
220223
}),
221224
},
222225
keychain: local_utxo.keychain,
@@ -257,8 +260,8 @@ pub struct TxIn {
257260
pub witness: Vec<Vec<u8>>,
258261
}
259262

260-
impl From<&bdk::bitcoin::blockdata::transaction::TxIn> for TxIn {
261-
fn from(x: &bdk::bitcoin::blockdata::transaction::TxIn) -> TxIn {
263+
impl From<&BdkTxIn> for TxIn {
264+
fn from(x: &BdkTxIn) -> Self {
262265
TxIn {
263266
previous_output: OutPoint {
264267
txid: x.previous_output.txid.to_string(),

bdk-ffi/src/psbt.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ impl PartiallySignedTransaction {
3535
pub(crate) fn extract_tx(&self) -> Arc<Transaction> {
3636
let tx = self.internal.lock().unwrap().clone().extract_tx();
3737
Arc::new(tx.into())
38-
// let buffer: Vec<u8> = serialize(&tx);
39-
// Arc::new(Transaction::new(buffer).unwrap())
4038
}
4139

4240
/// Combines this PartiallySignedTransaction with other PSBT as described by BIP 174.

0 commit comments

Comments
 (0)