channeldb+lnwallet: define zero-fee channel type
This commit is contained in:
parent
abefa93065
commit
d5cd9861d2
@ -244,6 +244,10 @@ const (
|
|||||||
// that only the responder can decide to cooperatively close the
|
// that only the responder can decide to cooperatively close the
|
||||||
// channel.
|
// channel.
|
||||||
FrozenBit ChannelType = 1 << 4
|
FrozenBit ChannelType = 1 << 4
|
||||||
|
|
||||||
|
// ZeroHtlcTxFeeBit indicates that the channel should use zero-fee
|
||||||
|
// second-level HTLC transactions.
|
||||||
|
ZeroHtlcTxFeeBit ChannelType = 1 << 5
|
||||||
)
|
)
|
||||||
|
|
||||||
// IsSingleFunder returns true if the channel type if one of the known single
|
// IsSingleFunder returns true if the channel type if one of the known single
|
||||||
@ -275,6 +279,12 @@ func (c ChannelType) HasAnchors() bool {
|
|||||||
return c&AnchorOutputsBit == AnchorOutputsBit
|
return c&AnchorOutputsBit == AnchorOutputsBit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ZeroHtlcTxFee returns true if this channel type uses second-level HTLC
|
||||||
|
// transactions signed with zero-fee.
|
||||||
|
func (c ChannelType) ZeroHtlcTxFee() bool {
|
||||||
|
return c&ZeroHtlcTxFeeBit == ZeroHtlcTxFeeBit
|
||||||
|
}
|
||||||
|
|
||||||
// IsFrozen returns true if the channel is considered to be "frozen". A frozen
|
// IsFrozen returns true if the channel is considered to be "frozen". A frozen
|
||||||
// channel means that only the responder can initiate a cooperative channel
|
// channel means that only the responder can initiate a cooperative channel
|
||||||
// closure.
|
// closure.
|
||||||
|
@ -278,6 +278,12 @@ func CommitWeight(chanType channeldb.ChannelType) int64 {
|
|||||||
func HtlcTimeoutFee(chanType channeldb.ChannelType,
|
func HtlcTimeoutFee(chanType channeldb.ChannelType,
|
||||||
feePerKw chainfee.SatPerKWeight) btcutil.Amount {
|
feePerKw chainfee.SatPerKWeight) btcutil.Amount {
|
||||||
|
|
||||||
|
// For zero-fee HTLC channels, this will always be zero, regardless of
|
||||||
|
// feerate.
|
||||||
|
if chanType.ZeroHtlcTxFee() {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
if chanType.HasAnchors() {
|
if chanType.HasAnchors() {
|
||||||
return feePerKw.FeeForWeight(input.HtlcTimeoutWeightConfirmed)
|
return feePerKw.FeeForWeight(input.HtlcTimeoutWeightConfirmed)
|
||||||
}
|
}
|
||||||
@ -290,6 +296,12 @@ func HtlcTimeoutFee(chanType channeldb.ChannelType,
|
|||||||
func HtlcSuccessFee(chanType channeldb.ChannelType,
|
func HtlcSuccessFee(chanType channeldb.ChannelType,
|
||||||
feePerKw chainfee.SatPerKWeight) btcutil.Amount {
|
feePerKw chainfee.SatPerKWeight) btcutil.Amount {
|
||||||
|
|
||||||
|
// For zero-fee HTLC channels, this will always be zero, regardless of
|
||||||
|
// feerate.
|
||||||
|
if chanType.ZeroHtlcTxFee() {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
if chanType.HasAnchors() {
|
if chanType.HasAnchors() {
|
||||||
return feePerKw.FeeForWeight(input.HtlcSuccessWeightConfirmed)
|
return feePerKw.FeeForWeight(input.HtlcSuccessWeightConfirmed)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user