Skip to content

Stellar Trustline Pre-Validation #558

Description

@Kingsman-99

Description

On Stellar, sending an asset to an account that has not established a trustline for that asset causes the transfer to fail at the network level, potentially leaving the contract in a partially-paid inconsistent state. Before activating an invoice, the contract must verify that every recipient address has a trustline for the payment token and surface the offending address if one is missing.

Technical Context

contracts/split/src/lib.rsactivate_invoice() entry point (or the final step of initialize()); trustline presence is inferred by calling soroban_sdk::token::Client::balance(recipient_address) and treating a host-trapped invocation as absent — wrap in env.try_invoke_contract or equivalent; contracts/split/src/validation.rs — add assert_recipients_have_trustlines(env: &Env, token: &Address, recipients: &[RecipientShare]); contracts/split/src/error.rs — add Error::RecipientMissingTrustline carrying the offending Address.

Acceptance Criteria

  • activate_invoice() iterates all recipients and calls the trustline helper before changing invoice status to Active
  • Any recipient whose balance() call traps or returns an error causes activation to fail with Error::RecipientMissingTrustline containing that recipient's address
  • The check is bypassed for XLM (native asset STROOP), which requires no trustline
  • A mock-based test in contracts/split/src/tests/trustline_tests.rs simulates a missing trustline on recipient index 2 of 4 and asserts Error::RecipientMissingTrustline with the correct address
  • A positive-path test confirms that activate_invoice() succeeds when all recipients return valid balance() responses
  • All CI checks (cargo build --target wasm32-unknown-unknown, cargo test, cargo clippy) pass and the branch has no merge conflicts

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave programcomplexity: highComplex feature requiring deep knowledge - 200 ptssecuritySecurity hardening and access control

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions