Skip to content

feat(message): add Action::AddBondInvoice#146

Merged
grunch merged 1 commit into
mainfrom
feat/add-bond-invoice
May 14, 2026
Merged

feat(message): add Action::AddBondInvoice#146
grunch merged 1 commit into
mainfrom
feat/add-bond-invoice

Conversation

@grunch
Copy link
Copy Markdown
Member

@grunch grunch commented May 14, 2026

Summary

  • Add a dedicated Action::AddBondInvoice variant so mostrod can distinguish a taker's bond-payout invoice from a buyer's trade payout invoice without inferring intent from order state.
  • Mirrors the existing AddInvoice / PayBondInvoice split: same payload shape (Payload::PaymentRequest), same id requirement, distinct kebab-case discriminator (add-bond-invoice).
  • MessageKind::verify and MessageKind::get_payment_request updated to recognize the new action; docs on Payload::PaymentRequest updated accordingly.
  • Added to the exhaustive BondResolution rejection test list, plus a dedicated test_add_bond_invoice_wire_format_and_verify covering accept/reject cases, kebab-case wire format, JSON roundtrip, and get_payment_request.

Motivation

In mostrod, add_bond_invoice_action currently receives Action::AddInvoice from users and has to disambiguate a bond-payout invoice from a trade buyer invoice based on order state. A distinct action discriminator removes that ambiguity at the protocol level.

Test plan

  • cargo build
  • cargo test --lib message:: — all 18 message tests pass, including the new one
  • Wire up mostrod to emit/consume Action::AddBondInvoice

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added support for a new bond invoice submission action with comprehensive payment request validation and protocol compliance checking.

Review Change Stack

Introduce a dedicated Action::AddBondInvoice variant so that mostrod
can distinguish a taker's bond-payout invoice from a buyer's trade
payout invoice without inferring intent from order state. Mirrors
the existing AddInvoice / PayBondInvoice split.

verify() accepts AddBondInvoice under the same payload rules as
AddInvoice (id required, PaymentRequest payload), and
get_payment_request() now surfaces the bolt11 for this action.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@grunch grunch merged commit f22f85f into main May 14, 2026
9 checks passed
@grunch grunch deleted the feat/add-bond-invoice branch May 14, 2026 17:38
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 14, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0cb9d910-d722-41b9-9cfe-fae5cab91331

📥 Commits

Reviewing files that changed from the base of the PR and between 243e63f and ee3d608.

📒 Files selected for processing (1)
  • src/message.rs

Walkthrough

A new Action::AddBondInvoice variant is added to the message protocol to support bond-payout invoices. Validation rules, payment extraction logic, and comprehensive test coverage ensure the variant follows the same well-formedness constraints as existing invoice-request actions.

Changes

AddBondInvoice Action Support

Layer / File(s) Summary
AddBondInvoice action variant definition
src/message.rs
New AddBondInvoice enum variant added to Action with documentation explaining it carries bond-payout invoice payment requests, distinct from normal payout invoices. Payload documentation updated to reference the new action.
Validation and payment extraction
src/message.rs
MessageKind::verify extended so AddBondInvoice requires an id and Payload::PaymentRequest, matching other invoice-request actions. MessageKind::get_payment_request updated to extract bolt11 strings for AddBondInvoice messages.
Test coverage for AddBondInvoice
src/message.rs
Existing BondResolution rejection test updated to include AddBondInvoice in the action set that must reject that payload. New unit test test_add_bond_invoice_wire_format_and_verify validates kebab-case discriminator serialization, successful roundtrip decoding, rejection of missing id or invalid payload types, and correct get_payment_request extraction.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • MostroP2P/mostro-core#143: Both PRs modify src/message.rs message validation around BondResolution; the retrieved PR adds the BondResolution payload and enforces rejection for non-admin actions, while this PR extends the rejection action set to include AddBondInvoice.
  • MostroP2P/mostro-core#144: Both PRs add a new Action variant for bond invoices with Payload::PaymentRequest + id validation rules and comprehensive wire-format unit tests in MessageKind::verify and payment-request extraction.
  • MostroP2P/mostro-core#120: Both PRs extend the Action enum and update MessageKind::verify with validation rules for a newly added action variant, plus corresponding test coverage.

Poem

🐰 A bond invoice hops into the action,
Kebab-case keeps it sharp with fraction,
Validation rules hold steady and tight,
Tests confirm the path shines bright,
Mostro's message stack takes flight! 🚀

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/add-bond-invoice

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant