Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove TransactionDetails from Wallet API #1048

Merged
merged 6 commits into from Aug 31, 2023

Conversation

notmandatory
Copy link
Member

@notmandatory notmandatory commented Jul 27, 2023

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:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing

New Features:

  • I've added tests for the new feature
  • I've added docs for the new feature

@notmandatory notmandatory self-assigned this Jul 27, 2023
@notmandatory notmandatory changed the title test(wallet): add wallet test test_get_funded_wallet_tx_details test(wallet): add test to verify wallet::get_tx TransactionDetails amounts Jul 27, 2023
@LLFourn
Copy link
Contributor

LLFourn commented Jul 27, 2023

I think the plan is to deprecate TransactionDetails altogether. What about just doing #1015 or is the plan to change this test to test the things in #1015 when they're added?

EDIT: this comment was made before seeing the discussion in #1015 -- I've commented over there.

@notmandatory notmandatory marked this pull request as draft July 27, 2023 14:06
@notmandatory notmandatory changed the title test(wallet): add test to verify wallet::get_tx TransactionDetails amounts Remove TransactionDetails from Wallet API, add Wallet::sent_and_received function Jul 27, 2023
@notmandatory notmandatory changed the title Remove TransactionDetails from Wallet API, add Wallet::sent_and_received function Remove TransactionDetails from Wallet API Jul 27, 2023
@notmandatory notmandatory force-pushed the wallet_txdetails branch 5 times, most recently from ebb9f82 to 40d5af3 Compare July 28, 2023 04:25
@notmandatory notmandatory marked this pull request as ready for review July 28, 2023 04:29
Copy link
Member

@danielabrozzoni danielabrozzoni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just have a nit

ACK 40d5af3

crates/bdk/src/wallet/mod.rs Outdated Show resolved Hide resolved
@notmandatory notmandatory force-pushed the wallet_txdetails branch 7 times, most recently from 16452c5 to 1667496 Compare August 1, 2023 06:14
@notmandatory
Copy link
Member Author

notmandatory commented Aug 1, 2023

@LLFourn continuing #1015 (comment) here.

Are you ok with the name TotalSentReceived for the struct and total_sent_received for the function? I just don't think and in the names is as useful as total. But if you really hate it I can live with SentAndReceived/sent_and_received.

I'm now calling the TxGraph::calculate_fee function but added a friendlier Result return type and new CalculateFeeError. If you like this approach should I move it down to TxGraph?

Copy link
Contributor

@LLFourn LLFourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK. See minor comments.

crates/chain/src/spk_txout_index.rs Outdated Show resolved Hide resolved
crates/bdk/tests/wallet.rs Outdated Show resolved Hide resolved
crates/bdk/src/wallet/mod.rs Outdated Show resolved Hide resolved
crates/bdk/src/wallet/mod.rs Show resolved Hide resolved
Copy link
Contributor

@LLFourn LLFourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 1992c62

left some nits

Added
- Wallet::sent_and_received function
- Wallet::calculate_fee and Wallet::calculate_fee_rate functions
- Wallet::error::CalculateFeeError

BREAKING CHANGES:

Removed
- TransactionDetails struct

Changed
- Wallet::get_tx now returns CanonicalTx instead of TransactionDetails
- TxBuilder::finish now returns only a PartiallySignedTransaction
…alculateFeeError>

added
- tx_graph::CalculateFeeError enum

BREAKING CHANGES:

changed
- TxGraph::calculate_fee function to return Result<u64,CalculateFeeError> instead of Option<i64>
…fee functions

added
    - Wallet::insert_txout function to allow inserting foreign TxOuts
    - test to verify error when trying to calculate fee with missing foreign utxo
    - test to calculate fee with inserted foreign utxo

updated
    - docs for Wallet::calculate_fee, Wallet::calculate_fee_rate, and TxGraph::calculate_fee
      with note about missing foreign utxos
@notmandatory
Copy link
Member Author

notmandatory commented Aug 30, 2023

I've rebased, fixed docs and fixed a new MSRV issue. Just need @evanlinjin to ACK and then I'll merge, which will also fix master branch CI.

…f psbt.fee_amount()

- removed test_calculate_fee_with_inserted_foreign_utxo() since it now duplicates test in test_add_foreign_utxo()
Copy link
Member

@evanlinjin evanlinjin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 5fb5061

@evanlinjin evanlinjin merged commit 93e8eaf into bitcoindevkit:master Aug 31, 2023
12 checks passed
This was referenced Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Wallet::sent_and_received doesn't exist Kill TransactionDetails
4 participants