Skip to content

Conversation

@anton-java
Copy link

No description provided.

@@ -1 +1,2 @@
.idea No newline at end of file
.idea
encypted-private-keys No newline at end of file
Copy link
Author

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

@glossd glossd self-requested a review May 15, 2023 08:03
compress := false
format := wallet.GetFormat(compress)
net := netchain.TestNet
wif, address, privateKey := wallet.New(net, compress)
Copy link
Owner

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) {
Copy link
Owner

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 {
Copy link
Owner

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)
Copy link
Owner

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) {
Copy link
Owner

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 {
Copy link
Owner

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:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants