func TestCreateAccount(t *testing.T) {
m := mockAccountManager(t)
- xpubs := []vcrypto.XPubKeyer{testutil.TestXPub}
- account, err := m.Create(xpubs, 1, "test-alias", signers.BIP0044)
+ // xpubs := []vcrypto.XPubKeyer{testutil.TestXPub}
+ xpubers := make([]vcrypto.XPubKeyer, 1)
+ xpubers[0] = testutil.TestXPub
+ account, err := m.Create(xpubers, 1, "test-alias", signers.BIP0044)
if err != nil {
testutil.FatalErr(t, err)
}
- fmt.Println("account is:", account, "account xpub:", account.XPubs)
+ fmt.Println("TestCreateAccount account is:", account, "account xpub:", account.XPubs, "type of xpubs:", reflect.TypeOf(account.XPubs[0]))
found, err := m.FindByID(account.ID)
if err != nil {
t.Errorf("unexpected error %v", err)
}
- fmt.Println("found is:", found, "found xpub:", found.XPubs)
+ fmt.Println("TestCreateAccount found is:", found, "found xpub:", found.XPubs, "type of xpubs:", reflect.TypeOf(found.XPubs[0]))
if !testutil.DeepEqual(account, found) {
t.Errorf("expected account %v to be recorded as %v", account, found)
//////////
return hex.EncodeToString(xprv.Bytes())
}
-func NewXPub(str string) (xpub *XPub, err error) {
- if len(str) != 2*extendedPublicKeySize {
+func NewXPub(str string) (*XPub, error) {
+ xpub := new(XPub)
+ if len(str) != 2*64 {
fmt.Println("str length is:", len(str))
fmt.Println("str is:", str)
return nil, errors.New("string length is invalid.")
if xpubBytes, err := hex.DecodeString(str); err != nil {
return nil, err
} else {
+
+ fmt.Println("NewXPub xpub is:", xpub)
+ fmt.Println("NewXPub xpubBytes is:", xpubBytes)
copy(xpub[:], xpubBytes[:])
}
-
return xpub, nil
}