mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-22 14:22:37 +01:00
rpc: remove NewWitnessAddress RPC
In this commit, we remove the unnecessary NewWitnessAddress RPC. We do this as, at the moment, we only expose the wallet to generate witness addresses. Now that the RPC has been removed, its REST endpoint has been assigned to the NewAddress RPC, which should be the de facto way of having the wallet generate any type of supported address. Fixes #1986.
This commit is contained in:
parent
b341dea373
commit
bdcc847a44
6 changed files with 526 additions and 585 deletions
|
@ -37,10 +37,8 @@ description):
|
|||
(many outputs).
|
||||
* NewAddress
|
||||
* Returns a new address, the following address types are supported:
|
||||
pay-to-public-key-hash (p2pkh), pay-to-witness-key-hash (p2wkh), and
|
||||
nested-pay-to-witness-key-hash (np2wkh).
|
||||
* NewWitnessAddress
|
||||
* Returns a new witness address (np2wkh) under control of the local wallet.
|
||||
pay-to-witness-key-hash (p2wkh) and nested-pay-to-witness-key-hash
|
||||
(np2wkh).
|
||||
* SignMessage
|
||||
* Signs a message with the node's identity key and returns a
|
||||
zbase32 encoded signature.
|
||||
|
|
1031
lnrpc/rpc.pb.go
1031
lnrpc/rpc.pb.go
File diff suppressed because it is too large
Load diff
|
@ -124,11 +124,19 @@ func request_Lightning_SendCoins_0(ctx context.Context, marshaler runtime.Marsha
|
|||
|
||||
}
|
||||
|
||||
func request_Lightning_NewWitnessAddress_0(ctx context.Context, marshaler runtime.Marshaler, client LightningClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq NewWitnessAddressRequest
|
||||
var (
|
||||
filter_Lightning_NewAddress_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
||||
)
|
||||
|
||||
func request_Lightning_NewAddress_0(ctx context.Context, marshaler runtime.Marshaler, client LightningClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq NewAddressRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
msg, err := client.NewWitnessAddress(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_Lightning_NewAddress_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.NewAddress(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
@ -976,7 +984,7 @@ func RegisterLightningHandler(ctx context.Context, mux *runtime.ServeMux, conn *
|
|||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Lightning_NewWitnessAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
mux.Handle("GET", pattern_Lightning_NewAddress_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 {
|
||||
|
@ -994,14 +1002,14 @@ func RegisterLightningHandler(ctx context.Context, mux *runtime.ServeMux, conn *
|
|||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Lightning_NewWitnessAddress_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
resp, md, err := request_Lightning_NewAddress_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Lightning_NewWitnessAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
forward_Lightning_NewAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
|
@ -1800,7 +1808,7 @@ var (
|
|||
|
||||
pattern_Lightning_SendCoins_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "transactions"}, ""))
|
||||
|
||||
pattern_Lightning_NewWitnessAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "newaddress"}, ""))
|
||||
pattern_Lightning_NewAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "newaddress"}, ""))
|
||||
|
||||
pattern_Lightning_ConnectPeer_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "peers"}, ""))
|
||||
|
||||
|
@ -1866,7 +1874,7 @@ var (
|
|||
|
||||
forward_Lightning_SendCoins_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Lightning_NewWitnessAddress_0 = runtime.ForwardResponseMessage
|
||||
forward_Lightning_NewAddress_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Lightning_ConnectPeer_0 = runtime.ForwardResponseMessage
|
||||
|
||||
|
|
|
@ -249,12 +249,7 @@ service Lightning {
|
|||
/** lncli: `newaddress`
|
||||
NewAddress creates a new address under control of the local wallet.
|
||||
*/
|
||||
rpc NewAddress (NewAddressRequest) returns (NewAddressResponse);
|
||||
|
||||
/**
|
||||
NewWitnessAddress creates a new witness address under control of the local wallet.
|
||||
*/
|
||||
rpc NewWitnessAddress (NewWitnessAddressRequest) returns (NewAddressResponse) {
|
||||
rpc NewAddress (NewAddressRequest) returns (NewAddressResponse) {
|
||||
option (google.api.http) = {
|
||||
get: "/v1/newaddress"
|
||||
};
|
||||
|
@ -807,7 +802,6 @@ message SendCoinsResponse {
|
|||
|
||||
- `p2wkh`: Pay to witness key hash (`WITNESS_PUBKEY_HASH` = 0)
|
||||
- `np2wkh`: Pay to nested witness key hash (`NESTED_PUBKEY_HASH` = 1)
|
||||
- `p2pkh`: Pay to public key hash (`PUBKEY_HASH` = 2)
|
||||
*/
|
||||
message NewAddressRequest {
|
||||
enum AddressType {
|
||||
|
@ -818,10 +812,6 @@ message NewAddressRequest {
|
|||
/// The address type
|
||||
AddressType type = 1;
|
||||
}
|
||||
|
||||
message NewWitnessAddressRequest {
|
||||
}
|
||||
|
||||
message NewAddressResponse {
|
||||
/// The newly generated wallet address
|
||||
string address = 1 [json_name = "address"];
|
||||
|
|
|
@ -732,8 +732,8 @@
|
|||
},
|
||||
"/v1/newaddress": {
|
||||
"get": {
|
||||
"summary": "*\nNewWitnessAddress creates a new witness address under control of the local wallet.",
|
||||
"operationId": "NewWitnessAddress",
|
||||
"summary": "* lncli: `newaddress`\nNewAddress creates a new address under control of the local wallet.",
|
||||
"operationId": "NewAddress",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "",
|
||||
|
@ -742,6 +742,20 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "type",
|
||||
"description": "/ The address type.",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"WITNESS_PUBKEY_HASH",
|
||||
"NESTED_PUBKEY_HASH"
|
||||
],
|
||||
"default": "WITNESS_PUBKEY_HASH"
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"Lightning"
|
||||
]
|
||||
|
|
20
rpcserver.go
20
rpcserver.go
|
@ -160,10 +160,6 @@ var (
|
|||
Entity: "address",
|
||||
Action: "write",
|
||||
}},
|
||||
"/lnrpc.Lightning/NewWitnessAddress": {{
|
||||
Entity: "address",
|
||||
Action: "write",
|
||||
}},
|
||||
"/lnrpc.Lightning/SignMessage": {{
|
||||
Entity: "message",
|
||||
Action: "write",
|
||||
|
@ -538,22 +534,6 @@ func (r *rpcServer) NewAddress(ctx context.Context,
|
|||
return &lnrpc.NewAddressResponse{Address: addr.String()}, nil
|
||||
}
|
||||
|
||||
// NewWitnessAddress returns a new native witness address under the control of
|
||||
// the local wallet.
|
||||
func (r *rpcServer) NewWitnessAddress(ctx context.Context,
|
||||
in *lnrpc.NewWitnessAddressRequest) (*lnrpc.NewAddressResponse, error) {
|
||||
|
||||
addr, err := r.server.cc.wallet.NewAddress(
|
||||
lnwallet.NestedWitnessPubKey, false,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rpcsLog.Infof("[newaddress] addr=%v", addr.String())
|
||||
return &lnrpc.NewAddressResponse{Address: addr.String()}, nil
|
||||
}
|
||||
|
||||
var (
|
||||
// signedMsgPrefix is a special prefix that we'll prepend to any
|
||||
// messages we sign/verify. We do this to ensure that we don't
|
||||
|
|
Loading…
Add table
Reference in a new issue