add support for deterministic pub keys

fix a couple of bugs
This commit is contained in:
Niko Storni 2022-06-10 18:18:08 +02:00
parent e5ab0f883e
commit 365d23f0e2
2 changed files with 6 additions and 5 deletions

View file

@ -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 {

View file

@ -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())
}