-
Notifications
You must be signed in to change notification settings - Fork 1
Add support for compressed WIF and Bitcoin adsress #1
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
base: master
Are you sure you want to change the base?
Conversation
| @@ -1 +1,2 @@ | |||
| .idea No newline at end of file | |||
| .idea | |||
| encypted-private-keys No newline at end of file | |||
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.
Add encypted-private-keys to .gitignore
| compress := false | ||
| format := wallet.GetFormat(compress) | ||
| net := netchain.TestNet | ||
| wif, address, privateKey := wallet.New(net, compress) |
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.
You broke backward compatibility here, now my repos wallet.New won't compile. Can you create a new function wallet.NewWIF?
| return wif.String(), addr.EncodeAddress(), hex.EncodeToString(priv.Serialize()) | ||
| } | ||
|
|
||
| func GetWallet(hexPriv string, net netchain.Net, compress bool) (wifString string, bitcoinAddress 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.
It's basically converting privateKey to wif format comppresed/ uncompressed?
|
|
||
| func NewAddress(net netchain.Net) string { | ||
| _, address := New(net) | ||
| func GetBitcoinAddress(priv *btcec.PrivateKey, net netchain.Net, compress bool) *btcutil.AddressPubKey { |
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.
I don't want to expose an object from internal library, that one day I might replace. Again it's me worrying for backward compatibility in the future
| ) | ||
|
|
||
| func TestAddressFromPrivateKey(t *testing.T) { | ||
| address, err := AddressFromPrivateKey("932u6Q4xEC9UYRb3rS2BWrSpSPEt5KaU8NNP7EWy7zSkWmfBiGe", netchain.TestNet) |
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.
Keep the test unchanged, that will ensure backward compatibility:)
| "github.com/glossd/btc/netchain" | ||
| ) | ||
|
|
||
| func AddressFromPrivateKey(privKey string, net netchain.Net) (string, error) { |
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.
Yeah, we need to keep the function, just proxy it to AddressFromWif(privKey, net, false)
| return err == nil | ||
| } | ||
|
|
||
| func GetFormat(compress bool) 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.
It's a bit redundant:)
No description provided.