Skip to content

Commit 93e8eaf

Browse files
committed
Merge #1048: Remove TransactionDetails from Wallet API
5fb5061 ci: fix msrv dependency versions for rustls (Steve Myers) dd5b8d7 test(wallet): add check_fee!(wallet,psbt) macro and use it in place of psbt.fee_amount() (Steve Myers) 465d53c docs(wallet): update docs for calculate_fee/fee_rate and add_foreign_utxo (Steve Myers) 0362998 feat(wallet): add Wallet::insert_txout function and updated docs for fee functions (Steve Myers) d443fe7 feat(tx_graph)!: change TxGraph::calculate_fee to return Result<u64,CalculateFeeError> (Steve Myers) b4c31cd feat(wallet)!: remove TransactionDetails from bdk::Wallet API (Steve Myers) Pull request description: ### Description Removed `TransactionDetails` and changed `Wallet::get_tx` to return a `CanonicalTx`, and `TxBuilder::finish` to return only a `PartiallySignedTransaction`. This should fix #922 and fix #1015. I also added `Wallet` functions to get a `Transaction` send and receive amounts, fee, and `FeeRate`. see: #922 (comment) ### Notes to the reviewers Alot of wallet tests had to change since `TxBuilder::finish` only returns a PSBT now. I added a new `CalculateFeeError` which follows changes coming in #1028. ### Changelog notice Added - Wallet::sent_and_received function - Wallet::calculate_fee and Wallet::calculate_fee_rate functions - Wallet::error::CalculateFeeError - Wallet::insert_txout function to allow inserting foreign TxOuts BREAKING CHANGES: Removed - TransactionDetails struct Changed - Wallet::get_tx now returns CanonicalTx instead of TransactionDetails - TxBuilder::finish now returns only a PartiallySignedTransaction ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing #### New Features: * [x] I've added tests for the new feature * [x] I've added docs for the new feature ACKs for top commit: evanlinjin: ACK 5fb5061 Tree-SHA512: 1a0be1c229b8871e5ee23ba6874ff40370170477a0a8bb104c0197e7fd97765d84854285f863dd1b38a34c3b71815e75e4db5b25288c81caea99a14ddaa78254
2 parents e5fb1ec + 5fb5061 commit 93e8eaf

File tree

16 files changed

+688
-402
lines changed

16 files changed

+688
-402
lines changed

.github/workflows/cont_integration.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ jobs:
3232
run: |
3333
cargo update -p log --precise "0.4.18"
3434
cargo update -p tempfile --precise "3.6.0"
35-
cargo update -p rustls:0.21.6 --precise "0.21.1"
35+
cargo update -p rustls:0.21.7 --precise "0.21.1"
36+
cargo update -p rustls:0.20.9 --precise "0.20.8"
3637
cargo update -p tokio:1.32.0 --precise "1.29.1"
3738
cargo update -p flate2:1.0.27 --precise "1.0.26"
3839
cargo update -p reqwest --precise "0.11.18"

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,15 @@ This library should compile with any combination of features with Rust 1.57.0.
6464

6565
To build with the MSRV you will need to pin dependencies as follows:
6666

67-
```
67+
```shell
6868
# log 0.4.19 has MSRV 1.60.0+
6969
cargo update -p log --precise "0.4.18"
7070
# tempfile 3.7.0 has MSRV 1.63.0+
7171
cargo update -p tempfile --precise "3.6.0"
7272
# rustls 0.21.2 has MSRV 1.60.0+
73-
cargo update -p rustls:0.21.6 --precise "0.21.1"
73+
cargo update -p rustls:0.21.7 --precise "0.21.1"
74+
# rustls 0.20.9 has MSRV 1.60.0+
75+
cargo update -p rustls:0.20.9 --precise "0.20.8"
7476
# tokio 1.30 has MSRV 1.63.0+
7577
cargo update -p tokio:1.32.0 --precise "1.29.1"
7678
# flate2 1.0.27 has MSRV 1.63.0+

crates/bdk/src/keys/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ fn expand_multi_keys<Pk: IntoDescriptorKey<Ctx>, Ctx: ScriptContext>(
754754
let (key_map, valid_networks) = key_maps_networks.into_iter().fold(
755755
(KeyMap::default(), any_network()),
756756
|(mut keys_acc, net_acc), (key, net)| {
757-
keys_acc.extend(key.into_iter());
757+
keys_acc.extend(key);
758758
let net_acc = merge_networks(&net_acc, &net);
759759

760760
(keys_acc, net_acc)

crates/bdk/src/types.rs

+2-36
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ use core::convert::AsRef;
1414
use core::ops::Sub;
1515

1616
use bdk_chain::ConfirmationTime;
17-
use bitcoin::blockdata::transaction::{OutPoint, Transaction, TxOut};
18-
use bitcoin::{hash_types::Txid, psbt, Weight};
17+
use bitcoin::blockdata::transaction::{OutPoint, TxOut};
18+
use bitcoin::{psbt, Weight};
1919

2020
use serde::{Deserialize, Serialize};
2121

@@ -234,40 +234,6 @@ impl Utxo {
234234
}
235235
}
236236

237-
/// A wallet transaction
238-
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
239-
pub struct TransactionDetails {
240-
/// Optional transaction
241-
pub transaction: Option<Transaction>,
242-
/// Transaction id
243-
pub txid: Txid,
244-
/// Received value (sats)
245-
/// Sum of owned outputs of this transaction.
246-
pub received: u64,
247-
/// Sent value (sats)
248-
/// Sum of owned inputs of this transaction.
249-
pub sent: u64,
250-
/// Fee value in sats if it was available.
251-
pub fee: Option<u64>,
252-
/// If the transaction is confirmed, contains height and Unix timestamp of the block containing the
253-
/// transaction, unconfirmed transaction contains `None`.
254-
pub confirmation_time: ConfirmationTime,
255-
}
256-
257-
impl PartialOrd for TransactionDetails {
258-
fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> {
259-
Some(self.cmp(other))
260-
}
261-
}
262-
263-
impl Ord for TransactionDetails {
264-
fn cmp(&self, other: &Self) -> core::cmp::Ordering {
265-
self.confirmation_time
266-
.cmp(&other.confirmation_time)
267-
.then_with(|| self.txid.cmp(&other.txid))
268-
}
269-
}
270-
271237
#[cfg(test)]
272238
mod tests {
273239
use super::*;

crates/bdk/src/wallet/coin_selection.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
//! .unwrap()
8787
//! .require_network(Network::Testnet)
8888
//! .unwrap();
89-
//! let (psbt, details) = {
89+
//! let psbt = {
9090
//! let mut builder = wallet.build_tx().coin_selection(AlwaysSpendEverything);
9191
//! builder.add_recipient(to_address.script_pubkey(), 50_000);
9292
//! builder.finish()?

0 commit comments

Comments
 (0)