Skip to content

processTx considered harmful #260

@dcousens

Description

@dcousens

Copied from #258 for discussion.

[Is] processTx actually over complicating things more than it should?
Why do we need anything other than the unspents?
The Wallet should probably just contain all unspents, and as unspents usually have an accompanying confirmations field, we could just feed that in and put in a parameterized minimum confirmations for the following functions:

  • getBalance
  • getUnspentOutputs
  • createTransaction

There is never going to be a 'catch-all' Wallet design, so maybe we should just make this one as simple as possible?
In what scenario is processTransaction actually useful unless we start including support for non-addressable scriptPubKeys anyway (arguably could still avoid it then)?
This is basically an exact contradiction to [some of the changes I made in #258]... but I've made the issue more transparently 2-sided with [#258].
Anything more complicated than this would be context specific anyway.

My [other] gripe with processTransaction right now is the fact that if you don't process transactions in exact chronological order, then there is the real possibility for missed spends and invalid unspent outputs to occur inside the Wallet.
The only way to work around this is to ensure that all transactions are correctly chained and processed in accordance to their graph-like structure. Thankfully its acyclic at least.
[Still], it would require a lot more support code which we probably don't need to provide with bitcoinjs-lib. Therefore I vote to veto and remove processTransaction completely in 2.0.0, and completely contradict my self from #258, by saying unspents should be the only way to deal with the Wallet in future.

This kind of sucks, but I think we'll see 2.0.0 sooner than we'd like, simply because this was part of the library I just didn't have time to get around to until now (in terms of my involvement).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions