@@ -283,19 +283,6 @@ func (m *Manager) handleLoopInSweepReq(ctx context.Context,
283283 return err
284284 }
285285
286- loopIn .Address , err = m .cfg .AddressManager .GetStaticAddress (ctx )
287- if err != nil {
288- return err
289- }
290-
291- deposits , err := m .cfg .DepositManager .DepositsForOutpoints (
292- ctx , loopIn .DepositOutpoints ,
293- )
294- if err != nil {
295- return err
296- }
297- loopIn .Deposits = deposits
298-
299286 reader := bytes .NewReader (req .SweepTxPsbt )
300287 sweepPacket , err := psbt .NewFromRawBytes (reader , false )
301288 if err != nil {
@@ -304,7 +291,7 @@ func (m *Manager) handleLoopInSweepReq(ctx context.Context,
304291
305292 sweepTx := sweepPacket .UnsignedTx
306293
307- // If the loop-in is not in the Succeeded state we return an
294+ // If the loop-in is not in the Succeeded state, we return an
308295 // error.
309296 if ! loopIn .IsInState (Succeeded ) {
310297 // We'll notify the server that we don't consider the swap
@@ -322,8 +309,8 @@ func (m *Manager) handleLoopInSweepReq(ctx context.Context,
322309 }
323310
324311 // If the user selected an amount that is less than the total deposit
325- // amount we'll check that the server sends us the correct change amount
326- // back to our static address.
312+ // amount, we'll check that the server sends us the correct change
313+ // amount back to our static address.
327314 totalDepositAmount := loopIn .TotalDepositAmount ()
328315 changeAmt := totalDepositAmount - loopIn .SelectedAmount
329316 if changeAmt > 0 && changeAmt < totalDepositAmount {
@@ -404,8 +391,21 @@ func (m *Manager) handleLoopInSweepReq(ctx context.Context,
404391 )
405392
406393 copy (serverNonce [:], nonce )
394+
395+ deposit , err := m .cfg .DepositManager .DepositsForOutpoints (
396+ ctx , []string {depositOutpoint },
397+ )
398+ if err != nil {
399+ return err
400+ }
401+ if len (deposit ) != 1 {
402+ return fmt .Errorf ("expected 1 deposit for " +
403+ "outpoint %v, got %v" , depositOutpoint ,
404+ len (deposit ))
405+ }
406+
407407 musig2Session , err := loopIn .createMusig2Session (
408- ctx , m .cfg .Signer ,
408+ ctx , m .cfg .Signer , deposit [ 0 ],
409409 )
410410 if err != nil {
411411 return err
@@ -484,7 +484,7 @@ func (m *Manager) recoverLoopIns(ctx context.Context) error {
484484
485485 // Retrieve all deposits regardless of deposit state. If any of
486486 // the deposits is not active in the in-mem map of the deposits
487- // manager we log it, but continue to recover the loop-in.
487+ // manager, we log it but continue to recover the loop-in.
488488 var allActive bool
489489 loopIn .Deposits , allActive =
490490 m .cfg .DepositManager .AllStringOutpointsActiveDeposits (
@@ -502,13 +502,6 @@ func (m *Manager) recoverLoopIns(ctx context.Context) error {
502502 return err
503503 }
504504
505- loopIn .Address , err = m .cfg .AddressManager .GetStaticAddress (
506- ctx ,
507- )
508- if err != nil {
509- return err
510- }
511-
512505 // Create a state machine for a given loop-in.
513506 var (
514507 recovery = true
0 commit comments