Skip to content

fix: reject unknown network names, normalize IntegerType unlock heights - #1878

Open
jannik-stacks wants to merge 1 commit into
mainfrom
chore/fix-staking-derive
Open

fix: reject unknown network names, normalize IntegerType unlock heights#1878
jannik-stacks wants to merge 1 commit into
mainfrom
chore/fix-staking-derive

Conversation

@jannik-stacks

Copy link
Copy Markdown
Collaborator
  • reject unknown network names

@jannik-stacks
jannik-stacks requested a lite review from Copilot August 17, 2026 16:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR tightens correctness around network selection and lock-proof construction by normalizing IntegerType unlock heights and preventing silent fallback to mainnet when an unknown network name is provided.

Changes:

  • Normalize IntegerType unlock heights when building lock proofs.
  • Reject unrecognized network name strings instead of returning them and falling through to mainnet params.
  • Correct EarnedRewards unit documentation (sBTC sats vs micro-STX).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/bitcoin-staking/src/types.ts Fixes EarnedRewards unit documentation to match current semantics.
packages/bitcoin-staking/src/proof.ts Normalizes unlockHeight conversion before placing it in the lock proof object.
packages/bitcoin-staking/src/network.ts Adds explicit validation for supported network name strings and throws on unknowns.
.changeset/witty-otters-unlock.md Announces patch changes for unlock-height normalization + docs fix.
.changeset/spotty-planes-refuse.md Announces patch change for rejecting unrecognized network strings.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

txIndex: input.merkleProof.pos,
amount,
unlockBurnHeight: Number(input.unlockHeight),
unlockBurnHeight: Number(intToBigInt(input.unlockHeight)),
Comment on lines +18 to +31
if (typeof network === 'string') {
if (
network === 'mainnet' ||
network === 'testnet' ||
network === 'devnet' ||
network === 'mocknet'
) {
return network;
}
// An unrecognized name would miss the closed per-network tables downstream
// and silently fall through to mainnet params (e.g. a mainnet lock address
// for `'regtest'`), so reject it here.
throw new Error(`networkNameFrom: unrecognized network name '${network}'`);
}
// An unrecognized name would miss the closed per-network tables downstream
// and silently fall through to mainnet params (e.g. a mainnet lock address
// for `'regtest'`), so reject it here.
throw new Error(`networkNameFrom: unrecognized network name '${network}'`);
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.

2 participants