@bitgo-beta/babylonlabs-io-btc-staking-ts 0.4.0-beta.73 → 0.4.0-beta.730

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/index.d.cts CHANGED
@@ -5,6 +5,7 @@ import { ProofOfPossessionBTC } from '@babylonlabs-io/babylon-proto-ts/dist/gene
5
5
  import { PsbtInputExtended } from 'bip174/src/lib/interfaces';
6
6
  import { Psbt, Transaction, networks } from 'bitcoinjs-lib';
7
7
  import { Input } from 'bitcoinjs-lib/src/transaction';
8
+ import { Emitter } from 'nanoevents';
8
9
 
9
10
  /**
10
11
  * Base interface for staking parameters that define the rules and constraints
@@ -25,6 +26,18 @@ export interface StakingParams {
25
26
  minSlashingTxFeeSat: number;
26
27
  };
27
28
  }
29
+ /**
30
+ * Type for StakingParams where slashing is required
31
+ */
32
+ export type StakingParamsWithSlashing = StakingParams & {
33
+ slashing: NonNullable<StakingParams["slashing"]>;
34
+ };
35
+ /**
36
+ * Type guard to check if slashing exists in StakingParams
37
+ */
38
+ export declare function hasSlashing(params: StakingParams): params is StakingParams & {
39
+ slashing: NonNullable<StakingParams["slashing"]>;
40
+ };
28
41
  /**
29
42
  * Extension of StakingParams that includes activation height and version information.
30
43
  * These parameters are used to identify and select the appropriate staking rules at
@@ -40,6 +53,20 @@ export interface VersionedStakingParams extends StakingParams {
40
53
  export interface ObservableVersionedStakingParams extends VersionedStakingParams {
41
54
  tag: string;
42
55
  }
56
+ /**
57
+ * PsbtResult is an object containing a partially signed transaction and its fee
58
+ */
59
+ export interface PsbtResult {
60
+ psbt: Psbt;
61
+ fee: number;
62
+ }
63
+ /**
64
+ * TransactionResult is an object containing an unsigned transaction and its fee
65
+ */
66
+ export interface TransactionResult {
67
+ transaction: Transaction;
68
+ fee: number;
69
+ }
43
70
  export interface UTXO {
44
71
  txid: string;
45
72
  vout: number;
@@ -144,20 +171,6 @@ export declare class StakingScriptData {
144
171
  */
145
172
  buildMultiKeyScript(pks: Buffer[], threshold: number, withVerify: boolean): Buffer;
146
173
  }
147
- /**
148
- * PsbtResult is an object containing a partially signed transaction and its fee
149
- */
150
- export interface PsbtResult {
151
- psbt: Psbt;
152
- fee: number;
153
- }
154
- /**
155
- * TransactionResult is an object containing an unsigned transaction and its fee
156
- */
157
- export interface TransactionResult {
158
- transaction: Transaction;
159
- fee: number;
160
- }
161
174
  export interface StakerInfo {
162
175
  address: string;
163
176
  publicKeyNoCoordHex: string;
@@ -166,9 +179,9 @@ export declare class Staking {
166
179
  network: networks.Network;
167
180
  stakerInfo: StakerInfo;
168
181
  params: StakingParams;
169
- finalityProviderPkNoCoordHex: string;
182
+ finalityProviderPksNoCoordHex: string[];
170
183
  stakingTimelock: number;
171
- constructor(network: networks.Network, stakerInfo: StakerInfo, params: StakingParams, finalityProviderPkNoCoordHex: string, stakingTimelock: number);
184
+ constructor(network: networks.Network, stakerInfo: StakerInfo, params: StakingParams, finalityProviderPksNoCoordHex: string[], stakingTimelock: number);
172
185
  /**
173
186
  * buildScripts builds the staking scripts for the staking transaction.
174
187
  * Note: different staking types may have different scripts.
@@ -189,6 +202,49 @@ export declare class Staking {
189
202
  * @throws {StakingError} - If the transaction cannot be built
190
203
  */
191
204
  createStakingTransaction(stakingAmountSat: number, inputUTXOs: UTXO[], feeRate: number): TransactionResult;
205
+ /**
206
+ * Creates a staking expansion transaction that extends an existing BTC stake
207
+ * to new finality providers or renews the timelock.
208
+ *
209
+ * This method implements RFC 037 BTC Stake Expansion,
210
+ * allowing existing active BTC staking transactions
211
+ * to extend their delegation to new finality providers without going through
212
+ * the full unbonding process.
213
+ *
214
+ * The expansion transaction:
215
+ * 1. Spends the previous staking transaction output as the first input
216
+ * 2. Uses funding UTXO as additional input to cover transaction fees or
217
+ * to increase the staking amount
218
+ * 3. Creates a new staking output with expanded finality provider coverage or
219
+ * renews the timelock
220
+ * 4. Has an output returning the remaining funds as change (if any) to the
221
+ * staker BTC address
222
+ *
223
+ * @param {number} stakingAmountSat - The total staking amount in satoshis
224
+ * (The amount had to be equal to the previous staking amount for now, this
225
+ * lib does not yet support increasing the staking amount at this stage)
226
+ * @param {UTXO[]} inputUTXOs - Available UTXOs to use for funding the
227
+ * expansion transaction fees. Only one will be selected for the expansion
228
+ * @param {number} feeRate - Fee rate in satoshis per byte for the
229
+ * expansion transaction
230
+ * @param {StakingParams} paramsForPreviousStakingTx - Staking parameters
231
+ * used in the previous staking transaction
232
+ * @param {Object} previousStakingTxInfo - Necessary information to spend the
233
+ * previous staking transaction.
234
+ * @returns {TransactionResult & { fundingUTXO: UTXO }} - An object containing
235
+ * the unsigned expansion transaction and calculated fee, and the funding UTXO
236
+ * @throws {StakingError} - If the transaction cannot be built or validation
237
+ * fails
238
+ */
239
+ createStakingExpansionTransaction(stakingAmountSat: number, inputUTXOs: UTXO[], feeRate: number, paramsForPreviousStakingTx: StakingParams, previousStakingTxInfo: {
240
+ stakingTx: Transaction;
241
+ stakingInput: {
242
+ finalityProviderPksNoCoordHex: string[];
243
+ stakingTimelock: number;
244
+ };
245
+ }): TransactionResult & {
246
+ fundingUTXO: UTXO;
247
+ };
192
248
  /**
193
249
  * Create a staking psbt based on the existing staking transaction.
194
250
  *
@@ -199,6 +255,28 @@ export declare class Staking {
199
255
  * @returns {Psbt} - The psbt.
200
256
  */
201
257
  toStakingPsbt(stakingTx: Transaction, inputUTXOs: UTXO[]): Psbt;
258
+ /**
259
+ * Convert a staking expansion transaction to a PSBT.
260
+ *
261
+ * @param {Transaction} stakingExpansionTx - The staking expansion
262
+ * transaction to convert
263
+ * @param {UTXO[]} inputUTXOs - Available UTXOs for the
264
+ * funding input (second input)
265
+ * @param {StakingParams} paramsForPreviousStakingTx - Staking parameters
266
+ * used for the previous staking transaction
267
+ * @param {Object} previousStakingTxInfo - Information about the previous
268
+ * staking transaction
269
+ * @returns {Psbt} The PSBT for the staking expansion transaction
270
+ * @throws {Error} If the previous staking output cannot be found or
271
+ * validation fails
272
+ */
273
+ toStakingExpansionPsbt(stakingExpansionTx: Transaction, inputUTXOs: UTXO[], paramsForPreviousStakingTx: StakingParams, previousStakingTxInfo: {
274
+ stakingTx: Transaction;
275
+ stakingInput: {
276
+ finalityProviderPksNoCoordHex: string[];
277
+ stakingTimelock: number;
278
+ };
279
+ }): Psbt;
202
280
  /**
203
281
  * Create an unbonding transaction for staking.
204
282
  *
@@ -269,214 +347,630 @@ export declare class Staking {
269
347
  */
270
348
  createWithdrawSlashingPsbt(slashingTx: Transaction, feeRate: number): PsbtResult;
271
349
  }
272
- export interface ObservableStakingScripts extends StakingScripts {
273
- dataEmbedScript: Buffer;
350
+ export type RegistrationStep = "staking-slashing" | "unbonding-slashing" | "proof-of-possession" | "create-btc-delegation-msg";
351
+ export type WithdrawalType = "staking-expired" | "early-unbonded" | "slashing";
352
+ export type EventData = Record<string, string | number | string[] | number[]>;
353
+ export interface ManagerEvents {
354
+ "delegation:create": (data?: EventData) => void;
355
+ "delegation:register": (data?: EventData) => void;
356
+ "delegation:stake": (data?: EventData) => void;
357
+ "delegation:unbond": (data?: EventData) => void;
358
+ "delegation:withdraw": (data?: EventData) => void;
359
+ "delegation:expand": (data?: EventData) => void;
274
360
  }
275
- export declare class ObservableStakingScriptData extends StakingScriptData {
276
- magicBytes: Buffer;
277
- constructor(stakerKey: Buffer, finalityProviderKeys: Buffer[], covenantKeys: Buffer[], covenantThreshold: number, stakingTimelock: number, unbondingTimelock: number, magicBytes: Buffer);
278
- /**
279
- * Builds a data embed script for staking in the form:
280
- * OP_RETURN || <serializedStakingData>
281
- * where serializedStakingData is the concatenation of:
282
- * MagicBytes || Version || StakerPublicKey || FinalityProviderPublicKey || StakingTimeLock
283
- * Note: Only a single finality provider key is supported for now in phase 1
284
- * @throws {Error} If the number of finality provider keys is not equal to 1.
285
- * @returns {Buffer} The compiled data embed script.
286
- */
287
- buildDataEmbedScript(): Buffer;
288
- /**
289
- * Builds the staking scripts.
290
- * @returns {ObservableStakingScripts} The staking scripts that can be used to stake.
291
- * contains the timelockScript, unbondingScript, slashingScript,
292
- * unbondingTimelockScript, and dataEmbedScript.
293
- * @throws {Error} If script data is invalid.
294
- */
295
- buildScripts(): ObservableStakingScripts;
361
+ export type DelegationEvent = keyof ManagerEvents;
362
+ export interface Action {
363
+ name: ActionName;
296
364
  }
297
- /**
298
- * ObservableStaking is a class that provides an interface to create observable
299
- * staking transactions for the Babylon Staking protocol.
300
- *
301
- * The class requires a network and staker information to create staking
302
- * transactions.
303
- * The staker information includes the staker's address and
304
- * public key(without coordinates).
305
- */
306
- export declare class ObservableStaking extends Staking {
307
- params: ObservableVersionedStakingParams;
308
- constructor(network: networks.Network, stakerInfo: StakerInfo, params: ObservableVersionedStakingParams, finalityProviderPkNoCoordHex: string, stakingTimelock: number);
365
+ declare enum ActionName {
366
+ SIGN_BTC_STAKING_TRANSACTION = "sign-btc-staking-transaction",
367
+ SIGN_BTC_UNBONDING_TRANSACTION = "sign-btc-unbonding-transaction",
368
+ SIGN_BTC_WITHDRAW_TRANSACTION = "sign-btc-withdraw-transaction",
369
+ SIGN_BTC_SLASHING_TRANSACTION = "sign-btc-slashing-transaction",
370
+ SIGN_BTC_UNBONDING_SLASHING_TRANSACTION = "sign-btc-unbonding-slashing-transaction"
371
+ }
372
+ export interface Contract {
373
+ id: ContractId;
374
+ params: ContractData;
375
+ }
376
+ declare enum ContractId {
377
+ STAKING = "babylon:staking",
378
+ UNBONDING = "babylon:unbonding",
379
+ SLASHING = "babylon:slashing",
380
+ WITHDRAW = "babylon:withdraw",
381
+ SLASHING_BURN = "babylon:slashing-burn"
382
+ }
383
+ export type ContractData = Record<string, string | number | string[] | number[]>;
384
+ export interface SignPsbtOptions {
385
+ contracts: Contract[];
386
+ action: Action;
387
+ }
388
+ export interface BtcProvider {
389
+ signPsbt(psbtHex: string, options?: SignPsbtOptions): Promise<string>;
390
+ signMessage: (message: string, type: "ecdsa" | "bip322-simple") => Promise<string>;
391
+ getTransactionHex(txid: string): Promise<string>;
392
+ }
393
+ export interface BabylonProvider {
309
394
  /**
310
- * Build the staking scripts for observable staking.
311
- * This method overwrites the base method to include the OP_RETURN tag based
312
- * on the tag provided in the parameters.
395
+ * Signs a Babylon chain transaction.
396
+ * This is primarily used for signing MsgCreateBTCDelegation transactions
397
+ * which register the BTC delegation on the Babylon Genesis chain.
313
398
  *
314
- * @returns {ObservableStakingScripts} - The staking scripts for observable staking.
315
- * @throws {StakingError} - If the scripts cannot be built.
399
+ * @param {object} msg - The Cosmos SDK transaction message to sign
400
+ * @param {string} msg.typeUrl - The Protobuf type URL identifying the message type
401
+ * @param {T} msg.value - The transaction message data matching the typeUrl
402
+ * @returns {Promise<Uint8Array>} The signed transaction bytes
316
403
  */
317
- buildScripts(): ObservableStakingScripts;
404
+ signTransaction: <T extends object>(msg: {
405
+ typeUrl: string;
406
+ value: T;
407
+ }) => Promise<Uint8Array>;
318
408
  /**
319
- * Create a staking transaction for observable staking.
320
- * This overwrites the method from the Staking class with the addtion
321
- * of the
322
- * 1. OP_RETURN tag in the staking scripts
323
- * 2. lockHeight parameter
409
+ * Gets the current height of the Babylon Genesis chain.
324
410
  *
325
- * @param {number} stakingAmountSat - The amount to stake in satoshis.
326
- * @param {UTXO[]} inputUTXOs - The UTXOs to use as inputs for the staking
327
- * transaction.
328
- * @param {number} feeRate - The fee rate for the transaction in satoshis per byte.
329
- * @returns {TransactionResult} - An object containing the unsigned transaction,
330
- * and fee
411
+ * @returns {Promise<number>} The current Babylon chain height
331
412
  */
332
- createStakingTransaction(stakingAmountSat: number, inputUTXOs: UTXO[], feeRate: number): TransactionResult;
413
+ getCurrentHeight?: () => Promise<number>;
333
414
  /**
334
- * Create a staking psbt for observable staking.
415
+ * Gets the chain ID of the Babylon Genesis chain.
335
416
  *
336
- * @param {Transaction} stakingTx - The staking transaction.
337
- * @param {UTXO[]} inputUTXOs - The UTXOs to use as inputs for the staking
338
- * transaction.
339
- * @returns {Psbt} - The psbt.
417
+ * @returns {Promise<string>} The Babylon chain ID
340
418
  */
341
- toStakingPsbt(stakingTx: Transaction, inputUTXOs: UTXO[]): Psbt;
419
+ getChainId?: () => Promise<string>;
342
420
  }
343
- export interface CovenantSignature {
344
- btcPkHex: string;
345
- sigHex: string;
421
+ export interface StakingInputs {
422
+ finalityProviderPksNoCoordHex: string[];
423
+ stakingAmountSat: number;
424
+ stakingTimelock: number;
425
+ }
426
+ export interface InclusionProof {
427
+ pos: number;
428
+ merkle: string[];
429
+ blockHashHex: string;
346
430
  }
347
431
  /**
348
- * Constructs an unsigned BTC Staking transaction in psbt format.
349
- *
350
- * Outputs:
351
- * - psbt:
352
- * - The first output corresponds to the staking script with the specified amount.
353
- * - The second output corresponds to the change from spending the amount and the transaction fee.
354
- * - If a data embed script is provided, it will be added as the second output, and the fee will be the third output.
355
- * - fee: The total fee amount for the transaction.
356
- *
357
- * Inputs:
358
- * - scripts:
359
- * - timelockScript, unbondingScript, slashingScript: Scripts for different transaction types.
360
- * - dataEmbedScript: Optional data embed script.
361
- * - amount: Amount to stake.
362
- * - changeAddress: Address to send the change to.
363
- * - inputUTXOs: All available UTXOs from the wallet.
364
- * - network: Bitcoin network.
365
- * - feeRate: Fee rate in satoshis per byte.
366
- * - publicKeyNoCoord: Public key if the wallet is in taproot mode.
367
- * - lockHeight: Optional block height locktime to set for the transaction (i.e., not mined until the block height).
368
- *
369
- * @param {Object} scripts - Scripts used to construct the taproot output.
370
- * such as timelockScript, unbondingScript, slashingScript, and dataEmbedScript.
371
- * @param {number} amount - The amount to stake.
372
- * @param {string} changeAddress - The address to send the change to.
373
- * @param {UTXO[]} inputUTXOs - All available UTXOs from the wallet.
374
- * @param {networks.Network} network - The Bitcoin network.
375
- * @param {number} feeRate - The fee rate in satoshis per byte.
376
- * @param {number} [lockHeight] - The optional block height locktime.
377
- * @returns {TransactionResult} - An object containing the unsigned transaction and fee
378
- * @throws Will throw an error if the amount or fee rate is less than or equal
379
- * to 0, if the change address is invalid, or if the public key is invalid.
380
- */
381
- export declare function stakingTransaction(scripts: {
382
- timelockScript: Buffer;
383
- unbondingScript: Buffer;
384
- slashingScript: Buffer;
385
- dataEmbedScript?: Buffer;
386
- }, amount: number, changeAddress: string, inputUTXOs: UTXO[], network: networks.Network, feeRate: number, lockHeight?: number): TransactionResult;
387
- /**
388
- * Constructs a withdrawal transaction for manually unbonded delegation.
389
- *
390
- * This transaction spends the unbonded output from the staking transaction.
391
- *
392
- * Inputs:
393
- * - scripts: Scripts used to construct the taproot output.
394
- * - unbondingTimelockScript: Script for the unbonding timelock condition.
395
- * - slashingScript: Script for the slashing condition.
396
- * - unbondingTx: The unbonding transaction.
397
- * - withdrawalAddress: The address to send the withdrawn funds to.
398
- * - network: The Bitcoin network.
399
- * - feeRate: The fee rate for the transaction in satoshis per byte.
400
- *
401
- * Returns:
402
- * - psbt: The partially signed transaction (PSBT).
403
- *
404
- * @param {Object} scripts - The scripts used in the transaction.
405
- * @param {Transaction} unbondingTx - The unbonding transaction.
406
- * @param {string} withdrawalAddress - The address to send the withdrawn funds to.
407
- * @param {networks.Network} network - The Bitcoin network.
408
- * @param {number} feeRate - The fee rate for the transaction in satoshis per byte.
409
- * @returns {PsbtResult} An object containing the partially signed transaction (PSBT).
410
- */
411
- export declare function withdrawEarlyUnbondedTransaction(scripts: {
412
- unbondingTimelockScript: Buffer;
413
- slashingScript: Buffer;
414
- }, unbondingTx: Transaction, withdrawalAddress: string, network: networks.Network, feeRate: number): PsbtResult;
415
- /**
416
- * Constructs a withdrawal transaction for naturally unbonded delegation.
417
- *
418
- * This transaction spends the unbonded output from the staking transaction when the timelock has expired.
419
- *
420
- * Inputs:
421
- * - scripts: Scripts used to construct the taproot output.
422
- * - timelockScript: Script for the timelock condition.
423
- * - slashingScript: Script for the slashing condition.
424
- * - unbondingScript: Script for the unbonding condition.
425
- * - tx: The original staking transaction.
426
- * - withdrawalAddress: The address to send the withdrawn funds to.
427
- * - network: The Bitcoin network.
428
- * - feeRate: The fee rate for the transaction in satoshis per byte.
429
- * - outputIndex: The index of the output to be spent in the original transaction (default is 0).
430
- *
431
- * Returns:
432
- * - psbt: The partially signed transaction (PSBT).
433
- *
434
- * @param {Object} scripts - The scripts used in the transaction.
435
- * @param {Transaction} tx - The original staking transaction.
436
- * @param {string} withdrawalAddress - The address to send the withdrawn funds to.
437
- * @param {networks.Network} network - The Bitcoin network.
438
- * @param {number} feeRate - The fee rate for the transaction in satoshis per byte.
439
- * @param {number} [outputIndex=0] - The index of the output to be spent in the original transaction.
440
- * @returns {PsbtResult} An object containing the partially signed transaction (PSBT).
432
+ * Upgrade configuration for Babylon POP (Proof of Possession) context.
433
+ * This is used to determine when to switch to the new POP context format
434
+ * based on the Babylon chain height and version.
441
435
  */
442
- export declare function withdrawTimelockUnbondedTransaction(scripts: {
443
- timelockScript: Buffer;
444
- slashingScript: Buffer;
445
- unbondingScript: Buffer;
446
- }, tx: Transaction, withdrawalAddress: string, network: networks.Network, feeRate: number, outputIndex?: number): PsbtResult;
436
+ export interface UpgradeConfig {
437
+ /**
438
+ * POP context upgrade configuration.
439
+ */
440
+ pop?: PopUpgradeConfig;
441
+ }
447
442
  /**
448
- * Constructs a withdrawal transaction for a slashing transaction.
449
- *
450
- * This transaction spends the output from the slashing transaction.
451
- *
452
- * @param {Object} scripts - The unbondingTimelockScript
453
- * We use the unbonding timelock script as the timelock of the slashing transaction.
454
- * This is due to slashing tx timelock is the same as the unbonding timelock.
455
- * @param {Transaction} slashingTx - The slashing transaction.
456
- * @param {string} withdrawalAddress - The address to send the withdrawn funds to.
457
- * @param {networks.Network} network - The Bitcoin network.
458
- * @param {number} feeRate - The fee rate for the transaction in satoshis per byte.
459
- * @param {number} outputIndex - The index of the output to be spent in the original transaction.
460
- * @returns {PsbtResult} An object containing the partially signed transaction (PSBT).
443
+ * Configuration for POP context upgrade.
444
+ * - upgradeHeight: The Babylon chain height at which the POP context upgrade is activated.
445
+ * - version: The version of the POP context to use after the upgrade.
461
446
  */
462
- export declare function withdrawSlashingTransaction(scripts: {
463
- unbondingTimelockScript: Buffer;
464
- }, slashingTx: Transaction, withdrawalAddress: string, network: networks.Network, feeRate: number, outputIndex: number): PsbtResult;
465
- /**
466
- * Constructs a slashing transaction for a staking output without prior unbonding.
467
- *
468
- * This transaction spends the staking output of the staking transaction and distributes the funds
469
- * according to the specified slashing rate.
470
- *
471
- * Outputs:
472
- * - The first output sends `input * slashing_rate` funds to the slashing address.
473
- * - The second output sends `input * (1 - slashing_rate) - fee` funds back to the user's address.
474
- *
475
- * Inputs:
476
- * - scripts: Scripts used to construct the taproot output.
477
- * - slashingScript: Script for the slashing condition.
478
- * - timelockScript: Script for the timelock condition.
479
- * - unbondingScript: Script for the unbonding condition.
447
+ export interface PopUpgradeConfig {
448
+ /**
449
+ * The Babylon chain height at which the POP context upgrade is activated.
450
+ */
451
+ upgradeHeight: number;
452
+ /**
453
+ * The version of the POP context to use after the upgrade.
454
+ */
455
+ version: number;
456
+ }
457
+ export declare class BabylonBtcStakingManager {
458
+ protected network: networks.Network;
459
+ protected stakingParams: VersionedStakingParams[];
460
+ protected btcProvider: BtcProvider;
461
+ protected babylonProvider: BabylonProvider;
462
+ protected ee?: Emitter<ManagerEvents> | undefined;
463
+ private upgradeConfig?;
464
+ constructor(network: networks.Network, stakingParams: VersionedStakingParams[], btcProvider: BtcProvider, babylonProvider: BabylonProvider, ee?: Emitter<ManagerEvents> | undefined, upgradeConfig?: UpgradeConfig);
465
+ /**
466
+ * Creates a signed Pre-Staking Registration transaction that is ready to be
467
+ * sent to the Babylon chain.
468
+ * @param stakerBtcInfo - The staker BTC info which includes the BTC address
469
+ * and the no-coord public key in hex format.
470
+ * @param stakingInput - The staking inputs.
471
+ * @param babylonBtcTipHeight - The Babylon BTC tip height.
472
+ * @param inputUTXOs - The UTXOs that will be used to pay for the staking
473
+ * transaction.
474
+ * @param feeRate - The fee rate in satoshis per byte. Typical value for the
475
+ * fee rate is above 1. If the fee rate is too low, the transaction will not
476
+ * be included in a block.
477
+ * @param babylonAddress - The Babylon bech32 encoded address of the staker.
478
+ * @returns The signed babylon pre-staking registration transaction in base64
479
+ * format.
480
+ */
481
+ preStakeRegistrationBabylonTransaction(stakerBtcInfo: StakerInfo, stakingInput: StakingInputs, babylonBtcTipHeight: number, inputUTXOs: UTXO[], feeRate: number, babylonAddress: string): Promise<{
482
+ signedBabylonTx: Uint8Array;
483
+ stakingTx: Transaction;
484
+ }>;
485
+ /**
486
+ * Create a signed staking expansion transaction that is ready to be sent to
487
+ * the Babylon chain.
488
+ */
489
+ stakingExpansionRegistrationBabylonTransaction(stakerBtcInfo: StakerInfo, stakingInput: StakingInputs, babylonBtcTipHeight: number, inputUTXOs: UTXO[], feeRate: number, babylonAddress: string, previousStakingTxInfo: {
490
+ stakingTx: Transaction;
491
+ paramVersion: number;
492
+ stakingInput: StakingInputs;
493
+ }): Promise<{
494
+ signedBabylonTx: Uint8Array;
495
+ stakingTx: Transaction;
496
+ }>;
497
+ /**
498
+ * Estimates the transaction fee for a BTC staking expansion transaction.
499
+ *
500
+ * @param {StakerInfo} stakerBtcInfo - The staker's Bitcoin information
501
+ * including address and public key
502
+ * @param {number} babylonBtcTipHeight - The current Babylon BTC tip height
503
+ * used to determine staking parameters
504
+ * @param {StakingInputs} stakingInput - The new staking input parameters for
505
+ * the expansion
506
+ * @param {UTXO[]} inputUTXOs - Available UTXOs that can be used for funding
507
+ * the expansion transaction
508
+ * @param {number} feeRate - Fee rate in satoshis per byte for the expansion
509
+ * transaction
510
+ * @param {Object} previousStakingTxInfo - Information about the previous
511
+ * staking transaction being expanded
512
+ * @returns {number} - The estimated transaction fee in satoshis
513
+ * @throws {Error} - If validation fails or the fee cannot be calculated
514
+ */
515
+ estimateBtcStakingExpansionFee(stakerBtcInfo: StakerInfo, babylonBtcTipHeight: number, stakingInput: StakingInputs, inputUTXOs: UTXO[], feeRate: number, previousStakingTxInfo: {
516
+ stakingTx: Transaction;
517
+ paramVersion: number;
518
+ stakingInput: StakingInputs;
519
+ }): number;
520
+ /**
521
+ * Creates a signed post-staking registration transaction that is ready to be
522
+ * sent to the Babylon chain. This is used when a staking transaction is
523
+ * already created and included in a BTC block and we want to register it on
524
+ * the Babylon chain.
525
+ * @param stakerBtcInfo - The staker BTC info which includes the BTC address
526
+ * and the no-coord public key in hex format.
527
+ * @param stakingTx - The staking transaction.
528
+ * @param stakingTxHeight - The BTC height in which the staking transaction
529
+ * is included.
530
+ * @param stakingInput - The staking inputs.
531
+ * @param inclusionProof - Merkle Proof of Inclusion: Verifies transaction
532
+ * inclusion in a Bitcoin block that is k-deep.
533
+ * @param babylonAddress - The Babylon bech32 encoded address of the staker.
534
+ * @returns The signed babylon transaction in base64 format.
535
+ */
536
+ postStakeRegistrationBabylonTransaction(stakerBtcInfo: StakerInfo, stakingTx: Transaction, stakingTxHeight: number, stakingInput: StakingInputs, inclusionProof: InclusionProof, babylonAddress: string): Promise<{
537
+ signedBabylonTx: Uint8Array;
538
+ }>;
539
+ /**
540
+ * Estimates the BTC fee required for staking.
541
+ * @param stakerBtcInfo - The staker BTC info which includes the BTC address
542
+ * and the no-coord public key in hex format.
543
+ * @param babylonBtcTipHeight - The BTC tip height recorded on the Babylon
544
+ * chain.
545
+ * @param stakingInput - The staking inputs.
546
+ * @param inputUTXOs - The UTXOs that will be used to pay for the staking
547
+ * transaction.
548
+ * @param feeRate - The fee rate in satoshis per byte. Typical value for the
549
+ * fee rate is above 1. If the fee rate is too low, the transaction will not
550
+ * be included in a block.
551
+ * @returns The estimated BTC fee in satoshis.
552
+ */
553
+ estimateBtcStakingFee(stakerBtcInfo: StakerInfo, babylonBtcTipHeight: number, stakingInput: StakingInputs, inputUTXOs: UTXO[], feeRate: number): number;
554
+ /**
555
+ * Creates a signed staking transaction that is ready to be sent to the BTC
556
+ * network.
557
+ * @param stakerBtcInfo - The staker BTC info which includes the BTC address
558
+ * and the no-coord public key in hex format.
559
+ * @param stakingInput - The staking inputs.
560
+ * @param unsignedStakingTx - The unsigned staking transaction.
561
+ * @param inputUTXOs - The UTXOs that will be used to pay for the staking
562
+ * transaction.
563
+ * @param stakingParamsVersion - The params version that was used to create the
564
+ * delegation in Babylon chain
565
+ * @returns The signed staking transaction.
566
+ */
567
+ createSignedBtcStakingTransaction(stakerBtcInfo: StakerInfo, stakingInput: StakingInputs, unsignedStakingTx: Transaction, inputUTXOs: UTXO[], stakingParamsVersion: number): Promise<Transaction>;
568
+ /**
569
+ * Creates a signed staking expansion transaction that is ready to be sent to
570
+ * the BTC network.
571
+ *
572
+ * @param {StakerInfo} stakerBtcInfo - The staker's BTC information including
573
+ * address and public key
574
+ * @param {StakingInputs} stakingInput - The staking inputs for the expansion
575
+ * @param {Transaction} unsignedStakingExpansionTx - The unsigned staking
576
+ * expansion transaction
577
+ * @param {UTXO[]} inputUTXOs - Available UTXOs for the funding input
578
+ * @param {number} stakingParamsVersion - The version of staking parameters
579
+ * that was used when registering the staking expansion delegation.
580
+ * @param {Object} previousStakingTxInfo - Information about the previous
581
+ * staking transaction
582
+ * @param {Array} covenantStakingExpansionSignatures - Covenant committee
583
+ * signatures for the expansion
584
+ * @returns {Promise<Transaction>} The fully signed staking expansion
585
+ * transaction
586
+ * @throws {Error} If signing fails, validation fails, or required data is
587
+ * missing
588
+ */
589
+ createSignedBtcStakingExpansionTransaction(stakerBtcInfo: StakerInfo, stakingInput: StakingInputs, unsignedStakingExpansionTx: Transaction, inputUTXOs: UTXO[], stakingParamsVersion: number, previousStakingTxInfo: {
590
+ stakingTx: Transaction;
591
+ paramVersion: number;
592
+ stakingInput: StakingInputs;
593
+ }, covenantStakingExpansionSignatures: {
594
+ btcPkHex: string;
595
+ sigHex: string;
596
+ }[]): Promise<Transaction>;
597
+ /**
598
+ * Creates a partial signed unbonding transaction that is only signed by the
599
+ * staker. In order to complete the unbonding transaction, the covenant
600
+ * unbonding signatures need to be added to the transaction before sending it
601
+ * to the BTC network.
602
+ * NOTE: This method should only be used for Babylon phase-1 unbonding.
603
+ * @param stakerBtcInfo - The staker BTC info which includes the BTC address
604
+ * and the no-coord public key in hex format.
605
+ * @param stakingInput - The staking inputs.
606
+ * @param stakingParamsVersion - The params version that was used to create the
607
+ * delegation in Babylon chain
608
+ * @param stakingTx - The staking transaction.
609
+ * @returns The partial signed unbonding transaction and its fee.
610
+ */
611
+ createPartialSignedBtcUnbondingTransaction(stakerBtcInfo: StakerInfo, stakingInput: StakingInputs, stakingParamsVersion: number, stakingTx: Transaction): Promise<TransactionResult>;
612
+ /**
613
+ * Creates a signed unbonding transaction that is ready to be sent to the BTC
614
+ * network.
615
+ * @param stakerBtcInfo - The staker BTC info which includes the BTC address
616
+ * and the no-coord public key in hex format.
617
+ * @param stakingInput - The staking inputs.
618
+ * @param stakingParamsVersion - The params version that was used to create the
619
+ * delegation in Babylon chain
620
+ * @param stakingTx - The staking transaction.
621
+ * @param unsignedUnbondingTx - The unsigned unbonding transaction.
622
+ * @param covenantUnbondingSignatures - The covenant unbonding signatures.
623
+ * It can be retrieved from the Babylon chain or API.
624
+ * @returns The signed unbonding transaction and its fee.
625
+ */
626
+ createSignedBtcUnbondingTransaction(stakerBtcInfo: StakerInfo, stakingInput: StakingInputs, stakingParamsVersion: number, stakingTx: Transaction, unsignedUnbondingTx: Transaction, covenantUnbondingSignatures: {
627
+ btcPkHex: string;
628
+ sigHex: string;
629
+ }[]): Promise<TransactionResult>;
630
+ /**
631
+ * Creates a signed withdrawal transaction on the unbodning output expiry path
632
+ * that is ready to be sent to the BTC network.
633
+ * @param stakingInput - The staking inputs.
634
+ * @param stakingParamsVersion - The params version that was used to create the
635
+ * delegation in Babylon chain
636
+ * @param earlyUnbondingTx - The early unbonding transaction.
637
+ * @param feeRate - The fee rate in satoshis per byte. Typical value for the
638
+ * fee rate is above 1. If the fee rate is too low, the transaction will not
639
+ * be included in a block.
640
+ * @returns The signed withdrawal transaction and its fee.
641
+ */
642
+ createSignedBtcWithdrawEarlyUnbondedTransaction(stakerBtcInfo: StakerInfo, stakingInput: StakingInputs, stakingParamsVersion: number, earlyUnbondingTx: Transaction, feeRate: number): Promise<TransactionResult>;
643
+ /**
644
+ * Creates a signed withdrawal transaction on the staking output expiry path
645
+ * that is ready to be sent to the BTC network.
646
+ * @param stakerBtcInfo - The staker BTC info which includes the BTC address
647
+ * and the no-coord public key in hex format.
648
+ * @param stakingInput - The staking inputs.
649
+ * @param stakingParamsVersion - The params version that was used to create the
650
+ * delegation in Babylon chain
651
+ * @param stakingTx - The staking transaction.
652
+ * @param feeRate - The fee rate in satoshis per byte. Typical value for the
653
+ * fee rate is above 1. If the fee rate is too low, the transaction will not
654
+ * be included in a block.
655
+ * @returns The signed withdrawal transaction and its fee.
656
+ */
657
+ createSignedBtcWithdrawStakingExpiredTransaction(stakerBtcInfo: StakerInfo, stakingInput: StakingInputs, stakingParamsVersion: number, stakingTx: Transaction, feeRate: number): Promise<TransactionResult>;
658
+ /**
659
+ * Creates a signed withdrawal transaction for the expired slashing output that
660
+ * is ready to be sent to the BTC network.
661
+ * @param stakerBtcInfo - The staker BTC info which includes the BTC address
662
+ * and the no-coord public key in hex format.
663
+ * @param stakingInput - The staking inputs.
664
+ * @param stakingParamsVersion - The params version that was used to create the
665
+ * delegation in Babylon chain
666
+ * @param slashingTx - The slashing transaction.
667
+ * @param feeRate - The fee rate in satoshis per byte. Typical value for the
668
+ * fee rate is above 1. If the fee rate is too low, the transaction will not
669
+ * be included in a block.
670
+ * @returns The signed withdrawal transaction and its fee.
671
+ */
672
+ createSignedBtcWithdrawSlashingTransaction(stakerBtcInfo: StakerInfo, stakingInput: StakingInputs, stakingParamsVersion: number, slashingTx: Transaction, feeRate: number): Promise<TransactionResult>;
673
+ /**
674
+ * Creates a proof of possession for the staker based on ECDSA signature.
675
+ * @param bech32Address - The staker's bech32 address.
676
+ * @returns The proof of possession.
677
+ */
678
+ createProofOfPossession(channel: "delegation:create" | "delegation:register" | "delegation:expand", bech32Address: string, stakerBtcAddress: string): Promise<ProofOfPossessionBTC>;
679
+ /**
680
+ * Creates the unbonding, slashing, and unbonding slashing transactions and
681
+ * PSBTs.
682
+ * @param stakingInstance - The staking instance.
683
+ * @param stakingTx - The staking transaction.
684
+ * @returns The unbonding, slashing, and unbonding slashing transactions and
685
+ * PSBTs.
686
+ */
687
+ private createDelegationTransactionsAndPsbts;
688
+ /**
689
+ * Creates a protobuf message for the BTC delegation.
690
+ * @param channel - The event channel to emit the message on.
691
+ * @param stakingInstance - The staking instance.
692
+ * @param stakingInput - The staking inputs.
693
+ * @param stakingTx - The staking transaction.
694
+ * @param bech32Address - The staker's babylon chain bech32 address
695
+ * @param stakerBtcInfo - The staker's BTC information such as address and
696
+ * public key
697
+ * @param params - The staking parameters.
698
+ * @param options - The options for the BTC delegation.
699
+ * @param options.inclusionProof - The inclusion proof of the staking
700
+ * transaction.
701
+ * @param options.delegationExpansionInfo - The information for the BTC
702
+ * delegation expansion.
703
+ * @returns The protobuf message.
704
+ */
705
+ createBtcDelegationMsg(channel: "delegation:create" | "delegation:register" | "delegation:expand", stakingInstance: Staking, stakingInput: StakingInputs, stakingTx: Transaction, bech32Address: string, stakerBtcInfo: StakerInfo, params: StakingParams, options?: {
706
+ inclusionProof?: btcstaking.InclusionProof;
707
+ delegationExpansionInfo?: {
708
+ previousStakingTx: Transaction;
709
+ fundingTx: Transaction;
710
+ };
711
+ }): Promise<{
712
+ typeUrl: string;
713
+ value: btcstakingtx.MsgCreateBTCDelegation | btcstakingtx.MsgBtcStakeExpand;
714
+ }>;
715
+ /**
716
+ * Gets the inclusion proof for the staking transaction.
717
+ * See the type `InclusionProof` for more information
718
+ * @param inclusionProof - The inclusion proof.
719
+ * @returns The inclusion proof.
720
+ */
721
+ private getInclusionProof;
722
+ }
723
+ /**
724
+ * Get the staker signature from the unbonding transaction
725
+ * This is used mostly for unbonding transactions from phase-1(Observable)
726
+ * @param unbondingTx - The unbonding transaction
727
+ * @returns The staker signature
728
+ */
729
+ export declare const getUnbondingTxStakerSignature: (unbondingTx: Transaction) => string;
730
+ export interface ObservableStakingScripts extends StakingScripts {
731
+ dataEmbedScript: Buffer;
732
+ }
733
+ export declare class ObservableStakingScriptData extends StakingScriptData {
734
+ magicBytes: Buffer;
735
+ constructor(stakerKey: Buffer, finalityProviderKeys: Buffer[], covenantKeys: Buffer[], covenantThreshold: number, stakingTimelock: number, unbondingTimelock: number, magicBytes: Buffer);
736
+ /**
737
+ * Builds a data embed script for staking in the form:
738
+ * OP_RETURN || <serializedStakingData>
739
+ * where serializedStakingData is the concatenation of:
740
+ * MagicBytes || Version || StakerPublicKey || FinalityProviderPublicKey || StakingTimeLock
741
+ * Note: Only a single finality provider key is supported for now in phase 1
742
+ * @throws {Error} If the number of finality provider keys is not equal to 1.
743
+ * @returns {Buffer} The compiled data embed script.
744
+ */
745
+ buildDataEmbedScript(): Buffer;
746
+ /**
747
+ * Builds the staking scripts.
748
+ * @returns {ObservableStakingScripts} The staking scripts that can be used to stake.
749
+ * contains the timelockScript, unbondingScript, slashingScript,
750
+ * unbondingTimelockScript, and dataEmbedScript.
751
+ * @throws {Error} If script data is invalid.
752
+ */
753
+ buildScripts(): ObservableStakingScripts;
754
+ }
755
+ /**
756
+ * ObservableStaking is a class that provides an interface to create observable
757
+ * staking transactions for the Babylon Staking protocol.
758
+ *
759
+ * The class requires a network and staker information to create staking
760
+ * transactions.
761
+ * The staker information includes the staker's address and
762
+ * public key(without coordinates).
763
+ */
764
+ export declare class ObservableStaking extends Staking {
765
+ params: ObservableVersionedStakingParams;
766
+ constructor(network: networks.Network, stakerInfo: StakerInfo, params: ObservableVersionedStakingParams, finalityProviderPksNoCoordHex: string[], stakingTimelock: number);
767
+ /**
768
+ * Build the staking scripts for observable staking.
769
+ * This method overwrites the base method to include the OP_RETURN tag based
770
+ * on the tag provided in the parameters.
771
+ *
772
+ * @returns {ObservableStakingScripts} - The staking scripts for observable staking.
773
+ * @throws {StakingError} - If the scripts cannot be built.
774
+ */
775
+ buildScripts(): ObservableStakingScripts;
776
+ /**
777
+ * Create a staking transaction for observable staking.
778
+ * This overwrites the method from the Staking class with the addtion
779
+ * of the
780
+ * 1. OP_RETURN tag in the staking scripts
781
+ * 2. lockHeight parameter
782
+ *
783
+ * @param {number} stakingAmountSat - The amount to stake in satoshis.
784
+ * @param {UTXO[]} inputUTXOs - The UTXOs to use as inputs for the staking
785
+ * transaction.
786
+ * @param {number} feeRate - The fee rate for the transaction in satoshis per byte.
787
+ * @returns {TransactionResult} - An object containing the unsigned transaction,
788
+ * and fee
789
+ */
790
+ createStakingTransaction(stakingAmountSat: number, inputUTXOs: UTXO[], feeRate: number): TransactionResult;
791
+ /**
792
+ * Create a staking psbt for observable staking.
793
+ *
794
+ * @param {Transaction} stakingTx - The staking transaction.
795
+ * @param {UTXO[]} inputUTXOs - The UTXOs to use as inputs for the staking
796
+ * transaction.
797
+ * @returns {Psbt} - The psbt.
798
+ */
799
+ toStakingPsbt(stakingTx: Transaction, inputUTXOs: UTXO[]): Psbt;
800
+ }
801
+ export interface CovenantSignature {
802
+ btcPkHex: string;
803
+ sigHex: string;
804
+ }
805
+ /**
806
+ * Constructs an unsigned BTC Staking transaction in psbt format.
807
+ *
808
+ * Outputs:
809
+ * - psbt:
810
+ * - The first output corresponds to the staking script with the specified amount.
811
+ * - The second output corresponds to the change from spending the amount and the transaction fee.
812
+ * - If a data embed script is provided, it will be added as the second output, and the fee will be the third output.
813
+ * - fee: The total fee amount for the transaction.
814
+ *
815
+ * Inputs:
816
+ * - scripts:
817
+ * - timelockScript, unbondingScript, slashingScript: Scripts for different transaction types.
818
+ * - dataEmbedScript: Optional data embed script.
819
+ * - amount: Amount to stake.
820
+ * - changeAddress: Address to send the change to.
821
+ * - inputUTXOs: All available UTXOs from the wallet.
822
+ * - network: Bitcoin network.
823
+ * - feeRate: Fee rate in satoshis per byte.
824
+ * - publicKeyNoCoord: Public key if the wallet is in taproot mode.
825
+ * - lockHeight: Optional block height locktime to set for the transaction (i.e., not mined until the block height).
826
+ *
827
+ * @param {Object} scripts - Scripts used to construct the taproot output.
828
+ * such as timelockScript, unbondingScript, slashingScript, and dataEmbedScript.
829
+ * @param {number} amount - The amount to stake.
830
+ * @param {string} changeAddress - The address to send the change to.
831
+ * @param {UTXO[]} inputUTXOs - All available UTXOs from the wallet.
832
+ * @param {networks.Network} network - The Bitcoin network.
833
+ * @param {number} feeRate - The fee rate in satoshis per byte.
834
+ * @param {number} [lockHeight] - The optional block height locktime.
835
+ * @returns {TransactionResult} - An object containing the unsigned transaction and fee
836
+ * @throws Will throw an error if the amount or fee rate is less than or equal
837
+ * to 0, if the change address is invalid, or if the public key is invalid.
838
+ */
839
+ export declare function stakingTransaction(scripts: {
840
+ timelockScript: Buffer;
841
+ unbondingScript: Buffer;
842
+ slashingScript: Buffer;
843
+ dataEmbedScript?: Buffer;
844
+ }, amount: number, changeAddress: string, inputUTXOs: UTXO[], network: networks.Network, feeRate: number, lockHeight?: number): TransactionResult;
845
+ /**
846
+ * Expand an existing staking transaction with additional finality providers
847
+ * or renew timelock.
848
+ *
849
+ * This function builds a Bitcoin transaction that:
850
+ * 1. Spends the previous staking transaction output as the first input
851
+ * 2. Uses a funding UTXO as the second input to cover transaction fees
852
+ * 3. Creates new staking outputs where the timelock is renewed or FPs added
853
+ * 4. Returns any remaining funds as change
854
+ *
855
+ * @param network - Bitcoin network (mainnet, testnet, etc.)
856
+ * @param scripts - Scripts for the new staking outputs
857
+ * @param amount - Total staking amount (must equal previous staking amount,
858
+ * we only support equal amounts for now)
859
+ * @param changeAddress - Bitcoin address to receive change from funding UTXO
860
+ * @param feeRate - Fee rate in satoshis per byte
861
+ * @param inputUTXOs - Available UTXOs to use for funding the expansion
862
+ * @param previousStakingTxInfo - Details of the previous staking transaction
863
+ * being expanded
864
+ * @returns {TransactionResult & { fundingUTXO: UTXO }} containing the built
865
+ * transaction and calculated fee, and the funding UTXO
866
+ */
867
+ export declare function stakingExpansionTransaction(network: networks.Network, scripts: {
868
+ timelockScript: Buffer;
869
+ unbondingScript: Buffer;
870
+ slashingScript: Buffer;
871
+ }, amount: number, changeAddress: string, feeRate: number, inputUTXOs: UTXO[], previousStakingTxInfo: {
872
+ stakingTx: Transaction;
873
+ scripts: {
874
+ timelockScript: Buffer;
875
+ unbondingScript: Buffer;
876
+ slashingScript: Buffer;
877
+ };
878
+ }): TransactionResult & {
879
+ fundingUTXO: UTXO;
880
+ };
881
+ /**
882
+ * Constructs a withdrawal transaction for manually unbonded delegation.
883
+ *
884
+ * This transaction spends the unbonded output from the staking transaction.
885
+ *
886
+ * Inputs:
887
+ * - scripts: Scripts used to construct the taproot output.
888
+ * - unbondingTimelockScript: Script for the unbonding timelock condition.
889
+ * - slashingScript: Script for the slashing condition.
890
+ * - unbondingTx: The unbonding transaction.
891
+ * - withdrawalAddress: The address to send the withdrawn funds to.
892
+ * - network: The Bitcoin network.
893
+ * - feeRate: The fee rate for the transaction in satoshis per byte.
894
+ *
895
+ * Returns:
896
+ * - psbt: The partially signed transaction (PSBT).
897
+ *
898
+ * @param {Object} scripts - The scripts used in the transaction.
899
+ * @param {Transaction} unbondingTx - The unbonding transaction.
900
+ * @param {string} withdrawalAddress - The address to send the withdrawn funds to.
901
+ * @param {networks.Network} network - The Bitcoin network.
902
+ * @param {number} feeRate - The fee rate for the transaction in satoshis per byte.
903
+ * @returns {PsbtResult} An object containing the partially signed transaction (PSBT).
904
+ */
905
+ export declare function withdrawEarlyUnbondedTransaction(scripts: {
906
+ unbondingTimelockScript: Buffer;
907
+ slashingScript: Buffer;
908
+ }, unbondingTx: Transaction, withdrawalAddress: string, network: networks.Network, feeRate: number): PsbtResult;
909
+ /**
910
+ * Constructs a withdrawal transaction for naturally unbonded delegation.
911
+ *
912
+ * This transaction spends the unbonded output from the staking transaction when the timelock has expired.
913
+ *
914
+ * Inputs:
915
+ * - scripts: Scripts used to construct the taproot output.
916
+ * - timelockScript: Script for the timelock condition.
917
+ * - slashingScript: Script for the slashing condition.
918
+ * - unbondingScript: Script for the unbonding condition.
919
+ * - tx: The original staking transaction.
920
+ * - withdrawalAddress: The address to send the withdrawn funds to.
921
+ * - network: The Bitcoin network.
922
+ * - feeRate: The fee rate for the transaction in satoshis per byte.
923
+ * - outputIndex: The index of the output to be spent in the original transaction (default is 0).
924
+ *
925
+ * Returns:
926
+ * - psbt: The partially signed transaction (PSBT).
927
+ *
928
+ * @param {Object} scripts - The scripts used in the transaction.
929
+ * @param {Transaction} tx - The original staking transaction.
930
+ * @param {string} withdrawalAddress - The address to send the withdrawn funds to.
931
+ * @param {networks.Network} network - The Bitcoin network.
932
+ * @param {number} feeRate - The fee rate for the transaction in satoshis per byte.
933
+ * @param {number} [outputIndex=0] - The index of the output to be spent in the original transaction.
934
+ * @returns {PsbtResult} An object containing the partially signed transaction (PSBT).
935
+ */
936
+ export declare function withdrawTimelockUnbondedTransaction(scripts: {
937
+ timelockScript: Buffer;
938
+ slashingScript: Buffer;
939
+ unbondingScript: Buffer;
940
+ }, tx: Transaction, withdrawalAddress: string, network: networks.Network, feeRate: number, outputIndex?: number): PsbtResult;
941
+ /**
942
+ * Constructs a withdrawal transaction for a slashing transaction.
943
+ *
944
+ * This transaction spends the output from the slashing transaction.
945
+ *
946
+ * @param {Object} scripts - The unbondingTimelockScript
947
+ * We use the unbonding timelock script as the timelock of the slashing transaction.
948
+ * This is due to slashing tx timelock is the same as the unbonding timelock.
949
+ * @param {Transaction} slashingTx - The slashing transaction.
950
+ * @param {string} withdrawalAddress - The address to send the withdrawn funds to.
951
+ * @param {networks.Network} network - The Bitcoin network.
952
+ * @param {number} feeRate - The fee rate for the transaction in satoshis per byte.
953
+ * @param {number} outputIndex - The index of the output to be spent in the original transaction.
954
+ * @returns {PsbtResult} An object containing the partially signed transaction (PSBT).
955
+ */
956
+ export declare function withdrawSlashingTransaction(scripts: {
957
+ unbondingTimelockScript: Buffer;
958
+ }, slashingTx: Transaction, withdrawalAddress: string, network: networks.Network, feeRate: number, outputIndex: number): PsbtResult;
959
+ /**
960
+ * Constructs a slashing transaction for a staking output without prior unbonding.
961
+ *
962
+ * This transaction spends the staking output of the staking transaction and distributes the funds
963
+ * according to the specified slashing rate.
964
+ *
965
+ * Outputs:
966
+ * - The first output sends `input * slashing_rate` funds to the slashing address.
967
+ * - The second output sends `input * (1 - slashing_rate) - fee` funds back to the user's address.
968
+ *
969
+ * Inputs:
970
+ * - scripts: Scripts used to construct the taproot output.
971
+ * - slashingScript: Script for the slashing condition.
972
+ * - timelockScript: Script for the timelock condition.
973
+ * - unbondingScript: Script for the unbonding condition.
480
974
  * - unbondingTimelockScript: Script for the unbonding timelock condition.
481
975
  * - transaction: The original staking transaction.
482
976
  * - slashingAddress: The address to send the slashed funds to.
@@ -548,28 +1042,71 @@ export declare const isValidBitcoinAddress: (btcAddress: string, network: networ
548
1042
  * @returns {boolean} - True if the address is a Taproot address, otherwise false.
549
1043
  */
550
1044
  export declare const isTaproot: (taprootAddress: string, network: networks.Network) => boolean;
1045
+ /**
1046
+ * Check whether the given address is a Native SegWit address.
1047
+ *
1048
+ * @param {string} segwitAddress - The Bitcoin bech32 encoded address to check.
1049
+ * @param {object} network - The Bitcoin network (e.g., bitcoin.networks.bitcoin).
1050
+ * @returns {boolean} - True if the address is a Native SegWit address, otherwise false.
1051
+ */
1052
+ export declare const isNativeSegwit: (segwitAddress: string, network: networks.Network) => boolean;
551
1053
  /**
552
1054
  * Check whether the given public key is a valid public key without a coordinate.
553
1055
  *
554
- * @param {string} pkWithNoCoord - public key without the coordinate.
555
- * @returns {boolean} - True if the public key without the coordinate is valid, otherwise false.
1056
+ * @param {string} pkWithNoCoord - public key without the coordinate.
1057
+ * @returns {boolean} - True if the public key without the coordinate is valid, otherwise false.
1058
+ */
1059
+ export declare const isValidNoCoordPublicKey: (pkWithNoCoord: string) => boolean;
1060
+ /**
1061
+ * Get the public key without the coordinate.
1062
+ *
1063
+ * @param {string} pkHex - The public key in hex, with or without the coordinate.
1064
+ * @returns {string} - The public key without the coordinate in hex.
1065
+ * @throws {Error} - If the public key is invalid.
1066
+ */
1067
+ export declare const getPublicKeyNoCoord: (pkHex: string) => string;
1068
+ /**
1069
+ * Convert a transaction id to a hash. in buffer format.
1070
+ *
1071
+ * @param {string} txId - The transaction id.
1072
+ * @returns {Buffer} - The transaction hash.
1073
+ */
1074
+ export declare const transactionIdToHash: (txId: string) => Buffer;
1075
+ export declare const getBabylonParamByBtcHeight: (height: number, babylonParamsVersions: VersionedStakingParams[]) => StakingParams;
1076
+ export declare const getBabylonParamByVersion: (version: number, babylonParams: VersionedStakingParams[]) => StakingParams;
1077
+ export declare const findInputUTXO: (inputUTXOs: UTXO[], input: Input) => UTXO;
1078
+ /**
1079
+ * Determines and constructs the correct PSBT input fields for a given UTXO based on its script type.
1080
+ * This function handles different Bitcoin script types (P2PKH, P2SH, P2WPKH, P2WSH, P2TR) and returns
1081
+ * the appropriate PSBT input fields required for that UTXO.
1082
+ *
1083
+ * @param {UTXO} utxo - The unspent transaction output to process
1084
+ * @param {Buffer} [publicKeyNoCoord] - The public of the staker (optional).
1085
+ * @returns {object} PSBT input fields object containing the necessary data
1086
+ * @throws {Error} If required input data is missing or if an unsupported script type is provided
556
1087
  */
557
- export declare const isValidNoCoordPublicKey: (pkWithNoCoord: string) => boolean;
1088
+ export declare const getPsbtInputFields: (utxo: UTXO, publicKeyNoCoord?: Buffer) => PsbtInputExtended;
558
1089
  /**
559
- * Get the public key without the coordinate.
560
- *
561
- * @param {string} pkHex - The public key in hex, with or without the coordinate.
562
- * @returns {string} - The public key without the coordinate in hex.
563
- * @throws {Error} - If the public key is invalid.
1090
+ * Supported Bitcoin script types
564
1091
  */
565
- export declare const getPublicKeyNoCoord: (pkHex: string) => String;
1092
+ export declare enum BitcoinScriptType {
1093
+ P2PKH = "pubkeyhash",
1094
+ P2SH = "scripthash",
1095
+ P2WPKH = "witnesspubkeyhash",
1096
+ P2WSH = "witnessscripthash",
1097
+ P2TR = "taproot"
1098
+ }
566
1099
  /**
567
- * Convert a transaction id to a hash. in buffer format.
1100
+ * Determines the type of Bitcoin script.
568
1101
  *
569
- * @param {string} txId - The transaction id.
570
- * @returns {Buffer} - The transaction hash.
1102
+ * This function tries to parse the script using different Bitcoin payment types and returns
1103
+ * a string identifier for the script type.
1104
+ *
1105
+ * @param script - The raw script as a Buffer
1106
+ * @returns {BitcoinScriptType} The identified script type
1107
+ * @throws {Error} If the script cannot be identified as any known type
571
1108
  */
572
- export declare const transactionIdToHash: (txId: string) => Buffer;
1109
+ export declare const getScriptType: (script: Buffer) => BitcoinScriptType;
573
1110
  /**
574
1111
  * Validates a Babylon address. Babylon addresses are encoded in Bech32 format
575
1112
  * and have a prefix of "bbn".
@@ -658,33 +1195,6 @@ export declare const deriveSlashingOutput: (scripts: {
658
1195
  * @throws {Error} - If the matching output is not found.
659
1196
  */
660
1197
  export declare const findMatchingTxOutputIndex: (tx: Transaction, outputAddress: string, network: networks.Network) => number;
661
- /**
662
- * Validate the staking transaction input data.
663
- *
664
- * @param {number} stakingAmountSat - The staking amount in satoshis.
665
- * @param {number} timelock - The staking time in blocks.
666
- * @param {StakingParams} params - The staking parameters.
667
- * @param {UTXO[]} inputUTXOs - The input UTXOs.
668
- * @param {number} feeRate - The Bitcoin fee rate in sat/vbyte
669
- * @throws {StakingError} - If the input data is invalid.
670
- */
671
- export declare const validateStakingTxInputData: (stakingAmountSat: number, timelock: number, params: StakingParams, inputUTXOs: UTXO[], feeRate: number) => void;
672
- /**
673
- * Validate the staking parameters.
674
- * Extend this method to add additional validation for staking parameters based
675
- * on the staking type.
676
- * @param {StakingParams} params - The staking parameters.
677
- * @throws {StakingError} - If the parameters are invalid.
678
- */
679
- export declare const validateParams: (params: StakingParams) => void;
680
- /**
681
- * Validate the staking timelock.
682
- *
683
- * @param {number} stakingTimelock - The staking timelock.
684
- * @param {StakingParams} params - The staking parameters.
685
- * @throws {StakingError} - If the staking timelock is invalid.
686
- */
687
- export declare const validateStakingTimelock: (stakingTimelock: number, params: StakingParams) => void;
688
1198
  /**
689
1199
  * toBuffers converts an array of strings to an array of buffers.
690
1200
  *
@@ -693,256 +1203,33 @@ export declare const validateStakingTimelock: (stakingTimelock: number, params:
693
1203
  * @throws {StakingError} - If the values cannot be converted to buffers.
694
1204
  */
695
1205
  export declare const toBuffers: (inputs: string[]) => Buffer[];
696
- export declare const findInputUTXO: (inputUTXOs: UTXO[], input: Input) => UTXO;
697
1206
  /**
698
- * Determines and constructs the correct PSBT input fields for a given UTXO based on its script type.
699
- * This function handles different Bitcoin script types (P2PKH, P2SH, P2WPKH, P2WSH, P2TR) and returns
700
- * the appropriate PSBT input fields required for that UTXO.
701
- *
702
- * @param {UTXO} utxo - The unspent transaction output to process
703
- * @param {Buffer} [publicKeyNoCoord] - The public of the staker (optional).
704
- * @returns {object} PSBT input fields object containing the necessary data
705
- * @throws {Error} If required input data is missing or if an unsupported script type is provided
1207
+ * Strips all signatures from a transaction by clearing both the script and
1208
+ * witness data. This is due to the fact that we only need the raw unsigned
1209
+ * transaction structure. The signatures are sent in a separate protobuf field
1210
+ * when creating the delegation message in the Babylon.
1211
+ * @param tx - The transaction to strip signatures from
1212
+ * @returns A copy of the transaction with all signatures removed
706
1213
  */
707
- export declare const getPsbtInputFields: (utxo: UTXO, publicKeyNoCoord?: Buffer) => PsbtInputExtended;
1214
+ export declare const clearTxSignatures: (tx: Transaction) => Transaction;
708
1215
  /**
709
- * Supported Bitcoin script types
1216
+ * Derives the merkle proof from the list of hex strings. Note the
1217
+ * sibling hashes are reversed from hex before concatenation.
1218
+ * @param merkle - The merkle proof hex strings.
1219
+ * @returns The merkle proof in hex string format.
710
1220
  */
711
- export declare enum BitcoinScriptType {
712
- P2PKH = "pubkeyhash",
713
- P2SH = "scripthash",
714
- P2WPKH = "witnesspubkeyhash",
715
- P2WSH = "witnessscripthash",
716
- P2TR = "taproot"
717
- }
1221
+ export declare const deriveMerkleProof: (merkle: string[]) => string;
718
1222
  /**
719
- * Determines the type of Bitcoin script.
1223
+ * Extracts the first valid Schnorr signature from a signed transaction.
720
1224
  *
721
- * This function tries to parse the script using different Bitcoin payment types and returns
722
- * a string identifier for the script type.
1225
+ * Since we only handle transactions with a single input and request a signature
1226
+ * for one public key, there can be at most one signature from the Bitcoin node.
1227
+ * A valid Schnorr signature is exactly 64 bytes in length.
723
1228
  *
724
- * @param script - The raw script as a Buffer
725
- * @returns {BitcoinScriptType} The identified script type
726
- * @throws {Error} If the script cannot be identified as any known type
727
- */
728
- export declare const getScriptType: (script: Buffer) => BitcoinScriptType;
729
- export declare const getBabylonParamByBtcHeight: (height: number, babylonParamsVersions: VersionedStakingParams[]) => StakingParams;
730
- export declare const getBabylonParamByVersion: (version: number, babylonParams: VersionedStakingParams[]) => StakingParams;
731
- export interface BtcProvider {
732
- signPsbt(signingStep: SigningStep, psbtHex: string): Promise<string>;
733
- signMessage?: (signingStep: SigningStep, message: string, type: "ecdsa") => Promise<string>;
734
- }
735
- export interface BabylonProvider {
736
- signTransaction: <T extends object>(signingStep: SigningStep, msg: {
737
- typeUrl: string;
738
- value: T;
739
- }) => Promise<Uint8Array>;
740
- }
741
- export declare enum SigningStep {
742
- STAKING_SLASHING = "staking-slashing",
743
- UNBONDING_SLASHING = "unbonding-slashing",
744
- PROOF_OF_POSSESSION = "proof-of-possession",
745
- CREATE_BTC_DELEGATION_MSG = "create-btc-delegation-msg",
746
- STAKING = "staking",
747
- UNBONDING = "unbonding",
748
- WITHDRAW_STAKING_EXPIRED = "withdraw-staking-expired",
749
- WITHDRAW_EARLY_UNBONDED = "withdraw-early-unbonded",
750
- WITHDRAW_SLASHING = "withdraw-slashing"
751
- }
752
- export interface StakingInputs {
753
- finalityProviderPkNoCoordHex: string;
754
- stakingAmountSat: number;
755
- stakingTimelock: number;
756
- }
757
- export interface InclusionProof {
758
- pos: number;
759
- merkle: string[];
760
- blockHashHex: string;
761
- }
762
- export declare class BabylonBtcStakingManager {
763
- private stakingParams;
764
- private btcProvider;
765
- private network;
766
- private babylonProvider;
767
- constructor(network: networks.Network, stakingParams: VersionedStakingParams[], btcProvider: BtcProvider, babylonProvider: BabylonProvider);
768
- /**
769
- * Creates a signed Pre-Staking Registration transaction that is ready to be
770
- * sent to the Babylon chain.
771
- * @param stakerBtcInfo - The staker BTC info which includes the BTC address
772
- * and the no-coord public key in hex format.
773
- * @param stakingInput - The staking inputs.
774
- * @param babylonBtcTipHeight - The Babylon BTC tip height.
775
- * @param inputUTXOs - The UTXOs that will be used to pay for the staking
776
- * transaction.
777
- * @param feeRate - The fee rate in satoshis per byte.
778
- * @param babylonAddress - The Babylon bech32 encoded address of the staker.
779
- * @returns The signed babylon pre-staking registration transaction in base64
780
- * format.
781
- */
782
- preStakeRegistrationBabylonTransaction(stakerBtcInfo: StakerInfo, stakingInput: StakingInputs, babylonBtcTipHeight: number, inputUTXOs: UTXO[], feeRate: number, babylonAddress: string): Promise<{
783
- signedBabylonTx: Uint8Array;
784
- stakingTx: Transaction;
785
- }>;
786
- /**
787
- * Creates a signed post-staking registration transaction that is ready to be
788
- * sent to the Babylon chain. This is used when a staking transaction is
789
- * already created and included in a BTC block and we want to register it on
790
- * the Babylon chain.
791
- * @param stakerBtcInfo - The staker BTC info which includes the BTC address
792
- * and the no-coord public key in hex format.
793
- * @param stakingTx - The staking transaction.
794
- * @param stakingTxHeight - The BTC height in which the staking transaction
795
- * is included.
796
- * @param stakingInput - The staking inputs.
797
- * @param inclusionProof - The inclusion proof of the staking transaction.
798
- * @param babylonAddress - The Babylon bech32 encoded address of the staker.
799
- * @returns The signed babylon transaction in base64 format.
800
- */
801
- postStakeRegistrationBabylonTransaction(stakerBtcInfo: StakerInfo, stakingTx: Transaction, stakingTxHeight: number, stakingInput: StakingInputs, inclusionProof: InclusionProof, babylonAddress: string): Promise<{
802
- signedBabylonTx: Uint8Array;
803
- }>;
804
- /**
805
- * Estimates the BTC fee required for staking.
806
- * @param stakerBtcInfo - The staker BTC info which includes the BTC address
807
- * and the no-coord public key in hex format.
808
- * @param babylonBtcTipHeight - The BTC tip height recorded on the Babylon
809
- * chain.
810
- * @param stakingInput - The staking inputs.
811
- * @param inputUTXOs - The UTXOs that will be used to pay for the staking
812
- * transaction.
813
- * @param feeRate - The fee rate in satoshis per byte.
814
- * @returns The estimated BTC fee in satoshis.
815
- */
816
- estimateBtcStakingFee(stakerBtcInfo: StakerInfo, babylonBtcTipHeight: number, stakingInput: StakingInputs, inputUTXOs: UTXO[], feeRate: number): number;
817
- /**
818
- * Creates a signed staking transaction that is ready to be sent to the BTC
819
- * network.
820
- * @param stakerBtcInfo - The staker BTC info which includes the BTC address
821
- * and the no-coord public key in hex format.
822
- * @param stakingInput - The staking inputs.
823
- * @param unsignedStakingTx - The unsigned staking transaction.
824
- * @param inputUTXOs - The UTXOs that will be used to pay for the staking
825
- * transaction.
826
- * @param stakingParamsVersion - The params version that was used to create the
827
- * delegation in Babylon chain
828
- * @returns The signed staking transaction.
829
- */
830
- createSignedBtcStakingTransaction(stakerBtcInfo: StakerInfo, stakingInput: StakingInputs, unsignedStakingTx: Transaction, inputUTXOs: UTXO[], stakingParamsVersion: number): Promise<Transaction>;
831
- /**
832
- * Creates a partial signed unbonding transaction that is only signed by the
833
- * staker. In order to complete the unbonding transaction, the covenant
834
- * unbonding signatures need to be added to the transaction before sending it
835
- * to the BTC network.
836
- * NOTE: This method should only be used for Babylon phase-1 unbonding.
837
- * @param stakerBtcInfo - The staker BTC info which includes the BTC address
838
- * and the no-coord public key in hex format.
839
- * @param stakingInput - The staking inputs.
840
- * @param stakingParamsVersion - The params version that was used to create the
841
- * delegation in Babylon chain
842
- * @param stakingTx - The staking transaction.
843
- * @returns The partial signed unbonding transaction and its fee.
844
- */
845
- createPartialSignedBtcUnbondingTransaction(stakerBtcInfo: StakerInfo, stakingInput: StakingInputs, stakingParamsVersion: number, stakingTx: Transaction): Promise<TransactionResult>;
846
- /**
847
- * Creates a signed unbonding transaction that is ready to be sent to the BTC
848
- * network.
849
- * @param stakerBtcInfo - The staker BTC info which includes the BTC address
850
- * and the no-coord public key in hex format.
851
- * @param stakingInput - The staking inputs.
852
- * @param stakingParamsVersion - The params version that was used to create the
853
- * delegation in Babylon chain
854
- * @param stakingTx - The staking transaction.
855
- * @param unsignedUnbondingTx - The unsigned unbonding transaction.
856
- * @param covenantUnbondingSignatures - The covenant unbonding signatures.
857
- * It can be retrieved from the Babylon chain or API.
858
- * @returns The signed unbonding transaction and its fee.
859
- */
860
- createSignedBtcUnbondingTransaction(stakerBtcInfo: StakerInfo, stakingInput: StakingInputs, stakingParamsVersion: number, stakingTx: Transaction, unsignedUnbondingTx: Transaction, covenantUnbondingSignatures: {
861
- btcPkHex: string;
862
- sigHex: string;
863
- }[]): Promise<TransactionResult>;
864
- /**
865
- * Creates a signed withdrawal transaction on the unbodning output expiry path
866
- * that is ready to be sent to the BTC network.
867
- * @param stakingInput - The staking inputs.
868
- * @param stakingParamsVersion - The params version that was used to create the
869
- * delegation in Babylon chain
870
- * @param earlyUnbondingTx - The early unbonding transaction.
871
- * @param feeRate - The fee rate in satoshis per byte.
872
- * @returns The signed withdrawal transaction and its fee.
873
- */
874
- createSignedBtcWithdrawEarlyUnbondedTransaction(stakerBtcInfo: StakerInfo, stakingInput: StakingInputs, stakingParamsVersion: number, earlyUnbondingTx: Transaction, feeRate: number): Promise<TransactionResult>;
875
- /**
876
- * Creates a signed withdrawal transaction on the staking output expiry path
877
- * that is ready to be sent to the BTC network.
878
- * @param stakerBtcInfo - The staker BTC info which includes the BTC address
879
- * and the no-coord public key in hex format.
880
- * @param stakingInput - The staking inputs.
881
- * @param stakingParamsVersion - The params version that was used to create the
882
- * delegation in Babylon chain
883
- * @param stakingTx - The staking transaction.
884
- * @param feeRate - The fee rate in satoshis per byte.
885
- * @returns The signed withdrawal transaction and its fee.
886
- */
887
- createSignedBtcWithdrawStakingExpiredTransaction(stakerBtcInfo: StakerInfo, stakingInput: StakingInputs, stakingParamsVersion: number, stakingTx: Transaction, feeRate: number): Promise<TransactionResult>;
888
- /**
889
- * Creates a signed withdrawal transaction for the expired slashing output that
890
- * is ready to be sent to the BTC network.
891
- * @param stakerBtcInfo - The staker BTC info which includes the BTC address
892
- * and the no-coord public key in hex format.
893
- * @param stakingInput - The staking inputs.
894
- * @param stakingParamsVersion - The params version that was used to create the
895
- * delegation in Babylon chain
896
- * @param slashingTx - The slashing transaction.
897
- * @param feeRate - The fee rate in satoshis per byte.
898
- * @returns The signed withdrawal transaction and its fee.
899
- */
900
- createSignedBtcWithdrawSlashingTransaction(stakerBtcInfo: StakerInfo, stakingInput: StakingInputs, stakingParamsVersion: number, slashingTx: Transaction, feeRate: number): Promise<TransactionResult>;
901
- /**
902
- * Creates a proof of possession for the staker based on ECDSA signature.
903
- * @param bech32Address - The staker's bech32 address.
904
- * @returns The proof of possession.
905
- */
906
- createProofOfPossession(bech32Address: string): Promise<ProofOfPossessionBTC>;
907
- /**
908
- * Creates the unbonding, slashing, and unbonding slashing transactions and
909
- * PSBTs.
910
- * @param stakingInstance - The staking instance.
911
- * @param stakingTx - The staking transaction.
912
- * @returns The unbonding, slashing, and unbonding slashing transactions and
913
- * PSBTs.
914
- */
915
- private createDelegationTransactionsAndPsbts;
916
- /**
917
- * Creates a protobuf message for the BTC delegation.
918
- * @param stakingInstance - The staking instance.
919
- * @param stakingInput - The staking inputs.
920
- * @param stakingTx - The staking transaction.
921
- * @param bech32Address - The staker's babylon chain bech32 address
922
- * @param stakerBtcInfo - The staker's BTC information such as address and
923
- * public key
924
- * @param params - The staking parameters.
925
- * @param inclusionProof - The inclusion proof of the staking transaction.
926
- * @returns The protobuf message.
927
- */
928
- createBtcDelegationMsg(stakingInstance: Staking, stakingInput: StakingInputs, stakingTx: Transaction, bech32Address: string, stakerBtcInfo: StakerInfo, params: StakingParams, inclusionProof?: btcstaking.InclusionProof): Promise<{
929
- typeUrl: string;
930
- value: btcstakingtx.MsgCreateBTCDelegation;
931
- }>;
932
- /**
933
- * Gets the inclusion proof for the staking transaction.
934
- * See the type `InclusionProof` for more information
935
- * @param inclusionProof - The inclusion proof.
936
- * @returns The inclusion proof.
937
- */
938
- private getInclusionProof;
939
- }
940
- /**
941
- * Get the staker signature from the unbonding transaction
942
- * This is used mostly for unbonding transactions from phase-1(Observable)
943
- * @param unbondingTx - The unbonding transaction
944
- * @returns The staker signature
1229
+ * @param singedTransaction - The signed Bitcoin transaction to extract the signature from
1230
+ * @returns The first valid 64-byte Schnorr signature found in the transaction witness data,
1231
+ * or undefined if no valid signature exists
945
1232
  */
946
- export declare const getUnbondingTxStakerSignature: (unbondingTx: Transaction) => string;
1233
+ export declare const extractFirstSchnorrSignatureFromTransaction: (singedTransaction: Transaction) => Buffer | undefined;
947
1234
 
948
1235
  export {};