rpcserver: include upfront shutdown script in ListChannels response
This field could be omitted from the response if we were unable to calculate the channel's uptime.
This commit is contained in:
parent
b947ed552a
commit
17ca1d78f0
38
rpcserver.go
38
rpcserver.go
@ -3299,6 +3299,25 @@ func createRPCOpenChannel(r *rpcServer, graph *channeldb.ChannelGraph,
|
|||||||
channel.PushAmountSat = uint64(localBalance.ToSatoshis())
|
channel.PushAmountSat = uint64(localBalance.ToSatoshis())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()
|
||||||
|
}
|
||||||
|
|
||||||
outpoint := dbChannel.FundingOutpoint
|
outpoint := dbChannel.FundingOutpoint
|
||||||
|
|
||||||
// Get the lifespan observed by the channel event store. If the channel is
|
// Get the lifespan observed by the channel event store. If the channel is
|
||||||
@ -3336,25 +3355,6 @@ func createRPCOpenChannel(r *rpcServer, graph *channeldb.ChannelGraph,
|
|||||||
}
|
}
|
||||||
channel.Uptime = int64(uptime.Seconds())
|
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
|
return channel, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user