@@ -21,10 +21,12 @@ import (
2121 "github.com/davecgh/go-spew/spew"
2222 "github.com/lightningnetwork/lnd/chainntnfs"
2323 "github.com/lightningnetwork/lnd/channeldb"
24+ "github.com/lightningnetwork/lnd/fn"
2425 "github.com/lightningnetwork/lnd/input"
2526 "github.com/lightningnetwork/lnd/lntypes"
2627 "github.com/lightningnetwork/lnd/lnwallet/chainfee"
2728 "github.com/lightningnetwork/lnd/lnwire"
29+ "github.com/lightningnetwork/lnd/tlv"
2830 "github.com/stretchr/testify/require"
2931)
3032
@@ -5695,6 +5697,7 @@ func TestChannelUnilateralCloseHtlcResolution(t *testing.T) {
56955697 spendDetail ,
56965698 aliceChannel .channelState .RemoteCommitment ,
56975699 aliceChannel .channelState .RemoteCurrentRevocation ,
5700+ fn .None [AuxLeafStore ](),
56985701 )
56995702 require .NoError (t , err , "unable to create alice close summary" )
57005703
@@ -5844,6 +5847,7 @@ func TestChannelUnilateralClosePendingCommit(t *testing.T) {
58445847 spendDetail ,
58455848 aliceChannel .channelState .RemoteCommitment ,
58465849 aliceChannel .channelState .RemoteCurrentRevocation ,
5850+ fn .None [AuxLeafStore ](),
58475851 )
58485852 require .NoError (t , err , "unable to create alice close summary" )
58495853
@@ -5861,6 +5865,7 @@ func TestChannelUnilateralClosePendingCommit(t *testing.T) {
58615865 spendDetail ,
58625866 aliceRemoteChainTip .Commitment ,
58635867 aliceChannel .channelState .RemoteNextRevocation ,
5868+ fn .None [AuxLeafStore ](),
58645869 )
58655870 require .NoError (t , err , "unable to create alice close summary" )
58665871
@@ -6741,6 +6746,7 @@ func TestNewBreachRetributionSkipsDustHtlcs(t *testing.T) {
67416746 breachTx := aliceChannel .channelState .RemoteCommitment .CommitTx
67426747 breachRet , err := NewBreachRetribution (
67436748 aliceChannel .channelState , revokedStateNum , 100 , breachTx ,
6749+ fn .None [AuxLeafStore ](),
67446750 )
67456751 require .NoError (t , err , "unable to create breach retribution" )
67466752
@@ -8343,10 +8349,10 @@ func TestEvaluateView(t *testing.T) {
83438349 }
83448350 }
83458351
8346- view := & htlcView {
8347- ourUpdates : test .ourHtlcs ,
8348- theirUpdates : test .theirHtlcs ,
8349- feePerKw : feePerKw ,
8352+ view := & HtlcView {
8353+ OurUpdates : test .ourHtlcs ,
8354+ TheirUpdates : test .theirHtlcs ,
8355+ FeePerKw : feePerKw ,
83508356 }
83518357
83528358 var (
@@ -8367,17 +8373,17 @@ func TestEvaluateView(t *testing.T) {
83678373 t .Fatalf ("unexpected error: %v" , err )
83688374 }
83698375
8370- if result .feePerKw != test .expectedFee {
8376+ if result .FeePerKw != test .expectedFee {
83718377 t .Fatalf ("expected fee: %v, got: %v" ,
8372- test .expectedFee , result .feePerKw )
8378+ test .expectedFee , result .FeePerKw )
83738379 }
83748380
83758381 checkExpectedHtlcs (
8376- t , result .ourUpdates , test .ourExpectedHtlcs ,
8382+ t , result .OurUpdates , test .ourExpectedHtlcs ,
83778383 )
83788384
83798385 checkExpectedHtlcs (
8380- t , result .theirUpdates , test .theirExpectedHtlcs ,
8386+ t , result .TheirUpdates , test .theirExpectedHtlcs ,
83818387 )
83828388
83838389 if lc .channelState .TotalMSatSent != test .expectSent {
@@ -8600,15 +8606,15 @@ func TestProcessFeeUpdate(t *testing.T) {
86008606 EntryType : FeeUpdate ,
86018607 }
86028608
8603- view := & htlcView {
8604- feePerKw : chainfee .SatPerKWeight (feePerKw ),
8609+ view := & HtlcView {
8610+ FeePerKw : chainfee .SatPerKWeight (feePerKw ),
86058611 }
86068612 processFeeUpdate (
86078613 update , nextHeight , test .remoteChain ,
86088614 test .mutate , view ,
86098615 )
86108616
8611- if view .feePerKw != test .expectedFee {
8617+ if view .FeePerKw != test .expectedFee {
86128618 t .Fatalf ("expected fee: %v, got: %v" ,
86138619 test .expectedFee , feePerKw )
86148620 }
@@ -9753,15 +9759,21 @@ func TestCreateHtlcRetribution(t *testing.T) {
97539759 aliceChannel .channelState ,
97549760 )
97559761 htlc := & channeldb.HTLCEntry {
9756- Amt : testAmt ,
9757- Incoming : true ,
9758- OutputIndex : 1 ,
9762+ Amt : tlv.NewRecordT [tlv.TlvType4 , tlv.BigSizeT [btcutil.Amount ]](
9763+ tlv .NewBigSizeT (testAmt ),
9764+ ),
9765+ Incoming : tlv.NewPrimitiveRecord [tlv.TlvType3 , bool ](
9766+ true ,
9767+ ),
9768+ OutputIndex : tlv.NewPrimitiveRecord [tlv.TlvType2 , uint16 ](
9769+ 1 ,
9770+ ),
97599771 }
97609772
97619773 // Create the htlc retribution.
97629774 hr , err := createHtlcRetribution (
97639775 aliceChannel .channelState , keyRing , commitHash ,
9764- dummyPrivate , leaseExpiry , htlc ,
9776+ dummyPrivate , leaseExpiry , htlc , fn . None [ CommitAuxLeaves ](),
97659777 )
97669778 // Expect no error.
97679779 require .NoError (t , err )
@@ -9810,30 +9822,33 @@ func TestCreateBreachRetribution(t *testing.T) {
98109822 aliceChannel .channelState ,
98119823 )
98129824 htlc := & channeldb.HTLCEntry {
9813- Amt : btcutil .Amount (testAmt ),
9814- Incoming : true ,
9815- OutputIndex : uint16 (htlcIndex ),
9825+ Amt : tlv.NewRecordT [tlv.TlvType4 , tlv.BigSizeT [btcutil.Amount ]](
9826+ tlv .NewBigSizeT (btcutil .Amount (testAmt )),
9827+ ),
9828+ Incoming : tlv.NewPrimitiveRecord [tlv.TlvType3 , bool ](
9829+ true ,
9830+ ),
9831+ OutputIndex : tlv.NewPrimitiveRecord [tlv.TlvType2 , uint16 ](
9832+ uint16 (htlcIndex ),
9833+ ),
98169834 }
98179835
98189836 // Create a dummy revocation log.
98199837 ourAmtMsat := lnwire .MilliSatoshi (ourAmt * 1000 )
98209838 theirAmtMsat := lnwire .MilliSatoshi (theirAmt * 1000 )
9821- revokedLog := channeldb.RevocationLog {
9822- CommitTxHash : commitHash ,
9823- OurOutputIndex : uint16 (localIndex ),
9824- TheirOutputIndex : uint16 (remoteIndex ),
9825- HTLCEntries : []* channeldb.HTLCEntry {htlc },
9826- TheirBalance : & theirAmtMsat ,
9827- OurBalance : & ourAmtMsat ,
9828- }
9839+ revokedLog := channeldb .NewRevocationLog (
9840+ uint16 (localIndex ), uint16 (remoteIndex ), commitHash ,
9841+ fn .Some (theirAmtMsat ), fn .Some (ourAmtMsat ),
9842+ []* channeldb.HTLCEntry {htlc }, fn .None [tlv.Blob ](),
9843+ )
98299844
98309845 // Create a log with an empty local output index.
98319846 revokedLogNoLocal := revokedLog
9832- revokedLogNoLocal .OurOutputIndex = channeldb .OutputIndexEmpty
9847+ revokedLogNoLocal .OurOutputIndex . Val = channeldb .OutputIndexEmpty
98339848
98349849 // Create a log with an empty remote output index.
98359850 revokedLogNoRemote := revokedLog
9836- revokedLogNoRemote .TheirOutputIndex = channeldb .OutputIndexEmpty
9851+ revokedLogNoRemote .TheirOutputIndex . Val = channeldb .OutputIndexEmpty
98379852
98389853 testCases := []struct {
98399854 name string
@@ -9863,14 +9878,18 @@ func TestCreateBreachRetribution(t *testing.T) {
98639878 {
98649879 name : "fail due to our index too big" ,
98659880 revocationLog : & channeldb.RevocationLog {
9866- OurOutputIndex : uint16 (htlcIndex + 1 ),
9881+ OurOutputIndex : tlv.NewPrimitiveRecord [tlv.TlvType0 , uint16 ](
9882+ uint16 (htlcIndex + 1 ),
9883+ ),
98679884 },
98689885 expectedErr : ErrOutputIndexOutOfRange ,
98699886 },
98709887 {
98719888 name : "fail due to their index too big" ,
98729889 revocationLog : & channeldb.RevocationLog {
9873- TheirOutputIndex : uint16 (htlcIndex + 1 ),
9890+ TheirOutputIndex : tlv.NewPrimitiveRecord [tlv.TlvType1 , uint16 ](
9891+ uint16 (htlcIndex + 1 ),
9892+ ),
98749893 },
98759894 expectedErr : ErrOutputIndexOutOfRange ,
98769895 },
@@ -9956,9 +9975,9 @@ func TestCreateBreachRetribution(t *testing.T) {
99569975 }
99579976
99589977 br , our , their , err := createBreachRetribution (
9959- tc .revocationLog , tx ,
9960- aliceChannel . channelState , keyRing ,
9961- dummyPrivate , leaseExpiry ,
9978+ tc .revocationLog , tx , aliceChannel . channelState ,
9979+ keyRing , dummyPrivate , leaseExpiry ,
9980+ fn . None [ CommitAuxLeaves ]() ,
99629981 )
99639982
99649983 // Check the error if expected.
@@ -10077,13 +10096,15 @@ func testNewBreachRetribution(t *testing.T, chanType channeldb.ChannelType) {
1007710096 // error as there are no past delta state saved as revocation logs yet.
1007810097 _ , err = NewBreachRetribution (
1007910098 aliceChannel .channelState , stateNum , breachHeight , breachTx ,
10099+ fn .None [AuxLeafStore ](),
1008010100 )
1008110101 require .ErrorIs (t , err , channeldb .ErrNoPastDeltas )
1008210102
1008310103 // We also check that the same error is returned if no breach tx is
1008410104 // provided.
1008510105 _ , err = NewBreachRetribution (
1008610106 aliceChannel .channelState , stateNum , breachHeight , nil ,
10107+ fn .None [AuxLeafStore ](),
1008710108 )
1008810109 require .ErrorIs (t , err , channeldb .ErrNoPastDeltas )
1008910110
@@ -10129,6 +10150,7 @@ func testNewBreachRetribution(t *testing.T, chanType channeldb.ChannelType) {
1012910150 // successfully.
1013010151 br , err := NewBreachRetribution (
1013110152 aliceChannel .channelState , stateNum , breachHeight , breachTx ,
10153+ fn .None [AuxLeafStore ](),
1013210154 )
1013310155 require .NoError (t , err )
1013410156
@@ -10140,6 +10162,7 @@ func testNewBreachRetribution(t *testing.T, chanType channeldb.ChannelType) {
1014010162 // since the necessary info should now be found in the revocation log.
1014110163 br , err = NewBreachRetribution (
1014210164 aliceChannel .channelState , stateNum , breachHeight , nil ,
10165+ fn .None [AuxLeafStore ](),
1014310166 )
1014410167 require .NoError (t , err )
1014510168 assertRetribution (br , 1 , 0 )
@@ -10148,13 +10171,15 @@ func testNewBreachRetribution(t *testing.T, chanType channeldb.ChannelType) {
1014810171 // error.
1014910172 _ , err = NewBreachRetribution (
1015010173 aliceChannel .channelState , stateNum + 1 , breachHeight , breachTx ,
10174+ fn .None [AuxLeafStore ](),
1015110175 )
1015210176 require .ErrorIs (t , err , channeldb .ErrLogEntryNotFound )
1015310177
1015410178 // Once again, repeat the check for the case when no breach tx is
1015510179 // provided.
1015610180 _ , err = NewBreachRetribution (
1015710181 aliceChannel .channelState , stateNum + 1 , breachHeight , nil ,
10182+ fn .None [AuxLeafStore ](),
1015810183 )
1015910184 require .ErrorIs (t , err , channeldb .ErrLogEntryNotFound )
1016010185}
@@ -10192,7 +10217,7 @@ func TestExtractPayDescs(t *testing.T) {
1019210217 // NOTE: we use nil commitment key rings to avoid checking the htlc
1019310218 // scripts(`genHtlcScript`) as it should be tested independently.
1019410219 incomingPDs , outgoingPDs , err := lnChan .extractPayDescs (
10195- 0 , 0 , htlcs , nil , nil , true ,
10220+ 0 , 0 , htlcs , nil , nil , true , fn . None [ CommitAuxLeaves ](),
1019610221 )
1019710222 require .NoError (t , err )
1019810223
0 commit comments