-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlninter.go
More file actions
50 lines (41 loc) · 1.09 KB
/
lninter.go
File metadata and controls
50 lines (41 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package clip
import (
"context"
"fmt"
"os"
)
type LnInteractive struct {
pubKey string
network string
}
func NewLnInteractive(network string, pubKey string) *LnInteractive {
return &LnInteractive{
pubKey: pubKey,
network: network,
}
}
func (l *LnInteractive) Close() error {
return nil
}
func (l *LnInteractive) GetAlias(ctx context.Context, pubkey string) (string, error) {
return "", nil
}
func (l *LnInteractive) GetNodeInfo(_ context.Context) (NodeInfoResponse, error) {
return NodeInfoResponse{
PubKey: l.pubKey,
Network: l.network,
}, nil
}
func (l *LnInteractive) SignMessage(_ context.Context, msg []byte) (string, error) {
// Printing the message to be signed to stdout and reading the signature from stdin.
stringMsg := string(msg)
fmt.Fprintf(os.Stderr, "\nPlease sign the following message with your Lightning node:\n%s\n\nEnter the signature here: ", stringMsg)
var sig string
_, err := fmt.Scanln(&sig)
if err != nil {
return "", fmt.Errorf("reading signature from stdin: %w", err)
}
fmt.Printf("\n")
return sig, nil
}
var _ LightningNode = (*LnInteractive)(nil)