Skip to content

[BCN] Handle missing Solana token ATA in txhistory#4173

Open
msalcala11 wants to merge 1 commit into
bitpay:masterfrom
msalcala11:fix-solana-history-error
Open

[BCN] Handle missing Solana token ATA in txhistory#4173
msalcala11 wants to merge 1 commit into
bitpay:masterfrom
msalcala11:fix-solana-history-error

Conversation

@msalcala11
Copy link
Copy Markdown
Contributor

@msalcala11 msalcala11 commented May 19, 2026

Description

Fixes a BitPay app txhistory failure observed with zero-balance Solana token wallets.

Zero-balance Solana token wallets can still have transaction history. A user may have received or sent a token before, then sent the balance back to zero or closed the associated token account. In that state, the wallet should still be able to show historical activity.

Observed failure mode: When the app fetched txhistory for one of these token wallets, BWS returned a plain-text Error getting ATA address response instead of an empty or historical transaction list.

Root cause: BWS forwards /v1/txhistory/ requests with tokenAddress to bitcore-node wallet transaction streaming. In the Solana token path, bitcore-node resolves the wallet address's associated token account before listing signatures. If there is no currently initialized ATA, getConfirmedAta throws and the stream fails.

The fix: This change keeps getConfirmedAta as the first lookup, so invalid mints and other non-missing-ATA failures keep their existing behavior. For the missing or uninitialized ATA case, it derives the deterministic ATA address and uses it to find any prior token-account activity. If prior activity exists, txhistory returns the corresponding transaction history even if the ATA was later closed.

Changelog

  • Fall back to the derived Solana ATA when SPL token txhistory has no currently initialized ATA.
  • Preserve existing error behavior for invalid mints and other non-missing-ATA failures.
  • Add regression coverage for SOL + tokenAddress + missing current ATA.

Testing Notes

From packages/bitcore-node, run:

npm run tsc && BCN_LOG_LEVEL=none npm exec -- mocha 'build/test/integration/solana/csp.test.js' --grep 'derived ATA'
npm run test:integration

@msalcala11 msalcala11 changed the title handle missing Solana token ATA in txhistory [BCN] Handle missing Solana token ATA in txhistory May 19, 2026
@msalcala11 msalcala11 force-pushed the fix-solana-history-error branch 29 times, most recently from 80ab6fd to 03b5dc1 Compare May 20, 2026 20:41
@msalcala11 msalcala11 force-pushed the fix-solana-history-error branch 4 times, most recently from 7d469b0 to 18e0943 Compare May 20, 2026 22:19
@msalcala11 msalcala11 force-pushed the fix-solana-history-error branch from 18e0943 to d634fea Compare May 20, 2026 22:42
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