Use From trait for conversion
This commit is contained in:
parent
358cc35b60
commit
c6c4446092
@ -82,7 +82,8 @@ pub enum Transaction {
|
||||
},
|
||||
}
|
||||
|
||||
fn to_transaction(x: &bdk::TransactionDetails) -> Transaction {
|
||||
impl From<&bdk::TransactionDetails> for Transaction {
|
||||
fn from(x: &bdk::TransactionDetails) -> Transaction {
|
||||
let details = TransactionDetails {
|
||||
fees: x.fee,
|
||||
id: x.txid.to_string(),
|
||||
@ -96,6 +97,7 @@ fn to_transaction(x: &bdk::TransactionDetails) -> Transaction {
|
||||
},
|
||||
None => Transaction::Unconfirmed { details },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
trait OfflineWalletOperations<B>: WalletHolder<B> {
|
||||
@ -133,7 +135,7 @@ trait OfflineWalletOperations<B>: WalletHolder<B> {
|
||||
|
||||
fn get_transactions(&self) -> Result<Vec<Transaction>, Error> {
|
||||
let transactions = self.get_wallet().list_transactions(true)?;
|
||||
Ok(transactions.iter().map(to_transaction).collect())
|
||||
Ok(transactions.iter().map(Transaction::from).collect())
|
||||
}
|
||||
}
|
||||
|
||||
@ -275,7 +277,7 @@ impl OnlineWallet {
|
||||
) -> Result<Transaction, Error> {
|
||||
let tx = psbt.internal.lock().unwrap().clone().extract_tx();
|
||||
self.get_wallet().broadcast(tx)?;
|
||||
Ok(to_transaction(&psbt.details))
|
||||
Ok(Transaction::from(&psbt.details))
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user