many fixes and some logs.

This commit is contained in:
fiatjaf
2021-02-07 07:56:55 -03:00
parent 32c21eb652
commit b4481918fe
2 changed files with 53 additions and 38 deletions
+7 -5
View File
@@ -13,10 +13,11 @@ import (
)
const (
KindSetMetadata uint8 = 0
KindTextNote uint8 = 1
KindRecommendServer uint8 = 2
KindContactList uint8 = 3
KindSetMetadata uint8 = 0
KindTextNote uint8 = 1
KindRecommendServer uint8 = 2
KindContactList uint8 = 3
KindEncryptedDirectMessage uint8 = 4
)
type Event struct {
@@ -130,7 +131,7 @@ func (evt Event) CheckSignature() (bool, error) {
}
// Sign signs an event with a given privateKey
func (evt Event) Sign(privateKey string) error {
func (evt *Event) Sign(privateKey string) error {
h := sha256.Sum256(evt.Serialize())
s, _ := new(big.Int).SetString(privateKey, 16)
@@ -145,6 +146,7 @@ func (evt Event) Sign(privateKey string) error {
return err
}
evt.ID = hex.EncodeToString(h[:])
evt.Sig = hex.EncodeToString(sig[:])
return nil
}