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

Add transactions method on wallet #432

Merged
merged 1 commit into from
Dec 15, 2023

Conversation

reez
Copy link
Collaborator

@reez reez commented Dec 7, 2023

Description

Adds transactions method on Wallet.

Notes to the reviewers

Simplified return type to list of Transactions.

Changelog notice

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

Bugfixes:

  • This pull request breaks the existing API
  • I've added tests to reproduce the issue which are now passing
  • I'm linking the issue being fixed by this PR

@reez reez force-pushed the 1048-transactions branch 3 times, most recently from f5f38dc to 9c9010d Compare December 7, 2023 20:04
@reez reez marked this pull request as ready for review December 7, 2023 20:29
@reez reez changed the title feat: add transactions method on wallet Add transactions method on wallet Dec 7, 2023
@reez reez self-assigned this Dec 7, 2023
Copy link
Member

@thunderbiscuit thunderbiscuit left a comment

Choose a reason for hiding this comment

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

I think this works in practice, but I have 2 questions about the theory I'm still wondering about:

  1. The API doc for the method is one line: Iterate over the transactions in the wallet.. I wonder if (a) this is meant to be used for more than just returning the transactions, and (b) only returns transactions "owned" by the wallet. For example I see that it's basically traversing the TxGraph... but if I understand correctly you can add any transactions to this TxGraph (?)
  2. The type of CanonicalTx.TxNode.tx is &'a T, which I don't understand well. Will you always be able to get a Transaction type out of it when you apply the .into() method on it?

@reez reez force-pushed the 1048-transactions branch 2 times, most recently from 6ab8eea to 27c10a7 Compare December 12, 2023 20:05
@reez
Copy link
Collaborator Author

reez commented Dec 12, 2023

Great Q’s/Feedback Thunder! I think I caught some of the conversation about this on the dev call this morning, and I think(?) what I heard as the conclusion is that we are leaving this transactions function as is but are just making sure we expose isMine to the users at some point so they can filter based on isMine.

If that is all correct than is it cool to add isMine in a follow up PR?

If my understanding is incorrect I can update to whatever is needed, happy to do whatever needed, and I enjoyed the conversation and questions around this PR so far.

@thunderbiscuit
Copy link
Member

thunderbiscuit commented Dec 14, 2023

Yeah roughly my take on it is that isMine is implied in the the transaction method at the moment. We can add isMine and tell people to filter, but that feels like a weird API, in part because not all users will get the message that they in fact need to do both, and also because we don't actually offer any methods (at the moment at least) to add anything to your TxGraph, so at the moment the isMine filter would be redundant.

My current take on it is this (happy to hear your thoughts): we should add the isMine filter to the method directly. This ensures the method is explicit in returning only wallet-related txs (even thought that's really all it can return at the moment). We open an issue on the bdk repo to discuss this weird API and see what might have been the thinking behind it. One good option proposed by @notmandatory was to add an argument onlyMine to the method (at the rust layer) or something like that, to make it explicit that the method can return much more than that if that flag is not set.

Edit: I forgot to write it initially but the problem with this of course is that we're transforming the API, and so far we've been trying to keep them in very close sync; this would be a departure from that, so should be thought through seriously. We'll also see what comes out of the discussion in #1239

@thunderbiscuit
Copy link
Member

I'm changing my mind on this. I think we should expose the API as is on the Rust side, and open issues/fix it upstream if there are things to improve. For now, exposing it as is is the better/cleaner way. We also don't offer ways to impact the TxGraph manually at this point on the ffi side, so the problems that this could cause are limited.

Copy link
Member

@thunderbiscuit thunderbiscuit left a comment

Choose a reason for hiding this comment

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

Just a small nit. This is ready to go afterwards IMO. I tested locally.

bdk-python/tests/test_live_wallet.py Outdated Show resolved Hide resolved
@reez
Copy link
Collaborator Author

reez commented Dec 15, 2023

@thunderbiscuit PR is updated now per suggestions and tests pass, thanks!

Copy link
Member

@thunderbiscuit thunderbiscuit left a comment

Choose a reason for hiding this comment

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

ACK a1a4599.

@thunderbiscuit thunderbiscuit merged commit a1a4599 into bitcoindevkit:master Dec 15, 2023
17 checks passed
@reez reez deleted the 1048-transactions branch December 15, 2023 18:23
@reez reez mentioned this pull request Apr 7, 2024
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants