Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/L-02-unlock-height.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove the faulty `reward-cycle-to-unlock-height` from pox-5.
1 change: 1 addition & 0 deletions changelog.d/l1-bond-integration.added
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Complete L1 bitcoin staking integration tests, including both normal exit after the timelock expires, and early exit.
16 changes: 8 additions & 8 deletions contrib/core-contract-tests/tests/clarigen-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4805,7 +4805,7 @@ export const contracts = {
{ name: 'target-rate', type: 'uint128' },
{ name: 'stx-value-ratio', type: 'uint128' },
{ name: 'min-ustx-ratio', type: 'uint128' },
{ name: 'early-unlock-signers', type: { buffer: { length: 683 } } },
{ name: 'early-unlock-bytes', type: { buffer: { length: 683 } } },
{ name: 'early-unlock-admin', type: 'principal' },
{
name: 'allowlist',
Expand All @@ -4829,7 +4829,7 @@ export const contracts = {
tuple: [
{ name: 'bond-index', type: 'uint128' },
{
name: 'early-unlock-signers',
name: 'early-unlock-bytes',
type: { buffer: { length: 683 } },
},
{ name: 'max-allocation-sats', type: 'uint128' },
Expand All @@ -4848,7 +4848,7 @@ export const contracts = {
targetRate: TypedAbiArg<number | bigint, 'targetRate'>,
stxValueRatio: TypedAbiArg<number | bigint, 'stxValueRatio'>,
minUstxRatio: TypedAbiArg<number | bigint, 'minUstxRatio'>,
earlyUnlockSigners: TypedAbiArg<Uint8Array, 'earlyUnlockSigners'>,
earlyUnlockBytes: TypedAbiArg<Uint8Array, 'earlyUnlockBytes'>,
earlyUnlockAdmin: TypedAbiArg<string, 'earlyUnlockAdmin'>,
allowlist: TypedAbiArg<
{
Expand All @@ -4861,7 +4861,7 @@ export const contracts = {
Response<
{
bondIndex: bigint;
earlyUnlockSigners: Uint8Array;
earlyUnlockBytes: Uint8Array;
maxAllocationSats: bigint;
minUstxRatio: bigint;
stxValueRatio: bigint;
Expand Down Expand Up @@ -5352,7 +5352,7 @@ export const contracts = {
tuple: [
{ name: 'early-unlock-admin', type: 'principal' },
{
name: 'early-unlock-signers',
name: 'early-unlock-bytes',
type: { buffer: { length: 683 } },
},
{ name: 'min-ustx-ratio', type: 'uint128' },
Expand All @@ -5366,7 +5366,7 @@ export const contracts = {
[bondIndex: TypedAbiArg<number | bigint, 'bondIndex'>],
{
earlyUnlockAdmin: string;
earlyUnlockSigners: Uint8Array;
earlyUnlockBytes: Uint8Array;
minUstxRatio: bigint;
stxValueRatio: bigint;
targetRate: bigint;
Expand Down Expand Up @@ -6039,7 +6039,7 @@ export const contracts = {
value: {
tuple: [
{ name: 'early-unlock-admin', type: 'principal' },
{ name: 'early-unlock-signers', type: { buffer: { length: 683 } } },
{ name: 'early-unlock-bytes', type: { buffer: { length: 683 } } },
{ name: 'min-ustx-ratio', type: 'uint128' },
{ name: 'stx-value-ratio', type: 'uint128' },
{ name: 'target-rate', type: 'uint128' },
Expand All @@ -6049,7 +6049,7 @@ export const contracts = {
number | bigint,
{
earlyUnlockAdmin: string;
earlyUnlockSigners: Uint8Array;
earlyUnlockBytes: Uint8Array;
minUstxRatio: bigint;
stxValueRatio: bigint;
targetRate: bigint;
Expand Down
18 changes: 14 additions & 4 deletions contrib/core-contract-tests/tests/pox-5/pox-5-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
import { accounts, project } from '../clarigen-types';
import { rov, rovOk, txOk } from '@clarigen/test';
import { sha256 } from '@noble/hashes/sha2.js';
import { concatBytes } from '@noble/hashes/utils.js';
import { secp256k1 } from '@noble/curves/secp256k1.js';
import { expect } from 'vitest';

Expand Down Expand Up @@ -55,20 +56,29 @@ export function serializeLockupScript({
unlockBytes: Uint8Array;
earlyUnlockBytes: Uint8Array;
}) {
// `unlockBytes` and `earlyUnlockBytes` are caller-supplied Bitcoin
// subscripts (e.g. `<pubkey> OP_CHECKSIG`) that the contract splices
// in raw — they must NOT go through `Script.encode` as Uint8Array
// elements, which would wrap them in an OP_PUSHBYTES_N push.
const stackerEncoded = serializeCV(principalCV(stacker));
return BTC.Script.encode([
const prefix = BTC.Script.encode([
hex.decode(stackerEncoded),
'DROP',
'IF',
Number(unlockBurnHeight),
'CHECKLOCKTIMEVERIFY',
'DROP',
]);
const OP_ELSE = new Uint8Array([0x67]);
const OP_ENDIF = new Uint8Array([0x68]);
return concatBytes(
prefix,
unlockBytes,
'ELSE',
OP_ELSE,
earlyUnlockBytes,
unlockBytes,
'ENDIF',
]);
OP_ENDIF,
);
}

/**
Expand Down
Loading
Loading