Skip to content

Commit 4efa453

Browse files
committed
tapchannelmsg: include stxo flag in commitment blob
1 parent 2bf7457 commit 4efa453

File tree

7 files changed

+33
-8
lines changed

7 files changed

+33
-8
lines changed

rfq/manager_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ func createChannelWithCustomData(t *testing.T, id asset.ID, localBalance,
111111
),
112112
},
113113
nil, nil, lnwallet.CommitAuxLeaves{},
114+
false,
114115
),
115116
OpenChan: *tpchmsg.NewOpenChannel(
116117
[]*tpchmsg.AssetOutput{

tapchannel/auf_leaf_signer_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func setupAuxLeafSigner(t *testing.T, numJobs int32) (*AuxLeafSigner,
110110
}
111111

112112
com := cmsg.NewCommitment(
113-
nil, nil, outgoingHtlcs, nil, lnwallet.CommitAuxLeaves{},
113+
nil, nil, outgoingHtlcs, nil, lnwallet.CommitAuxLeaves{}, false,
114114
)
115115
cancelChan := make(chan struct{})
116116

tapchannel/aux_funding_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,7 @@ func newCommitBlobAndLeaves(pendingFunding *pendingAssetFunding,
565565
// needs the sum of the remote+local assets, so we'll populate that.
566566
fakePrevState := cmsg.NewCommitment(
567567
localAssets, remoteAssets, nil, nil, lnwallet.CommitAuxLeaves{},
568+
stxo,
568569
)
569570

570571
// Just like above, we don't have a real HTLC view here, so we'll pass

tapchannel/commitment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,7 @@ func ToCommitment(allocations []*tapsend.Allocation,
12781278

12791279
return cmsg.NewCommitment(
12801280
localAssets, remoteAssets, outgoingHtlcs, incomingHtlcs,
1281-
auxLeaves,
1281+
auxLeaves, false,
12821282
), nil
12831283
}
12841284

tapchannelmsg/custom_channel_data_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ func TestReadChannelCustomData(t *testing.T) {
5050
}, map[input.HtlcIndex][]*AssetOutput{
5151
2: {output4},
5252
}, lnwallet.CommitAuxLeaves{},
53+
false,
5354
)
5455

5556
fundingBlob := fundingState.Bytes()
@@ -157,19 +158,19 @@ func TestReadBalanceCustomData(t *testing.T) {
157158

158159
openChannel1 := NewCommitment(
159160
[]*AssetOutput{output1}, []*AssetOutput{output2}, nil, nil,
160-
lnwallet.CommitAuxLeaves{},
161+
lnwallet.CommitAuxLeaves{}, false,
161162
)
162163
openChannel2 := NewCommitment(
163164
[]*AssetOutput{output2}, []*AssetOutput{output3}, nil, nil,
164-
lnwallet.CommitAuxLeaves{},
165+
lnwallet.CommitAuxLeaves{}, false,
165166
)
166167
pendingChannel1 := NewCommitment(
167168
[]*AssetOutput{output3}, nil, nil, nil,
168-
lnwallet.CommitAuxLeaves{},
169+
lnwallet.CommitAuxLeaves{}, false,
169170
)
170171
pendingChannel2 := NewCommitment(
171172
nil, []*AssetOutput{output1}, nil, nil,
172-
lnwallet.CommitAuxLeaves{},
173+
lnwallet.CommitAuxLeaves{}, false,
173174
)
174175

175176
var customChannelData bytes.Buffer

tapchannelmsg/records.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,13 +453,17 @@ type Commitment struct {
453453

454454
// AuxLeaves are the auxiliary leaves that correspond to the commitment.
455455
AuxLeaves tlv.RecordT[tlv.TlvType4, AuxLeaves]
456+
457+
// STXO is a flag indicating whether this commitment supports stxo
458+
// proofs.
459+
STXO tlv.RecordT[tlv.TlvType5, bool]
456460
}
457461

458462
// NewCommitment creates a new Commitment record with the given local and remote
459463
// assets, and incoming and outgoing HTLCs.
460464
func NewCommitment(localAssets, remoteAssets []*AssetOutput, outgoingHtlcs,
461465
incomingHtlcs map[input.HtlcIndex][]*AssetOutput,
462-
auxLeaves lnwallet.CommitAuxLeaves) *Commitment {
466+
auxLeaves lnwallet.CommitAuxLeaves, stxo bool) *Commitment {
463467

464468
return &Commitment{
465469
LocalAssets: tlv.NewRecordT[tlv.TlvType0](
@@ -485,6 +489,7 @@ func NewCommitment(localAssets, remoteAssets []*AssetOutput, outgoingHtlcs,
485489
auxLeaves.IncomingHtlcLeaves,
486490
),
487491
),
492+
STXO: tlv.NewPrimitiveRecord[tlv.TlvType5](stxo),
488493
}
489494
}
490495

@@ -496,6 +501,7 @@ func (c *Commitment) records() []tlv.Record {
496501
c.OutgoingHtlcAssets.Record(),
497502
c.IncomingHtlcAssets.Record(),
498503
c.AuxLeaves.Record(),
504+
c.STXO.Record(),
499505
}
500506
}
501507

tapchannelmsg/records_test.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ func TestCommitment(t *testing.T) {
215215
name: "commitment with empty HTLC maps",
216216
commitment: NewCommitment(
217217
nil, nil, nil, nil, lnwallet.CommitAuxLeaves{},
218+
false,
218219
),
219220
},
220221
{
@@ -228,7 +229,21 @@ func TestCommitment(t *testing.T) {
228229
NewAssetOutput(
229230
[32]byte{1}, 1000, *randProof,
230231
),
231-
}, nil, nil, lnwallet.CommitAuxLeaves{},
232+
}, nil, nil, lnwallet.CommitAuxLeaves{}, false,
233+
),
234+
},
235+
{
236+
name: "commitment with balances and stxo",
237+
commitment: NewCommitment(
238+
[]*AssetOutput{
239+
NewAssetOutput(
240+
[32]byte{1}, 1000, *randProof,
241+
),
242+
}, []*AssetOutput{
243+
NewAssetOutput(
244+
[32]byte{1}, 1000, *randProof,
245+
),
246+
}, nil, nil, lnwallet.CommitAuxLeaves{}, true,
232247
),
233248
},
234249
{
@@ -319,6 +334,7 @@ func TestCommitment(t *testing.T) {
319334
},
320335
},
321336
},
337+
false,
322338
),
323339
},
324340
}

0 commit comments

Comments
 (0)