-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Wallet clean #258
Wallet clean #258
Conversation
edit: See further comments. |
This does repeat the O(n) lookup several times, but that can be fixed by using an O(1) lookup instead (and will be later). Clarity first.
The RegExp for the UTXO validation was removed as the errors are now more verbose and specific to each case.
also, move processTx out of Wallet scope
also, move the assert to the end to simplify the logic
Clean up Wallet constructor function
@weilu what are your thoughts on Why do we need anything other than the unspents? The
There is never going to be a 'catch-all' In what scenario is edit: This is basically an exact contradiction to what I just mentioned above, but arguably I've made the issue more transparently 2-sided with this PR. So I guess my question is, can we see ourselves wanting to support a more complicated Arguably anything more complicated would be context specific anyway. |
My biggest gripe with 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. But still, it would require a lot more support code which we probably don't need to provide with |
This pull request attempts to clean the
Wallet
class so as to adhere to practices used throughout the rest of the repository.It deprecates the following methods:
newMasterKey
--- considered harmful, and there is no reason not to just usenew Wallet(...)
instead, which is explicit and less ambiguous about what may happen.setUnspentOutputs
--- this should only ever be done on initialization, and therefore has been included as an optional argument to the constructor. All other UTXO handling is done throughprocessTx
.It also moves as many of the closure scoped methods to the prototype as possible without modifying/increasing the API.
As a side note, the testing infrastructure really needs to become data driven, at the moment it was simpler to use
testnet
more often as the test data was more readily available.