@secondlayer/stacks 4.1.0 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/shared/stacks-03vfm21t.cjs +222 -0
- package/dist/shared/stacks-03vfm21t.cjs.map +12 -0
- package/dist/shared/stacks-0eatsx6d.cjs +25 -0
- package/dist/shared/stacks-0eatsx6d.cjs.map +10 -0
- package/dist/shared/stacks-1arrcd11.js.map +2 -2
- package/dist/shared/{stacks-mrk6tkkh.cjs → stacks-3mt2q2na.cjs} +26 -2
- package/dist/shared/{stacks-mrk6tkkh.cjs.map → stacks-3mt2q2na.cjs.map} +1 -1
- package/dist/shared/{stacks-bw8qvqd1.js → stacks-7wkf2rph.js} +3 -15
- package/dist/shared/{stacks-bw8qvqd1.js.map → stacks-7wkf2rph.js.map} +3 -4
- package/dist/shared/stacks-8pfdscq6.js +52 -0
- package/dist/shared/stacks-8pfdscq6.js.map +12 -0
- package/dist/shared/stacks-e4xn4m7j.js +27 -0
- package/dist/shared/stacks-e4xn4m7j.js.map +10 -0
- package/dist/shared/stacks-enpj9krt.cjs.map +2 -2
- package/dist/shared/{stacks-9qcr921s.cjs → stacks-kem68d80.cjs} +3 -3
- package/dist/shared/stacks-kem68d80.cjs.map +10 -0
- package/dist/shared/stacks-wdp5yr8n.cjs +39 -0
- package/dist/shared/stacks-wdp5yr8n.cjs.map +12 -0
- package/dist/shared/{stacks-y4f7fm03.cjs → stacks-ycbq8pf7.cjs} +2 -14
- package/dist/shared/{stacks-y4f7fm03.cjs.map → stacks-ycbq8pf7.cjs.map} +3 -4
- package/dist/shared/{stacks-rpqtgpyj.js → stacks-zcpvzbr0.js} +3 -3
- package/dist/shared/stacks-zcpvzbr0.js.map +10 -0
- package/dist/shared/stacks-ztzygy90.js +237 -0
- package/dist/shared/stacks-ztzygy90.js.map +12 -0
- package/dist/src/actions/index.cjs +2 -1
- package/dist/src/actions/index.cjs.map +1 -1
- package/dist/src/actions/index.d.cts +6 -1
- package/dist/src/actions/index.d.ts +6 -1
- package/dist/src/actions/index.js +6 -4
- package/dist/src/actions/index.js.map +1 -1
- package/dist/src/bitcoin/index.cjs +1 -217
- package/dist/src/bitcoin/index.cjs.map +3 -5
- package/dist/src/bitcoin/index.js +11 -223
- package/dist/src/bitcoin/index.js.map +3 -5
- package/dist/src/bns/index.js +1 -1
- package/dist/src/clarity/index.d.cts +1 -1
- package/dist/src/clarity/index.d.ts +1 -1
- package/dist/src/index.cjs +2 -1
- package/dist/src/index.cjs.map +3 -3
- package/dist/src/index.d.cts +5 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.js +6 -4
- package/dist/src/index.js.map +3 -3
- package/dist/src/postconditions/index.d.cts +3 -2
- package/dist/src/postconditions/index.d.ts +3 -2
- package/dist/src/postconditions/index.js +1 -1
- package/dist/src/pox/index.cjs +1 -24
- package/dist/src/pox/index.cjs.map +3 -4
- package/dist/src/pox/index.js +8 -25
- package/dist/src/pox/index.js.map +3 -4
- package/dist/src/pox5/index.cjs +1118 -204
- package/dist/src/pox5/index.cjs.map +13 -8
- package/dist/src/pox5/index.d.cts +618 -162
- package/dist/src/pox5/index.d.ts +618 -162
- package/dist/src/pox5/index.js +1136 -208
- package/dist/src/pox5/index.js.map +13 -8
- package/dist/src/stackingdao/index.js +1 -1
- package/dist/src/tools/index.cjs +13 -1
- package/dist/src/tools/index.cjs.map +6 -5
- package/dist/src/tools/index.js +13 -1
- package/dist/src/tools/index.js.map +6 -5
- package/package.json +4 -3
- package/dist/shared/stacks-2evvn48s.js +0 -22
- package/dist/shared/stacks-2evvn48s.js.map +0 -10
- package/dist/shared/stacks-3kj51c6p.cjs +0 -16
- package/dist/shared/stacks-3kj51c6p.cjs.map +0 -10
- package/dist/shared/stacks-9qcr921s.cjs.map +0 -10
- package/dist/shared/stacks-rdgg7mj3.js +0 -7
- package/dist/shared/stacks-rdgg7mj3.js.map +0 -10
- package/dist/shared/stacks-rpqtgpyj.js.map +0 -10
- package/dist/shared/stacks-wscmfs7q.cjs +0 -5
- package/dist/shared/stacks-wscmfs7q.cjs.map +0 -10
package/dist/src/pox5/index.d.ts
CHANGED
|
@@ -350,167 +350,6 @@ declare const C_SCRIPT_NUM_MAX = 549755813888n;
|
|
|
350
350
|
* commit a height Bitcoin would reinterpret.
|
|
351
351
|
*/
|
|
352
352
|
declare const BITCOIN_LOCKTIME_THRESHOLD = 500000000n;
|
|
353
|
-
/**
|
|
354
|
-
* Pure cycle/height math, mirroring the pox-5 helper read-onlys byte-for-byte
|
|
355
|
-
* (`burn-height-to-reward-cycle`, `reward-cycle-to-burn-height`,
|
|
356
|
-
* `bond-period-to-reward-cycle`, `burn-height-to-distribution-index`).
|
|
357
|
-
*
|
|
358
|
-
* All functions anchor on chain-reported parameters — pass values from
|
|
359
|
-
* `/v2/pox` (`first_burnchain_block_height`, `reward_cycle_length`,
|
|
360
|
-
* `prepare_cycle_length`) and `getPox5Activation` (`firstRewardCycleId` =
|
|
361
|
-
* the contract's `first-bond-period-cycle`). Nothing is hardcoded, so the
|
|
362
|
-
* math is correct on mainnet, testnet, and devnet alike.
|
|
363
|
-
*/
|
|
364
|
-
type PoxCycleParams = {
|
|
365
|
-
/** `/v2/pox` `first_burnchain_block_height`. */
|
|
366
|
-
firstBurnchainBlockHeight: number
|
|
367
|
-
/** `/v2/pox` `reward_cycle_length` (mainnet 2100). */
|
|
368
|
-
rewardCycleLength: number
|
|
369
|
-
};
|
|
370
|
-
type BondCycleParams = PoxCycleParams & {
|
|
371
|
-
/** pox-5's first bond-period cycle (`getPox5Activation().firstRewardCycleId`). */
|
|
372
|
-
firstBondPeriodCycle: number
|
|
373
|
-
};
|
|
374
|
-
/** Reward cycle containing `burnHeight`. Mirrors `burn-height-to-reward-cycle`. */
|
|
375
|
-
declare function burnHeightToRewardCycle(burnHeight: number, params: PoxCycleParams): number;
|
|
376
|
-
/** Burn height at the start of `cycle`. Mirrors `reward-cycle-to-burn-height`. */
|
|
377
|
-
declare function rewardCycleToBurnHeight(cycle: number, params: PoxCycleParams): number;
|
|
378
|
-
/** Reward cycle at which bond period `bondIndex` starts. Mirrors `bond-period-to-reward-cycle`. */
|
|
379
|
-
declare function bondPeriodToRewardCycle(bondIndex: number, params: BondCycleParams): number;
|
|
380
|
-
/** Burn height at which bond period `bondIndex` starts. Mirrors `bond-period-to-burn-height`. */
|
|
381
|
-
declare function bondPeriodToBurnHeight(bondIndex: number, params: BondCycleParams): number;
|
|
382
|
-
/** First reward cycle in which bond `bondIndex`'s STX unlock (start + 12 cycles). */
|
|
383
|
-
declare function bondUnlockCycle(bondIndex: number, params: BondCycleParams): number;
|
|
384
|
-
/**
|
|
385
|
-
* Distribution-cycle index at `burnHeight` — distribution cycles are half a
|
|
386
|
-
* reward cycle long. Mirrors `burn-height-to-distribution-index`.
|
|
387
|
-
*/
|
|
388
|
-
declare function burnHeightToDistributionIndex(burnHeight: number, params: PoxCycleParams): number;
|
|
389
|
-
/**
|
|
390
|
-
* Whether `burnHeight` falls in a cycle's prepare phase (the final
|
|
391
|
-
* `prepareCycleLength` blocks). pox-5 rejects `unstake-sbtc` and
|
|
392
|
-
* `announce-l1-early-exit` during a prepare phase.
|
|
393
|
-
*/
|
|
394
|
-
declare function isInPreparePhase(burnHeight: number, params: PoxCycleParams & {
|
|
395
|
-
prepareCycleLength: number
|
|
396
|
-
}): boolean;
|
|
397
|
-
type BondPhase = "too-early" | "open" | "locked" | "unlocked";
|
|
398
|
-
/**
|
|
399
|
-
* Coarse lifecycle phase of bond `bondIndex` at `burnHeight`: `too-early`
|
|
400
|
-
* (before the bond's start is registerable), `open`/`locked` while active,
|
|
401
|
-
* `unlocked` after 12 cycles.
|
|
402
|
-
*/
|
|
403
|
-
declare function bondPhaseAtHeight(bondIndex: number, burnHeight: number, params: BondCycleParams): BondPhase;
|
|
404
|
-
type BitcoinNetwork = "mainnet" | "testnet" | "regtest";
|
|
405
|
-
/**
|
|
406
|
-
* Byte-for-byte TypeScript mirrors of pox-5's Bitcoin-script helpers
|
|
407
|
-
* (`serialize-c-script-num`, `push-c-script-num`, `push-script-bytes`,
|
|
408
|
-
* `construct-lockup-script`, `construct-lockup-output-script`), pinned
|
|
409
|
-
* against the final contract in stacks-core 4.0.1. The contract validates a
|
|
410
|
-
* staker's L1 lockup output against exactly these bytes, so any divergence
|
|
411
|
-
* means a rejected registration — the read-onlys on-chain double as a
|
|
412
|
-
* cross-check oracle for these functions.
|
|
413
|
-
*/
|
|
414
|
-
/**
|
|
415
|
-
* Minimal little-endian ScriptNum encoding of a non-negative integer
|
|
416
|
-
* (`0` → empty; a `0x00` sign byte is appended when the top byte's high bit
|
|
417
|
-
* is set). Mirrors `serialize-c-script-num`, including its 2^39 ceiling.
|
|
418
|
-
*/
|
|
419
|
-
declare function serializeCScriptNum(n: number | bigint): Uint8Array;
|
|
420
|
-
/**
|
|
421
|
-
* Push arbitrary bytes onto a Bitcoin script: direct length byte under 76,
|
|
422
|
-
* `OP_PUSHDATA1` under 256, `OP_PUSHDATA2` otherwise. Mirrors
|
|
423
|
-
* `push-script-bytes`.
|
|
424
|
-
*/
|
|
425
|
-
declare function pushScriptBytes(bytes: Uint8Array): Uint8Array;
|
|
426
|
-
/**
|
|
427
|
-
* Push a numeric script value: `OP_0` for zero, the single-byte ops
|
|
428
|
-
* `OP_1`..`OP_16` for 1–16, else a minimal ScriptNum push. Mirrors
|
|
429
|
-
* `push-c-script-num`.
|
|
430
|
-
*/
|
|
431
|
-
declare function pushCScriptNum(n: number | bigint): Uint8Array;
|
|
432
|
-
/** `to-consensus-buff?` of a principal — the staker identity the script commits to. */
|
|
433
|
-
declare function stakerConsensusBuff(stxAddress: string): Uint8Array;
|
|
434
|
-
/**
|
|
435
|
-
* The 32-byte witness item the early-exit branch must reveal:
|
|
436
|
-
* `sha256(to-consensus-buff? staker)`. The script stores `sha256` of THIS,
|
|
437
|
-
* so revealing it proves which staker the exit is for.
|
|
438
|
-
*/
|
|
439
|
-
declare function stakerPreimage(stxAddress: string): Uint8Array;
|
|
440
|
-
type BuildLockupScriptOptions = {
|
|
441
|
-
/** Staker principal (standard or contract address). */
|
|
442
|
-
stxAddress: string
|
|
443
|
-
/** Burn height at which the CLTV branch becomes spendable. */
|
|
444
|
-
unlockBurnHeight: number | bigint
|
|
445
|
-
/** Staker-signature subscript, run last in BOTH branches. */
|
|
446
|
-
stakerUnlockBytes: Uint8Array | string
|
|
447
|
-
/** Per-bond early-unlock subscript (from `protocol-bonds.early-unlock-bytes`). */
|
|
448
|
-
earlyUnlockBytes: Uint8Array | string
|
|
449
|
-
};
|
|
450
|
-
/**
|
|
451
|
-
* The L1 lockup witness script. Mirrors `construct-lockup-script`:
|
|
452
|
-
*
|
|
453
|
-
* ```
|
|
454
|
-
* OP_IF
|
|
455
|
-
* <unlockBurnHeight> OP_CHECKLOCKTIMEVERIFY
|
|
456
|
-
* OP_ELSE
|
|
457
|
-
* OP_SIZE <32> OP_EQUALVERIFY OP_SHA256
|
|
458
|
-
* <sha256(sha256(consensus-buff(staker)))> OP_EQUALVERIFY
|
|
459
|
-
* <earlyUnlockBytes>
|
|
460
|
-
* OP_ENDIF
|
|
461
|
-
* OP_VERIFY
|
|
462
|
-
* <stakerUnlockBytes>
|
|
463
|
-
* ```
|
|
464
|
-
*/
|
|
465
|
-
declare function buildLockupScript(opts: BuildLockupScriptOptions): Uint8Array;
|
|
466
|
-
/**
|
|
467
|
-
* P2WSH `scriptPubKey` for a lockup script: `0x0020 || sha256(script)`.
|
|
468
|
-
* Mirrors `construct-lockup-output-script`.
|
|
469
|
-
*/
|
|
470
|
-
declare function buildLockupOutputScript(opts: BuildLockupScriptOptions): Uint8Array;
|
|
471
|
-
/** The bech32 P2WSH address a staker sends their L1 BTC lockup to. */
|
|
472
|
-
declare function buildLockupAddress(opts: BuildLockupScriptOptions, network?: BitcoinNetwork): string;
|
|
473
|
-
/**
|
|
474
|
-
* The default staker subscript: `<pubkey> OP_CHECKSIG` — spendable by one
|
|
475
|
-
* key. Any script tail is valid as far as the contract is concerned; this is
|
|
476
|
-
* the common case.
|
|
477
|
-
*/
|
|
478
|
-
declare function buildDefaultStakerUnlockBytes(publicKey: Uint8Array | string): Uint8Array;
|
|
479
|
-
/**
|
|
480
|
-
* PoX-5 signer-key grants: SIP-018 structured-data signatures authorizing a
|
|
481
|
-
* signer-manager contract to use a signer key. Mirrors
|
|
482
|
-
* `pox-5.get-signer-grant-message-hash` — domain `pox-5-signer/1.0.0`,
|
|
483
|
-
* message `{ topic: "grant-authorization", signer-manager, auth-id }`.
|
|
484
|
-
*/
|
|
485
|
-
type SignerGrantOptions = {
|
|
486
|
-
/** The signer-manager contract principal being authorized. */
|
|
487
|
-
signerManager: string
|
|
488
|
-
/** Replay-protection id, chosen by the signer. */
|
|
489
|
-
authId: bigint | number
|
|
490
|
-
/** Stacks chain id (`mainnet.id` / `testnet.id`). */
|
|
491
|
-
chainId: number
|
|
492
|
-
};
|
|
493
|
-
/**
|
|
494
|
-
* The 32-byte hash a signer signs to grant their key — byte-identical to the
|
|
495
|
-
* contract's `get-signer-grant-message-hash` read-only (which doubles as an
|
|
496
|
-
* on-chain cross-check).
|
|
497
|
-
*/
|
|
498
|
-
declare function computeSignerGrantHash(opts: SignerGrantOptions): Uint8Array;
|
|
499
|
-
/**
|
|
500
|
-
* Sign a signer-key grant. Returns the 65-byte recoverable signature in RSV
|
|
501
|
-
* order (recovery byte last), hex — the layout `grant-signer-key`'s
|
|
502
|
-
* `signer-sig (buff 65)` expects.
|
|
503
|
-
*/
|
|
504
|
-
declare function signSignerGrant(account: LocalAccount, opts: SignerGrantOptions): Promise<string>;
|
|
505
|
-
/**
|
|
506
|
-
* Verify a signer-key grant signature locally: recover the pubkey from the
|
|
507
|
-
* RSV signature over the grant hash and compare. Returns `false` for
|
|
508
|
-
* malformed input rather than throwing.
|
|
509
|
-
*/
|
|
510
|
-
declare function verifySignerGrant(opts: SignerGrantOptions & {
|
|
511
|
-
publicKey: Uint8Array | string
|
|
512
|
-
signature: Uint8Array | string
|
|
513
|
-
}): boolean;
|
|
514
353
|
type IntegerType = number | string | bigint | Uint8Array;
|
|
515
354
|
/**
|
|
516
355
|
* Named fee tiers. `'low' | 'mid' | 'high'` map to the node's three fee
|
|
@@ -713,6 +552,462 @@ type RevokeSignerGrantParams = TxOptions & {
|
|
|
713
552
|
signerManager: string
|
|
714
553
|
signerKey: Uint8Array | string
|
|
715
554
|
};
|
|
555
|
+
type SetBondAdminParams = TxOptions & {
|
|
556
|
+
newAdmin: string
|
|
557
|
+
};
|
|
558
|
+
type SetPauseAdminParams = TxOptions & {
|
|
559
|
+
newAdmin: string
|
|
560
|
+
};
|
|
561
|
+
type PauseRewardsParams = TxOptions;
|
|
562
|
+
type EligibilityResult = {
|
|
563
|
+
ok: true
|
|
564
|
+
} | {
|
|
565
|
+
ok: false
|
|
566
|
+
reasons: [Pox5ErrorCode, ...Pox5ErrorCode[]]
|
|
567
|
+
};
|
|
568
|
+
type EligibleStakeParams = {
|
|
569
|
+
staker: string
|
|
570
|
+
signerManager: string
|
|
571
|
+
amountUstx: IntegerType
|
|
572
|
+
numCycles: IntegerType
|
|
573
|
+
startBurnHeight: IntegerType
|
|
574
|
+
};
|
|
575
|
+
type EligibleRegisterForBondParams = {
|
|
576
|
+
staker: string
|
|
577
|
+
bondIndex: IntegerType
|
|
578
|
+
signerManager: string
|
|
579
|
+
amountUstx: IntegerType
|
|
580
|
+
btcLockup: BtcLockup
|
|
581
|
+
};
|
|
582
|
+
type EligibleUnstakeParams = {
|
|
583
|
+
staker: string
|
|
584
|
+
oldSignerManager: string
|
|
585
|
+
};
|
|
586
|
+
type EligibleUnstakeSbtcParams = {
|
|
587
|
+
staker: string
|
|
588
|
+
signerManager: string
|
|
589
|
+
amountSats: IntegerType
|
|
590
|
+
};
|
|
591
|
+
type EligibleClaimRewardsParams = {
|
|
592
|
+
signer: string
|
|
593
|
+
rewardCycle: IntegerType
|
|
594
|
+
bondIndex?: IntegerType
|
|
595
|
+
bondPeriods?: IntegerType[]
|
|
596
|
+
};
|
|
597
|
+
type EligibleGrantSignerKeyParams = {
|
|
598
|
+
signerKey: Uint8Array | string
|
|
599
|
+
signerManager: string
|
|
600
|
+
authId: IntegerType
|
|
601
|
+
};
|
|
602
|
+
type EligibleAdminParams = {
|
|
603
|
+
caller: string
|
|
604
|
+
};
|
|
605
|
+
declare function eligibleStake2(client: Client, params: EligibleStakeParams): Promise<EligibilityResult>;
|
|
606
|
+
declare function eligibleRegisterForBond2(client: Client, params: EligibleRegisterForBondParams): Promise<EligibilityResult>;
|
|
607
|
+
declare function eligibleUnstake2(client: Client, params: EligibleUnstakeParams): Promise<EligibilityResult>;
|
|
608
|
+
declare function eligibleUnstakeSbtc2(client: Client, params: EligibleUnstakeSbtcParams): Promise<EligibilityResult>;
|
|
609
|
+
declare function eligibleClaimRewards2(client: Client, params: EligibleClaimRewardsParams): Promise<EligibilityResult>;
|
|
610
|
+
declare function eligibleGrantSignerKey2(client: Client, params: EligibleGrantSignerKeyParams): Promise<EligibilityResult>;
|
|
611
|
+
declare function eligibleSetBondAdmin2(client: Client, params: EligibleAdminParams): Promise<EligibilityResult>;
|
|
612
|
+
declare function eligiblePauseRewards2(client: Client, params: EligibleAdminParams): Promise<EligibilityResult>;
|
|
613
|
+
/**
|
|
614
|
+
* Pure cycle/height math, mirroring the pox-5 helper read-onlys byte-for-byte
|
|
615
|
+
* (`burn-height-to-reward-cycle`, `reward-cycle-to-burn-height`,
|
|
616
|
+
* `bond-period-to-reward-cycle`, `burn-height-to-distribution-index`).
|
|
617
|
+
*
|
|
618
|
+
* All functions anchor on chain-reported parameters — pass values from
|
|
619
|
+
* `/v2/pox` (`first_burnchain_block_height`, `reward_cycle_length`,
|
|
620
|
+
* `prepare_cycle_length`) and `getPox5Activation` (`firstRewardCycleId` =
|
|
621
|
+
* the contract's `first-bond-period-cycle`). Nothing is hardcoded, so the
|
|
622
|
+
* math is correct on mainnet, testnet, and devnet alike.
|
|
623
|
+
*/
|
|
624
|
+
type PoxCycleParams = {
|
|
625
|
+
/** `/v2/pox` `first_burnchain_block_height`. */
|
|
626
|
+
firstBurnchainBlockHeight: number
|
|
627
|
+
/** `/v2/pox` `reward_cycle_length` (mainnet 2100). */
|
|
628
|
+
rewardCycleLength: number
|
|
629
|
+
};
|
|
630
|
+
type BondCycleParams = PoxCycleParams & {
|
|
631
|
+
/** pox-5's first bond-period cycle (`getPox5Activation().firstRewardCycleId`). */
|
|
632
|
+
firstBondPeriodCycle: number
|
|
633
|
+
};
|
|
634
|
+
/** Reward cycle containing `burnHeight`. Mirrors `burn-height-to-reward-cycle`. */
|
|
635
|
+
declare function burnHeightToRewardCycle(burnHeight: number, params: PoxCycleParams): number;
|
|
636
|
+
/** Burn height at the start of `cycle`. Mirrors `reward-cycle-to-burn-height`. */
|
|
637
|
+
declare function rewardCycleToBurnHeight(cycle: number, params: PoxCycleParams): number;
|
|
638
|
+
/** Reward cycle at which bond period `bondIndex` starts. Mirrors `bond-period-to-reward-cycle`. */
|
|
639
|
+
declare function bondPeriodToRewardCycle(bondIndex: number, params: BondCycleParams): number;
|
|
640
|
+
/** Burn height at which bond period `bondIndex` starts. Mirrors `bond-period-to-burn-height`. */
|
|
641
|
+
declare function bondPeriodToBurnHeight(bondIndex: number, params: BondCycleParams): number;
|
|
642
|
+
/** First reward cycle in which bond `bondIndex`'s STX unlock (start + 12 cycles). */
|
|
643
|
+
declare function bondUnlockCycle(bondIndex: number, params: BondCycleParams): number;
|
|
644
|
+
/**
|
|
645
|
+
* Minimum L1 CLTV height for bond `bondIndex` — half a cycle before the
|
|
646
|
+
* bond period ends. Mirrors `get-bond-l1-unlock-height`. Distinct from
|
|
647
|
+
* {@link bondUnlockCycle} (the STX unlock cycle).
|
|
648
|
+
*/
|
|
649
|
+
declare function computeBondUnlockHeight(bondIndex: number, params: BondCycleParams): number;
|
|
650
|
+
/**
|
|
651
|
+
* Distribution-cycle index at `burnHeight` — distribution cycles are half a
|
|
652
|
+
* reward cycle long. Mirrors `burn-height-to-distribution-index`.
|
|
653
|
+
*/
|
|
654
|
+
declare function burnHeightToDistributionIndex(burnHeight: number, params: PoxCycleParams): number;
|
|
655
|
+
/** Burn height at the start of `distIndex`. Mirrors `distribution-cycle-to-burn-height`. */
|
|
656
|
+
declare function distributionCycleToBurnHeight(distIndex: number, params: PoxCycleParams): number;
|
|
657
|
+
/**
|
|
658
|
+
* Distribution cycle containing `burnHeight`. Named after the contract's
|
|
659
|
+
* `current-distribution-cycle` but takes height as an argument — no clock.
|
|
660
|
+
*/
|
|
661
|
+
declare function currentDistributionCycle(burnHeight: number, params: PoxCycleParams): number;
|
|
662
|
+
/**
|
|
663
|
+
* Whether `burnHeight` falls in a cycle's prepare phase (the final
|
|
664
|
+
* `prepareCycleLength` blocks). pox-5 rejects `unstake-sbtc` and
|
|
665
|
+
* `announce-l1-early-exit` during a prepare phase.
|
|
666
|
+
*/
|
|
667
|
+
declare function isInPreparePhase(burnHeight: number, params: PoxCycleParams & {
|
|
668
|
+
prepareCycleLength: number
|
|
669
|
+
}): boolean;
|
|
670
|
+
type BondPhase = "too-early" | "open" | "locked" | "unlocked";
|
|
671
|
+
/**
|
|
672
|
+
* Coarse lifecycle phase of bond `bondIndex` at `burnHeight`: `too-early`
|
|
673
|
+
* (before the bond's start is registerable), `open`/`locked` while active,
|
|
674
|
+
* `unlocked` after 12 cycles.
|
|
675
|
+
*/
|
|
676
|
+
declare function bondPhaseAtHeight(bondIndex: number, burnHeight: number, params: BondCycleParams): BondPhase;
|
|
677
|
+
/**
|
|
678
|
+
* Prepare-aware bond lifecycle. `open` is the registerable window — it
|
|
679
|
+
* ends when the start cycle's prepare phase begins (`register-for-bond`
|
|
680
|
+
* then fails with `ERR_STAKE_IN_PREPARE_PHASE`). Coarse cycle buckets
|
|
681
|
+
* (whole pre-start cycle as `open`) stay on {@link BondPhase}.
|
|
682
|
+
*
|
|
683
|
+
* `eligible`/`missed`/`finished` are omitted: they are not contract
|
|
684
|
+
* states (registration is height-gated, not a per-staker enum).
|
|
685
|
+
*/
|
|
686
|
+
type BondStatusName = "too-early" | "open" | "locked" | "unlocked";
|
|
687
|
+
declare function bondStatusAtHeight(bondIndex: number, burnHeight: number, params: BondCycleParams & {
|
|
688
|
+
prepareCycleLength: number
|
|
689
|
+
}): BondStatusName;
|
|
690
|
+
type BitcoinNetwork = "mainnet" | "testnet" | "regtest";
|
|
691
|
+
/**
|
|
692
|
+
* Byte-for-byte TypeScript mirrors of pox-5's Bitcoin-script helpers
|
|
693
|
+
* (`serialize-c-script-num`, `push-c-script-num`, `push-script-bytes`,
|
|
694
|
+
* `construct-lockup-script`, `construct-lockup-output-script`), pinned
|
|
695
|
+
* against the final contract in stacks-core 4.0.1. The contract validates a
|
|
696
|
+
* staker's L1 lockup output against exactly these bytes, so any divergence
|
|
697
|
+
* means a rejected registration — the read-onlys on-chain double as a
|
|
698
|
+
* cross-check oracle for these functions.
|
|
699
|
+
*/
|
|
700
|
+
/**
|
|
701
|
+
* Minimal little-endian ScriptNum encoding of a non-negative integer
|
|
702
|
+
* (`0` → empty; a `0x00` sign byte is appended when the top byte's high bit
|
|
703
|
+
* is set). Mirrors `serialize-c-script-num`, including its 2^39 ceiling.
|
|
704
|
+
*/
|
|
705
|
+
declare function serializeCScriptNum(n: number | bigint): Uint8Array;
|
|
706
|
+
/**
|
|
707
|
+
* Push arbitrary bytes onto a Bitcoin script: direct length byte under 76,
|
|
708
|
+
* `OP_PUSHDATA1` under 256, `OP_PUSHDATA2` otherwise. Mirrors
|
|
709
|
+
* `push-script-bytes`.
|
|
710
|
+
*/
|
|
711
|
+
declare function pushScriptBytes(bytes: Uint8Array): Uint8Array;
|
|
712
|
+
/**
|
|
713
|
+
* Push a numeric script value: `OP_0` for zero, the single-byte ops
|
|
714
|
+
* `OP_1`..`OP_16` for 1–16, else a minimal ScriptNum push. Mirrors
|
|
715
|
+
* `push-c-script-num`.
|
|
716
|
+
*/
|
|
717
|
+
declare function pushCScriptNum(n: number | bigint): Uint8Array;
|
|
718
|
+
/** `to-consensus-buff?` of a principal — the staker identity the script commits to. */
|
|
719
|
+
declare function stakerConsensusBuff(stxAddress: string): Uint8Array;
|
|
720
|
+
/**
|
|
721
|
+
* The 32-byte witness item the early-exit branch must reveal:
|
|
722
|
+
* `sha256(to-consensus-buff? staker)`. The script stores `sha256` of THIS,
|
|
723
|
+
* so revealing it proves which staker the exit is for.
|
|
724
|
+
*/
|
|
725
|
+
declare function stakerPreimage(stxAddress: string): Uint8Array;
|
|
726
|
+
type BuildLockupScriptOptions = {
|
|
727
|
+
/** Staker principal (standard or contract address). */
|
|
728
|
+
stxAddress: string
|
|
729
|
+
/** Burn height at which the CLTV branch becomes spendable. */
|
|
730
|
+
unlockBurnHeight: number | bigint
|
|
731
|
+
/** Staker-signature subscript, run last in BOTH branches. */
|
|
732
|
+
stakerUnlockBytes: Uint8Array | string
|
|
733
|
+
/** Per-bond early-unlock subscript (from `protocol-bonds.early-unlock-bytes`). */
|
|
734
|
+
earlyUnlockBytes: Uint8Array | string
|
|
735
|
+
};
|
|
736
|
+
/**
|
|
737
|
+
* The L1 lockup witness script. Mirrors `construct-lockup-script`:
|
|
738
|
+
*
|
|
739
|
+
* ```
|
|
740
|
+
* OP_IF
|
|
741
|
+
* <unlockBurnHeight> OP_CHECKLOCKTIMEVERIFY
|
|
742
|
+
* OP_ELSE
|
|
743
|
+
* OP_SIZE <32> OP_EQUALVERIFY OP_SHA256
|
|
744
|
+
* <sha256(sha256(consensus-buff(staker)))> OP_EQUALVERIFY
|
|
745
|
+
* <earlyUnlockBytes>
|
|
746
|
+
* OP_ENDIF
|
|
747
|
+
* OP_VERIFY
|
|
748
|
+
* <stakerUnlockBytes>
|
|
749
|
+
* ```
|
|
750
|
+
*/
|
|
751
|
+
declare function buildLockupScript(opts: BuildLockupScriptOptions): Uint8Array;
|
|
752
|
+
/**
|
|
753
|
+
* P2WSH `scriptPubKey` for a lockup script: `0x0020 || sha256(script)`.
|
|
754
|
+
* Mirrors `construct-lockup-output-script`.
|
|
755
|
+
*/
|
|
756
|
+
declare function buildLockupOutputScript(opts: BuildLockupScriptOptions): Uint8Array;
|
|
757
|
+
/** The bech32 P2WSH address a staker sends their L1 BTC lockup to. */
|
|
758
|
+
declare function buildLockupAddress(opts: BuildLockupScriptOptions, network?: BitcoinNetwork): string;
|
|
759
|
+
/**
|
|
760
|
+
* The default staker subscript: `<pubkey> OP_CHECKSIG` — spendable by one
|
|
761
|
+
* key. Any script tail is valid as far as the contract is concerned; this is
|
|
762
|
+
* the common case.
|
|
763
|
+
*/
|
|
764
|
+
declare function buildDefaultStakerUnlockBytes(publicKey: Uint8Array | string): Uint8Array;
|
|
765
|
+
type RegisterMetadata = {
|
|
766
|
+
lockAddress: string
|
|
767
|
+
lockScript: Uint8Array
|
|
768
|
+
outputScript: Uint8Array
|
|
769
|
+
unlockBytes: Uint8Array
|
|
770
|
+
unlockHeight: number
|
|
771
|
+
};
|
|
772
|
+
/**
|
|
773
|
+
* One-call L1 register metadata: unlock height, staker subscript, lock
|
|
774
|
+
* script, P2WSH output, and address. Staker funds `lockAddress` then
|
|
775
|
+
* passes `lockScript` into the proof mapper.
|
|
776
|
+
*/
|
|
777
|
+
declare function buildRegisterMetadata(opts: {
|
|
778
|
+
bondIndex: number
|
|
779
|
+
stxAddress: string
|
|
780
|
+
bitcoinPublicKey: Uint8Array | string
|
|
781
|
+
earlyUnlockBytes: Uint8Array | string
|
|
782
|
+
network?: BitcoinNetwork
|
|
783
|
+
cycle: BondCycleParams
|
|
784
|
+
}): RegisterMetadata;
|
|
785
|
+
/**
|
|
786
|
+
* PoX-5 signer-key grants: SIP-018 structured-data signatures authorizing a
|
|
787
|
+
* signer-manager contract to use a signer key. Mirrors
|
|
788
|
+
* `pox-5.get-signer-grant-message-hash` — domain `pox-5-signer/1.0.0`,
|
|
789
|
+
* message `{ topic: "grant-authorization", signer-manager, auth-id }`.
|
|
790
|
+
*/
|
|
791
|
+
type SignerGrantOptions = {
|
|
792
|
+
/** The signer-manager contract principal being authorized. */
|
|
793
|
+
signerManager: string
|
|
794
|
+
/** Replay-protection id, chosen by the signer. */
|
|
795
|
+
authId: bigint | number
|
|
796
|
+
/** Stacks chain id (`mainnet.id` / `testnet.id`). */
|
|
797
|
+
chainId: number
|
|
798
|
+
};
|
|
799
|
+
/**
|
|
800
|
+
* The 32-byte hash a signer signs to grant their key — byte-identical to the
|
|
801
|
+
* contract's `get-signer-grant-message-hash` read-only (which doubles as an
|
|
802
|
+
* on-chain cross-check).
|
|
803
|
+
*/
|
|
804
|
+
declare function computeSignerGrantHash(opts: SignerGrantOptions): Uint8Array;
|
|
805
|
+
/**
|
|
806
|
+
* Sign a signer-key grant. Returns the 65-byte recoverable signature in RSV
|
|
807
|
+
* order (recovery byte last), hex — the layout `grant-signer-key`'s
|
|
808
|
+
* `signer-sig (buff 65)` expects.
|
|
809
|
+
*/
|
|
810
|
+
declare function signSignerGrant(account: LocalAccount, opts: SignerGrantOptions): Promise<string>;
|
|
811
|
+
/**
|
|
812
|
+
* Verify a signer-key grant signature locally: recover the pubkey from the
|
|
813
|
+
* RSV signature over the grant hash and compare. Returns `false` for
|
|
814
|
+
* malformed input rather than throwing.
|
|
815
|
+
*/
|
|
816
|
+
declare function verifySignerGrant(opts: SignerGrantOptions & {
|
|
817
|
+
publicKey: Uint8Array | string
|
|
818
|
+
signature: Uint8Array | string
|
|
819
|
+
}): boolean;
|
|
820
|
+
/**
|
|
821
|
+
* A Bitcoin merkle inclusion proof, shaped for the SIP-044 `verify-merkle-proof`
|
|
822
|
+
* built-in: `(leaf-hash, root-hash, tx-index, tx-count, sibling-hashes)`.
|
|
823
|
+
*
|
|
824
|
+
* - `siblings` are the sibling node hashes from the leaf up to (excluding) the
|
|
825
|
+
* root, in *internal* byte order — never reversed.
|
|
826
|
+
* - `txCount` (not tree-depth) pins the canonical tree shape; the built-in
|
|
827
|
+
* rejects any proof whose length differs from `ceil(log2(tx-count))`.
|
|
828
|
+
*/
|
|
829
|
+
interface MerkleProof {
|
|
830
|
+
siblings: Uint8Array[];
|
|
831
|
+
txIndex: number;
|
|
832
|
+
txCount: number;
|
|
833
|
+
}
|
|
834
|
+
/**
|
|
835
|
+
* A self-contained Bitcoin SPV proof: everything the SIP-044 built-ins need to
|
|
836
|
+
* prove a tx (and one of its outputs) is committed in a confirmed block. Hashes
|
|
837
|
+
* are internal byte order throughout.
|
|
838
|
+
*/
|
|
839
|
+
interface SpvProof {
|
|
840
|
+
rawTx: Uint8Array;
|
|
841
|
+
/** The tx's txid, internal order — the merkle leaf. */
|
|
842
|
+
txidInternal: Uint8Array;
|
|
843
|
+
/** Output index of interest, if the proof targets a specific output. */
|
|
844
|
+
vout?: number;
|
|
845
|
+
merkle: MerkleProof;
|
|
846
|
+
/** The 80-byte block header that commits the tx. */
|
|
847
|
+
header: Uint8Array;
|
|
848
|
+
/** Bitcoin block height. */
|
|
849
|
+
height: number;
|
|
850
|
+
}
|
|
851
|
+
/** The block context a `ProofSource` resolves for a confirmed tx. */
|
|
852
|
+
interface BlockForTx {
|
|
853
|
+
/** 80-byte block header. */
|
|
854
|
+
header: Uint8Array;
|
|
855
|
+
height: number;
|
|
856
|
+
/** All of the block's txids, internal order, in block order. */
|
|
857
|
+
txidsInternal: Uint8Array[];
|
|
858
|
+
/** Index of the target tx within the block. */
|
|
859
|
+
txIndex: number;
|
|
860
|
+
}
|
|
861
|
+
/**
|
|
862
|
+
* Where proof inputs come from. The default is the integrator's own Bitcoin node
|
|
863
|
+
* (`bitcoinRpcSource`) — trustless; a hosted Esplora-compatible endpoint
|
|
864
|
+
* (`esploraSource`) is the fallback. `buildTxProof` independently re-checks
|
|
865
|
+
* whatever a source returns, so a wrong or hostile source fails loudly rather
|
|
866
|
+
* than producing a bad proof.
|
|
867
|
+
*/
|
|
868
|
+
interface ProofSource {
|
|
869
|
+
/** Raw (serialized) tx bytes for a txid (display-order hex). */
|
|
870
|
+
getRawTx(txid: string): Promise<Uint8Array>;
|
|
871
|
+
/** The confirming block's header, height, and txid set for a txid. */
|
|
872
|
+
getBlockForTx(txid: string): Promise<BlockForTx>;
|
|
873
|
+
}
|
|
874
|
+
/**
|
|
875
|
+
* Map a generic SIP-044 `SpvProof` onto pox-5's `L1LockupOutput`.
|
|
876
|
+
* Witness is stripped, the lockup vout is resolved against the P2WSH
|
|
877
|
+
* of `lockScript`, and more than {@link MAX_LEAF_HASHES} siblings throws.
|
|
878
|
+
*/
|
|
879
|
+
declare function spvProofToL1LockupOutput(opts: {
|
|
880
|
+
proof: SpvProof
|
|
881
|
+
/** Witness script; hashed to match the P2WSH lockup output. */
|
|
882
|
+
lockScript: Uint8Array
|
|
883
|
+
unlockBurnHeight: IntegerType
|
|
884
|
+
/** Default: `proof.vout`, else the unique matching output. */
|
|
885
|
+
vout?: number
|
|
886
|
+
}): L1LockupOutput;
|
|
887
|
+
/**
|
|
888
|
+
* Fetch a SIP-044 proof from `source` and map it onto pox-5's lockup shape.
|
|
889
|
+
* `source` is required — no hosted Esplora default.
|
|
890
|
+
*/
|
|
891
|
+
declare function buildPox5LockProof(opts: {
|
|
892
|
+
source: ProofSource
|
|
893
|
+
txid: string
|
|
894
|
+
lockScript: Uint8Array
|
|
895
|
+
unlockBurnHeight: IntegerType
|
|
896
|
+
vout?: number
|
|
897
|
+
}): Promise<L1LockupOutput>;
|
|
898
|
+
import * as btc from "@scure/btc-signer";
|
|
899
|
+
/**
|
|
900
|
+
* Spend a pox-5 P2WSH lockup back out.
|
|
901
|
+
*
|
|
902
|
+
* Two paths through the lockup script (mirror of `construct-lockup-script`):
|
|
903
|
+
* - `'locktime'` — CLTV exit (`OP_IF`), single-sig, spendable once the burn
|
|
904
|
+
* height is past the lock's unlock height.
|
|
905
|
+
* - `'early-exit'` — cosigned exit (`OP_ELSE`), 2-of-2 staker + bond cosigner.
|
|
906
|
+
* Valid only after `announce-l1-early-exit` on Stacks; this helper spends the
|
|
907
|
+
* UTXO and does not announce.
|
|
908
|
+
*/
|
|
909
|
+
type ReclaimPath = "locktime" | "early-exit";
|
|
910
|
+
/** Confirmed lockup UTXO (esplora / mempool.space shape). */
|
|
911
|
+
type ReclaimUtxo = {
|
|
912
|
+
txid: string
|
|
913
|
+
vout: number
|
|
914
|
+
value: IntegerType
|
|
915
|
+
/** Cross-check only; re-derived from `lockScript` when omitted. */
|
|
916
|
+
scriptPubKey?: Uint8Array
|
|
917
|
+
};
|
|
918
|
+
/** Inputs to {@link buildReclaim}. */
|
|
919
|
+
type BuildReclaimOpts = {
|
|
920
|
+
path: ReclaimPath
|
|
921
|
+
utxo: ReclaimUtxo
|
|
922
|
+
network: BitcoinNetwork
|
|
923
|
+
/**
|
|
924
|
+
* Sweep output: `value - feeSats` pays `address`. Mutate the returned tx's
|
|
925
|
+
* outputs before signing if needed (`SIGHASH_ALL` commits to them).
|
|
926
|
+
*/
|
|
927
|
+
output: {
|
|
928
|
+
address: string
|
|
929
|
+
feeSats: IntegerType
|
|
930
|
+
}
|
|
931
|
+
/**
|
|
932
|
+
* The lockup `witnessScript` — pass the bytes you funded (typically
|
|
933
|
+
* `buildLockupScript(...)` / `RegisterMetadata.lockScript`). The CLTV
|
|
934
|
+
* unlock height is decoded from it.
|
|
935
|
+
*/
|
|
936
|
+
lockScript: Uint8Array | string
|
|
937
|
+
};
|
|
938
|
+
/**
|
|
939
|
+
* Build the unsigned reclaim transaction (a `@scure/btc-signer` `Transaction`).
|
|
940
|
+
*
|
|
941
|
+
* One P2WSH input with `witnessUtxo` + `witnessScript` so the tx is a complete
|
|
942
|
+
* PSBT (`toPSBT` / `fromPSBT` round-trip). HSM path: `buildReclaim` →
|
|
943
|
+
* `tx.signIdx` or {@link computeReclaimSighash} + detached `partialSig` →
|
|
944
|
+
* {@link finalizeReclaim}.
|
|
945
|
+
*
|
|
946
|
+
* - `path: "early-exit"` → `sequence = 0xffffffff`, `lockTime = 0`
|
|
947
|
+
* - `path: "locktime"` → `sequence = 0xfffffffe`, `lockTime = unlockHeight`
|
|
948
|
+
*/
|
|
949
|
+
declare function buildReclaim(opts: BuildReclaimOpts): btc.Transaction;
|
|
950
|
+
/**
|
|
951
|
+
* Input-0 BIP-143 sighash for a reclaim tx.
|
|
952
|
+
*
|
|
953
|
+
* In-process keys should prefer `tx.signIdx(privateKey, 0)`. This helper is
|
|
954
|
+
* for HSMs / MPC that sign a bare digest, and for passing the early-exit
|
|
955
|
+
* sighash between parties. Recompute after any output/fee change.
|
|
956
|
+
*
|
|
957
|
+
* Reads `witnessScript` + amount off the tx (set by {@link buildReclaim});
|
|
958
|
+
* pass `opts` to re-supply them for a tx parsed from raw hex.
|
|
959
|
+
*/
|
|
960
|
+
declare function computeReclaimSighash(tx: btc.Transaction, opts?: {
|
|
961
|
+
witnessScript?: Uint8Array | string
|
|
962
|
+
amountSats?: IntegerType
|
|
963
|
+
}): Uint8Array;
|
|
964
|
+
/**
|
|
965
|
+
* Sign a reclaim sighash with a software key: DER + trailing `SIGHASH_ALL`.
|
|
966
|
+
* `lowR` defaults to `false` to match btc-signer's `signIdx`. Kept as the
|
|
967
|
+
* software stand-in for a detached signer (HSM tests).
|
|
968
|
+
*/
|
|
969
|
+
declare function signReclaim(sighash: Uint8Array, privateKey: Uint8Array | string, opts?: {
|
|
970
|
+
lowR?: boolean
|
|
971
|
+
}): Uint8Array;
|
|
972
|
+
/** Arguments to {@link finalizeReclaim}, discriminated on the spend path. */
|
|
973
|
+
type FinalizeReclaimOpts = {
|
|
974
|
+
path: "early-exit"
|
|
975
|
+
tx: btc.Transaction
|
|
976
|
+
/** Staker principal — rebuilds the 32-byte preimage the `OP_ELSE` branch reveals. */
|
|
977
|
+
stxAddress: string
|
|
978
|
+
} | {
|
|
979
|
+
path: "locktime"
|
|
980
|
+
tx: btc.Transaction
|
|
981
|
+
};
|
|
982
|
+
/**
|
|
983
|
+
* Assemble the custom IF/ELSE witness from signatures already on the tx.
|
|
984
|
+
*
|
|
985
|
+
* btc-signer's own finalizer cannot build this script, so we splice
|
|
986
|
+
* `finalScriptWitness` directly. Does not broadcast.
|
|
987
|
+
*
|
|
988
|
+
* - locktime: `[stakerSig, 0x01, witnessScript]`
|
|
989
|
+
* - early-exit: `[stakerSig, cosignerSig, preimage, <empty>, witnessScript]`
|
|
990
|
+
*/
|
|
991
|
+
declare function finalizeReclaim(opts: FinalizeReclaimOpts): {
|
|
992
|
+
txHex: string
|
|
993
|
+
txid: string
|
|
994
|
+
};
|
|
995
|
+
type ReclaimOpts = BuildReclaimOpts & {
|
|
996
|
+
/** 32-byte BTC private key (raw bytes or hex). Not a Stacks account key. */
|
|
997
|
+
stakerPrivateKey: Uint8Array | string
|
|
998
|
+
/** Required for `path: "early-exit"`. */
|
|
999
|
+
cosignerPrivateKey?: Uint8Array | string
|
|
1000
|
+
/** Required for `path: "early-exit"` — feeds {@link stakerPreimage}. */
|
|
1001
|
+
stxAddress?: string
|
|
1002
|
+
};
|
|
1003
|
+
/**
|
|
1004
|
+
* One-shot reclaim for in-process BTC keys: build + signIdx + finalize.
|
|
1005
|
+
* Does not broadcast; the caller relays `txHex`.
|
|
1006
|
+
*/
|
|
1007
|
+
declare function reclaim(opts: ReclaimOpts): {
|
|
1008
|
+
txHex: string
|
|
1009
|
+
txid: string
|
|
1010
|
+
};
|
|
716
1011
|
/**
|
|
717
1012
|
* A staker's whole PoX-5 position in ONE batched request: staker info, bond
|
|
718
1013
|
* membership, custodied sBTC, and the current cycle — the state a dashboard
|
|
@@ -744,6 +1039,27 @@ type Pox5Actions = {
|
|
|
744
1039
|
verifySignerKeyGrant: (signerManager: string, signerKey: Uint8Array | string) => Promise<boolean>
|
|
745
1040
|
getCurrentRewardCycle: () => Promise<bigint>
|
|
746
1041
|
getFirstRewardCycle: () => Promise<bigint>
|
|
1042
|
+
getEarned: (params: {
|
|
1043
|
+
signer: string
|
|
1044
|
+
rewardCycle: IntegerType
|
|
1045
|
+
bondIndex?: IntegerType
|
|
1046
|
+
}) => Promise<bigint>
|
|
1047
|
+
getEarnedStakerRewards: (params: {
|
|
1048
|
+
signer: string
|
|
1049
|
+
rewardCycle: IntegerType
|
|
1050
|
+
bondIndex?: IntegerType
|
|
1051
|
+
staker: string
|
|
1052
|
+
}) => Promise<bigint>
|
|
1053
|
+
getLastRewardComputeHeight: () => Promise<bigint>
|
|
1054
|
+
getTotalSharesStakedForCycle: (rewardCycle: IntegerType, bondIndex?: IntegerType) => Promise<bigint>
|
|
1055
|
+
eligibleStake: (params: EligibleStakeParams) => Promise<EligibilityResult>
|
|
1056
|
+
eligibleRegisterForBond: (params: EligibleRegisterForBondParams) => Promise<EligibilityResult>
|
|
1057
|
+
eligibleUnstake: (params: EligibleUnstakeParams) => Promise<EligibilityResult>
|
|
1058
|
+
eligibleUnstakeSbtc: (params: EligibleUnstakeSbtcParams) => Promise<EligibilityResult>
|
|
1059
|
+
eligibleClaimRewards: (params: EligibleClaimRewardsParams) => Promise<EligibilityResult>
|
|
1060
|
+
eligibleGrantSignerKey: (params: EligibleGrantSignerKeyParams) => Promise<EligibilityResult>
|
|
1061
|
+
eligibleSetBondAdmin: (params: EligibleAdminParams) => Promise<EligibilityResult>
|
|
1062
|
+
eligiblePauseRewards: (params: EligibleAdminParams) => Promise<EligibilityResult>
|
|
747
1063
|
setupBond: (params: SetupBondParams) => Promise<string>
|
|
748
1064
|
registerForBond: (params: RegisterForBondParams) => Promise<string>
|
|
749
1065
|
updateBondRegistration: (params: UpdateBondRegistrationParams) => Promise<string>
|
|
@@ -757,6 +1073,16 @@ type Pox5Actions = {
|
|
|
757
1073
|
claimStakerRewardsForSigner: (params: ClaimStakerRewardsForSignerParams) => Promise<string>
|
|
758
1074
|
grantSignerKey: (params: GrantSignerKeyParams) => Promise<string>
|
|
759
1075
|
revokeSignerGrant: (params: RevokeSignerGrantParams) => Promise<string>
|
|
1076
|
+
setBondAdmin: (params: SetBondAdminParams) => Promise<string>
|
|
1077
|
+
setPauseAdmin: (params: SetPauseAdminParams) => Promise<string>
|
|
1078
|
+
pauseRewards: (params?: PauseRewardsParams) => Promise<string>
|
|
1079
|
+
buildLockProof: (opts: {
|
|
1080
|
+
source: ProofSource
|
|
1081
|
+
txid: string
|
|
1082
|
+
lockScript: Uint8Array
|
|
1083
|
+
unlockBurnHeight: IntegerType
|
|
1084
|
+
vout?: number
|
|
1085
|
+
}) => Promise<L1LockupOutput>
|
|
760
1086
|
}
|
|
761
1087
|
};
|
|
762
1088
|
/**
|
|
@@ -778,6 +1104,31 @@ type Pox5Actions = {
|
|
|
778
1104
|
* }
|
|
779
1105
|
*/
|
|
780
1106
|
declare function pox5(): (client: Client) => Pox5Actions;
|
|
1107
|
+
/**
|
|
1108
|
+
* SIP-005 PoX `pox-addr` tuple, decoded from a Bitcoin address. `version` is
|
|
1109
|
+
* the PoX byte (`POX_ADDRESS_VERSION`), not a Bitcoin network version
|
|
1110
|
+
* (`p2sh` is 0x01 here, 0x05 on mainnet Bitcoin). `hashbytes` is the 20- or
|
|
1111
|
+
* 32-byte payload — unpadded, matching `check-pox-addr-hashbytes`.
|
|
1112
|
+
*/
|
|
1113
|
+
type BtcAddressRepr = {
|
|
1114
|
+
version: number
|
|
1115
|
+
hashbytes: Uint8Array
|
|
1116
|
+
};
|
|
1117
|
+
/**
|
|
1118
|
+
* Parse a Bitcoin address string into a PoX address tuple.
|
|
1119
|
+
* Supports P2PKH, P2SH, P2WPKH, P2WSH, P2TR (mainnet, testnet, regtest).
|
|
1120
|
+
*/
|
|
1121
|
+
declare function parseBtcAddress(address: string): BtcAddressRepr;
|
|
1122
|
+
declare function stringifyBtcAddress(repr: BtcAddressRepr, network: BitcoinNetwork): string;
|
|
1123
|
+
declare const BtcAddress: {};
|
|
1124
|
+
declare function buildSignerCalldata(opts: {
|
|
1125
|
+
poxAddress: string | BtcAddressRepr
|
|
1126
|
+
maxFeeSats: IntegerType
|
|
1127
|
+
}): Uint8Array;
|
|
1128
|
+
declare function parseSignerCalldata(calldata: Uint8Array | string): {
|
|
1129
|
+
poxAddress: BtcAddressRepr
|
|
1130
|
+
maxFeeSats: bigint
|
|
1131
|
+
};
|
|
781
1132
|
declare const POX5_ABI: {
|
|
782
1133
|
readonly functions: readonly [{
|
|
783
1134
|
readonly name: "current-pox-reward-cycle"
|
|
@@ -950,6 +1301,59 @@ declare const POX5_ABI: {
|
|
|
950
1301
|
readonly error: "uint128"
|
|
951
1302
|
}
|
|
952
1303
|
}
|
|
1304
|
+
}, {
|
|
1305
|
+
readonly name: "get-earned"
|
|
1306
|
+
readonly access: "read-only"
|
|
1307
|
+
readonly args: readonly [{
|
|
1308
|
+
readonly name: "signer"
|
|
1309
|
+
readonly type: "principal"
|
|
1310
|
+
}, {
|
|
1311
|
+
readonly name: "reward-cycle"
|
|
1312
|
+
readonly type: "uint128"
|
|
1313
|
+
}, {
|
|
1314
|
+
readonly name: "bond-index"
|
|
1315
|
+
readonly type: {
|
|
1316
|
+
readonly optional: "uint128"
|
|
1317
|
+
}
|
|
1318
|
+
}]
|
|
1319
|
+
readonly outputs: "uint128"
|
|
1320
|
+
}, {
|
|
1321
|
+
readonly name: "get-earned-staker-rewards"
|
|
1322
|
+
readonly access: "read-only"
|
|
1323
|
+
readonly args: readonly [{
|
|
1324
|
+
readonly name: "signer"
|
|
1325
|
+
readonly type: "principal"
|
|
1326
|
+
}, {
|
|
1327
|
+
readonly name: "reward-cycle"
|
|
1328
|
+
readonly type: "uint128"
|
|
1329
|
+
}, {
|
|
1330
|
+
readonly name: "bond-index"
|
|
1331
|
+
readonly type: {
|
|
1332
|
+
readonly optional: "uint128"
|
|
1333
|
+
}
|
|
1334
|
+
}, {
|
|
1335
|
+
readonly name: "staker"
|
|
1336
|
+
readonly type: "principal"
|
|
1337
|
+
}]
|
|
1338
|
+
readonly outputs: "uint128"
|
|
1339
|
+
}, {
|
|
1340
|
+
readonly name: "get-last-reward-compute-height"
|
|
1341
|
+
readonly access: "read-only"
|
|
1342
|
+
readonly args: readonly []
|
|
1343
|
+
readonly outputs: "uint128"
|
|
1344
|
+
}, {
|
|
1345
|
+
readonly name: "get-total-shares-staked-for-cycle"
|
|
1346
|
+
readonly access: "read-only"
|
|
1347
|
+
readonly args: readonly [{
|
|
1348
|
+
readonly name: "reward-cycle"
|
|
1349
|
+
readonly type: "uint128"
|
|
1350
|
+
}, {
|
|
1351
|
+
readonly name: "bond-index"
|
|
1352
|
+
readonly type: {
|
|
1353
|
+
readonly optional: "uint128"
|
|
1354
|
+
}
|
|
1355
|
+
}]
|
|
1356
|
+
readonly outputs: "uint128"
|
|
953
1357
|
}, {
|
|
954
1358
|
readonly name: "announce-l1-early-exit"
|
|
955
1359
|
readonly access: "public"
|
|
@@ -1674,6 +2078,58 @@ declare const POX5_ABI: {
|
|
|
1674
2078
|
readonly error: "uint128"
|
|
1675
2079
|
}
|
|
1676
2080
|
}
|
|
2081
|
+
}, {
|
|
2082
|
+
readonly name: "set-bond-admin"
|
|
2083
|
+
readonly access: "public"
|
|
2084
|
+
readonly args: readonly [{
|
|
2085
|
+
readonly name: "new-admin"
|
|
2086
|
+
readonly type: "principal"
|
|
2087
|
+
}]
|
|
2088
|
+
readonly outputs: {
|
|
2089
|
+
readonly response: {
|
|
2090
|
+
readonly ok: {
|
|
2091
|
+
readonly tuple: readonly [{
|
|
2092
|
+
readonly name: "new-admin"
|
|
2093
|
+
readonly type: "principal"
|
|
2094
|
+
}, {
|
|
2095
|
+
readonly name: "old-admin"
|
|
2096
|
+
readonly type: "principal"
|
|
2097
|
+
}]
|
|
2098
|
+
}
|
|
2099
|
+
readonly error: "uint128"
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
2102
|
+
}, {
|
|
2103
|
+
readonly name: "set-pause-admin"
|
|
2104
|
+
readonly access: "public"
|
|
2105
|
+
readonly args: readonly [{
|
|
2106
|
+
readonly name: "new-admin"
|
|
2107
|
+
readonly type: "principal"
|
|
2108
|
+
}]
|
|
2109
|
+
readonly outputs: {
|
|
2110
|
+
readonly response: {
|
|
2111
|
+
readonly ok: {
|
|
2112
|
+
readonly tuple: readonly [{
|
|
2113
|
+
readonly name: "new-admin"
|
|
2114
|
+
readonly type: "principal"
|
|
2115
|
+
}, {
|
|
2116
|
+
readonly name: "old-admin"
|
|
2117
|
+
readonly type: "principal"
|
|
2118
|
+
}]
|
|
2119
|
+
}
|
|
2120
|
+
readonly error: "uint128"
|
|
2121
|
+
}
|
|
2122
|
+
}
|
|
2123
|
+
}, {
|
|
2124
|
+
readonly name: "pause-rewards"
|
|
2125
|
+
readonly access: "public"
|
|
2126
|
+
readonly args: readonly []
|
|
2127
|
+
readonly outputs: {
|
|
2128
|
+
readonly response: {
|
|
2129
|
+
readonly ok: "bool"
|
|
2130
|
+
readonly error: "uint128"
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
1677
2133
|
}]
|
|
1678
2134
|
};
|
|
1679
|
-
export { verifySignerGrant, stakerPreimage, stakerConsensusBuff, signSignerGrant, serializeCScriptNum, rewardCycleToBurnHeight, pushScriptBytes, pushCScriptNum, pox5ContractId, pox5, parsePox5Error, isPox5Active, isInPreparePhase, getPoxInfo2 as getPoxInfo, getPox5Activation, describePox5Error, computeSignerGrantHash, burnHeightToRewardCycle, burnHeightToDistributionIndex, buildLockupScript, buildLockupOutputScript, buildLockupAddress, buildDefaultStakerUnlockBytes, bondUnlockCycle, bondPhaseAtHeight, bondPeriodToRewardCycle, bondPeriodToBurnHeight, assertPox5Active, UpdateBondRegistrationParams, UnstakeSbtcParams, UnstakeParams, StakerState, StakeUpdateParams, StakeParams, SignerGrantOptions, SetupBondParams, RevokeSignerGrantParams, RegisterForBondParams, PoxCycleParams, Pox5Info, Pox5EventTopic, Pox5ErrorCode, Pox5Activation, Pox5Actions, POX5_SIGNER_DOMAIN, POX5_EVENT_TOPICS, POX5_ERROR_NAMES, POX5_CONTRACT_NAME, POX5_CONTRACT_ID_MAINNET, POX5_ACTIVATION_BURN_HEIGHT_MAINNET, POX5_ABI, MAX_NUM_CYCLES, L1LockupOutput, GrantSignerKeyParams, ClaimStakerRewardsForSignerParams, ClaimRewardsParams, CalculateRewardsParams, C_SCRIPT_NUM_MAX, BuildLockupScriptOptions, BtcLockup, BondPhase, BondCycleParams, BOND_LENGTH_CYCLES, BOND_GAP_CYCLES, BITCOIN_LOCKTIME_THRESHOLD, AnnounceL1EarlyExitParams };
|
|
2135
|
+
export { verifySignerGrant, stringifyBtcAddress, stakerPreimage, stakerConsensusBuff, spvProofToL1LockupOutput, signSignerGrant, signReclaim, serializeCScriptNum, rewardCycleToBurnHeight, reclaim, pushScriptBytes, pushCScriptNum, pox5ContractId, pox5, parseSignerCalldata, parsePox5Error, parseBtcAddress, isPox5Active, isInPreparePhase, getPoxInfo2 as getPoxInfo, getPox5Activation, finalizeReclaim, eligibleUnstakeSbtc2 as eligibleUnstakeSbtc, eligibleUnstake2 as eligibleUnstake, eligibleStake2 as eligibleStake, eligibleSetBondAdmin2 as eligibleSetBondAdmin, eligibleRegisterForBond2 as eligibleRegisterForBond, eligiblePauseRewards2 as eligiblePauseRewards, eligibleGrantSignerKey2 as eligibleGrantSignerKey, eligibleClaimRewards2 as eligibleClaimRewards, distributionCycleToBurnHeight, describePox5Error, currentDistributionCycle, computeSignerGrantHash, computeReclaimSighash, computeBondUnlockHeight, burnHeightToRewardCycle, burnHeightToDistributionIndex, buildSignerCalldata, buildRegisterMetadata, buildReclaim, buildPox5LockProof, buildLockupScript, buildLockupOutputScript, buildLockupAddress, buildDefaultStakerUnlockBytes, bondUnlockCycle, bondStatusAtHeight, bondPhaseAtHeight, bondPeriodToRewardCycle, bondPeriodToBurnHeight, assertPox5Active, UpdateBondRegistrationParams, UnstakeSbtcParams, UnstakeParams, StakerState, StakeUpdateParams, StakeParams, SignerGrantOptions, SetupBondParams, SetPauseAdminParams, SetBondAdminParams, RevokeSignerGrantParams, RegisterMetadata, RegisterForBondParams, ReclaimUtxo, ReclaimPath, ReclaimOpts, PoxCycleParams, Pox5Info, Pox5EventTopic, Pox5ErrorCode, Pox5Activation, Pox5Actions, PauseRewardsParams, POX5_SIGNER_DOMAIN, POX5_EVENT_TOPICS, POX5_ERROR_NAMES, POX5_CONTRACT_NAME, POX5_CONTRACT_ID_MAINNET, POX5_ACTIVATION_BURN_HEIGHT_MAINNET, POX5_ABI, MAX_NUM_CYCLES, L1LockupOutput, GrantSignerKeyParams, FinalizeReclaimOpts, EligibleUnstakeSbtcParams, EligibleUnstakeParams, EligibleStakeParams, EligibleRegisterForBondParams, EligibleGrantSignerKeyParams, EligibleClaimRewardsParams, EligibleAdminParams, EligibilityResult, ClaimStakerRewardsForSignerParams, ClaimRewardsParams, CalculateRewardsParams, C_SCRIPT_NUM_MAX, BuildReclaimOpts, BuildLockupScriptOptions, BtcLockup, BtcAddressRepr, BtcAddress, BondStatusName, BondPhase, BondCycleParams, BOND_LENGTH_CYCLES, BOND_GAP_CYCLES, BITCOIN_LOCKTIME_THRESHOLD, AnnounceL1EarlyExitParams };
|