mirror of
https://github.com/go-i2p/goSam.git
synced 2025-07-13 06:07:42 -04:00
make a version which stringifies i2pkeys
This commit is contained in:
13
i2pkeys.go
13
i2pkeys.go
@ -2,17 +2,14 @@ package goSam
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/eyedeekay/sam3/i2pkeys"
|
||||
)
|
||||
|
||||
// NewDestination generates a new I2P destination, creating the underlying
|
||||
// public/private keys in the process. The public key can be used to send messages
|
||||
// to the destination, while the private key can be used to reply to messages
|
||||
func (c *Client) NewDestination(sigType ...string) (i2pkeys.I2PKeys, error) {
|
||||
func (c *Client) NewDestination(sigType ...string) (string, error) {
|
||||
var (
|
||||
sigtmp string
|
||||
keys i2pkeys.I2PKeys
|
||||
)
|
||||
if len(sigType) > 0 {
|
||||
sigtmp = sigType[0]
|
||||
@ -22,14 +19,14 @@ func (c *Client) NewDestination(sigType ...string) (i2pkeys.I2PKeys, error) {
|
||||
sigtmp,
|
||||
)
|
||||
if err != nil {
|
||||
return keys, err
|
||||
return "", err
|
||||
}
|
||||
var pub, priv string
|
||||
if priv = r.Pairs["PRIV"]; priv == "" {
|
||||
return keys, errors.New("failed to generate private destination key")
|
||||
return "", errors.New("failed to generate private destination key")
|
||||
}
|
||||
if pub = r.Pairs["PUB"]; pub == "" {
|
||||
return keys, errors.New("failed to generate public destination key")
|
||||
return priv, errors.New("failed to generate public destination key")
|
||||
}
|
||||
return i2pkeys.NewKeys(i2pkeys.I2PAddr(pub), priv), nil
|
||||
return priv + pub, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user