@@ -1713,6 +1713,7 @@ func (a *AuxSweeper) resolveContract(
1713
1713
default :
1714
1714
return lfn.Err [tlv.Blob ](fmt .Errorf ("unknown resolution " +
1715
1715
"type: %v" , req .Type ))
1716
+ // TODO(roasbeef): need to do HTLC revocation casesj:w
1716
1717
}
1717
1718
1718
1719
// The input proofs above were made originally using the fake commit tx
@@ -1944,6 +1945,7 @@ func prepVpkts(bRes lfn.Result[blobWithWitnessInfo],
1944
1945
// extractInputVPackets extracts the vPackets from the inputs passed in. If
1945
1946
// none of the inputs have any resolution blobs. Then an empty slice will be
1946
1947
// returned.
1948
+ func extractInputVPackets (inputs []input.Input ) lfn.Result [sweepVpkts ] {
1947
1949
// Otherwise, we'll extract the set of resolution blobs from the inputs
1948
1950
// passed in.
1949
1951
relevantInputs := fn .Filter (inputs , func (i input.Input ) bool {
@@ -2148,7 +2150,7 @@ func (a *AuxSweeper) registerAndBroadcastSweep(req *sweep.BumpRequest,
2148
2150
2149
2151
// If we don't have any vPackets that had our resolution data in them,
2150
2152
// then we can exit early.
2151
- if len (vPkts ) == 0 {
2153
+ if len (vPkts . firstLevel ) == 0 && len ( vPkts . secondLevel ) == 0 {
2152
2154
log .Infof ("Sweep request had no vPkts, exiting" )
2153
2155
return nil
2154
2156
}
@@ -2170,17 +2172,52 @@ func (a *AuxSweeper) registerAndBroadcastSweep(req *sweep.BumpRequest,
2170
2172
internalKey .PubKey .SerializeCompressed ())
2171
2173
2172
2174
// We'll also use the passed in context to set the anchor key again for
2173
- // all the vOuts.
2174
- for idx := range vPkts {
2175
- for _ , vOut := range vPkts [idx ].Outputs {
2175
+ // all the vOuts, but only for first level vPkts, as second level
2176
+ // packets already commit to the internal key of the vOut.
2177
+ for idx := range vPkts .firstLevelPkts () {
2178
+ for _ , vOut := range vPkts .firstLevelPkts ()[idx ].Outputs {
2176
2179
vOut .SetAnchorInternalKey (
2177
2180
internalKey , a .cfg .ChainParams .HDCoinType ,
2178
2181
)
2179
2182
}
2180
2183
}
2181
2184
2185
+ // For any second level outputs we're sweeping, we'll need to sign for
2186
+ // it, as now we know the txid of the sweeping transaction.
2187
+ for _ , sweepSet := range vPkts .secondLevel {
2188
+ for _ , vPkt := range sweepSet .vPkts {
2189
+ for _ , vIn := range vPkt .Inputs {
2190
+ vIn .PrevID .OutPoint = sweepSet .btcInput .OutPoint ()
2191
+ }
2192
+ }
2193
+ }
2194
+
2195
+ // If we have second level vPkts, then we'll need to sign them here, as
2196
+ // now we know the input we're spending which was set above.
2197
+ for _ , sweepSet := range vPkts .secondLevel {
2198
+ tapSigDesc , err := sweepSet .tapSigDesc .UnwrapOrErr (
2199
+ fmt .Errorf ("tap sig desc not populated" ),
2200
+ )
2201
+ if err != nil {
2202
+ return err
2203
+ }
2204
+
2205
+ err = a .signSweepVpackets (
2206
+ sweepSet .vPkts , * sweepSet .btcInput .SignDesc (),
2207
+ tapSigDesc .TapTweak .Val , tapSigDesc .CtrlBlock .Val ,
2208
+ lfn .None [lnwallet.AuxSigDesc ](),
2209
+ lfn .None [uint32 ](),
2210
+ )
2211
+ if err != nil {
2212
+ return fmt .Errorf ("unable to sign second level " +
2213
+ "vPkts: %w" , err )
2214
+ }
2215
+ }
2216
+
2182
2217
// Now that we have our vPkts, we'll re-create the output commitments.
2183
- outCommitments , err := tapsend .CreateOutputCommitments (vPkts )
2218
+ outCommitments , err := tapsend .CreateOutputCommitments (
2219
+ vPkts .allPkts (),
2220
+ )
2184
2221
if err != nil {
2185
2222
return fmt .Errorf ("unable to create output " +
2186
2223
"commitments: %w" , err )
@@ -2202,15 +2239,16 @@ func (a *AuxSweeper) registerAndBroadcastSweep(req *sweep.BumpRequest,
2202
2239
//
2203
2240
// TODO(roasbeef): base off allocations? then can serialize, then
2204
2241
// re-use the logic
2205
- for idx := range vPkts {
2206
- vPkt := vPkts [idx ]
2242
+ allVpkts := vPkts .allPkts ()
2243
+ for idx := range allVpkts {
2244
+ vPkt := allVpkts [idx ]
2207
2245
for outIdx := range vPkt .Outputs {
2208
2246
exclusionCreator := sweepExclusionProofGen (
2209
2247
changeInternalKey ,
2210
2248
)
2211
2249
2212
2250
proofSuffix , err := tapsend .CreateProofSuffixCustom (
2213
- sweepTx , vPkt , outCommitments , outIdx , vPkts ,
2251
+ sweepTx , vPkt , outCommitments , outIdx , allVpkts ,
2214
2252
exclusionCreator ,
2215
2253
)
2216
2254
if err != nil {
@@ -2230,7 +2268,7 @@ func (a *AuxSweeper) registerAndBroadcastSweep(req *sweep.BumpRequest,
2230
2268
// We pass false for the last arg as we already updated our suffix
2231
2269
// proofs here.
2232
2270
return shipChannelTxn (
2233
- a .cfg .TxSender , sweepTx , outCommitments , vPkts , int64 (fee ),
2271
+ a .cfg .TxSender , sweepTx , outCommitments , allVpkts , int64 (fee ),
2234
2272
)
2235
2273
}
2236
2274
0 commit comments