fix: reverse swap double broadcast#486
Conversation
if a swap accepts zero-conf and goes into transaction.confirmed before the invoice is being settled, the client tries to broadcast again, leading to an insufficient replacement error
WalkthroughA conditional check was introduced in the Changes
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
internal/nursery/reverse.go (1)
163-166: LGTM! Effective fix for double broadcast prevention.The conditional check correctly prevents redundant claim transaction processing when the transaction has already been broadcast during the
TransactionMempoolphase. This addresses the "insufficient replacement" error described in the PR objectives.The logic is sound:
- Early exit before database operations and transaction construction
- Proper placement at the beginning of the
TransactionConfirmedcase- Clear comment explaining the rationale
Consider adding a debug log statement to improve troubleshooting:
// already broadcasted on transaction.mempool if reverseSwap.ClaimTransactionId != "" { + logger.Debugf("Skipping claim transaction construction for Reverse Swap %s - already broadcast", reverseSwap.Id) break }
if a swap accepts zero-conf and goes into transaction.confirmed before
the invoice is being settled, the client tries to broadcast again,
leading to an insufficient replacement error
Summary by CodeRabbit