mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 01:43:16 +01:00
lnrpc+rpcserver: return meaningful responses instead of empty
This commit is contained in:
parent
d8c920fa7a
commit
45e13cead1
File diff suppressed because it is too large
Load Diff
@ -643,6 +643,8 @@ message SendCustomMessageRequest {
|
||||
}
|
||||
|
||||
message SendCustomMessageResponse {
|
||||
// The status of the send operation.
|
||||
string status = 1;
|
||||
}
|
||||
|
||||
message Utxo {
|
||||
@ -1317,6 +1319,8 @@ message ConnectPeerRequest {
|
||||
uint64 timeout = 3;
|
||||
}
|
||||
message ConnectPeerResponse {
|
||||
// The status of the connect operation.
|
||||
string status = 1;
|
||||
}
|
||||
|
||||
message DisconnectPeerRequest {
|
||||
@ -1324,6 +1328,8 @@ message DisconnectPeerRequest {
|
||||
string pub_key = 1;
|
||||
}
|
||||
message DisconnectPeerResponse {
|
||||
// The status of the disconnect operation.
|
||||
string status = 1;
|
||||
}
|
||||
|
||||
message HTLC {
|
||||
@ -3542,6 +3548,8 @@ message NetworkInfo {
|
||||
message StopRequest {
|
||||
}
|
||||
message StopResponse {
|
||||
// The status of the stop operation.
|
||||
string status = 1;
|
||||
}
|
||||
|
||||
message GraphTopologySubscription {
|
||||
@ -4366,9 +4374,13 @@ message DeleteAllPaymentsRequest {
|
||||
}
|
||||
|
||||
message DeletePaymentResponse {
|
||||
// The status of the delete operation.
|
||||
string status = 1;
|
||||
}
|
||||
|
||||
message DeleteAllPaymentsResponse {
|
||||
// The status of the delete operation.
|
||||
string status = 1;
|
||||
}
|
||||
|
||||
message AbandonChannelRequest {
|
||||
@ -4385,6 +4397,8 @@ message AbandonChannelRequest {
|
||||
}
|
||||
|
||||
message AbandonChannelResponse {
|
||||
// The status of the abandon operation.
|
||||
string status = 1;
|
||||
}
|
||||
|
||||
message DebugLevelRequest {
|
||||
@ -4724,12 +4738,15 @@ message RestoreChanBackupRequest {
|
||||
}
|
||||
}
|
||||
message RestoreBackupResponse {
|
||||
// The number of channels successfully restored.
|
||||
uint32 num_restored = 1;
|
||||
}
|
||||
|
||||
message ChannelBackupSubscription {
|
||||
}
|
||||
|
||||
message VerifyChanBackupResponse {
|
||||
repeated string chan_points = 1;
|
||||
}
|
||||
|
||||
message MacaroonPermission {
|
||||
|
@ -3263,7 +3263,13 @@
|
||||
}
|
||||
},
|
||||
"lnrpcAbandonChannelResponse": {
|
||||
"type": "object"
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"status": {
|
||||
"type": "string",
|
||||
"description": "The status of the abandon operation."
|
||||
}
|
||||
}
|
||||
},
|
||||
"lnrpcAddInvoiceResponse": {
|
||||
"type": "object",
|
||||
@ -4593,7 +4599,13 @@
|
||||
}
|
||||
},
|
||||
"lnrpcConnectPeerResponse": {
|
||||
"type": "object"
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"status": {
|
||||
"type": "string",
|
||||
"description": "The status of the connect operation."
|
||||
}
|
||||
}
|
||||
},
|
||||
"lnrpcCustomMessage": {
|
||||
"type": "object",
|
||||
@ -4635,7 +4647,13 @@
|
||||
}
|
||||
},
|
||||
"lnrpcDeleteAllPaymentsResponse": {
|
||||
"type": "object"
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"status": {
|
||||
"type": "string",
|
||||
"description": "The status of the delete operation."
|
||||
}
|
||||
}
|
||||
},
|
||||
"lnrpcDeleteMacaroonIDResponse": {
|
||||
"type": "object",
|
||||
@ -4647,10 +4665,22 @@
|
||||
}
|
||||
},
|
||||
"lnrpcDeletePaymentResponse": {
|
||||
"type": "object"
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"status": {
|
||||
"type": "string",
|
||||
"description": "The status of the delete operation."
|
||||
}
|
||||
}
|
||||
},
|
||||
"lnrpcDisconnectPeerResponse": {
|
||||
"type": "object"
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"status": {
|
||||
"type": "string",
|
||||
"description": "The status of the disconnect operation."
|
||||
}
|
||||
}
|
||||
},
|
||||
"lnrpcEdgeLocator": {
|
||||
"type": "object",
|
||||
@ -6922,7 +6952,14 @@
|
||||
"description": " - ANCHOR: We resolved an anchor output.\n - INCOMING_HTLC: We are resolving an incoming htlc on chain. This if this htlc is\nclaimed, we swept the incoming htlc with the preimage. If it is timed\nout, our peer swept the timeout path.\n - OUTGOING_HTLC: We are resolving an outgoing htlc on chain. If this htlc is claimed,\nthe remote party swept the htlc with the preimage. If it is timed out,\nwe swept it with the timeout path.\n - COMMIT: We force closed and need to sweep our time locked commitment output."
|
||||
},
|
||||
"lnrpcRestoreBackupResponse": {
|
||||
"type": "object"
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"num_restored": {
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"description": "The number of channels successfully restored."
|
||||
}
|
||||
}
|
||||
},
|
||||
"lnrpcRestoreChanBackupRequest": {
|
||||
"type": "object",
|
||||
@ -7133,7 +7170,13 @@
|
||||
}
|
||||
},
|
||||
"lnrpcSendCustomMessageResponse": {
|
||||
"type": "object"
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"status": {
|
||||
"type": "string",
|
||||
"description": "The status of the send operation."
|
||||
}
|
||||
}
|
||||
},
|
||||
"lnrpcSendManyRequest": {
|
||||
"type": "object",
|
||||
@ -7338,7 +7381,13 @@
|
||||
"type": "object"
|
||||
},
|
||||
"lnrpcStopResponse": {
|
||||
"type": "object"
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"status": {
|
||||
"type": "string",
|
||||
"description": "The status of the stop operation."
|
||||
}
|
||||
}
|
||||
},
|
||||
"lnrpcStreamAuth": {
|
||||
"type": "object",
|
||||
@ -7485,7 +7534,15 @@
|
||||
}
|
||||
},
|
||||
"lnrpcVerifyChanBackupResponse": {
|
||||
"type": "object"
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"chan_points": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"lnrpcVerifyMessageRequest": {
|
||||
"type": "object",
|
||||
|
62
rpcserver.go
62
rpcserver.go
@ -1822,7 +1822,11 @@ func (r *rpcServer) ConnectPeer(ctx context.Context,
|
||||
}
|
||||
|
||||
rpcsLog.Debugf("Connected to peer: %v", peerAddr.String())
|
||||
return &lnrpc.ConnectPeerResponse{}, nil
|
||||
|
||||
return &lnrpc.ConnectPeerResponse{
|
||||
Status: fmt.Sprintf("connection to %v initiated",
|
||||
peerAddr.String()),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// DisconnectPeer attempts to disconnect one peer from another identified by a
|
||||
@ -1884,7 +1888,9 @@ func (r *rpcServer) DisconnectPeer(ctx context.Context,
|
||||
return nil, fmt.Errorf("unable to disconnect peer: %w", err)
|
||||
}
|
||||
|
||||
return &lnrpc.DisconnectPeerResponse{}, nil
|
||||
return &lnrpc.DisconnectPeerResponse{
|
||||
Status: "disconnect initiated",
|
||||
}, nil
|
||||
}
|
||||
|
||||
// newFundingShimAssembler returns a new fully populated
|
||||
@ -3165,7 +3171,9 @@ func (r *rpcServer) AbandonChannel(_ context.Context,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &lnrpc.AbandonChannelResponse{}, nil
|
||||
return &lnrpc.AbandonChannelResponse{
|
||||
Status: fmt.Sprintf("channel %v abandoned", chanPoint.String()),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// GetInfo returns general information concerning the lightning node including
|
||||
@ -7035,7 +7043,10 @@ func (r *rpcServer) StopDaemon(_ context.Context,
|
||||
}
|
||||
|
||||
r.interceptor.RequestShutdown()
|
||||
return &lnrpc.StopResponse{}, nil
|
||||
|
||||
return &lnrpc.StopResponse{
|
||||
Status: "shutdown initiated, check logs for progress",
|
||||
}, nil
|
||||
}
|
||||
|
||||
// SubscribeChannelGraph launches a streaming RPC that allows the caller to
|
||||
@ -7286,7 +7297,9 @@ func (r *rpcServer) DeletePayment(ctx context.Context,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &lnrpc.DeletePaymentResponse{}, nil
|
||||
return &lnrpc.DeletePaymentResponse{
|
||||
Status: "payment deleted",
|
||||
}, nil
|
||||
}
|
||||
|
||||
// DeleteAllPayments deletes all outgoing payments from DB.
|
||||
@ -7319,14 +7332,17 @@ func (r *rpcServer) DeleteAllPayments(ctx context.Context,
|
||||
"failed_htlcs_only=%v", req.FailedPaymentsOnly,
|
||||
req.FailedHtlcsOnly)
|
||||
|
||||
_, err := r.server.miscDB.DeletePayments(
|
||||
numDeletedPayments, err := r.server.miscDB.DeletePayments(
|
||||
req.FailedPaymentsOnly, req.FailedHtlcsOnly,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &lnrpc.DeleteAllPaymentsResponse{}, nil
|
||||
return &lnrpc.DeleteAllPaymentsResponse{
|
||||
Status: fmt.Sprintf("%v payments deleted, failed_htlcs_only=%v",
|
||||
numDeletedPayments, req.FailedHtlcsOnly),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// DebugLevel allows a caller to programmatically set the logging verbosity of
|
||||
@ -7974,6 +7990,10 @@ func (r *rpcServer) ExportChannelBackup(ctx context.Context,
|
||||
func (r *rpcServer) VerifyChanBackup(ctx context.Context,
|
||||
in *lnrpc.ChanBackupSnapshot) (*lnrpc.VerifyChanBackupResponse, error) {
|
||||
|
||||
var (
|
||||
channels []chanbackup.Single
|
||||
err error
|
||||
)
|
||||
switch {
|
||||
// If neither a Single or Multi has been specified, then we have nothing
|
||||
// to verify.
|
||||
@ -8004,7 +8024,7 @@ func (r *rpcServer) VerifyChanBackup(ctx context.Context,
|
||||
// With our PackedSingles created, we'll attempt to unpack the
|
||||
// backup. If this fails, then we know the backup is invalid for
|
||||
// some reason.
|
||||
_, err := chanBackup.Unpack(r.server.cc.KeyRing)
|
||||
channels, err = chanBackup.Unpack(r.server.cc.KeyRing)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid single channel "+
|
||||
"backup: %v", err)
|
||||
@ -8018,14 +8038,20 @@ func (r *rpcServer) VerifyChanBackup(ctx context.Context,
|
||||
|
||||
// We'll now attempt to unpack the Multi. If this fails, then we
|
||||
// know it's invalid.
|
||||
_, err := packedMulti.Unpack(r.server.cc.KeyRing)
|
||||
multi, err := packedMulti.Unpack(r.server.cc.KeyRing)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid multi channel backup: "+
|
||||
"%v", err)
|
||||
}
|
||||
|
||||
channels = multi.StaticBackups
|
||||
}
|
||||
|
||||
return &lnrpc.VerifyChanBackupResponse{}, nil
|
||||
return &lnrpc.VerifyChanBackupResponse{
|
||||
ChanPoints: fn.Map(func(c chanbackup.Single) string {
|
||||
return c.FundingOutpoint.String()
|
||||
}, channels),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// createBackupSnapshot converts the passed Single backup into a snapshot which
|
||||
@ -8142,6 +8168,10 @@ func (r *rpcServer) RestoreChannelBackups(ctx context.Context,
|
||||
|
||||
// We'll accept either a list of Single backups, or a single Multi
|
||||
// backup which contains several single backups.
|
||||
var (
|
||||
numRestored int
|
||||
err error
|
||||
)
|
||||
switch {
|
||||
case in.GetChanBackups() != nil:
|
||||
chanBackupsProtos := in.GetChanBackups()
|
||||
@ -8159,7 +8189,7 @@ func (r *rpcServer) RestoreChannelBackups(ctx context.Context,
|
||||
// write the new backups to disk, and then attempt to connect
|
||||
// out to any peers that we know of which were our prior
|
||||
// channel peers.
|
||||
_, err := chanbackup.UnpackAndRecoverSingles(
|
||||
numRestored, err = chanbackup.UnpackAndRecoverSingles(
|
||||
chanbackup.PackedSingles(packedBackups),
|
||||
r.server.cc.KeyRing, chanRestorer, r.server,
|
||||
)
|
||||
@ -8176,7 +8206,7 @@ func (r *rpcServer) RestoreChannelBackups(ctx context.Context,
|
||||
// out to any peers that we know of which were our prior
|
||||
// channel peers.
|
||||
packedMulti := chanbackup.PackedMulti(packedMultiBackup)
|
||||
_, err := chanbackup.UnpackAndRecoverMulti(
|
||||
numRestored, err = chanbackup.UnpackAndRecoverMulti(
|
||||
packedMulti, r.server.cc.KeyRing, chanRestorer,
|
||||
r.server,
|
||||
)
|
||||
@ -8186,7 +8216,9 @@ func (r *rpcServer) RestoreChannelBackups(ctx context.Context,
|
||||
}
|
||||
}
|
||||
|
||||
return &lnrpc.RestoreBackupResponse{}, nil
|
||||
return &lnrpc.RestoreBackupResponse{
|
||||
NumRestored: uint32(numRestored),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// SubscribeChannelBackups allows a client to sub-subscribe to the most up to
|
||||
@ -8807,7 +8839,9 @@ func (r *rpcServer) SendCustomMessage(ctx context.Context, req *lnrpc.SendCustom
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &lnrpc.SendCustomMessageResponse{}, nil
|
||||
return &lnrpc.SendCustomMessageResponse{
|
||||
Status: "message sent successfully",
|
||||
}, nil
|
||||
}
|
||||
|
||||
// SubscribeCustomMessages subscribes to a stream of incoming custom peer
|
||||
|
Loading…
Reference in New Issue
Block a user