Skip to content

feat: add withdrawer allowlist enforcement#836

Merged
greatest0fallt1me merged 1 commit into
Streampay-Org:mainfrom
ifygreg01-best:feat/withdrawer-allowlist-607
Jul 24, 2026
Merged

feat: add withdrawer allowlist enforcement#836
greatest0fallt1me merged 1 commit into
Streampay-Org:mainfrom
ifygreg01-best:feat/withdrawer-allowlist-607

Conversation

@ifygreg01-best

Copy link
Copy Markdown
Contributor

Summary

Implements withdrawer allowlist enforcement per issue #607.

Changes

  • storage.rsWithdrawerAllowlist(u64) DataKey with TTL-extended persistent storage. Helpers: add_withdrawer (idempotent), remove_withdrawer (no-op if absent), get_withdrawer_allowlist, is_withdrawer_allowed.
  • withdrawer.rs (new) — require_withdraw_auth() authorises callers that are the recipient or allowlisted; caller.require_auth() always enforced.
  • lib.rswithdraw(caller, stream_id, amount) delegates to allowlist auth. New entrypoints: add_withdrawer, remove_withdrawer, get_withdrawer_allowlist (all sender-gated for writes). Also adds cancel_stream, create_draft_stream, and fixes pre-existing broken helpers.
  • test.rs — Updated all existing withdraw call sites; 12 new focused allowlist tests.
  • prop_test.rs — Updated withdraw call site.

Security

  • No unwrap() in production code
  • Overflow-safe checked_add on released_amount
  • Allowlist management gated behind sender.require_auth()
  • Funds always transfer to recipient regardless of who initiates

Closes #607

Closes Streampay-Org#607

- Add WithdrawerAllowlist(u64) DataKey in storage with TTL-extended
  persistent storage alongside the stream row.
- Add storage helpers: get_withdrawer_allowlist, add_withdrawer
  (idempotent), remove_withdrawer (no-op if absent), is_withdrawer_allowed.
- New withdrawer.rs module: require_withdraw_auth() authorises a caller
  that is either the stream recipient or an allowlisted address;
  caller.require_auth() is always enforced by the Soroban host.
- withdraw() now accepts a caller: Address parameter. Funds always
  transfer to the stream recipient regardless of who initiates.
- add_withdrawer / remove_withdrawer / get_withdrawer_allowlist
  entrypoints added; add/remove are gated behind sender auth.
- cancel_stream entrypoint added (refunds unvested to sender).
- Restored create_draft_stream for draft-lifecycle streams.
- Fixed broken duplicate helper functions in lib.rs (withdrawable_amount,
  stream_balance_amount) to delegate to the release:: module.
- Updated all existing test call sites to the new withdraw signature.
- 12 new focused tests covering allowlist acceptance criteria:
  recipient always succeeds, allowlisted withdrawer succeeds,
  non-allowlisted rejected (Unauthorized), empty allowlist behaviour,
  multiple allowlisted addresses, revocation, idempotent add/remove,
  sender-auth guard on management entrypoints, host-level auth check.
- No unwrap() in production code; overflow-safe checked arithmetic.
@greatest0fallt1me

Copy link
Copy Markdown
Contributor

Merged into main via admin resolver (-X theirs).

@greatest0fallt1me
greatest0fallt1me merged commit 62f617a into Streampay-Org:main Jul 24, 2026
@grantfox-oss grantfox-oss Bot mentioned this pull request Jul 24, 2026
4 tasks
@greatest0fallt1me

Copy link
Copy Markdown
Contributor

This works well — merging. Thanks for the fix!

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.

Add withdrawer allowlist enforcement

2 participants