aboutsummaryrefslogtreecommitdiffstats
path: root/whisper/whisperv5/api.go
diff options
context:
space:
mode:
authorgluk256 <gluk256@users.noreply.github.com>2017-04-28 17:57:15 +0800
committerFelix Lange <fjl@users.noreply.github.com>2017-04-28 17:57:15 +0800
commitf9be9a2302dd73fe3cc792167d65f24c7b7d35c4 (patch)
treef36a8c8a964f16e68b352dc0e750235aff043930 /whisper/whisperv5/api.go
parent95f0bd0acf301bf8415747c4ff050e8a4dfdc864 (diff)
downloaddexon-f9be9a2302dd73fe3cc792167d65f24c7b7d35c4.tar.gz
dexon-f9be9a2302dd73fe3cc792167d65f24c7b7d35c4.tar.zst
dexon-f9be9a2302dd73fe3cc792167d65f24c7b7d35c4.zip
whisper: switching to v5 + minor refactoring (#14387)
Diffstat (limited to 'whisper/whisperv5/api.go')
-rw-r--r--whisper/whisperv5/api.go42
1 files changed, 21 insertions, 21 deletions
diff --git a/whisper/whisperv5/api.go b/whisper/whisperv5/api.go
index 841bbc2ba..1a4e4d879 100644
--- a/whisper/whisperv5/api.go
+++ b/whisper/whisperv5/api.go
@@ -231,14 +231,14 @@ func (api *PublicWhisperAPI) Subscribe(args WhisperFilterArgs) (string, error) {
return "", errors.New("subscribe: " + err.Error())
}
- if len(args.SignedWith) > 0 {
- sb := common.FromHex(args.SignedWith)
+ if len(args.Sig) > 0 {
+ sb := common.FromHex(args.Sig)
if sb == nil {
- return "", errors.New("subscribe: SignedWith parameter is invalid")
+ return "", errors.New("subscribe: sig parameter is invalid")
}
filter.Src = crypto.ToECDSAPub(sb)
if !ValidatePublicKey(filter.Src) {
- return "", errors.New("subscribe: invalid 'SignedWith' field")
+ return "", errors.New("subscribe: invalid 'sig' field")
}
}
@@ -319,8 +319,8 @@ func (api *PublicWhisperAPI) Post(args PostArgs) error {
return errors.New("post: key is missing")
}
- if len(args.SignWith) > 0 {
- params.Src, err = api.whisper.GetPrivateKey(args.SignWith)
+ if len(args.Sig) > 0 {
+ params.Src, err = api.whisper.GetPrivateKey(args.Sig)
if err != nil {
return err
}
@@ -391,7 +391,7 @@ func (api *PublicWhisperAPI) Post(args PostArgs) error {
type PostArgs struct {
Type string `json:"type"` // "sym"/"asym" (symmetric or asymmetric)
TTL uint32 `json:"ttl"` // time-to-live in seconds
- SignWith string `json:"signWith"` // id of the signing key
+ Sig string `json:"sig"` // id of the signing key
Key string `json:"key"` // key id (in case of sym) or public key (in case of asym)
Topic hexutil.Bytes `json:"topic"` // topic (4 bytes)
Padding hexutil.Bytes `json:"padding"` // optional padding bytes
@@ -402,12 +402,12 @@ type PostArgs struct {
}
type WhisperFilterArgs struct {
- Symmetric bool // encryption type
- Key string // id of the key to be used for decryption
- SignedWith string // public key of the sender to be verified
- MinPoW float64 // minimal PoW requirement
- Topics [][]byte // list of topics (up to 4 bytes each) to match
- AllowP2P bool // indicates wheather direct p2p messages are allowed for this filter
+ Symmetric bool // encryption type
+ Key string // id of the key to be used for decryption
+ Sig string // public key of the sender to be verified
+ MinPoW float64 // minimal PoW requirement
+ Topics [][]byte // list of topics (up to 4 bytes each) to match
+ AllowP2P bool // indicates wheather direct p2p messages are allowed for this filter
}
// UnmarshalJSON implements the json.Unmarshaler interface, invoked to convert a
@@ -415,12 +415,12 @@ type WhisperFilterArgs struct {
func (args *WhisperFilterArgs) UnmarshalJSON(b []byte) (err error) {
// Unmarshal the JSON message and sanity check
var obj struct {
- Type string `json:"type"`
- Key string `json:"key"`
- SignedWith string `json:"signedWith"`
- MinPoW float64 `json:"minPoW"`
- Topics []interface{} `json:"topics"`
- AllowP2P bool `json:"allowP2P"`
+ Type string `json:"type"`
+ Key string `json:"key"`
+ Sig string `json:"sig"`
+ MinPoW float64 `json:"minPoW"`
+ Topics []interface{} `json:"topics"`
+ AllowP2P bool `json:"allowP2P"`
}
if err := json.Unmarshal(b, &obj); err != nil {
return err
@@ -436,7 +436,7 @@ func (args *WhisperFilterArgs) UnmarshalJSON(b []byte) (err error) {
}
args.Key = obj.Key
- args.SignedWith = obj.SignedWith
+ args.Sig = obj.Sig
args.MinPoW = obj.MinPoW
args.AllowP2P = obj.AllowP2P
@@ -472,7 +472,7 @@ type WhisperMessage struct {
Topic string `json:"topic"`
Payload string `json:"payload"`
Padding string `json:"padding"`
- Src string `json:"signedWith"`
+ Src string `json:"sig"`
Dst string `json:"recipientPublicKey"`
Timestamp uint32 `json:"timestamp"`
TTL uint32 `json:"ttl"`