Skip to content

Commit c8b3b64

Browse files
authored
Merge pull request #1601 from lightninglabs/fix-dust-balance
bugfix: fix btc-only balance force close, fix incorrect policy in invoice hop hint
2 parents 5d667f4 + b40dde0 commit c8b3b64

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ require (
2929
github.com/lightninglabs/lightning-node-connect/hashmailrpc v1.0.3
3030
github.com/lightninglabs/lndclient v0.19.0-7
3131
github.com/lightninglabs/neutrino/cache v1.1.2
32-
github.com/lightninglabs/taproot-assets/taprpc v1.0.6
32+
github.com/lightninglabs/taproot-assets/taprpc v1.0.7
3333
github.com/lightningnetwork/lnd v0.19.0-beta
3434
github.com/lightningnetwork/lnd/cert v1.2.2
3535
github.com/lightningnetwork/lnd/clock v1.1.1

rpcserver.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8553,8 +8553,10 @@ func (r *rpcServer) getInboundPolicy(ctx context.Context, chanID uint64,
85538553
return nil, fmt.Errorf("unable to fetch channel: %w", err)
85548554
}
85558555

8556+
// We want the policy that corresponds to the node that is the remote
8557+
// peer in the channel.
85568558
policy := edge.Node2Policy
8557-
if edge.Node2Pub == remotePubStr {
8559+
if edge.Node1Pub == remotePubStr {
85588560
policy = edge.Node1Policy
85598561
}
85608562

tapchannel/commitment.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,10 @@ func addCommitmentOutputs(chanType channeldb.ChannelType, localChanCfg,
969969

970970
// We've asserted that we have a non-dust BTC balance if we have an
971971
// asset balance before, so we can just check the asset balance here.
972-
if ourAssetBalance > 0 || ourBalance > 0 {
972+
// In case there is no asset balance, and the BTC value is dust, it will
973+
// not be materialized on-chain, and we shouldn't create an allocation
974+
// for it.
975+
if ourAssetBalance > 0 || ourBalance > localChanCfg.DustLimit {
973976
toLocalScript, err := lnwallet.CommitScriptToSelf(
974977
chanType, initiator, keys.ToLocalKey,
975978
keys.RevocationKey, uint32(localChanCfg.CsvDelay),
@@ -1033,7 +1036,10 @@ func addCommitmentOutputs(chanType channeldb.ChannelType, localChanCfg,
10331036
addAllocation(allocation)
10341037
}
10351038

1036-
if theirAssetBalance > 0 || theirBalance > 0 {
1039+
// We only create an allocation if there is going to be an on-chain
1040+
// output. If this is dust (which is only allowed if there are no assets
1041+
// on the output), it will not be materialized on-chain.
1042+
if theirAssetBalance > 0 || theirBalance > localChanCfg.DustLimit {
10371043
toRemoteScript, _, err := lnwallet.CommitScriptToRemote(
10381044
chanType, initiator, keys.ToRemoteKey, leaseExpiry,
10391045
lfn.None[txscript.TapLeaf](),

0 commit comments

Comments
 (0)