mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-01-19 05:45:21 +01:00
lnrpc: display local upfront shutdown
This commit is contained in:
parent
6eab2a06dd
commit
eb3a2e63f2
1168
lnrpc/rpc.pb.go
1168
lnrpc/rpc.pb.go
File diff suppressed because it is too large
Load Diff
@ -1344,6 +1344,15 @@ message Channel {
|
||||
by the channel scoring system over the lifetime of the channel [EXPERIMENTAL].
|
||||
*/
|
||||
int64 uptime = 24 [json_name = "uptime"];
|
||||
|
||||
/**
|
||||
Close address is the address that we will enforce payout to on cooperative
|
||||
close if the channel was opened utilizing option upfront shutdown. This
|
||||
value can be set on channel open by setting close_address in an open channel
|
||||
request. If this value is not set, you can still choose a payout address by
|
||||
cooperatively closing with the delivery_address field set.
|
||||
*/
|
||||
string close_address = 25 [json_name ="close_address"];
|
||||
}
|
||||
|
||||
|
||||
|
@ -1819,6 +1819,10 @@
|
||||
"type": "string",
|
||||
"format": "int64",
|
||||
"description": "*\nThe number of seconds that the remote peer has been observed as being online\nby the channel scoring system over the lifetime of the channel [EXPERIMENTAL]."
|
||||
},
|
||||
"close_address": {
|
||||
"type": "string",
|
||||
"description": "*\nClose address is the address that we will enforce payout to on cooperative\nclose if the channel was opened utilizing option upfront shutdown. This\nvalue can be set on channel open by setting close_address in an open channel\nrequest. If this value is not set, you can still choose a payout address by\ncooperatively closing with the delivery_address field set."
|
||||
}
|
||||
}
|
||||
},
|
||||
|
23
rpcserver.go
23
rpcserver.go
@ -2984,6 +2984,25 @@ func createRPCOpenChannel(r *rpcServer, graph *channeldb.ChannelGraph,
|
||||
}
|
||||
channel.Uptime = int64(uptime.Seconds())
|
||||
|
||||
if len(dbChannel.LocalShutdownScript) > 0 {
|
||||
_, addresses, _, err := txscript.ExtractPkScriptAddrs(
|
||||
dbChannel.LocalShutdownScript, activeNetParams.Params,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// We only expect one upfront shutdown address for a channel. If
|
||||
// LocalShutdownScript is non-zero, there should be one payout address
|
||||
// set.
|
||||
if len(addresses) != 1 {
|
||||
return nil, fmt.Errorf("expected one upfront shutdown address, "+
|
||||
"got: %v", len(addresses))
|
||||
}
|
||||
|
||||
channel.CloseAddress = addresses[0].String()
|
||||
}
|
||||
|
||||
return channel, nil
|
||||
}
|
||||
|
||||
@ -3062,6 +3081,7 @@ func (r *rpcServer) SubscribeChannelEvents(req *lnrpc.ChannelEventSubscription,
|
||||
OpenChannel: channel,
|
||||
},
|
||||
}
|
||||
|
||||
case channelnotifier.ClosedChannelEvent:
|
||||
closedChannel := createRPCClosedChannel(event.CloseSummary)
|
||||
update = &lnrpc.ChannelEventUpdate{
|
||||
@ -3070,6 +3090,7 @@ func (r *rpcServer) SubscribeChannelEvents(req *lnrpc.ChannelEventSubscription,
|
||||
ClosedChannel: closedChannel,
|
||||
},
|
||||
}
|
||||
|
||||
case channelnotifier.ActiveChannelEvent:
|
||||
update = &lnrpc.ChannelEventUpdate{
|
||||
Type: lnrpc.ChannelEventUpdate_ACTIVE_CHANNEL,
|
||||
@ -3082,6 +3103,7 @@ func (r *rpcServer) SubscribeChannelEvents(req *lnrpc.ChannelEventSubscription,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
case channelnotifier.InactiveChannelEvent:
|
||||
update = &lnrpc.ChannelEventUpdate{
|
||||
Type: lnrpc.ChannelEventUpdate_INACTIVE_CHANNEL,
|
||||
@ -3094,6 +3116,7 @@ func (r *rpcServer) SubscribeChannelEvents(req *lnrpc.ChannelEventSubscription,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
default:
|
||||
return fmt.Errorf("unexpected channel event update: %v", event)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user