feat(sdk-coin-stx): honor a statics-declared Stacks chain ID - #9828
Draft
Doddanna17 wants to merge 1 commit into
Draft
Doddanna17 wants to merge 1 commit into
Doddanna17 wants to merge 1 commit into
Conversation
The Stacks chain ID is bytes 1-4 of a serialized transaction and is covered by the sighash, so a network with its own chain ID cannot be served by the two stock @stacks/network objects: the Stacks Foundation staking-testnet (chain ID 1280, on a private Bitcoin signet) rejects public-testnet transactions with "invalid chain ID 2147483648 (expected 1280)". Statics Stacks networks may now declare chainId / transactionVersion; the SDK applies them on top of the stock mainnet/testnet network. Both fields stay undefined for stx / tstx, so their transactions remain byte-identical - asserted by the new test and by the existing signed-transaction fixtures. Adds the StxStakingTestnet network (chain ID 1280, tx version 0x80) and toStacksNetwork(), with contract addresses verified against the live network: pox-5 at the boot address and sbtc-withdrawal at SN3R84XZYA63QS28932XQF3G1J8R9PC3W76P9CSQS (send-many-memo is not deployed there). Ticket: SI-1686 Refs: SI-1685
Contributor
Contributor
|
|
This branch has not been deployed
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.
First slice of SI-1677 / SI-1686 for the Stacks Foundation staking-testnet (chain ID 1280 on a private Bitcoin signet).
Why
The Stacks chain ID is bytes 1-4 of a serialized transaction and is covered by the SHA-512/256 sighash, so a network with its own chain ID cannot be served by the two stock
@stacks/networkobjects. Proven against the live node:chainId=1280, version0x8080 00000500NotEnoughFunds(all other validation passed)chainId=0x80000000(today'ststx), version0x8080 80000000SignatureValidation: invalid chain ID 2147483648 (expected 1280)What
statics:StacksNetworkgains optionalchainId/transactionVersion; newStxStakingTestnetnetwork (chain ID 1280, tx version0x80) registered underNetworks.test. Contract addresses verified live:pox-5at the boot address,sbtc-withdrawalatSN3R84XZYA63QS28932XQF3G1J8R9PC3W76P9CSQS;send-many-memois not deployed on this network, so its address is empty.sdk-coin-stx: newtoStacksNetwork()builds the@stacks/networkobject and applies a statics-declared chain identity on top of the stock mainnet/testnet network.transactionBuilder.tsuses it instead of the two-branch ternary.stx/tstxdeclare neither field, so their transactions are byte-identical — asserted by the new test (8080000000prefix) and by the existing signed-transaction fixtures.Verification
test/unit/network.ts— 5 tests pass, including serialization of prefix8000000500for a statics-declared chain ID.BITGOJS_TEST_PASSWORDenvironment failures (identical before this change).tsc --build modules/staticsclean; eslint and prettier clean on the changed files.Not in this PR
Coin entry (needs the ticker decision — proposal
tstxstk),register.ts/coinFactory/account-libwiring,environments.tsnode URL, and the three two-network maps (tokenConfig.ts:1099,sip10Token.ts:16,ofc.ts:1386,1441) — tracked in SI-1687.Ticket: SI-1686
Refs: SI-1685, SI-1677