Skip to content

Commit

Permalink
Added more test cases, minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mrz1836 committed Feb 3, 2022
1 parent 65a9cc1 commit 10c1b94
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
4 changes: 4 additions & 0 deletions address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ func TestGetAddressFromPrivateKeyCompression(t *testing.T) {
assert.NoError(t, err)

assert.NotEqual(t, addressCompressed, addressUncompressed)

addressCompressed, err = GetAddressFromPrivateKey(&bec.PrivateKey{}, true)
assert.Error(t, err)
assert.Equal(t, "", addressCompressed)
}

// ExampleGetAddressFromPrivateKey example using GetAddressFromPrivateKey()
Expand Down
8 changes: 4 additions & 4 deletions hd_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const (
DefaultInternalChain = 1
)

// GenerateHDKey will create a new master node for use in creating a hierarchical deterministic key chain
// GenerateHDKey will create a new master node for use in creating a hierarchical deterministic keychain
func GenerateHDKey(seedLength uint8) (hdKey *bip32.ExtendedKey, err error) {

// Missing or invalid seed length
Expand All @@ -44,7 +44,7 @@ func GenerateHDKey(seedLength uint8) (hdKey *bip32.ExtendedKey, err error) {
}

// GenerateHDKeyFromString will create a new master node for use in creating a
// hierarchical deterministic key chain from an xPrivKey string
// hierarchical deterministic keychain from an xPrivKey string
func GenerateHDKeyFromString(xPriv string) (hdKey *bip32.ExtendedKey, err error) {
return bip32.NewKeyFromString(xPriv)
}
Expand Down Expand Up @@ -164,7 +164,7 @@ func GetPublicKeysForPath(hdKey *bip32.ExtendedKey, num uint32) (pubKeys []*bec.
return
}

// Get the external pubkey from m/0/x
// Get the external pubKey from m/0/x
var pubKey *bec.PublicKey
if pubKey, err = childM0x.ECPubKey(); err != nil {
// Should never error since the previous method ensures a valid hdKey
Expand All @@ -179,7 +179,7 @@ func GetPublicKeysForPath(hdKey *bip32.ExtendedKey, num uint32) (pubKeys []*bec.
return
}

// Get the internal pubkey from m/1/x
// Get the internal pubKey from m/1/x
if pubKey, err = childM1x.ECPubKey(); err != nil {
// Should never error since the previous method ensures a valid hdKey
return
Expand Down
2 changes: 1 addition & 1 deletion hd_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ func TestGetHDKeyChild(t *testing.T) {
expectedNil bool
expectedError bool
}{
//{nil, 0, true, true},
// {nil, 0, true, true},
{validKey, 0, false, false},
{validKey, 10, false, false},
{validKey, 100, false, false},
Expand Down
1 change: 1 addition & 0 deletions transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ func CreateTx(utxos []*Utxo, addresses []*PayToAddress,
// Sign the transaction
if privateKey != nil {
myAccount := &account{PrivateKey: privateKey}
// todo: support context (ctx)
if err = tx.FillAllInputs(context.Background(), myAccount); err != nil {
return nil, err
}
Expand Down

0 comments on commit 10c1b94

Please sign in to comment.