Clean up type aliases and use more explicit variable names
This commit is contained in:
parent
f26031db80
commit
ac600a1312
@ -30,9 +30,11 @@ use bdk::keys::bip39::WordCount;
|
|||||||
use bdk::wallet::AddressIndex as BdkAddressIndex;
|
use bdk::wallet::AddressIndex as BdkAddressIndex;
|
||||||
use bdk::wallet::AddressInfo as BdkAddressInfo;
|
use bdk::wallet::AddressInfo as BdkAddressInfo;
|
||||||
use bdk::LocalUtxo as BdkLocalUtxo;
|
use bdk::LocalUtxo as BdkLocalUtxo;
|
||||||
|
use bdk::TransactionDetails as BdkTransactionDetails;
|
||||||
use bdk::{Balance as BdkBalance, BlockTime, Error as BdkError, FeeRate, KeychainKind};
|
use bdk::{Balance as BdkBalance, BlockTime, Error as BdkError, FeeRate, KeychainKind};
|
||||||
use std::convert::From;
|
use std::convert::From;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
use std::fmt::Debug;
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
@ -56,11 +58,11 @@ pub struct AddressInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl From<BdkAddressInfo> for AddressInfo {
|
impl From<BdkAddressInfo> for AddressInfo {
|
||||||
fn from(x: BdkAddressInfo) -> Self {
|
fn from(address_info: BdkAddressInfo) -> Self {
|
||||||
AddressInfo {
|
AddressInfo {
|
||||||
index: x.index,
|
index: address_info.index,
|
||||||
address: Arc::new(Address::from(x.address)),
|
address: Arc::new(Address::from(address_info.address)),
|
||||||
keychain: x.keychain,
|
keychain: address_info.keychain,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -93,8 +95,8 @@ pub enum AddressIndex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl From<AddressIndex> for BdkAddressIndex {
|
impl From<AddressIndex> for BdkAddressIndex {
|
||||||
fn from(x: AddressIndex) -> Self {
|
fn from(address_index: AddressIndex) -> Self {
|
||||||
match x {
|
match address_index {
|
||||||
AddressIndex::New => BdkAddressIndex::New,
|
AddressIndex::New => BdkAddressIndex::New,
|
||||||
AddressIndex::LastUnused => BdkAddressIndex::LastUnused,
|
AddressIndex::LastUnused => BdkAddressIndex::LastUnused,
|
||||||
AddressIndex::Peek { index } => BdkAddressIndex::Peek(index),
|
AddressIndex::Peek { index } => BdkAddressIndex::Peek(index),
|
||||||
@ -125,8 +127,8 @@ pub struct TransactionDetails {
|
|||||||
pub confirmation_time: Option<BlockTime>,
|
pub confirmation_time: Option<BlockTime>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<bdk::TransactionDetails> for TransactionDetails {
|
impl From<BdkTransactionDetails> for TransactionDetails {
|
||||||
fn from(tx_details: bdk::TransactionDetails) -> Self {
|
fn from(tx_details: BdkTransactionDetails) -> Self {
|
||||||
let optional_tx: Option<Arc<Transaction>> =
|
let optional_tx: Option<Arc<Transaction>> =
|
||||||
tx_details.transaction.map(|tx| Arc::new(tx.into()));
|
tx_details.transaction.map(|tx| Arc::new(tx.into()));
|
||||||
|
|
||||||
@ -151,10 +153,10 @@ pub struct OutPoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl From<&OutPoint> for BdkOutPoint {
|
impl From<&OutPoint> for BdkOutPoint {
|
||||||
fn from(x: &OutPoint) -> Self {
|
fn from(outpoint: &OutPoint) -> Self {
|
||||||
BdkOutPoint {
|
BdkOutPoint {
|
||||||
txid: Txid::from_str(&x.txid).unwrap(),
|
txid: Txid::from_str(&outpoint.txid).unwrap(),
|
||||||
vout: x.vout,
|
vout: outpoint.vout,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -197,11 +199,11 @@ pub struct TxOut {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl From<&BdkTxOut> for TxOut {
|
impl From<&BdkTxOut> for TxOut {
|
||||||
fn from(x: &BdkTxOut) -> Self {
|
fn from(tx_out: &BdkTxOut) -> Self {
|
||||||
TxOut {
|
TxOut {
|
||||||
value: x.value,
|
value: tx_out.value,
|
||||||
script_pubkey: Arc::new(Script {
|
script_pubkey: Arc::new(Script {
|
||||||
script: x.script_pubkey.clone(),
|
script: tx_out.script_pubkey.clone(),
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -251,7 +253,7 @@ impl BdkProgress for ProgressHolder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for ProgressHolder {
|
impl Debug for ProgressHolder {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.debug_struct("ProgressHolder").finish_non_exhaustive()
|
f.debug_struct("ProgressHolder").finish_non_exhaustive()
|
||||||
}
|
}
|
||||||
@ -266,17 +268,17 @@ pub struct TxIn {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl From<&BdkTxIn> for TxIn {
|
impl From<&BdkTxIn> for TxIn {
|
||||||
fn from(x: &BdkTxIn) -> Self {
|
fn from(tx_in: &BdkTxIn) -> Self {
|
||||||
TxIn {
|
TxIn {
|
||||||
previous_output: OutPoint {
|
previous_output: OutPoint {
|
||||||
txid: x.previous_output.txid.to_string(),
|
txid: tx_in.previous_output.txid.to_string(),
|
||||||
vout: x.previous_output.vout,
|
vout: tx_in.previous_output.vout,
|
||||||
},
|
},
|
||||||
script_sig: Arc::new(Script {
|
script_sig: Arc::new(Script {
|
||||||
script: x.script_sig.clone(),
|
script: tx_in.script_sig.clone(),
|
||||||
}),
|
}),
|
||||||
sequence: x.sequence.0,
|
sequence: tx_in.sequence.0,
|
||||||
witness: x.witness.to_vec(),
|
witness: tx_in.witness.to_vec(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -343,8 +345,8 @@ impl Transaction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<bdk::bitcoin::Transaction> for Transaction {
|
impl From<BdkTransaction> for Transaction {
|
||||||
fn from(tx: bdk::bitcoin::Transaction) -> Self {
|
fn from(tx: BdkTransaction) -> Self {
|
||||||
Transaction { internal: tx }
|
Transaction { internal: tx }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user