Merge pull request #1970 from Roasbeef/more-abandon-channel-details
rpc: populate additional information in AbandonChannel close summary
This commit is contained in:
commit
7fe095c541
30
rpcserver.go
30
rpcserver.go
@ -1190,12 +1190,16 @@ out:
|
|||||||
func (r *rpcServer) AbandonChannel(ctx context.Context,
|
func (r *rpcServer) AbandonChannel(ctx context.Context,
|
||||||
in *lnrpc.AbandonChannelRequest) (*lnrpc.AbandonChannelResponse, error) {
|
in *lnrpc.AbandonChannelRequest) (*lnrpc.AbandonChannelResponse, error) {
|
||||||
|
|
||||||
|
// If this isn't the debug build, then we won't allow the RPC to be
|
||||||
|
// executed, as it's an advanced feature and won't be activated in
|
||||||
|
// regular production/release builds.
|
||||||
if !DebugBuild {
|
if !DebugBuild {
|
||||||
return nil, fmt.Errorf("AbandonChannel RPC call only " +
|
return nil, fmt.Errorf("AbandonChannel RPC call only " +
|
||||||
"available in debug builds")
|
"available in debug builds")
|
||||||
}
|
}
|
||||||
|
|
||||||
index := in.ChannelPoint.OutputIndex
|
// We'll parse out the arguments to we can obtain the chanPoint of the
|
||||||
|
// target channel.
|
||||||
txidHash, err := getChanPointFundingTxid(in.GetChannelPoint())
|
txidHash, err := getChanPointFundingTxid(in.GetChannelPoint())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -1204,23 +1208,41 @@ func (r *rpcServer) AbandonChannel(ctx context.Context,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
index := in.ChannelPoint.OutputIndex
|
||||||
chanPoint := wire.NewOutPoint(txid, index)
|
chanPoint := wire.NewOutPoint(txid, index)
|
||||||
|
|
||||||
|
// With the chanPoint constructed, we'll attempt to find the target
|
||||||
|
// channel in the database. If we can't find the channel, then we'll
|
||||||
|
// return the error back to the caller.
|
||||||
dbChan, err := r.fetchOpenDbChannel(*chanPoint)
|
dbChan, err := r.fetchOpenDbChannel(*chanPoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Now that we've found the channel, we'll populate a close summary for
|
||||||
|
// the channel, so we can store as much information for this abounded
|
||||||
|
// channel as possible. We also ensure that we set Pending to false, to
|
||||||
|
// indicate that this channel has been "fully" closed.
|
||||||
|
_, bestHeight, err := r.server.cc.chainIO.GetBestBlock()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
summary := &channeldb.ChannelCloseSummary{
|
summary := &channeldb.ChannelCloseSummary{
|
||||||
|
CloseType: channeldb.Abandoned,
|
||||||
ChanPoint: *chanPoint,
|
ChanPoint: *chanPoint,
|
||||||
ChainHash: dbChan.ChainHash,
|
ChainHash: dbChan.ChainHash,
|
||||||
|
CloseHeight: uint32(bestHeight),
|
||||||
RemotePub: dbChan.IdentityPub,
|
RemotePub: dbChan.IdentityPub,
|
||||||
Capacity: dbChan.Capacity,
|
Capacity: dbChan.Capacity,
|
||||||
CloseType: channeldb.Abandoned,
|
SettledBalance: dbChan.LocalCommitment.LocalBalance.ToSatoshis(),
|
||||||
ShortChanID: dbChan.ShortChannelID,
|
ShortChanID: dbChan.ShortChanID(),
|
||||||
IsPending: false,
|
RemoteCurrentRevocation: dbChan.RemoteCurrentRevocation,
|
||||||
|
RemoteNextRevocation: dbChan.RemoteNextRevocation,
|
||||||
|
LocalChanConfig: dbChan.LocalChanCfg,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Finally, we'll close the channel in the DB, and return back to the
|
||||||
|
// caller.
|
||||||
err = dbChan.CloseChannel(summary)
|
err = dbChan.CloseChannel(summary)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
Reference in New Issue
Block a user