Repository navigation
wollet: sign stake records for the chain's height - #34
Merged
Merged
Conversation
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.
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.
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_heightis 163,000 for the testnet network (genesis-bound) and 1 elsewhere, since no node RPC reports it.sign_stake_record_inputsigns either way;StakeRecordSigning::for_next_blockpicks. A delegation is created withadd_record_authorization(a payment to the controller's key) followed bybuild_delegation_create_txfrom that coin. Two-step unbonding (build_unbond_tx,build_unbond_claim_tx) is new to the kit; payout records stay node-only.lwk_wasmexposes the same calls.The pinned vectors are re-derived from the node's own
PosRecordSignatureHash.lwk_wollet/tests/sequentia_stake_records.rsdrives 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 bytestmempoolacceptand in a block.