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

get rid of TransactionInput/TransactionOutput.parent #2998

Open
schildbach opened this issue Apr 8, 2023 · 1 comment
Open

get rid of TransactionInput/TransactionOutput.parent #2998

schildbach opened this issue Apr 8, 2023 · 1 comment
Labels
Developer discussion discussion between developers about a specific topic

Comments

@schildbach
Copy link
Member

schildbach commented Apr 8, 2023

Problems with the parent fields, and their getParentTransaction() accessors:

  • They pull information about how/where Input/Output are used into Input/Output themselves, and with it quite some business logic that depends on it.
  • We can't make Input/Ouput and Transaction entirely immutable as long as the parents exist, because of the circular reference.
  • It makes a number of methods more difficult to use than it should be, because a parent tx need to be supplied.
  • Unit Tests that only deal with inputs or outputs need to make up a fake parent transaction.

To get rid of the parents, I think we must:

  • Find better places for any business logic that involves using the parent. I expect in most, if not all, cases this would be Transaction.
  • TransactionOutput will then only be a touple of value and script – both pretty arbitrary and certainly not enough to identify a particular output. This means:
  • All places in the business logic that currently use TransactionOutput to identify an output would need to use TransactionOutPoint, which is exactly meant for this. This involves e.g. CoinSelector , CoinSelection, Wallet.unspents.
@schildbach schildbach added the Developer discussion discussion between developers about a specific topic label Apr 8, 2023
@schildbach schildbach changed the title get rid of TransactionInput/TransactionOutput..parent get rid of TransactionInput/TransactionOutput.parent Apr 8, 2023
@msgilligan
Copy link
Member

msgilligan commented Apr 8, 2023

This is a good start for thinking about this. I will sleep on it.

One thought: maybe we are approaching this "bermuda triangle" from the wrong direction. We've been trying to work up from outpoints, outputs, and inputs eventually getting to transaction. Maybe we should look at the transaction use cases and the "types" of transaction objects and work down to see which "types" of outpoints, outputs, and inputs they need?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Developer discussion discussion between developers about a specific topic
Projects
None yet
Development

No branches or pull requests

2 participants