feat(payments): add Stellar payment flow and safeguards#52
feat(payments): add Stellar payment flow and safeguards#52thesumedh wants to merge 2 commits intoStellar-Tools:mainfrom
Conversation
There was a problem hiding this comment.
1 issue found across 9 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="lib/assets.ts">
<violation number="1" location="lib/assets.ts:10">
P2: Native asset type guard is too broad (`"type" in asset`) and can misclassify malformed issued-asset inputs as native, bypassing issued-asset validation/control-flow checks.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
Checked this and the issue was valid. Root cause: Fix pushed in
@cubic-dev-ai re-run review. |
@thesumedh I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
2 issues found across 10 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="tools/stellar.ts">
<violation number="1" location="tools/stellar.ts:30">
P2: Memo schema validates character length instead of UTF-8 byte length, mismatching downstream Stellar memo byte-limit enforcement.</violation>
<violation number="2" location="tools/stellar.ts:78">
P1: User-supplied `horizonUrl` is used as an outbound Horizon endpoint without allowlisting, creating an SSRF/internal network access surface.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| { | ||
| network: selectedNetwork, | ||
| horizonUrl: | ||
| horizonUrl ?? |
There was a problem hiding this comment.
P1: User-supplied horizonUrl is used as an outbound Horizon endpoint without allowlisting, creating an SSRF/internal network access surface.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At tools/stellar.ts, line 78:
<comment>User-supplied `horizonUrl` is used as an outbound Horizon endpoint without allowlisting, creating an SSRF/internal network access surface.</comment>
<file context>
@@ -1,67 +1,94 @@
+ {
+ network: selectedNetwork,
+ horizonUrl:
+ horizonUrl ??
+ (selectedNetwork === "mainnet"
+ ? "https://horizon.stellar.org"
</file context>
| .describe("Optional asset descriptor. Omit to send native XLM."), | ||
| memo: z | ||
| .string() | ||
| .max(28) |
There was a problem hiding this comment.
P2: Memo schema validates character length instead of UTF-8 byte length, mismatching downstream Stellar memo byte-limit enforcement.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At tools/stellar.ts, line 30:
<comment>Memo schema validates character length instead of UTF-8 byte length, mismatching downstream Stellar memo byte-limit enforcement.</comment>
<file context>
@@ -1,67 +1,94 @@
+ .describe("Optional asset descriptor. Omit to send native XLM."),
+ memo: z
+ .string()
+ .max(28)
+ .optional()
+ .describe("Optional text memo up to 28 bytes"),
</file context>
Summary
createAccountwhen funding an unfunded address with native XLMAgentClientand document it in the READMEValidation
npm run buildnpm test(64/64 passing)Summary by cubic
Add a reusable Stellar payment flow for native XLM and issued assets with trustline checks, safe account funding, and stricter asset validation. Exposes payments via
AgentClient.sendPaymentand thestellar_send_paymenttool, with memo support and mainnet safety gating.New Features
lib/payments.sendPayment()sends XLM or issued assets; checks destination trustlines; auto-creates accounts for native to unfunded addresses; validates amount precision and 28-byte text memos; returns tx hash and metadata.AgentClient.sendPayment(...)wrapper and README examples.stellar_send_paymenttool forwards asset, memo, and Horizon overrides; blocks mainnet unlessallowMainnetis true.Bug Fixes
lib/assets.tsto only accept{ type: "native" }, preventing malformed issued assets from being treated as native; added tests.Written for commit fe241a1. Summary will update on new commits.