@bitgo-beta/babylonlabs-io-btc-staking-ts 0.4.0-alpha.57 → 0.4.0-alpha.59
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/README.md +1 -1
- package/dist/index.cjs +11 -11
- package/dist/index.d.cts +123 -123
- package/dist/index.js +11 -11
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
BitGo Fork of https://github.com/babylonlabs-io/btc-staking-ts/tree/
|
|
1
|
+
BitGo Fork of https://github.com/babylonlabs-io/btc-staking-ts/tree/v0.4.0-rc.2
|
package/dist/index.cjs
CHANGED
|
@@ -1861,6 +1861,17 @@ var ObservableStaking = class extends Staking {
|
|
|
1861
1861
|
}
|
|
1862
1862
|
};
|
|
1863
1863
|
|
|
1864
|
+
// src/utils/babylon.ts
|
|
1865
|
+
var import_encoding = require("@cosmjs/encoding");
|
|
1866
|
+
var isValidBabylonAddress = (address4) => {
|
|
1867
|
+
try {
|
|
1868
|
+
const { prefix } = (0, import_encoding.fromBech32)(address4);
|
|
1869
|
+
return prefix === "bbn";
|
|
1870
|
+
} catch (error) {
|
|
1871
|
+
return false;
|
|
1872
|
+
}
|
|
1873
|
+
};
|
|
1874
|
+
|
|
1864
1875
|
// src/utils/staking/param.ts
|
|
1865
1876
|
var getBabylonParamByBtcHeight = (height, babylonParamsVersions) => {
|
|
1866
1877
|
const sortedParams = [...babylonParamsVersions].sort(
|
|
@@ -1903,17 +1914,6 @@ var reverseBuffer = (buffer) => {
|
|
|
1903
1914
|
return clonedBuffer;
|
|
1904
1915
|
};
|
|
1905
1916
|
|
|
1906
|
-
// src/utils/babylon.ts
|
|
1907
|
-
var import_encoding = require("@cosmjs/encoding");
|
|
1908
|
-
var isValidBabylonAddress = (address4) => {
|
|
1909
|
-
try {
|
|
1910
|
-
const { prefix } = (0, import_encoding.fromBech32)(address4);
|
|
1911
|
-
return prefix === "bbn";
|
|
1912
|
-
} catch (error) {
|
|
1913
|
-
return false;
|
|
1914
|
-
}
|
|
1915
|
-
};
|
|
1916
|
-
|
|
1917
1917
|
// src/staking/manager.ts
|
|
1918
1918
|
var SigningStep = /* @__PURE__ */ ((SigningStep2) => {
|
|
1919
1919
|
SigningStep2["STAKING_SLASHING"] = "staking-slashing";
|
package/dist/index.d.cts
CHANGED
|
@@ -578,6 +578,129 @@ export declare const getPublicKeyNoCoord: (pkHex: string) => String;
|
|
|
578
578
|
* @returns {Buffer} - The transaction hash.
|
|
579
579
|
*/
|
|
580
580
|
export declare const transactionIdToHash: (txId: string) => Buffer;
|
|
581
|
+
/**
|
|
582
|
+
* Validates a Babylon address. Babylon addresses are encoded in Bech32 format
|
|
583
|
+
* and have a prefix of "bbn".
|
|
584
|
+
* @param address - The address to validate.
|
|
585
|
+
* @returns True if the address is valid, false otherwise.
|
|
586
|
+
*/
|
|
587
|
+
export declare const isValidBabylonAddress: (address: string) => boolean;
|
|
588
|
+
export type TransactionOutput = {
|
|
589
|
+
scriptPubKey: Buffer;
|
|
590
|
+
value: number;
|
|
591
|
+
};
|
|
592
|
+
export interface OutputInfo {
|
|
593
|
+
scriptPubKey: Buffer;
|
|
594
|
+
outputAddress: string;
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* Build the staking output for the transaction which contains p2tr output
|
|
598
|
+
* with staking scripts.
|
|
599
|
+
*
|
|
600
|
+
* @param {StakingScripts} scripts - The staking scripts.
|
|
601
|
+
* @param {networks.Network} network - The Bitcoin network.
|
|
602
|
+
* @param {number} amount - The amount to stake.
|
|
603
|
+
* @returns {TransactionOutput[]} - The staking transaction outputs.
|
|
604
|
+
* @throws {Error} - If the staking output cannot be built.
|
|
605
|
+
*/
|
|
606
|
+
export declare const buildStakingTransactionOutputs: (scripts: {
|
|
607
|
+
timelockScript: Buffer;
|
|
608
|
+
unbondingScript: Buffer;
|
|
609
|
+
slashingScript: Buffer;
|
|
610
|
+
dataEmbedScript?: Buffer;
|
|
611
|
+
}, network: networks.Network, amount: number) => TransactionOutput[];
|
|
612
|
+
/**
|
|
613
|
+
* Derive the staking output address from the staking scripts.
|
|
614
|
+
*
|
|
615
|
+
* @param {StakingScripts} scripts - The staking scripts.
|
|
616
|
+
* @param {networks.Network} network - The Bitcoin network.
|
|
617
|
+
* @returns {StakingOutput} - The staking output address and scriptPubKey.
|
|
618
|
+
* @throws {StakingError} - If the staking output address cannot be derived.
|
|
619
|
+
*/
|
|
620
|
+
export declare const deriveStakingOutputInfo: (scripts: {
|
|
621
|
+
timelockScript: Buffer;
|
|
622
|
+
unbondingScript: Buffer;
|
|
623
|
+
slashingScript: Buffer;
|
|
624
|
+
}, network: networks.Network) => {
|
|
625
|
+
outputAddress: string;
|
|
626
|
+
scriptPubKey: Buffer<ArrayBufferLike>;
|
|
627
|
+
};
|
|
628
|
+
/**
|
|
629
|
+
* Derive the unbonding output address and scriptPubKey from the staking scripts.
|
|
630
|
+
*
|
|
631
|
+
* @param {StakingScripts} scripts - The staking scripts.
|
|
632
|
+
* @param {networks.Network} network - The Bitcoin network.
|
|
633
|
+
* @returns {OutputInfo} - The unbonding output address and scriptPubKey.
|
|
634
|
+
* @throws {StakingError} - If the unbonding output address cannot be derived.
|
|
635
|
+
*/
|
|
636
|
+
export declare const deriveUnbondingOutputInfo: (scripts: {
|
|
637
|
+
unbondingTimelockScript: Buffer;
|
|
638
|
+
slashingScript: Buffer;
|
|
639
|
+
}, network: networks.Network) => {
|
|
640
|
+
outputAddress: string;
|
|
641
|
+
scriptPubKey: Buffer<ArrayBufferLike>;
|
|
642
|
+
};
|
|
643
|
+
/**
|
|
644
|
+
* Derive the slashing output address and scriptPubKey from the staking scripts.
|
|
645
|
+
*
|
|
646
|
+
* @param {StakingScripts} scripts - The unbonding timelock scripts, we use the
|
|
647
|
+
* unbonding timelock script as the timelock of the slashing transaction.
|
|
648
|
+
* This is due to slashing tx timelock is the same as the unbonding timelock.
|
|
649
|
+
* @param {networks.Network} network - The Bitcoin network.
|
|
650
|
+
* @returns {OutputInfo} - The slashing output address and scriptPubKey.
|
|
651
|
+
* @throws {StakingError} - If the slashing output address cannot be derived.
|
|
652
|
+
*/
|
|
653
|
+
export declare const deriveSlashingOutput: (scripts: {
|
|
654
|
+
unbondingTimelockScript: Buffer;
|
|
655
|
+
}, network: networks.Network) => {
|
|
656
|
+
outputAddress: string;
|
|
657
|
+
scriptPubKey: Buffer<ArrayBufferLike>;
|
|
658
|
+
};
|
|
659
|
+
/**
|
|
660
|
+
* Find the matching output index for the given transaction.
|
|
661
|
+
*
|
|
662
|
+
* @param {Transaction} tx - The transaction.
|
|
663
|
+
* @param {string} outputAddress - The output address.
|
|
664
|
+
* @param {networks.Network} network - The Bitcoin network.
|
|
665
|
+
* @returns {number} - The output index.
|
|
666
|
+
* @throws {Error} - If the matching output is not found.
|
|
667
|
+
*/
|
|
668
|
+
export declare const findMatchingTxOutputIndex: (tx: Transaction, outputAddress: string, network: networks.Network) => number;
|
|
669
|
+
/**
|
|
670
|
+
* Validate the staking transaction input data.
|
|
671
|
+
*
|
|
672
|
+
* @param {number} stakingAmountSat - The staking amount in satoshis.
|
|
673
|
+
* @param {number} timelock - The staking time in blocks.
|
|
674
|
+
* @param {StakingParams} params - The staking parameters.
|
|
675
|
+
* @param {UTXO[]} inputUTXOs - The input UTXOs.
|
|
676
|
+
* @param {number} feeRate - The Bitcoin fee rate in sat/vbyte
|
|
677
|
+
* @throws {StakingError} - If the input data is invalid.
|
|
678
|
+
*/
|
|
679
|
+
export declare const validateStakingTxInputData: (stakingAmountSat: number, timelock: number, params: StakingParams, inputUTXOs: UTXO[], feeRate: number) => void;
|
|
680
|
+
/**
|
|
681
|
+
* Validate the staking parameters.
|
|
682
|
+
* Extend this method to add additional validation for staking parameters based
|
|
683
|
+
* on the staking type.
|
|
684
|
+
* @param {StakingParams} params - The staking parameters.
|
|
685
|
+
* @throws {StakingError} - If the parameters are invalid.
|
|
686
|
+
*/
|
|
687
|
+
export declare const validateParams: (params: StakingParams) => void;
|
|
688
|
+
/**
|
|
689
|
+
* Validate the staking timelock.
|
|
690
|
+
*
|
|
691
|
+
* @param {number} stakingTimelock - The staking timelock.
|
|
692
|
+
* @param {StakingParams} params - The staking parameters.
|
|
693
|
+
* @throws {StakingError} - If the staking timelock is invalid.
|
|
694
|
+
*/
|
|
695
|
+
export declare const validateStakingTimelock: (stakingTimelock: number, params: StakingParams) => void;
|
|
696
|
+
/**
|
|
697
|
+
* toBuffers converts an array of strings to an array of buffers.
|
|
698
|
+
*
|
|
699
|
+
* @param {string[]} inputs - The input strings.
|
|
700
|
+
* @returns {Buffer[]} - The buffers.
|
|
701
|
+
* @throws {StakingError} - If the values cannot be converted to buffers.
|
|
702
|
+
*/
|
|
703
|
+
export declare const toBuffers: (inputs: string[]) => Buffer[];
|
|
581
704
|
export declare const findInputUTXO: (inputUTXOs: UTXO[], input: Input) => UTXO;
|
|
582
705
|
/**
|
|
583
706
|
* Determines and constructs the correct PSBT input fields for a given UTXO based on its script type.
|
|
@@ -852,128 +975,5 @@ export declare class BabylonBtcStakingManager {
|
|
|
852
975
|
* @returns The staker signature
|
|
853
976
|
*/
|
|
854
977
|
export declare const getUnbondingTxStakerSignature: (unbondingTx: Transaction) => string;
|
|
855
|
-
/**
|
|
856
|
-
* Validates a Babylon address. Babylon addresses are encoded in Bech32 format
|
|
857
|
-
* and have a prefix of "bbn".
|
|
858
|
-
* @param address - The address to validate.
|
|
859
|
-
* @returns True if the address is valid, false otherwise.
|
|
860
|
-
*/
|
|
861
|
-
export declare const isValidBabylonAddress: (address: string) => boolean;
|
|
862
|
-
export type TransactionOutput = {
|
|
863
|
-
scriptPubKey: Buffer;
|
|
864
|
-
value: number;
|
|
865
|
-
};
|
|
866
|
-
export interface OutputInfo {
|
|
867
|
-
scriptPubKey: Buffer;
|
|
868
|
-
outputAddress: string;
|
|
869
|
-
}
|
|
870
|
-
/**
|
|
871
|
-
* Build the staking output for the transaction which contains p2tr output
|
|
872
|
-
* with staking scripts.
|
|
873
|
-
*
|
|
874
|
-
* @param {StakingScripts} scripts - The staking scripts.
|
|
875
|
-
* @param {networks.Network} network - The Bitcoin network.
|
|
876
|
-
* @param {number} amount - The amount to stake.
|
|
877
|
-
* @returns {TransactionOutput[]} - The staking transaction outputs.
|
|
878
|
-
* @throws {Error} - If the staking output cannot be built.
|
|
879
|
-
*/
|
|
880
|
-
export declare const buildStakingTransactionOutputs: (scripts: {
|
|
881
|
-
timelockScript: Buffer;
|
|
882
|
-
unbondingScript: Buffer;
|
|
883
|
-
slashingScript: Buffer;
|
|
884
|
-
dataEmbedScript?: Buffer;
|
|
885
|
-
}, network: networks.Network, amount: number) => TransactionOutput[];
|
|
886
|
-
/**
|
|
887
|
-
* Derive the staking output address from the staking scripts.
|
|
888
|
-
*
|
|
889
|
-
* @param {StakingScripts} scripts - The staking scripts.
|
|
890
|
-
* @param {networks.Network} network - The Bitcoin network.
|
|
891
|
-
* @returns {StakingOutput} - The staking output address and scriptPubKey.
|
|
892
|
-
* @throws {StakingError} - If the staking output address cannot be derived.
|
|
893
|
-
*/
|
|
894
|
-
export declare const deriveStakingOutputInfo: (scripts: {
|
|
895
|
-
timelockScript: Buffer;
|
|
896
|
-
unbondingScript: Buffer;
|
|
897
|
-
slashingScript: Buffer;
|
|
898
|
-
}, network: networks.Network) => {
|
|
899
|
-
outputAddress: string;
|
|
900
|
-
scriptPubKey: Buffer<ArrayBufferLike>;
|
|
901
|
-
};
|
|
902
|
-
/**
|
|
903
|
-
* Derive the unbonding output address and scriptPubKey from the staking scripts.
|
|
904
|
-
*
|
|
905
|
-
* @param {StakingScripts} scripts - The staking scripts.
|
|
906
|
-
* @param {networks.Network} network - The Bitcoin network.
|
|
907
|
-
* @returns {OutputInfo} - The unbonding output address and scriptPubKey.
|
|
908
|
-
* @throws {StakingError} - If the unbonding output address cannot be derived.
|
|
909
|
-
*/
|
|
910
|
-
export declare const deriveUnbondingOutputInfo: (scripts: {
|
|
911
|
-
unbondingTimelockScript: Buffer;
|
|
912
|
-
slashingScript: Buffer;
|
|
913
|
-
}, network: networks.Network) => {
|
|
914
|
-
outputAddress: string;
|
|
915
|
-
scriptPubKey: Buffer<ArrayBufferLike>;
|
|
916
|
-
};
|
|
917
|
-
/**
|
|
918
|
-
* Derive the slashing output address and scriptPubKey from the staking scripts.
|
|
919
|
-
*
|
|
920
|
-
* @param {StakingScripts} scripts - The unbonding timelock scripts, we use the
|
|
921
|
-
* unbonding timelock script as the timelock of the slashing transaction.
|
|
922
|
-
* This is due to slashing tx timelock is the same as the unbonding timelock.
|
|
923
|
-
* @param {networks.Network} network - The Bitcoin network.
|
|
924
|
-
* @returns {OutputInfo} - The slashing output address and scriptPubKey.
|
|
925
|
-
* @throws {StakingError} - If the slashing output address cannot be derived.
|
|
926
|
-
*/
|
|
927
|
-
export declare const deriveSlashingOutput: (scripts: {
|
|
928
|
-
unbondingTimelockScript: Buffer;
|
|
929
|
-
}, network: networks.Network) => {
|
|
930
|
-
outputAddress: string;
|
|
931
|
-
scriptPubKey: Buffer<ArrayBufferLike>;
|
|
932
|
-
};
|
|
933
|
-
/**
|
|
934
|
-
* Find the matching output index for the given transaction.
|
|
935
|
-
*
|
|
936
|
-
* @param {Transaction} tx - The transaction.
|
|
937
|
-
* @param {string} outputAddress - The output address.
|
|
938
|
-
* @param {networks.Network} network - The Bitcoin network.
|
|
939
|
-
* @returns {number} - The output index.
|
|
940
|
-
* @throws {Error} - If the matching output is not found.
|
|
941
|
-
*/
|
|
942
|
-
export declare const findMatchingTxOutputIndex: (tx: Transaction, outputAddress: string, network: networks.Network) => number;
|
|
943
|
-
/**
|
|
944
|
-
* Validate the staking transaction input data.
|
|
945
|
-
*
|
|
946
|
-
* @param {number} stakingAmountSat - The staking amount in satoshis.
|
|
947
|
-
* @param {number} timelock - The staking time in blocks.
|
|
948
|
-
* @param {StakingParams} params - The staking parameters.
|
|
949
|
-
* @param {UTXO[]} inputUTXOs - The input UTXOs.
|
|
950
|
-
* @param {number} feeRate - The Bitcoin fee rate in sat/vbyte
|
|
951
|
-
* @throws {StakingError} - If the input data is invalid.
|
|
952
|
-
*/
|
|
953
|
-
export declare const validateStakingTxInputData: (stakingAmountSat: number, timelock: number, params: StakingParams, inputUTXOs: UTXO[], feeRate: number) => void;
|
|
954
|
-
/**
|
|
955
|
-
* Validate the staking parameters.
|
|
956
|
-
* Extend this method to add additional validation for staking parameters based
|
|
957
|
-
* on the staking type.
|
|
958
|
-
* @param {StakingParams} params - The staking parameters.
|
|
959
|
-
* @throws {StakingError} - If the parameters are invalid.
|
|
960
|
-
*/
|
|
961
|
-
export declare const validateParams: (params: StakingParams) => void;
|
|
962
|
-
/**
|
|
963
|
-
* Validate the staking timelock.
|
|
964
|
-
*
|
|
965
|
-
* @param {number} stakingTimelock - The staking timelock.
|
|
966
|
-
* @param {StakingParams} params - The staking parameters.
|
|
967
|
-
* @throws {StakingError} - If the staking timelock is invalid.
|
|
968
|
-
*/
|
|
969
|
-
export declare const validateStakingTimelock: (stakingTimelock: number, params: StakingParams) => void;
|
|
970
|
-
/**
|
|
971
|
-
* toBuffers converts an array of strings to an array of buffers.
|
|
972
|
-
*
|
|
973
|
-
* @param {string[]} inputs - The input strings.
|
|
974
|
-
* @returns {Buffer[]} - The buffers.
|
|
975
|
-
* @throws {StakingError} - If the values cannot be converted to buffers.
|
|
976
|
-
*/
|
|
977
|
-
export declare const toBuffers: (inputs: string[]) => Buffer[];
|
|
978
978
|
|
|
979
979
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -1788,6 +1788,17 @@ var ObservableStaking = class extends Staking {
|
|
|
1788
1788
|
}
|
|
1789
1789
|
};
|
|
1790
1790
|
|
|
1791
|
+
// src/utils/babylon.ts
|
|
1792
|
+
import { fromBech32 } from "@cosmjs/encoding";
|
|
1793
|
+
var isValidBabylonAddress = (address4) => {
|
|
1794
|
+
try {
|
|
1795
|
+
const { prefix } = fromBech32(address4);
|
|
1796
|
+
return prefix === "bbn";
|
|
1797
|
+
} catch (error) {
|
|
1798
|
+
return false;
|
|
1799
|
+
}
|
|
1800
|
+
};
|
|
1801
|
+
|
|
1791
1802
|
// src/utils/staking/param.ts
|
|
1792
1803
|
var getBabylonParamByBtcHeight = (height, babylonParamsVersions) => {
|
|
1793
1804
|
const sortedParams = [...babylonParamsVersions].sort(
|
|
@@ -1837,17 +1848,6 @@ var reverseBuffer = (buffer) => {
|
|
|
1837
1848
|
return clonedBuffer;
|
|
1838
1849
|
};
|
|
1839
1850
|
|
|
1840
|
-
// src/utils/babylon.ts
|
|
1841
|
-
import { fromBech32 } from "@cosmjs/encoding";
|
|
1842
|
-
var isValidBabylonAddress = (address4) => {
|
|
1843
|
-
try {
|
|
1844
|
-
const { prefix } = fromBech32(address4);
|
|
1845
|
-
return prefix === "bbn";
|
|
1846
|
-
} catch (error) {
|
|
1847
|
-
return false;
|
|
1848
|
-
}
|
|
1849
|
-
};
|
|
1850
|
-
|
|
1851
1851
|
// src/staking/manager.ts
|
|
1852
1852
|
var SigningStep = /* @__PURE__ */ ((SigningStep2) => {
|
|
1853
1853
|
SigningStep2["STAKING_SLASHING"] = "staking-slashing";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bitgo-beta/babylonlabs-io-btc-staking-ts",
|
|
3
|
-
"version": "0.4.0-alpha.
|
|
3
|
+
"version": "0.4.0-alpha.59",
|
|
4
4
|
"description": "Library exposing methods for the creation and consumption of Bitcoin transactions pertaining to Babylon's Bitcoin Staking protocol.",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "d11a6a5dde37cbaae12c871ddadfee7106ebbae9"
|
|
49
49
|
}
|