@babylonlabs-io/ts-sdk 0.0.0-semantic-release.2 → 0.1.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/LICENSE +1 -1
- package/README.md +124 -6
- package/dist/MockEthereumWallet-CKQlH2AM.cjs +2 -0
- package/dist/MockEthereumWallet-CKQlH2AM.cjs.map +1 -0
- package/dist/MockEthereumWallet-ibdry7pZ.js +127 -0
- package/dist/MockEthereumWallet-ibdry7pZ.js.map +1 -0
- package/dist/PayoutManager-Dg_i_S7w.cjs +2 -0
- package/dist/PayoutManager-Dg_i_S7w.cjs.map +1 -0
- package/dist/PayoutManager-rMj54HDh.js +1112 -0
- package/dist/PayoutManager-rMj54HDh.js.map +1 -0
- package/dist/challengeAssert-34HqeVFH.cjs +2 -0
- package/dist/challengeAssert-34HqeVFH.cjs.map +1 -0
- package/dist/challengeAssert-DVErOd8l.js +423 -0
- package/dist/challengeAssert-DVErOd8l.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +62 -1
- package/dist/index.js.map +1 -1
- package/dist/shared/index.cjs +1 -1
- package/dist/shared/index.d.ts +3 -1
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index.js +5 -1
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/wallets/__tests__/BitcoinWallet.test.d.ts +2 -0
- package/dist/shared/wallets/__tests__/BitcoinWallet.test.d.ts.map +1 -0
- package/dist/shared/wallets/__tests__/EthereumWallet.test.d.ts +2 -0
- package/dist/shared/wallets/__tests__/EthereumWallet.test.d.ts.map +1 -0
- package/dist/shared/wallets/index.d.ts +4 -0
- package/dist/shared/wallets/index.d.ts.map +1 -0
- package/dist/shared/wallets/interfaces/BitcoinWallet.d.ts +106 -0
- package/dist/shared/wallets/interfaces/BitcoinWallet.d.ts.map +1 -0
- package/dist/shared/wallets/interfaces/EthereumWallet.d.ts +6 -0
- package/dist/shared/wallets/interfaces/EthereumWallet.d.ts.map +1 -0
- package/dist/shared/wallets/interfaces/index.d.ts +4 -0
- package/dist/shared/wallets/interfaces/index.d.ts.map +1 -0
- package/dist/shared/wallets/mocks/MockBitcoinWallet.d.ts +29 -0
- package/dist/shared/wallets/mocks/MockBitcoinWallet.d.ts.map +1 -0
- package/dist/shared/wallets/mocks/MockEthereumWallet.d.ts +51 -0
- package/dist/shared/wallets/mocks/MockEthereumWallet.d.ts.map +1 -0
- package/dist/shared/wallets/mocks/index.d.ts +5 -0
- package/dist/shared/wallets/mocks/index.d.ts.map +1 -0
- package/dist/tbv/core/clients/index.d.ts +9 -0
- package/dist/tbv/core/clients/index.d.ts.map +1 -0
- package/dist/tbv/core/clients/mempool/index.d.ts +11 -0
- package/dist/tbv/core/clients/mempool/index.d.ts.map +1 -0
- package/dist/tbv/core/clients/mempool/mempoolApi.d.ts +94 -0
- package/dist/tbv/core/clients/mempool/mempoolApi.d.ts.map +1 -0
- package/dist/tbv/core/clients/mempool/types.d.ts +98 -0
- package/dist/tbv/core/clients/mempool/types.d.ts.map +1 -0
- package/dist/tbv/core/contracts/abis/BTCVaultsManager.abi.d.ts +187 -0
- package/dist/tbv/core/contracts/abis/BTCVaultsManager.abi.d.ts.map +1 -0
- package/dist/tbv/core/contracts/errors.d.ts +50 -0
- package/dist/tbv/core/contracts/errors.d.ts.map +1 -0
- package/dist/tbv/core/contracts/index.d.ts +11 -0
- package/dist/tbv/core/contracts/index.d.ts.map +1 -0
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.d.ts +17 -1
- package/dist/tbv/core/index.d.ts.map +1 -1
- package/dist/tbv/core/index.js +59 -1
- package/dist/tbv/core/index.js.map +1 -1
- package/dist/tbv/core/managers/PayoutManager.d.ts +158 -0
- package/dist/tbv/core/managers/PayoutManager.d.ts.map +1 -0
- package/dist/tbv/core/managers/PeginManager.d.ts +327 -0
- package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -0
- package/dist/tbv/core/managers/__tests__/PayoutManager.test.d.ts +8 -0
- package/dist/tbv/core/managers/__tests__/PayoutManager.test.d.ts.map +1 -0
- package/dist/tbv/core/managers/__tests__/PeginManager.test.d.ts +8 -0
- package/dist/tbv/core/managers/__tests__/PeginManager.test.d.ts.map +1 -0
- package/dist/tbv/core/managers/index.d.ts +75 -0
- package/dist/tbv/core/managers/index.d.ts.map +1 -0
- package/dist/tbv/core/primitives/index.cjs +2 -0
- package/dist/tbv/core/primitives/index.d.ts +77 -0
- package/dist/tbv/core/primitives/index.d.ts.map +1 -0
- package/dist/tbv/core/primitives/index.js +21 -0
- package/dist/tbv/{integrations/morpho → core/primitives}/index.js.map +1 -1
- package/dist/tbv/core/primitives/psbt/__tests__/constants.d.ts +137 -0
- package/dist/tbv/core/primitives/psbt/__tests__/constants.d.ts.map +1 -0
- package/dist/tbv/core/primitives/psbt/__tests__/helpers.d.ts +71 -0
- package/dist/tbv/core/primitives/psbt/__tests__/helpers.d.ts.map +1 -0
- package/dist/tbv/core/primitives/psbt/__tests__/payout.test.d.ts +8 -0
- package/dist/tbv/core/primitives/psbt/__tests__/payout.test.d.ts.map +1 -0
- package/dist/tbv/core/primitives/psbt/__tests__/pegin.test.d.ts +5 -0
- package/dist/tbv/core/primitives/psbt/__tests__/pegin.test.d.ts.map +1 -0
- package/dist/tbv/core/primitives/psbt/challengeAssert.d.ts +27 -0
- package/dist/tbv/core/primitives/psbt/challengeAssert.d.ts.map +1 -0
- package/dist/tbv/core/primitives/psbt/depositorPayout.d.ts +27 -0
- package/dist/tbv/core/primitives/psbt/depositorPayout.d.ts.map +1 -0
- package/dist/tbv/core/primitives/psbt/index.d.ts +27 -0
- package/dist/tbv/core/primitives/psbt/index.d.ts.map +1 -0
- package/dist/tbv/core/primitives/psbt/noPayout.d.ts +28 -0
- package/dist/tbv/core/primitives/psbt/noPayout.d.ts.map +1 -0
- package/dist/tbv/core/primitives/psbt/payout.d.ts +99 -0
- package/dist/tbv/core/primitives/psbt/payout.d.ts.map +1 -0
- package/dist/tbv/core/primitives/psbt/pegin.d.ts +88 -0
- package/dist/tbv/core/primitives/psbt/pegin.d.ts.map +1 -0
- package/dist/tbv/core/primitives/scripts/__tests__/payout.test.d.ts +5 -0
- package/dist/tbv/core/primitives/scripts/__tests__/payout.test.d.ts.map +1 -0
- package/dist/tbv/core/primitives/scripts/index.d.ts +10 -0
- package/dist/tbv/core/primitives/scripts/index.d.ts.map +1 -0
- package/dist/tbv/core/primitives/scripts/payout.d.ts +102 -0
- package/dist/tbv/core/primitives/scripts/payout.d.ts.map +1 -0
- package/dist/tbv/core/primitives/utils/__tests__/bitcoin.test.d.ts +5 -0
- package/dist/tbv/core/primitives/utils/__tests__/bitcoin.test.d.ts.map +1 -0
- package/dist/tbv/core/primitives/utils/bitcoin.d.ts +132 -0
- package/dist/tbv/core/primitives/utils/bitcoin.d.ts.map +1 -0
- package/dist/tbv/core/primitives/utils/index.d.ts +9 -0
- package/dist/tbv/core/primitives/utils/index.d.ts.map +1 -0
- package/dist/tbv/core/utils/btc/index.d.ts +10 -0
- package/dist/tbv/core/utils/btc/index.d.ts.map +1 -0
- package/dist/tbv/core/utils/btc/psbtInputFields.d.ts +41 -0
- package/dist/tbv/core/utils/btc/psbtInputFields.d.ts.map +1 -0
- package/dist/tbv/core/utils/btc/scriptType.d.ts +34 -0
- package/dist/tbv/core/utils/btc/scriptType.d.ts.map +1 -0
- package/dist/tbv/core/utils/fee/constants.d.ts +25 -0
- package/dist/tbv/core/utils/fee/constants.d.ts.map +1 -0
- package/dist/tbv/core/utils/fee/index.d.ts +7 -0
- package/dist/tbv/core/utils/fee/index.d.ts.map +1 -0
- package/dist/tbv/core/utils/index.d.ts +16 -0
- package/dist/tbv/core/utils/index.d.ts.map +1 -0
- package/dist/tbv/core/utils/transaction/__tests__/btcTxHash.test.d.ts +5 -0
- package/dist/tbv/core/utils/transaction/__tests__/btcTxHash.test.d.ts.map +1 -0
- package/dist/tbv/core/utils/transaction/__tests__/createSplitTransaction.test.d.ts +5 -0
- package/dist/tbv/core/utils/transaction/__tests__/createSplitTransaction.test.d.ts.map +1 -0
- package/dist/tbv/core/utils/transaction/__tests__/fundPeginTransaction.test.d.ts +5 -0
- package/dist/tbv/core/utils/transaction/__tests__/fundPeginTransaction.test.d.ts.map +1 -0
- package/dist/tbv/core/utils/transaction/btcTxHash.d.ts +15 -0
- package/dist/tbv/core/utils/transaction/btcTxHash.d.ts.map +1 -0
- package/dist/tbv/core/utils/transaction/createSplitTransaction.d.ts +106 -0
- package/dist/tbv/core/utils/transaction/createSplitTransaction.d.ts.map +1 -0
- package/dist/tbv/core/utils/transaction/fundPeginTransaction.d.ts +70 -0
- package/dist/tbv/core/utils/transaction/fundPeginTransaction.d.ts.map +1 -0
- package/dist/tbv/core/utils/transaction/index.d.ts +9 -0
- package/dist/tbv/core/utils/transaction/index.d.ts.map +1 -0
- package/dist/tbv/core/utils/utxo/__tests__/selectUtxos.test.d.ts +5 -0
- package/dist/tbv/core/utils/utxo/__tests__/selectUtxos.test.d.ts.map +1 -0
- package/dist/tbv/core/utils/utxo/index.d.ts +7 -0
- package/dist/tbv/core/utils/utxo/index.d.ts.map +1 -0
- package/dist/tbv/core/utils/utxo/selectUtxos.d.ts +65 -0
- package/dist/tbv/core/utils/utxo/selectUtxos.d.ts.map +1 -0
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +59 -1
- package/dist/tbv/index.js.map +1 -1
- package/dist/tbv/integrations/aave/clients/__tests__/spoke.test.d.ts +2 -0
- package/dist/tbv/integrations/aave/clients/__tests__/spoke.test.d.ts.map +1 -0
- package/dist/tbv/integrations/aave/clients/__tests__/transaction.test.d.ts +2 -0
- package/dist/tbv/integrations/aave/clients/__tests__/transaction.test.d.ts.map +1 -0
- package/dist/tbv/integrations/aave/clients/abis/AaveIntegrationController.abi.json.d.ts +1879 -0
- package/dist/tbv/integrations/aave/clients/abis/AaveSpoke.abi.json.d.ts +1262 -0
- package/dist/tbv/integrations/aave/clients/index.d.ts +4 -0
- package/dist/tbv/integrations/aave/clients/index.d.ts.map +1 -0
- package/dist/tbv/integrations/aave/clients/query.d.ts +27 -0
- package/dist/tbv/integrations/aave/clients/query.d.ts.map +1 -0
- package/dist/tbv/integrations/aave/clients/spoke.d.ts +161 -0
- package/dist/tbv/integrations/aave/clients/spoke.d.ts.map +1 -0
- package/dist/tbv/integrations/aave/clients/transaction.d.ts +110 -0
- package/dist/tbv/integrations/aave/clients/transaction.d.ts.map +1 -0
- package/dist/tbv/integrations/aave/config.d.ts +7 -0
- package/dist/tbv/integrations/aave/config.d.ts.map +1 -0
- package/dist/tbv/integrations/aave/constants.d.ts +113 -0
- package/dist/tbv/integrations/aave/constants.d.ts.map +1 -0
- package/dist/tbv/integrations/aave/index.cjs +2 -0
- package/dist/tbv/integrations/aave/index.cjs.map +1 -0
- package/dist/tbv/integrations/aave/index.d.ts +53 -0
- package/dist/tbv/integrations/aave/index.d.ts.map +1 -0
- package/dist/tbv/integrations/aave/index.js +307 -0
- package/dist/tbv/integrations/aave/index.js.map +1 -0
- package/dist/tbv/integrations/aave/types.d.ts +66 -0
- package/dist/tbv/integrations/aave/types.d.ts.map +1 -0
- package/dist/tbv/integrations/aave/utils/__tests__/aaveConversions.test.d.ts +5 -0
- package/dist/tbv/integrations/aave/utils/__tests__/aaveConversions.test.d.ts.map +1 -0
- package/dist/tbv/integrations/aave/utils/__tests__/borrowRatio.test.d.ts +5 -0
- package/dist/tbv/integrations/aave/utils/__tests__/borrowRatio.test.d.ts.map +1 -0
- package/dist/tbv/integrations/aave/utils/__tests__/debtUtils.test.d.ts +5 -0
- package/dist/tbv/integrations/aave/utils/__tests__/debtUtils.test.d.ts.map +1 -0
- package/dist/tbv/integrations/aave/utils/__tests__/healthFactor.test.d.ts +5 -0
- package/dist/tbv/integrations/aave/utils/__tests__/healthFactor.test.d.ts.map +1 -0
- package/dist/tbv/integrations/aave/utils/__tests__/vaultSelection.test.d.ts +2 -0
- package/dist/tbv/integrations/aave/utils/__tests__/vaultSelection.test.d.ts.map +1 -0
- package/dist/tbv/integrations/aave/utils/__tests__/vaultSplit.test.d.ts +5 -0
- package/dist/tbv/integrations/aave/utils/__tests__/vaultSplit.test.d.ts.map +1 -0
- package/dist/tbv/integrations/aave/utils/aaveConversions.d.ts +24 -0
- package/dist/tbv/integrations/aave/utils/aaveConversions.d.ts.map +1 -0
- package/dist/tbv/integrations/aave/utils/borrowRatio.d.ts +15 -0
- package/dist/tbv/integrations/aave/utils/borrowRatio.d.ts.map +1 -0
- package/dist/tbv/integrations/aave/utils/debtUtils.d.ts +14 -0
- package/dist/tbv/integrations/aave/utils/debtUtils.d.ts.map +1 -0
- package/dist/tbv/integrations/aave/utils/healthFactor.d.ts +108 -0
- package/dist/tbv/integrations/aave/utils/healthFactor.d.ts.map +1 -0
- package/dist/tbv/integrations/aave/utils/index.d.ts +10 -0
- package/dist/tbv/integrations/aave/utils/index.d.ts.map +1 -0
- package/dist/tbv/integrations/aave/utils/vaultSelection.d.ts +33 -0
- package/dist/tbv/integrations/aave/utils/vaultSelection.d.ts.map +1 -0
- package/dist/tbv/integrations/aave/utils/vaultSplit.d.ts +191 -0
- package/dist/tbv/integrations/aave/utils/vaultSplit.d.ts.map +1 -0
- package/package.json +37 -7
- package/dist/shared/__tests__/example.test.d.ts +0 -6
- package/dist/shared/__tests__/example.test.d.ts.map +0 -1
- package/dist/tbv/core/__tests__/example.test.d.ts +0 -6
- package/dist/tbv/core/__tests__/example.test.d.ts.map +0 -1
- package/dist/tbv/integrations/morpho/index.cjs +0 -2
- package/dist/tbv/integrations/morpho/index.d.ts +0 -2
- package/dist/tbv/integrations/morpho/index.d.ts.map +0 -1
- package/dist/tbv/integrations/morpho/index.js +0 -2
- /package/dist/tbv/{integrations/morpho → core/primitives}/index.cjs.map +0 -0
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import { Address, Chain, Hex, WalletClient } from 'viem';
|
|
2
|
+
import { BitcoinWallet } from '../../../shared/wallets/interfaces/BitcoinWallet';
|
|
3
|
+
import { Hash } from '../../../shared/wallets/interfaces/EthereumWallet';
|
|
4
|
+
import { Network } from '../primitives';
|
|
5
|
+
import { UTXO } from '../utils';
|
|
6
|
+
/**
|
|
7
|
+
* Configuration for the PeginManager.
|
|
8
|
+
*/
|
|
9
|
+
export interface PeginManagerConfig {
|
|
10
|
+
/**
|
|
11
|
+
* Bitcoin network to use for transactions.
|
|
12
|
+
*/
|
|
13
|
+
btcNetwork: Network;
|
|
14
|
+
/**
|
|
15
|
+
* Bitcoin wallet for signing peg-in transactions.
|
|
16
|
+
*/
|
|
17
|
+
btcWallet: BitcoinWallet;
|
|
18
|
+
/**
|
|
19
|
+
* Ethereum wallet for registering peg-in on-chain.
|
|
20
|
+
* Uses viem's WalletClient directly for proper gas estimation.
|
|
21
|
+
*/
|
|
22
|
+
ethWallet: WalletClient;
|
|
23
|
+
/**
|
|
24
|
+
* Ethereum chain configuration.
|
|
25
|
+
* Required for proper gas estimation in contract calls.
|
|
26
|
+
*/
|
|
27
|
+
ethChain: Chain;
|
|
28
|
+
/**
|
|
29
|
+
* Vault contract addresses.
|
|
30
|
+
*/
|
|
31
|
+
vaultContracts: {
|
|
32
|
+
/**
|
|
33
|
+
* BTCVaultsManager contract address on Ethereum.
|
|
34
|
+
*/
|
|
35
|
+
btcVaultsManager: Address;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Mempool API URL for fetching UTXO data and broadcasting transactions.
|
|
39
|
+
* Use MEMPOOL_API_URLS constant for standard mempool.space URLs, or provide
|
|
40
|
+
* a custom URL if running your own mempool instance.
|
|
41
|
+
*/
|
|
42
|
+
mempoolApiUrl: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Parameters for creating a peg-in transaction.
|
|
46
|
+
*/
|
|
47
|
+
export interface CreatePeginParams {
|
|
48
|
+
/**
|
|
49
|
+
* Amount to peg in (in satoshis).
|
|
50
|
+
*/
|
|
51
|
+
amount: bigint;
|
|
52
|
+
/**
|
|
53
|
+
* Vault provider's Ethereum address.
|
|
54
|
+
*/
|
|
55
|
+
vaultProvider: Address;
|
|
56
|
+
/**
|
|
57
|
+
* Vault provider's BTC public key (x-only, 64-char hex).
|
|
58
|
+
* Can be provided with or without "0x" prefix (will be stripped automatically).
|
|
59
|
+
*/
|
|
60
|
+
vaultProviderBtcPubkey: string;
|
|
61
|
+
/**
|
|
62
|
+
* Vault keeper BTC public keys (x-only, 64-char hex).
|
|
63
|
+
* Can be provided with or without "0x" prefix (will be stripped automatically).
|
|
64
|
+
*/
|
|
65
|
+
vaultKeeperBtcPubkeys: string[];
|
|
66
|
+
/**
|
|
67
|
+
* Universal challenger BTC public keys (x-only, 64-char hex).
|
|
68
|
+
* Can be provided with or without "0x" prefix (will be stripped automatically).
|
|
69
|
+
*/
|
|
70
|
+
universalChallengerBtcPubkeys: string[];
|
|
71
|
+
/**
|
|
72
|
+
* CSV timelock in blocks for the PegIn output.
|
|
73
|
+
*/
|
|
74
|
+
timelockPegin: number;
|
|
75
|
+
/**
|
|
76
|
+
* Amount in satoshis for the depositor's claim output.
|
|
77
|
+
*/
|
|
78
|
+
depositorClaimValue: bigint;
|
|
79
|
+
/**
|
|
80
|
+
* Available UTXOs from the depositor's wallet for funding the transaction.
|
|
81
|
+
*/
|
|
82
|
+
availableUTXOs: UTXO[];
|
|
83
|
+
/**
|
|
84
|
+
* Fee rate in satoshis per vbyte for the transaction.
|
|
85
|
+
*/
|
|
86
|
+
feeRate: number;
|
|
87
|
+
/**
|
|
88
|
+
* Bitcoin address for receiving change from the transaction.
|
|
89
|
+
*/
|
|
90
|
+
changeAddress: string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Result of a peg-in preparation.
|
|
94
|
+
*/
|
|
95
|
+
export interface PeginResult {
|
|
96
|
+
/**
|
|
97
|
+
* Bitcoin transaction hash (without 0x prefix).
|
|
98
|
+
* This is the hash of the unsigned transaction and will NOT change after signing.
|
|
99
|
+
* Used as the unique vault identifier in the contract.
|
|
100
|
+
*/
|
|
101
|
+
btcTxHash: string;
|
|
102
|
+
/**
|
|
103
|
+
* Funded but unsigned transaction hex.
|
|
104
|
+
* This transaction has inputs and outputs but is not yet signed.
|
|
105
|
+
*/
|
|
106
|
+
fundedTxHex: string;
|
|
107
|
+
/**
|
|
108
|
+
* Vault script pubkey hex.
|
|
109
|
+
*/
|
|
110
|
+
vaultScriptPubKey: string;
|
|
111
|
+
/**
|
|
112
|
+
* UTXOs selected for funding the transaction.
|
|
113
|
+
*/
|
|
114
|
+
selectedUTXOs: UTXO[];
|
|
115
|
+
/**
|
|
116
|
+
* Transaction fee in satoshis.
|
|
117
|
+
*/
|
|
118
|
+
fee: bigint;
|
|
119
|
+
/**
|
|
120
|
+
* Change amount in satoshis (if any).
|
|
121
|
+
*/
|
|
122
|
+
changeAmount: bigint;
|
|
123
|
+
/**
|
|
124
|
+
* Ethereum transaction hash (peg-in registration).
|
|
125
|
+
* Will be null until registerPeginOnChain is called.
|
|
126
|
+
*/
|
|
127
|
+
ethTxHash: Hash | null;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Parameters for signing and broadcasting a transaction.
|
|
131
|
+
*/
|
|
132
|
+
export interface SignAndBroadcastParams {
|
|
133
|
+
/**
|
|
134
|
+
* Funded transaction hex from preparePegin().
|
|
135
|
+
*/
|
|
136
|
+
fundedTxHex: string;
|
|
137
|
+
/**
|
|
138
|
+
* Depositor's BTC public key (x-only, 64-char hex).
|
|
139
|
+
* Can be provided with or without "0x" prefix.
|
|
140
|
+
* Required for Taproot signing.
|
|
141
|
+
*/
|
|
142
|
+
depositorBtcPubkey: string;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Parameters for registering a peg-in on Ethereum.
|
|
146
|
+
*/
|
|
147
|
+
export interface RegisterPeginParams {
|
|
148
|
+
/**
|
|
149
|
+
* Depositor's BTC public key (x-only, 64-char hex).
|
|
150
|
+
* Can be provided with or without "0x" prefix.
|
|
151
|
+
*/
|
|
152
|
+
depositorBtcPubkey: string;
|
|
153
|
+
/**
|
|
154
|
+
* Funded but unsigned BTC transaction hex.
|
|
155
|
+
*/
|
|
156
|
+
unsignedBtcTx: string;
|
|
157
|
+
/**
|
|
158
|
+
* Vault provider's Ethereum address.
|
|
159
|
+
*/
|
|
160
|
+
vaultProvider: Address;
|
|
161
|
+
/**
|
|
162
|
+
* Optional callback invoked after PoP signing completes but before ETH transaction.
|
|
163
|
+
*/
|
|
164
|
+
onPopSigned?: () => void | Promise<void>;
|
|
165
|
+
/**
|
|
166
|
+
* Depositor's BTC payout address (e.g. bc1p..., bc1q...).
|
|
167
|
+
* Converted to scriptPubKey internally via bitcoinjs-lib.
|
|
168
|
+
*
|
|
169
|
+
* If omitted, defaults to the connected BTC wallet's address
|
|
170
|
+
* via `btcWallet.getAddress()`.
|
|
171
|
+
*/
|
|
172
|
+
depositorPayoutBtcAddress?: string;
|
|
173
|
+
/** Keccak256 hash of the depositor's Lamport public key (bytes32) */
|
|
174
|
+
depositorLamportPkHash: Hex;
|
|
175
|
+
/**
|
|
176
|
+
* Pre-signed BTC PoP signature (hex with 0x prefix).
|
|
177
|
+
* When provided, the BTC wallet signing step is skipped and this signature is used directly.
|
|
178
|
+
* Useful for multi-vault deposits where PoP only needs to be signed once.
|
|
179
|
+
*/
|
|
180
|
+
preSignedBtcPopSignature?: Hex;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Result of registering a peg-in on Ethereum.
|
|
184
|
+
*/
|
|
185
|
+
export interface RegisterPeginResult {
|
|
186
|
+
/**
|
|
187
|
+
* Ethereum transaction hash for the peg-in registration.
|
|
188
|
+
*/
|
|
189
|
+
ethTxHash: Hash;
|
|
190
|
+
/**
|
|
191
|
+
* Vault identifier used in the BTCVaultsManager contract.
|
|
192
|
+
* This is the Bitcoin transaction hash with 0x prefix for Ethereum compatibility.
|
|
193
|
+
* Corresponds to btcTxHash from PeginResult, but formatted as Hex with '0x' prefix.
|
|
194
|
+
*/
|
|
195
|
+
vaultId: Hex;
|
|
196
|
+
/**
|
|
197
|
+
* The BTC PoP signature used for this registration (hex with 0x prefix).
|
|
198
|
+
* Returned so callers can reuse it for subsequent pegins without re-signing.
|
|
199
|
+
*/
|
|
200
|
+
btcPopSignature: Hex;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Manager for orchestrating peg-in operations.
|
|
204
|
+
*
|
|
205
|
+
* This manager provides a high-level API for creating peg-in transactions
|
|
206
|
+
* by coordinating between SDK primitives, utilities, and wallet interfaces.
|
|
207
|
+
*
|
|
208
|
+
* @remarks
|
|
209
|
+
* The complete peg-in flow consists of 4 steps:
|
|
210
|
+
*
|
|
211
|
+
* | Step | Method | Description |
|
|
212
|
+
* |------|--------|-------------|
|
|
213
|
+
* | 1 | {@link preparePegin} | Build and fund the transaction |
|
|
214
|
+
* | 2 | {@link registerPeginOnChain} | Submit to Ethereum contract with PoP |
|
|
215
|
+
* | 3 | {@link PayoutManager} | Sign BOTH payout authorizations |
|
|
216
|
+
* | 4 | {@link signAndBroadcast} | Sign and broadcast to Bitcoin network |
|
|
217
|
+
*
|
|
218
|
+
* **Important:** Step 3 uses {@link PayoutManager}, not this class. After step 2,
|
|
219
|
+
* the vault provider prepares 3 transactions per claimer:
|
|
220
|
+
* - `claim_tx` - Claim transaction
|
|
221
|
+
* - `assert_tx` - Assert transaction
|
|
222
|
+
* - `payout_tx` - Payout transaction
|
|
223
|
+
*
|
|
224
|
+
* You must sign the Payout transaction for each claimer:
|
|
225
|
+
* - {@link PayoutManager.signPayoutTransaction} - uses assert_tx as input reference
|
|
226
|
+
*
|
|
227
|
+
* Submit all signatures to the vault provider before proceeding to step 4.
|
|
228
|
+
*
|
|
229
|
+
* @see {@link PayoutManager} - Required for Step 3 (payout authorization)
|
|
230
|
+
* @see {@link buildPeginPsbt} - Lower-level primitive for custom implementations
|
|
231
|
+
* @see {@link https://github.com/babylonlabs-io/babylon-toolkit/blob/main/packages/babylon-ts-sdk/docs/quickstart/managers.md | Managers Quickstart}
|
|
232
|
+
*/
|
|
233
|
+
export declare class PeginManager {
|
|
234
|
+
private readonly config;
|
|
235
|
+
/**
|
|
236
|
+
* Creates a new PeginManager instance.
|
|
237
|
+
*
|
|
238
|
+
* @param config - Manager configuration including wallets and contract addresses
|
|
239
|
+
*/
|
|
240
|
+
constructor(config: PeginManagerConfig);
|
|
241
|
+
/**
|
|
242
|
+
* Prepares a peg-in transaction by building and funding it.
|
|
243
|
+
*
|
|
244
|
+
* This method orchestrates the following steps:
|
|
245
|
+
* 1. Get depositor BTC public key from wallet
|
|
246
|
+
* 2. Build unfunded PSBT using primitives
|
|
247
|
+
* 3. Select UTXOs using iterative fee calculation
|
|
248
|
+
* 4. Fund transaction by adding inputs and change output
|
|
249
|
+
*
|
|
250
|
+
* The returned transaction is funded but unsigned. Use `signAndBroadcast()`
|
|
251
|
+
* to complete the Bitcoin side, and `registerPeginOnChain()` for Ethereum.
|
|
252
|
+
*
|
|
253
|
+
* @param params - Peg-in parameters including amount, provider, UTXOs, and fee rate
|
|
254
|
+
* @returns Peg-in result with funded transaction and selection details
|
|
255
|
+
* @throws Error if wallet operations fail or insufficient funds
|
|
256
|
+
*/
|
|
257
|
+
preparePegin(params: CreatePeginParams): Promise<PeginResult>;
|
|
258
|
+
/**
|
|
259
|
+
* Signs and broadcasts a funded peg-in transaction to the Bitcoin network.
|
|
260
|
+
*
|
|
261
|
+
* This method:
|
|
262
|
+
* 1. Parses the funded transaction hex
|
|
263
|
+
* 2. Fetches UTXO data from mempool for each input
|
|
264
|
+
* 3. Creates a PSBT with proper witnessUtxo/tapInternalKey
|
|
265
|
+
* 4. Signs via btcWallet.signPsbt()
|
|
266
|
+
* 5. Finalizes and extracts the transaction
|
|
267
|
+
* 6. Broadcasts via mempool API
|
|
268
|
+
*
|
|
269
|
+
* @param params - Transaction hex and depositor public key
|
|
270
|
+
* @returns The broadcasted Bitcoin transaction ID
|
|
271
|
+
* @throws Error if signing or broadcasting fails
|
|
272
|
+
*/
|
|
273
|
+
signAndBroadcast(params: SignAndBroadcastParams): Promise<string>;
|
|
274
|
+
/**
|
|
275
|
+
* Registers a peg-in on Ethereum by calling the BTCVaultsManager contract.
|
|
276
|
+
*
|
|
277
|
+
* This method:
|
|
278
|
+
* 1. Gets depositor ETH address from wallet
|
|
279
|
+
* 2. Creates proof of possession (BTC signature of ETH address)
|
|
280
|
+
* 3. Checks if vault already exists (pre-flight check)
|
|
281
|
+
* 4. Encodes the contract call using viem
|
|
282
|
+
* 5. Estimates gas (catches contract errors early with proper revert reasons)
|
|
283
|
+
* 6. Sends transaction with pre-estimated gas via ethWallet.sendTransaction()
|
|
284
|
+
*
|
|
285
|
+
* @param params - Registration parameters including BTC pubkey and unsigned tx
|
|
286
|
+
* @returns Result containing Ethereum transaction hash and vault ID
|
|
287
|
+
* @throws Error if signing or transaction fails
|
|
288
|
+
* @throws Error if vault already exists
|
|
289
|
+
* @throws Error if contract simulation fails (e.g., invalid signature, unauthorized)
|
|
290
|
+
*/
|
|
291
|
+
registerPeginOnChain(params: RegisterPeginParams): Promise<RegisterPeginResult>;
|
|
292
|
+
/**
|
|
293
|
+
* Check if a vault already exists for a given vault ID.
|
|
294
|
+
*
|
|
295
|
+
* @param vaultId - The Bitcoin transaction hash (vault ID)
|
|
296
|
+
* @returns True if vault exists, false otherwise
|
|
297
|
+
*/
|
|
298
|
+
private checkVaultExists;
|
|
299
|
+
/**
|
|
300
|
+
* Resolve the BTC payout address to a scriptPubKey hex for the contract.
|
|
301
|
+
*
|
|
302
|
+
* If a payout address is provided, converts it directly.
|
|
303
|
+
* If omitted, uses the wallet's address and validates it against the
|
|
304
|
+
* wallet's public key to guard against a compromised wallet provider.
|
|
305
|
+
*/
|
|
306
|
+
private resolvePayoutScriptPubKey;
|
|
307
|
+
/**
|
|
308
|
+
* Resolve or create a BTC Proof-of-Possession signature.
|
|
309
|
+
*
|
|
310
|
+
* Reuses a pre-signed signature when provided (e.g. multi-vault deposits),
|
|
311
|
+
* otherwise signs a BIP-322 message with the BTC wallet.
|
|
312
|
+
*/
|
|
313
|
+
private resolvePopSignature;
|
|
314
|
+
/**
|
|
315
|
+
* Gets the configured Bitcoin network.
|
|
316
|
+
*
|
|
317
|
+
* @returns The Bitcoin network (mainnet, testnet, signet, regtest)
|
|
318
|
+
*/
|
|
319
|
+
getNetwork(): Network;
|
|
320
|
+
/**
|
|
321
|
+
* Gets the configured BTCVaultsManager contract address.
|
|
322
|
+
*
|
|
323
|
+
* @returns The Ethereum address of the BTCVaultsManager contract
|
|
324
|
+
*/
|
|
325
|
+
getVaultContractAddress(): Address;
|
|
326
|
+
}
|
|
327
|
+
//# sourceMappingURL=PeginManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PeginManager.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/managers/PeginManager.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PayoutManager.test.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/managers/__tests__/PayoutManager.test.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PeginManager.test.d.ts","sourceRoot":"","sources":["../../../../../src/tbv/core/managers/__tests__/PeginManager.test.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
*
|
|
4
|
+
* # Manager Layer - Wallet Orchestration (Level 2)
|
|
5
|
+
*
|
|
6
|
+
* High-level managers that orchestrate complex flows using primitives and utilities.
|
|
7
|
+
* These managers accept wallet interfaces and handle the complete operation lifecycle.
|
|
8
|
+
*
|
|
9
|
+
* ## Architecture
|
|
10
|
+
*
|
|
11
|
+
* Managers sit between your application and the primitives layer:
|
|
12
|
+
*
|
|
13
|
+
* ```
|
|
14
|
+
* Your Application
|
|
15
|
+
* ↓
|
|
16
|
+
* Managers (Level 2) ← This module
|
|
17
|
+
* ↓
|
|
18
|
+
* Primitives (Level 1) ← Pure functions
|
|
19
|
+
* ↓
|
|
20
|
+
* WASM (Rust Core) ← Cryptographic operations
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* ## When to Use Managers
|
|
24
|
+
*
|
|
25
|
+
* Use managers when you have:
|
|
26
|
+
* - **Frontend apps** with browser wallet integration (UniSat, OKX, etc.)
|
|
27
|
+
* - **Quick integration** needs with minimal code
|
|
28
|
+
* - **Standard flows** that don't require custom signing logic
|
|
29
|
+
*
|
|
30
|
+
* Use primitives instead when you need:
|
|
31
|
+
* - Backend services with KMS/HSM signing
|
|
32
|
+
* - Full control over every operation
|
|
33
|
+
* - Custom wallet integrations
|
|
34
|
+
*
|
|
35
|
+
* ## Available Managers
|
|
36
|
+
*
|
|
37
|
+
* ### {@link PeginManager}
|
|
38
|
+
* Orchestrates the peg-in deposit flow:
|
|
39
|
+
* - {@link PeginManager.preparePegin | preparePegin()} - Build and fund transaction
|
|
40
|
+
* - {@link PeginManager.registerPeginOnChain | registerPeginOnChain()} - Submit to Ethereum
|
|
41
|
+
* - {@link PeginManager.signAndBroadcast | signAndBroadcast()} - Broadcast to Bitcoin
|
|
42
|
+
*
|
|
43
|
+
* ### {@link PayoutManager}
|
|
44
|
+
* Signs payout authorization transactions (Step 3 of peg-in).
|
|
45
|
+
* - {@link PayoutManager.signPayoutTransaction | signPayoutTransaction()} - Sign payout (uses Assert tx as reference)
|
|
46
|
+
*
|
|
47
|
+
* ## Complete Peg-in Flow
|
|
48
|
+
*
|
|
49
|
+
* The 4-step peg-in flow uses both managers:
|
|
50
|
+
*
|
|
51
|
+
* | Step | Manager | Method |
|
|
52
|
+
* |------|---------|--------|
|
|
53
|
+
* | 1 | PeginManager | `preparePegin()` |
|
|
54
|
+
* | 2 | PeginManager | `registerPeginOnChain()` |
|
|
55
|
+
* | 3 | PayoutManager | `signPayoutTransaction()` |
|
|
56
|
+
* | 4 | PeginManager | `signAndBroadcast()` |
|
|
57
|
+
*
|
|
58
|
+
* **Step 3 Details:** The vault provider provides 3 transactions per claimer:
|
|
59
|
+
* - `claim_tx` - Claim transaction
|
|
60
|
+
* - `assert_tx` - Assert transaction
|
|
61
|
+
* - `payout_tx` - Payout transaction
|
|
62
|
+
*
|
|
63
|
+
* You must sign the Payout transaction (uses assert_tx as input reference) for each claimer.
|
|
64
|
+
*
|
|
65
|
+
* @see {@link https://github.com/babylonlabs-io/babylon-toolkit/blob/main/packages/babylon-ts-sdk/docs/quickstart/managers.md | Managers Quickstart}
|
|
66
|
+
*
|
|
67
|
+
* @module managers
|
|
68
|
+
*/
|
|
69
|
+
export { PeginManager } from './PeginManager';
|
|
70
|
+
export type { CreatePeginParams, PeginManagerConfig, PeginResult, RegisterPeginParams, RegisterPeginResult, SignAndBroadcastParams, } from './PeginManager';
|
|
71
|
+
export { PayoutManager } from './PayoutManager';
|
|
72
|
+
export type { PayoutManagerConfig, PayoutSignatureResult, SignPayoutParams, } from './PayoutManager';
|
|
73
|
+
export type { UTXO } from '../utils/utxo/selectUtxos';
|
|
74
|
+
export type { BitcoinNetwork, BitcoinWallet, SignInputOptions, SignPsbtOptions, } from '../../../shared/wallets/interfaces/BitcoinWallet';
|
|
75
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/managers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,YAAY,EACV,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACX,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EACV,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AAGzB,YAAY,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAC;AACtD,YAAY,EACV,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,eAAe,GAChB,MAAM,kDAAkD,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../../challengeAssert-34HqeVFH.cjs");exports.buildChallengeAssertPsbt=e.buildChallengeAssertPsbt;exports.buildDepositorPayoutPsbt=e.buildDepositorPayoutPsbt;exports.buildNoPayoutPsbt=e.buildNoPayoutPsbt;exports.buildPayoutPsbt=e.buildPayoutPsbt;exports.buildPeginPsbt=e.buildPeginPsbt;exports.createPayoutScript=e.createPayoutScript;exports.deriveNativeSegwitAddress=e.deriveNativeSegwitAddress;exports.deriveTaprootAddress=e.deriveTaprootAddress;exports.extractPayoutSignature=e.extractPayoutSignature;exports.hexToUint8Array=e.hexToUint8Array;exports.isAddressFromPublicKey=e.isAddressFromPublicKey;exports.isValidHex=e.isValidHex;exports.processPublicKeyToXOnly=e.processPublicKeyToXOnly;exports.stripHexPrefix=e.stripHexPrefix;exports.toXOnly=e.toXOnly;exports.uint8ArrayToHex=e.uint8ArrayToHex;exports.validateWalletPubkey=e.validateWalletPubkey;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
*
|
|
4
|
+
* # Vault Primitives
|
|
5
|
+
*
|
|
6
|
+
* Pure functions for vault operations with no wallet dependencies.
|
|
7
|
+
* These functions wrap the WASM implementation and provide:
|
|
8
|
+
*
|
|
9
|
+
* - **PSBT Building** - Create unsigned PSBTs for peg-in and payout transactions
|
|
10
|
+
* - **Script Creation** - Generate taproot scripts for vault spending conditions
|
|
11
|
+
* - **Signature Extraction** - Extract Schnorr signatures from signed PSBTs
|
|
12
|
+
* - **Bitcoin Utilities** - Public key conversion, hex manipulation, validation
|
|
13
|
+
*
|
|
14
|
+
* ## Architecture
|
|
15
|
+
*
|
|
16
|
+
* Primitives are the lowest level of the SDK, sitting directly above the Rust WASM core:
|
|
17
|
+
*
|
|
18
|
+
* ```
|
|
19
|
+
* Your Application
|
|
20
|
+
* ↓
|
|
21
|
+
* Managers (Level 2) ← High-level orchestration with wallet integration
|
|
22
|
+
* ↓
|
|
23
|
+
* Primitives (Level 1) ← Pure functions (this module)
|
|
24
|
+
* ↓
|
|
25
|
+
* WASM (Rust Core) ← Cryptographic operations
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* ## When to Use Primitives
|
|
29
|
+
*
|
|
30
|
+
* Use primitives when you need:
|
|
31
|
+
* - **Full control** over every operation
|
|
32
|
+
* - **Custom wallet integrations** (KMS/HSM, hardware wallets)
|
|
33
|
+
* - **Backend services** with custom signing flows
|
|
34
|
+
* - **Serverless environments** with specific requirements
|
|
35
|
+
*
|
|
36
|
+
* For frontend apps with browser wallet integration, consider using
|
|
37
|
+
* the managers module instead (PeginManager and PayoutManager).
|
|
38
|
+
*
|
|
39
|
+
* ## Key Exports
|
|
40
|
+
*
|
|
41
|
+
* ### PSBT Builders
|
|
42
|
+
* - {@link buildPeginPsbt} - Create unfunded peg-in transaction
|
|
43
|
+
* - {@link buildPayoutPsbt} - Create payout PSBT for signing
|
|
44
|
+
* - {@link extractPayoutSignature} - Extract Schnorr signature from signed PSBT
|
|
45
|
+
* - {@link buildDepositorPayoutPsbt} - Create depositor's own Payout PSBT (depositor-as-claimer path)
|
|
46
|
+
* - {@link buildNoPayoutPsbt} - Create NoPayout PSBT per challenger (depositor-as-claimer path)
|
|
47
|
+
* - {@link buildChallengeAssertPsbt} - Create ChallengeAssert PSBT per challenger (depositor-as-claimer path)
|
|
48
|
+
*
|
|
49
|
+
* ### Script Generators
|
|
50
|
+
* - {@link createPayoutScript} - Generate taproot payout script
|
|
51
|
+
*
|
|
52
|
+
* ### Bitcoin Utilities
|
|
53
|
+
* - {@link processPublicKeyToXOnly} - Convert any pubkey format to x-only
|
|
54
|
+
* - {@link validateWalletPubkey} - Validate wallet matches expected depositor
|
|
55
|
+
* - {@link hexToUint8Array} / {@link uint8ArrayToHex} - Hex conversion
|
|
56
|
+
* - {@link stripHexPrefix} / {@link isValidHex} - Hex validation
|
|
57
|
+
* - {@link toXOnly} - Convert compressed pubkey bytes to x-only
|
|
58
|
+
*
|
|
59
|
+
* @see {@link https://github.com/babylonlabs-io/babylon-toolkit/blob/main/packages/babylon-ts-sdk/docs/quickstart/primitives.md | Primitives Quickstart}
|
|
60
|
+
*
|
|
61
|
+
* @module primitives
|
|
62
|
+
*/
|
|
63
|
+
export type { Network } from '@babylonlabs-io/babylon-tbv-rust-wasm';
|
|
64
|
+
export { buildPeginPsbt } from './psbt/pegin';
|
|
65
|
+
export type { PeginParams, PeginPsbtResult } from './psbt/pegin';
|
|
66
|
+
export { buildPayoutPsbt, extractPayoutSignature } from './psbt/payout';
|
|
67
|
+
export type { PayoutParams, PayoutPsbtResult } from './psbt/payout';
|
|
68
|
+
export { buildDepositorPayoutPsbt } from './psbt/depositorPayout';
|
|
69
|
+
export type { DepositorPayoutParams } from './psbt/depositorPayout';
|
|
70
|
+
export { buildNoPayoutPsbt } from './psbt/noPayout';
|
|
71
|
+
export type { NoPayoutParams } from './psbt/noPayout';
|
|
72
|
+
export { buildChallengeAssertPsbt } from './psbt/challengeAssert';
|
|
73
|
+
export type { ChallengeAssertParams } from './psbt/challengeAssert';
|
|
74
|
+
export { createPayoutScript } from './scripts/payout';
|
|
75
|
+
export type { PayoutScriptParams, PayoutScriptResult } from './scripts/payout';
|
|
76
|
+
export { deriveNativeSegwitAddress, deriveTaprootAddress, hexToUint8Array, isAddressFromPublicKey, isValidHex, processPublicKeyToXOnly, stripHexPrefix, toXOnly, uint8ArrayToHex, validateWalletPubkey, type WalletPubkeyValidationResult, } from './utils/bitcoin';
|
|
77
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tbv/core/primitives/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AAGH,YAAY,EAAE,OAAO,EAAE,MAAM,uCAAuC,CAAC;AAGrE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEjE,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACxE,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAClE,YAAY,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAEpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAClE,YAAY,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAGpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,YAAY,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAG/E,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACpB,eAAe,EACf,sBAAsB,EACtB,UAAU,EACV,uBAAuB,EACvB,cAAc,EACd,OAAO,EACP,eAAe,EACf,oBAAoB,EACpB,KAAK,4BAA4B,GAClC,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { f as e, c as t, d as i, a as r, b as o, g as d, h as l, i as u, e as P, j as b, k as y, l as c, p as n, s as p, t as x, u as A, v as g } from "../../../challengeAssert-DVErOd8l.js";
|
|
2
|
+
export {
|
|
3
|
+
e as buildChallengeAssertPsbt,
|
|
4
|
+
t as buildDepositorPayoutPsbt,
|
|
5
|
+
i as buildNoPayoutPsbt,
|
|
6
|
+
r as buildPayoutPsbt,
|
|
7
|
+
o as buildPeginPsbt,
|
|
8
|
+
d as createPayoutScript,
|
|
9
|
+
l as deriveNativeSegwitAddress,
|
|
10
|
+
u as deriveTaprootAddress,
|
|
11
|
+
P as extractPayoutSignature,
|
|
12
|
+
b as hexToUint8Array,
|
|
13
|
+
y as isAddressFromPublicKey,
|
|
14
|
+
c as isValidHex,
|
|
15
|
+
n as processPublicKeyToXOnly,
|
|
16
|
+
p as stripHexPrefix,
|
|
17
|
+
x as toXOnly,
|
|
18
|
+
A as uint8ArrayToHex,
|
|
19
|
+
g as validateWalletPubkey
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|