Skip to content

Update "Create Account" tutorial to use RPC - #1786

Merged
Shaptic merged 22 commits into
mainfrom
update-account
Sep 20, 2025
Merged

Shaptic merged 22 commits into
mainfrom
update-account

Conversation

@Shaptic

@Shaptic Shaptic commented Sep 16, 2025 •

Copy link
Copy Markdown
Contributor

1 similar comment
@Shaptic
Shaptic marked this pull request as ready for review September 18, 2025 18:53
@sreuland

sreuland commented Sep 18, 2025 •

Copy link
Copy Markdown
Contributor

main observations after reading the guide top down:

  • I wasn't sure how to run the example code to create an account. Since there are multiple fenced code block fragments and no instructions to the reader for how these should be re-assembled to a single runnable program.
  • for consideration would be to consolidate all code blocks to single code block for the whole working script/program in each language and put that as last part and move all the copy that explains key aspects above it.
  • remove the entire footnote section, it refers to a lot of context that is beyond this guide's purpose which is to just create accounts.

@Shaptic

Shaptic commented Sep 19, 2025

Copy link
Copy Markdown
Contributor Author

@sreuland @karthikiyer56 thanks for the review y'all, I decided to gut the piecemeal approach and just make every section be a standalone runnable example with no footnotes or anything of the like. I also added a "Checking balances" section to facilitate this. Please have another look!


```java
// create a completely new and unique pair of keys.
// see more about KeyPair objects: https://stellar.github.io/java-stellar-sdk/org/stellar/sdk/KeyPair.html

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this link never worked. it also highlights awareness at this point to change any ref's to java sdk repo to be - https://github.com/lightsail-network/java-stellar-sdk

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For java snippets in general, it would be worthwhile to put a one liner at top:

// Requires Java Stellar SDK, refer to https://github.com/lightsail-network/java-stellar-sdk developer usage.

it'll resolve questions up front on 'how do I run this'.

@sreuland sreuland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, nice work!

@Shaptic
Shaptic merged commit 340a050 into main Sep 20, 2025
@Shaptic
Shaptic deleted the update-account branch September 20, 2025 01:09
ElliotFriend pushed a commit that referenced this pull request Sep 8, 2026
* Update Verify Trustlines guide to use RPC instead of Horizon

Removes the Horizon section and rebuilds the RPC section around the
modern JS SDK helpers.

- Delete "Checking a Trustline through the Horizon API" entirely, matching
  the sibling migrations (#1769, #1779, #1784, #1786, #1793).
- Split the RPC section in two: `getAssetBalance` for existence and
  authorization, `getLedgerEntries` for the trustline limit (which
  `getAssetBalance` does not surface).
- Use the public `getLedgerEntries` instead of the private
  `_getLedgerEntries`, which also drops the manual
  `xdr.LedgerEntryData.fromXDR` step since `entries[].val` is already
  decoded.
- Fix a correctness bug: trustline flags are a bitfield, so
  `flags() !== 1` wrongly reported an authorized, clawback-enabled
  trustline (flags = 5) as unauthorized. Now checks `flags() & 1`.
- Replace the hardcoded receiver, which 404s on Testnet after a reset,
  with a placeholder plus guidance on creating one.
- SAC section: `authorized` does not return false for a missing
  trustline — the simulation fails with Error(Contract, #13) — so
  document which branch handles which case. Also point the bindings
  command at ./sac so the generated package name matches the
  `import { Client } from "sac"` below it, and drop a leftover
  commented-out transfer block.
- Link to the official Migrate from Horizon to RPC page, which documents
  that RPC does not return trustlines alongside accounts.

All snippets were run against Testnet with @stellar/stellar-sdk 16.2.0,
covering the missing-trustline, authorized, and insufficient-limit paths.

Fixes #1743

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* Address review: fix int64 precision and error conflation

- Keep trustline limit arithmetic in BigInt stroops. Converting int64
  amounts through Number loses precision above 2^53-1, and trustline
  limits routinely sit at the int64 maximum (922,337,203,685.4775807).
  The old Number path falsely rejected valid payments: with a limit at
  the maximum and 1000 stroops of headroom, sending 0.0001 was reported
  as exceeding the limit. Adds a `toStroops` helper so the amount to send
  is converted without going through a float, and links the Amount
  precision reference.

- Drop the same Number conversion from the getAssetBalance snippet and
  report `amount` as the stroops string the SDK returns.

- Stop reporting every getAssetBalance failure as "trustline not found".
  The SDK's getTrustline swallows the underlying error and always throws
  the same "not found" message, so an unreachable RPC endpoint is
  indistinguishable from a genuinely missing trustline. The example now
  rethrows the original error and says "could not confirm", and a warning
  documents the caveat and points at getLedgerEntries, which returns an
  empty entries array for a missing trustline and only rejects on a
  transport error.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

---------

Co-authored-by: Wlad Mendes <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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.

4 participants