From 365d23f0e273850c3df2fb1f53192fb110225433 Mon Sep 17 00:00:00 2001 From: Niko Storni Date: Fri, 10 Jun 2022 18:18:08 +0200 Subject: [PATCH] add support for deterministic pub keys fix a couple of bugs --- extras/jsonrpc/daemon_types.go | 6 ++---- schema/keys/keys.go | 5 ++++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/extras/jsonrpc/daemon_types.go b/extras/jsonrpc/daemon_types.go index c135991..9628d8c 100644 --- a/extras/jsonrpc/daemon_types.go +++ b/extras/jsonrpc/daemon_types.go @@ -49,11 +49,10 @@ type File struct { Height int `json:"height"` IsFullyReflected bool `json:"is_fully_reflected"` Key string `json:"key"` - Metadata *lbryschema.Claim `json:"protobuf"` + Value *lbryschema.Claim `json:"protobuf"` MimeType string `json:"mime_type"` Nout int `json:"nout"` Outpoint string `json:"outpoint"` - Protobuf string `json:"protobuf"` PurchaseReceipt interface{} `json:"purchase_receipt"` ReflectorProgress int `json:"reflector_progress"` SdHash string `json:"sd_hash"` @@ -253,10 +252,9 @@ type Transaction struct { PermanentUrl string `json:"permanent_url"` SigningChannel *Claim `json:"signing_channel,omitempty"` TimeStamp uint64 `json:"time_stamp"` - Protobuf string `json:"protobuf,omitempty"` Txid string `json:"txid"` Type string `json:"type"` - Value *lbryschema.Claim `json:"protobuf"` + Value *lbryschema.Claim `json:"protobuf,omitempty"` } type TransactionSummary struct { diff --git a/schema/keys/keys.go b/schema/keys/keys.go index 1c86ed2..d00cf92 100644 --- a/schema/keys/keys.go +++ b/schema/keys/keys.go @@ -62,12 +62,15 @@ func PrivateKeyToDER(key *btcec.PrivateKey) ([]byte, error) { } func GetPublicKeyFromBytes(pubKeyBytes []byte) (*btcec.PublicKey, error) { + if len(pubKeyBytes) == 33 { + return btcec.ParsePubKey(pubKeyBytes, btcec.S256()) + } PKInfo := publicKeyInfo{} _, err := asn1.Unmarshal(pubKeyBytes, &PKInfo) if err != nil { return nil, errors.Err(err) } - pubkeyBytes1 := []byte(PKInfo.PublicKey.Bytes) + pubkeyBytes1 := PKInfo.PublicKey.Bytes return btcec.ParsePubKey(pubkeyBytes1, btcec.S256()) }