Skip to content

Commit

Permalink
. fix for "sweepbatcher: add mixed batches option"
Browse files Browse the repository at this point in the history
Real SignOutputRaw requires prevOuts for all inputs, not only the ones
being signed.

This commit will be squashed.
  • Loading branch information
starius committed Aug 19, 2024
1 parent f21ec9a commit fcc5d41
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions sweepbatcher/sweep_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -1330,9 +1330,17 @@ func (b *batch) publishMixedBatch(ctx context.Context) (btcutil.Amount, error,

// Now sign the remaining sweeps' inputs non-cooperatively.
// For that, first collect sign descriptors for the signatures.
// Also collect prevOuts for all inputs.
signDescs := make([]*lndclient.SignDescriptor, 0, nonCoopInputs)
prevOutsList := make([]*wire.TxOut, 0, nonCoopInputs)
prevOutsList := make([]*wire.TxOut, 0, len(sweeps))
for i, sweep := range sweeps {
// Create and store the previous outpoint for this sweep.
prevOut := &wire.TxOut{
Value: int64(sweep.value),
PkScript: sweep.htlc.PkScript,
}
prevOutsList = append(prevOutsList, prevOut)

// Skip cooperative sweeps.
if !sweep.nonCoopHint && !sweep.coopFailed {
continue
Expand All @@ -1346,13 +1354,6 @@ func (b *batch) publishMixedBatch(ctx context.Context) (btcutil.Amount, error,
err), false
}

// Create and store the previous outpoint for this sweep.
prevOut := &wire.TxOut{
Value: int64(sweep.value),
PkScript: sweep.htlc.PkScript,
}
prevOutsList = append(prevOutsList, prevOut)

// Create and store the sign descriptor for this sweep.
signDesc := lndclient.SignDescriptor{
WitnessScript: sweep.htlc.SuccessScript(),
Expand All @@ -1377,10 +1378,10 @@ func (b *batch) publishMixedBatch(ctx context.Context) (btcutil.Amount, error,
return 0, fmt.Errorf("unexpected size of signDescs: %d != %d",
len(signDescs), nonCoopInputs), false
}
if len(prevOutsList) != nonCoopInputs {
if len(prevOutsList) != len(sweeps) {
// This must not happen by construction.
return 0, fmt.Errorf("unexpected size of prevOutsList: "+
"%d != %d", len(prevOutsList), nonCoopInputs), false
"%d != %d", len(prevOutsList), len(sweeps)), false
}

var rawSigs [][]byte
Expand Down

0 comments on commit fcc5d41

Please sign in to comment.