Skip to content

fix(walletconnect): check a signed transaction the wallet returns before broadcasting it - #850

Open
kome12 wants to merge 2 commits into
fix/privy-signed-tx-checkfrom
fix/walletconnect-signed-tx-check
Open

kome12 wants to merge 2 commits into
fix/privy-signed-tx-checkfrom
fix/walletconnect-signed-tx-check

Conversation

@kome12

@kome12 kome12 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #849. This PR's base is #849's branch, so the diff shows only the WalletConnect change. CI runs once #849 merges and this PR targets main.

What

When a WalletConnect wallet returns signed bytes instead of broadcasting itself, the CLI broadcast them as they came back. The send functions in src/walletconnect-trading.js now take the wallet address and check what comes back, using the checks added in #849.

  • EVM: the sender must recover to the connected wallet. Chain, recipient, value, calldata and gas limit must match what was sent. The wallet still chooses nonce and fees.
  • Solana: the message must be identical and the wallet's signature must verify. A signature-only reply must verify against the transaction the CLI built.

A mismatch fails with SIGNED_TX_MISMATCH. The message says the wallet may have sent the transaction itself, so check its activity before retrying. In a swap the code is kept, not replaced by the generic ambiguous-send error, and no other quote is tried. A reply carrying only a hash, where the wallet broadcast itself, is unchanged.

Callers updated: swaps, approvals, allowance revokes, wallet send and limit orders.

Why

Every pre-sign check (target, intent binding, value, fee cap, simulation) runs on the transaction sent to the wallet. Returned bytes encoding a different transaction would have been broadcast unchecked. A gas limit lower than requested would make a swap revert and still burn fees.

Before / after

Wallet returns before after
EVM swap with the recipient swapped broadcast, reported as success refused (SIGNED_TX_MISMATCH), nothing broadcast
Approval with the spender swapped broadcast refused
EVM transaction with a different gas limit broadcast refused
Solana swap, different message broadcast refused
Solana signature that doesn't verify injected and broadcast refused

Follow-up to #849

Testing

  • New walletconnect-signed-tx.test.js: execute-level tests with the walletconnect subprocess stubbed, honest controls and substituted replies (above). The refusal tests fail without the fix.
  • walletconnect-trading.test.js: unit tests for the refusals and the gas-limit check.
  • Full suite and lint pass locally.

🤖 Generated with Claude Code

kome12 and others added 2 commits November 17, 2026 15:00
…ore broadcasting it

When a WalletConnect wallet returns signed bytes instead of broadcasting
itself, the CLI broadcast them as they came back, although every pre-sign
check had run on the transaction it sent the wallet.

The send functions now take the wallet address and refuse returned bytes
that are not signed by it or differ from what was sent (EVM: chain,
recipient, value, calldata and gas limit; the wallet still picks nonce and
fees. Solana: the same message). A signature-only Solana reply must verify.
The error is SIGNED_TX_MISMATCH and says the wallet may have sent the
transaction itself. A reply carrying only a hash is unchanged. Covers
swaps, approvals, allowance revokes, wallet send and limit orders.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kome12 kome12 self-assigned this Nov 17, 2026
@kome12
kome12 marked this pull request as ready for review November 17, 2026 08:23
@kome12
kome12 changed the base branch from feat/remote-signer-tx-checks to fix/privy-signed-tx-check November 17, 2026 08:30
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.

1 participant