fix: allow tx sign and tx hash without an RPC URL (#2455)#2642
Open
NicoMoli wants to merge 2 commits into
Open
fix: allow tx sign and tx hash without an RPC URL (#2455)#2642NicoMoli wants to merge 2 commits into
tx sign and tx hash without an RPC URL (#2455)#2642NicoMoli wants to merge 2 commits into
Conversation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011WsVE7zXVYWKQkxMmhiqVV
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011WsVE7zXVYWKQkxMmhiqVV
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes the unnecessary requirement for an RPC URL when running offline-only commands (stellar tx sign and stellar tx hash). It introduces an opt-in network resolver for non-RPC contexts while keeping the existing strict RPC-required behavior unchanged for RPC-dependent commands.
Changes:
- Added
network::Args::get_no_rpc()(backed by a sharedresolve(require_rpc)helper) to allow passphrase-only resolution with an emptyrpc_url. - Switched
tx signandtx hashto useget_no_rpc()so they work without--rpc-url. - Updated help docs and added unit + integration tests covering the new offline behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| FULL_HELP_DOCS.md | Regenerated CLI help docs to remove the stale stellar xdr [CHANNEL] argument. |
| cmd/soroban-cli/src/config/network.rs | Introduces get_no_rpc() and shared resolver; adds unit tests for passphrase-only behavior vs strict RPC behavior. |
| cmd/soroban-cli/src/commands/tx/sign.rs | Uses get_no_rpc() so signing works without an RPC URL. |
| cmd/soroban-cli/src/commands/tx/hash.rs | Uses get_no_rpc() so hashing works without an RPC URL. |
| cmd/crates/soroban-test/tests/it/tx.rs | Adds offline integration tests for tx sign and tx hash requiring only --network-passphrase. |
| cmd/crates/soroban-test/tests/it/main.rs | Registers the new tx integration test module. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
stellar tx signandstellar tx hashno longer require an RPC URL. Both only need the network passphrase (it's mixed into the transaction hash that gets signed), and neither ever contacts an RPC server. Previously they errored withnetwork passphrase is used but rpc-url is missing, forcing the--rpc-url ""workaround fromstellar tx signshouldn't require an RPC URL #2455.network::Args::get_no_rpc()alongside the existing strictget(). Both share a privateresolve(require_rpc)helper; the only difference is that a passphrase-only invocation resolves to aNetworkwith an emptyrpc_urlinstead of erroring. RPC-dependent commands keep the strictget()unchanged.tx signandtx hashtoget_no_rpc().chorecommit that regeneratesFULL_HELP_DOCS.md, dropping the stalestellar xdr [CHANNEL]arg. It's unrelated to this fix but produced bymake docs/the pre-commit hook, since the committed docs were stale onmain.Fixes #2455.
Test plan
cargo test -p soroban-cli config::network::tests— 25 passed (incl. 4 new: passphrase-only resolves with emptyrpc_url; rpc-without-passphrase still errors; both-supplied preserves the URL; strictget()still rejects passphrase-only).cargo test -p soroban-test --test it tx::— 2 new offline integration tests pass (tx sign/tx hashsucceed with only--network-passphrase).echo $TX | stellar tx sign --network-passphrase "specified manually" --sign-with-key $SKandtx hashboth succeed (signing hash matches the issue).tx sendstill errors on missing rpc-url — regression preserved.cargo clippy -p soroban-cli --all-targetsclean;cargo fmt --all --checkclean.