Skip to content

Commit

Permalink
Added toProtoKeyList
Browse files Browse the repository at this point in the history
  • Loading branch information
andrix10 committed Oct 7, 2020
1 parent 2630d39 commit c64c73d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion account_create_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func NewAccountCreateTransaction() *AccountCreateTransaction {
// SetKey sets the key that must sign each transfer out of the account. If RecieverSignatureRequired is true, then it
// must also sign any transfer into the account.
func (transaction *AccountCreateTransaction) SetKey(publicKey PublicKey) *AccountCreateTransaction {
transaction.pb.Key = publicKey.toProtobuf()
transaction.pb.Key = publicKey.toProtoKey()
return transaction
}

Expand Down
4 changes: 2 additions & 2 deletions crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const ed25519PrivateKeyPrefix = "302e020100300506032b657004220420"
const ed25519PubKeyPrefix = "302a300506032b6570032100"

type Key interface {
toProtobuf() *proto.Key
toProtoKey() *proto.Key
}

func publicKeyFromProto(pbKey *proto.Key) (Key, error) {
Expand Down Expand Up @@ -346,7 +346,7 @@ func (pk PublicKey) Bytes() []byte {
return pk.keyData
}

func (pk PublicKey) toProtobuf() *proto.Key {
func (pk PublicKey) toProtoKey() *proto.Key {
return &proto.Key{Key: &proto.Key_Ed25519{Ed25519: pk.keyData}}
}

Expand Down
16 changes: 14 additions & 2 deletions key_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func NewKeyList() *KeyList {
}

func (kl *KeyList) Add(key Key) *KeyList {
kl.keys = append(kl.keys, key.toProtobuf())
kl.keys = append(kl.keys, key.toProtoKey())
return kl
}

Expand All @@ -36,7 +36,7 @@ func (kl *KeyList) AddAll(keys []Key) *KeyList {
return kl
}

func (kl *KeyList) toProtobuf() *proto.Key {
func (kl *KeyList) toProtoKey() *proto.Key {
if kl.threshold >= 0 {
return &proto.Key{
Key: &proto.Key_ThresholdKey{
Expand All @@ -58,3 +58,15 @@ func (kl *KeyList) toProtobuf() *proto.Key {
}
}
}

func (kl *KeyList) toProtoKeyList() *proto.KeyList {
return &proto.KeyList{
Keys: kl.keys,
}
}

func keyListFromProto(pb *proto.KeyList) KeyList {
return KeyList{
keys: pb.Keys,
}
}

0 comments on commit c64c73d

Please sign in to comment.