lnrpc: add new ChangePassword RPC to WalletUnlocker

This commit is contained in:
Wilmer Paulino committed 2018-05-31 17:23:56 -07:00
1 parent 7cf5ebe265
commit e73b457e1f
4 files changed
+662 -483

No files matched your search

+543 -465
View File
File diff suppressed because it is too large. Load diff
+48 -18
View File
@@ -71,6 +71,19 @@ func request_WalletUnlocker_UnlockWallet_0(ctx context.Context, marshaler runtim
}
func request_WalletUnlocker_ChangePassword_0(ctx context.Context, marshaler runtime.Marshaler, client WalletUnlockerClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ChangePasswordRequest
var metadata runtime.ServerMetadata
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.ChangePassword(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func request_Lightning_WalletBalance_0(ctx context.Context, marshaler runtime.Marshaler, client LightningClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq WalletBalanceRequest
var metadata runtime.ServerMetadata
@@ -592,15 +605,7 @@ func RegisterWalletUnlockerHandlerFromEndpoint(ctx context.Context, mux *runtime
// RegisterWalletUnlockerHandler registers the http handlers for service WalletUnlocker to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterWalletUnlockerHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
return RegisterWalletUnlockerHandlerClient(ctx, mux, NewWalletUnlockerClient(conn))
}
// RegisterWalletUnlockerHandler registers the http handlers for service WalletUnlocker to "mux".
// The handlers forward requests to the grpc endpoint over the given implementation of "WalletUnlockerClient".
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "WalletUnlockerClient"
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
// "WalletUnlockerClient" to call the correct interceptors.
func RegisterWalletUnlockerHandlerClient(ctx context.Context, mux *runtime.ServeMux, client WalletUnlockerClient) error {
client := NewWalletUnlockerClient(conn)
mux.Handle("GET", pattern_WalletUnlocker_GenSeed_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
@@ -689,6 +694,35 @@ func RegisterWalletUnlockerHandlerClient(ctx context.Context, mux *runtime.Serve
})
mux.Handle("POST", pattern_WalletUnlocker_ChangePassword_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_WalletUnlocker_ChangePassword_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_WalletUnlocker_ChangePassword_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
@@ -698,6 +732,8 @@ var (
pattern_WalletUnlocker_InitWallet_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "initwallet"}, ""))
pattern_WalletUnlocker_UnlockWallet_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "unlockwallet"}, ""))
pattern_WalletUnlocker_ChangePassword_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "changepassword"}, ""))
)
var (
@@ -706,6 +742,8 @@ var (
forward_WalletUnlocker_InitWallet_0 = runtime.ForwardResponseMessage
forward_WalletUnlocker_UnlockWallet_0 = runtime.ForwardResponseMessage
forward_WalletUnlocker_ChangePassword_0 = runtime.ForwardResponseMessage
)
// RegisterLightningHandlerFromEndpoint is same as RegisterLightningHandler but
@@ -736,15 +774,7 @@ func RegisterLightningHandlerFromEndpoint(ctx context.Context, mux *runtime.Serv
// RegisterLightningHandler registers the http handlers for service Lightning to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterLightningHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
return RegisterLightningHandlerClient(ctx, mux, NewLightningClient(conn))
}
// RegisterLightningHandler registers the http handlers for service Lightning to "mux".
// The handlers forward requests to the grpc endpoint over the given implementation of "LightningClient".
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "LightningClient"
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
// "LightningClient" to call the correct interceptors.
func RegisterLightningHandlerClient(ctx context.Context, mux *runtime.ServeMux, client LightningClient) error {
client := NewLightningClient(conn)
mux.Handle("GET", pattern_Lightning_WalletBalance_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
+26
View File
@@ -75,6 +75,17 @@ service WalletUnlocker {
body: "*"
};
}
/** lncli: `changepassword`
ChangePassword changes the password of the encrypted wallet. This will
automatically unlock the wallet database if successful.
*/
rpc ChangePassword (ChangePasswordRequest) returns (ChangePasswordResponse) {
option (google.api.http) = {
post: "/v1/changepassword"
body: "*"
};
}
}
message GenSeedRequest {
@@ -159,6 +170,21 @@ message UnlockWalletRequest {
}
message UnlockWalletResponse {}
message ChangePasswordRequest {
/**
current_password should be the current valid passphrase used to unlock the
daemon.
*/
bytes current_password = 1;
/**
new_password should be the new passphrase that will be needed to unlock the
daemon.
*/
bytes new_password = 2;
}
message ChangePasswordResponse {}
service Lightning {
/** lncli: `walletbalance`
WalletBalance returns total unspent outputs(confirmed and unconfirmed), all
+45
View File
@@ -49,6 +49,33 @@
]
}
},
"/v1/changepassword": {
"post": {
"summary": "* lncli: `changepassword`\nChangePassword changes the password of the encrypted wallet. This will\nautomatically unlock the wallet database if successful.",
"operationId": "ChangePassword",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/lnrpcChangePasswordResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/lnrpcChangePasswordRequest"
}
}
],
"tags": [
"WalletUnlocker"
]
}
},
"/v1/channels": {
"get": {
"summary": "* lncli: `listchannels`\nListChannels returns a description of all the open channels that this node\nis a participant in.",
@@ -920,6 +947,24 @@
}
}
},
"lnrpcChangePasswordRequest": {
"type": "object",
"properties": {
"current_password": {
"type": "string",
"format": "byte",
"description": "*\ncurrent_password should be the current valid passphrase used to unlock the\ndaemon."
},
"new_password": {
"type": "string",
"format": "byte",
"description": "*\nnew_password should be the new passphrase that will be needed to unlock the\ndaemon."
}
}
},
"lnrpcChangePasswordResponse": {
"type": "object"
},
"lnrpcChannel": {
"type": "object",
"properties": {