Skip to content

feat(bridge): implement cross-chain bridge payment relay for invoices (#343) - #1061

Closed
huangji6693-max wants to merge 1 commit into
Stellar-split:mainfrom
huangji6693-max:feat/cross-chain-bridge-invoice-relay-343
Closed

huangji6693-max wants to merge 1 commit into
Stellar-split:mainfrom
huangji6693-max:feat/cross-chain-bridge-invoice-relay-343

Conversation

@huangji6693-max

Copy link
Copy Markdown

Summary

Implements a cross-chain bridge payment relay (bridge_pay, BridgeProof, set_bridge_authority) enabling external-chain payments to settle StellarSplit invoices on Stellar.

Closes #343

Key Changes

  1. Relay Proof & Authority Configuration:
    • Added BridgeProof struct (invoice_id, source_chain_id, source_tx_hash, sender_address, amount, signature).
    • Added set_bridge_authority(env, admin, authority_pubkey: BytesN<32>) and get_bridge_authority(env) stored under bridge_authority_key() (brg_auth).
  2. Signature Verification & Replay Protection (bridge_pay):
    • Computes a domain-separated canonical SHA-256 digest (compute_bridge_proof_digest) over (invoice_id, source_chain_id, source_tx_hash, sender_address, amount) and verifies proof.signature against the stored bridge_authority Ed25519 public key via env.crypto().ed25519_verify.
    • Stores consumed source_tx_hash keys under bridge_consumed_tx_key (("brg_tx", source_tx_hash)) and panics with "AlreadyConsumed" on replay attempts.
  3. Payment Flow & Event Integration:
    • Emits BridgePaymentReceived with full proof metadata (payer, source_chain_id, source_tx_hash, sender_address, amount, event_seq).
    • Credits the invoice and triggers automatic release (Self::_release) when the invoice becomes fully funded.
  4. Storage Key Snapshot & Migration Note:
    • Registered bridge_authority_key in contracts/split/src/storage_snapshot.rs and updated tests/snapshots/storage_keys.json (collision-free).
  5. Unit Tests (issue_343_tests):
    • test_bridge_pay_valid_relay_and_auto_release
    • test_bridge_pay_invalid_signature_rejected
    • test_bridge_pay_replayed_proof_rejected
    • test_bridge_pay_wrong_invoice_rejected
    • test_bridge_pay_wrong_amount_rejected

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.

Implement cross-chain bridge payment relay for invoices

2 participants