Skip to content

Commit 6926a62

Browse files
authored
Merge pull request #1603 from Roasbeef/allocation-loggign
tapchannel: add additional logging for commitment sort error cases
2 parents c8b3b64 + 9becce7 commit 6926a62

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

tapchannel/commitment.go

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,12 +1672,34 @@ func InPlaceCustomCommitSort(tx *wire.MsgTx, cltvs []uint32,
16721672
htlcIndexes []input.HtlcIndex,
16731673
allocations []*tapsend.Allocation) error {
16741674

1675+
log.Tracef("Sorting commit tx with %d outputs, %d allocations, "+
1676+
"%d cltvs, %d htlc indexes", len(tx.TxOut), len(allocations),
1677+
len(cltvs), len(htlcIndexes))
1678+
16751679
if len(tx.TxOut) != len(allocations) {
1676-
return fmt.Errorf("output and allocation size mismatch")
1680+
log.Errorf("Output and allocation size mismatch: "+
1681+
"len(tx.TxOut)=%d, len(allocations)=%d. "+
1682+
"allocations=%v, htlc_indexes=%v",
1683+
len(tx.TxOut), len(allocations),
1684+
limitSpewer.Sdump(allocations),
1685+
limitSpewer.Sdump(htlcIndexes))
1686+
1687+
return fmt.Errorf("output and allocation size mismatch: "+
1688+
"len(tx.TxOut)=%d, len(allocations)=%d",
1689+
len(tx.TxOut), len(allocations))
16771690
}
16781691

16791692
if len(tx.TxOut) != len(cltvs) {
1680-
return fmt.Errorf("output and cltv list size mismatch")
1693+
log.Errorf("Output and cltv list size mismatch: "+
1694+
"len(tx.TxOut)=%d, len(cltvs)=%d. "+
1695+
"allocations=%v, htlc_indexes=%v",
1696+
len(tx.TxOut), len(cltvs),
1697+
limitSpewer.Sdump(allocations),
1698+
limitSpewer.Sdump(htlcIndexes))
1699+
1700+
return fmt.Errorf("output and cltv list size mismatch: "+
1701+
"len(tx.TxOut)=%d, len(cltvs)=%d",
1702+
len(tx.TxOut), len(cltvs))
16811703
}
16821704

16831705
// First the easy part, sort the inputs by BIP69.
@@ -1708,6 +1730,14 @@ func InPlaceCustomCommitSort(tx *wire.MsgTx, cltvs []uint32,
17081730
}
17091731

17101732
if allocation == nil {
1733+
log.Errorf("Could not find allocation for output %d: "+
1734+
"pk_script=%x, value=%d, cltv=%d, "+
1735+
"htlc_index=%d", i, original.PkScript,
1736+
original.Value, cltvs[i], htlcIndexes[i])
1737+
1738+
log.Errorf("allocations=%v",
1739+
limitSpewer.Sdump(allocations))
1740+
17111741
return fmt.Errorf("no corresponding allocation entry "+
17121742
"found for output index %d", i)
17131743
}

0 commit comments

Comments
 (0)