Skip to content

Commit

Permalink
multi: allow wallet unlocks via a passphrase token.
Browse files Browse the repository at this point in the history
This updates the grpc interceptor to accept private
passphrases set in context metadatas. When set
the private passphrase takes precedence over the
optional request passphrase field.
  • Loading branch information
dnldd committed Apr 25, 2019
1 parent f63072c commit 68e2526
Show file tree
Hide file tree
Showing 3 changed files with 211 additions and 34 deletions.
18 changes: 17 additions & 1 deletion rpc/documentation/clientusage.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,20 @@ import (
"github.com/decred/dcrd/dcrutil"
)

type Auth struct {
privPass string
}

func (auth Auth) GetRequestMetadata(ctx context.Context, in ...string) (map[string]string, error) {
return map[string]string{
"privpass": auth.privPass,
}, nil
}

func (Auth) RequireTransportSecurity() bool {
return true
}

var certificateFile = filepath.Join(dcrutil.AppDataDir("dcrwallet", false), "rpc.cert")

func main() {
Expand All @@ -68,7 +82,9 @@ func main() {
fmt.Println(err)
return
}
conn, err := grpc.Dial("localhost:19111", grpc.WithTransportCredentials(creds))
conn, err := grpc.Dial("localhost:19111",
grpc.WithTransportCredentials(creds),
grpc.WithPerRPCCredentials(Auth{privPass: "private-pass"}))
if err != nil {
fmt.Println(err)
return
Expand Down
Loading

0 comments on commit 68e2526

Please sign in to comment.