-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Migrates Address to stricter API #140
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
Conversation
|
I'm still not sure where the responsibility should lie for an Fixes #126 and conforms to #113 and #106 . edit: accidentally closed the PR, re-opened |
|
+1 |
|
Rebased on HEAD and added more meaningful error messages if the assertions fail. |
|
@dcousens Can you rebase this one on top of current master? It'll be easier to review :) |
|
Rebased on HEAD. |
src/message.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. But address string is reasonable as an argument here. What about if(typeof address === 'string')?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to if(typeof address === 'string')? as it is more strict of what we are actually allowing as the alternative.
Now (horrendously) supports other networks
Migrates Address to stricter API
Depends on #139.
This pull request simplifies the
Addressmodule so that it conforms to a highly strict subset of its original functionality.It is primarily a wrapper for a
pubKeyHashorscriptHash; and is limited to that subset.The following builder functions are supported:
Address.fromBase58Check, andAddress.fromPubKeyWith the standard
Address.prototype.toBase58Checkbeing aliased byAddress.prototype.toString.This pull request introduces a slight circular dependency with
ECPubKey, however the intent is to eventually removeECKey.getAddressto resolve this.Script.createOutputScripthad to be modified for these changes to proceed, mostly due to its inability to support non-standard network versions.The fix implemented for this is not very pretty, but it is a functioning replacement (no extra tests for this have been provided beyond the bitcoin network however, I do intend to do that when I refactor
Transaction).Test fixtures for
Addresshave also been added intest/fixtures/address.Unlike in other pull requests, I did not make an effort to first check compatibility with the original test vectors for this pull request, and instead migrated to the new test vectors immediately.
This was done because the new API was not immediately compatible with the old, and would have required all new tests anyway.
If requested, I can import the old test vectors for testing with the current test setup, however the current vectors should be more than suitable (verify if unsure).