Skip to content

Commit 1f472ae

Browse files
committed
staticaddr: guard channel open and withdraw against unconfirmed deposits
Now that Deposited includes mempool outputs, channel opens and withdrawals must explicitly reject unconfirmed deposits (ConfirmationHeight <= 0) since both operations require confirmed inputs.
1 parent 8311b54 commit 1f472ae

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

staticaddr/openchannel/manager.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,14 @@ func (m *Manager) OpenChannel(ctx context.Context,
325325
}
326326
}
327327

328+
for _, d := range deposits {
329+
// Deposited now includes mempool outputs for static loop-ins, but
330+
// channel opens still require the deposit input to be confirmed.
331+
if d.ConfirmationHeight <= 0 {
332+
return nil, ErrOpeningChannelUnavailableDeposits
333+
}
334+
}
335+
328336
// Pre-check: calculate the channel funding amount and the optional
329337
// change before locking deposits. This ensures the selected deposits
330338
// can cover the funding amount plus fees.

staticaddr/withdraw/manager.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,15 @@ func (m *Manager) WithdrawDeposits(ctx context.Context,
381381
}
382382
}
383383

384+
for _, d := range deposits {
385+
// Deposited now includes mempool outputs for static loop-ins, but
386+
// withdrawals still require the deposit input to be confirmed.
387+
if d.ConfirmationHeight <= 0 {
388+
return "", "", fmt.Errorf("can't withdraw, " +
389+
"unconfirmed deposits can't be withdrawn")
390+
}
391+
}
392+
384393
var (
385394
withdrawalAddress btcutil.Address
386395
err error

0 commit comments

Comments
 (0)