Skip to content

wollet: sign stake records for the chain's height - #34

Merged
GracedEternalKingCabbageMan merged 1 commit into
sequentiafrom
feature/stake-records-v2
Oct 7, 2026
Merged

GracedEternalKingCabbageMan merged 1 commit into
sequentiafrom
feature/stake-records-v2

Conversation

@GracedEternalKingCabbageMan

Copy link
Copy Markdown
Collaborator

From Sequentia Core 25.2.1's fork (height 163,000 on the testnet, block 1 on custom chains and regtest) a delegation record must be created by a transaction that spends a coin of its controller, and every spend of a staking, unbonding, delegation or payout output signs the segwit-v0 hash, committing to the amount, with one canonical scriptSig. The kit built all of these the old way and would have been refused from that height.

The signing is chosen by height: pos_records_v2_height is 163,000 for the testnet network (genesis-bound) and 1 elsewhere, since no node RPC reports it. sign_stake_record_input signs either way; StakeRecordSigning::for_next_block picks. A delegation is created with add_record_authorization (a payment to the controller's key) followed by build_delegation_create_tx from that coin. Two-step unbonding (build_unbond_tx, build_unbond_claim_tx) is new to the kit; payout records stay node-only. lwk_wasm exposes the same calls.

The pinned vectors are re-derived from the node's own PosRecordSignatureHash. lwk_wollet/tests/sequentia_stake_records.rs drives a regtest node: a bond, a delegation created from the controller's coin, a re-point, a reclaim, a payout announcement, an unbond and a claim each confirm in a block, from block one and across a fork at a chosen height; the old signing, an unauthorised record and a premature claim are refused by testmempoolaccept and in a block.

Sequentia Core 25.2.1 changes stake records at pos_records_v2_height
(163,000 on the testnet, block 1 on every new chain): a spend of a
staking, unbonding, delegation or payout output signs the segwit-v0
hash over the record script, committing to the amount, in a canonical
scriptSig, and the legacy signature is refused. From the same height a
delegation record must be created by a transaction spending a coin of
its controller. The kit signed every record spend the legacy way and
created records from wallet coins alone, so every wallet on it would
stop being able to leave or join a pool at the fork.

- sequentia_stake_records: StakeRecordSigning chooses the signature
  for the block after the wallet's tip; pos_records_v2_height() carries
  the fork height per network, since no node RPC reports it, and binds
  the testnet's to its whole definition, genesis hash included.
- Delegation spends sign accordingly (DelegationSpendPlan.signing).
  Records are created from a P2WPKH coin of the controller that the
  wallet pays first (TxBuilder::add_record_authorization, then
  build_delegation_create_tx); both are mined together.
- Unbonding in two steps (build_unbond_tx, build_unbond_claim_tx),
  which no wallet on the kit could do at all: a bonded stake had no way
  out but the node wallet.
- lwk_wasm exposes the same: buildDelegationCreateTx,
  addRecordAuthorization, buildUnbondTx, buildUnbondClaimTx,
  stakeRecordSigning; buildDelegationSpendTx takes tipHeight (defaulting
  to locktime, as wallets already pass) and refuses to guess without it.

Pinned vectors are derived with the node's own test framework
(PosRecordSignatureHash, RFC 6979), and must match byte for byte.
tests/sequentia_stake_records.rs has a proof-of-stake sequentiad
confirm a bond, a delegation, a re-point, a reclaim, a payout
announcement and withdrawal and both unbonding steps under default
relay policy, on both sides of the fork height; each wrong case is
refused by the mempool and by a block that accepts the right one, and
the wasm bindings must rebuild every confirmed transaction exactly.
@GracedEternalKingCabbageMan
GracedEternalKingCabbageMan merged commit b1a0618 into sequentia Oct 7, 2026
12 of 20 checks passed
@GracedEternalKingCabbageMan
GracedEternalKingCabbageMan deleted the feature/stake-records-v2 branch October 7, 2026 17: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