@bestinslot/wallet-kit 0.7.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/README.md +108 -0
- package/dist/balances-BQiaAIaq.js +9627 -0
- package/dist/browser.js +205 -0
- package/dist/core.js +39 -0
- package/dist/mint-BXVHw4CQ.js +70722 -0
- package/dist/node.js +1787 -0
- package/dist/react.js +14 -0
- package/dist/register-browser-providers-CLLT6W6P.js +499 -0
- package/dist/types/adapters/react/use-network.d.ts +8 -0
- package/dist/types/adapters/react/use-wallet.d.ts +15 -0
- package/dist/types/adapters/vue/use-network.d.ts +12 -0
- package/dist/types/api/balances.d.ts +52 -0
- package/dist/types/api/brc20.d.ts +110 -0
- package/dist/types/api/helpers.d.ts +3 -0
- package/dist/types/api/mint.d.ts +57 -0
- package/dist/types/api/modal.d.ts +3 -0
- package/dist/types/api/swap.d.ts +122 -0
- package/dist/types/api/wallet.browser.d.ts +2 -0
- package/dist/types/api/wallet.d.ts +6 -0
- package/dist/types/api/wallet.node.d.ts +4 -0
- package/dist/types/browser.d.ts +10 -0
- package/dist/types/components/Dev.vue.d.ts +11 -0
- package/dist/types/components/connect-modal-view.d.ts +28 -0
- package/dist/types/components/dev/BRC20.vue.d.ts +2 -0
- package/dist/types/components/dev/Button.vue.d.ts +17 -0
- package/dist/types/components/dev/Input.vue.d.ts +12 -0
- package/dist/types/components/dev/Label.vue.d.ts +17 -0
- package/dist/types/components/dev/Select.vue.d.ts +17 -0
- package/dist/types/components/dev/SessionInfo.vue.d.ts +6 -0
- package/dist/types/core/bis.d.ts +21 -0
- package/dist/types/core/bis_swap.d.ts +622 -0
- package/dist/types/core/brc20.d.ts +229 -0
- package/dist/types/core/connect-modal.d.ts +15 -0
- package/dist/types/core/helpers.d.ts +212 -0
- package/dist/types/core/mint.d.ts +364 -0
- package/dist/types/core/modal.d.ts +21 -0
- package/dist/types/core/providers.d.ts +90 -0
- package/dist/types/core/register-browser-providers.d.ts +1 -0
- package/dist/types/core/register-local-provider.d.ts +1 -0
- package/dist/types/core/storage.d.ts +19 -0
- package/dist/types/core/store-network.d.ts +20 -0
- package/dist/types/core/store.d.ts +39 -0
- package/dist/types/core.d.ts +10 -0
- package/dist/types/lib/bitcoin.d.ts +8 -0
- package/dist/types/lib/dev-worker.d.ts +1 -0
- package/dist/types/lib/dev.d.ts +9 -0
- package/dist/types/lib/swap-constants.d.ts +7 -0
- package/dist/types/lib/swap-reporting.d.ts +80 -0
- package/dist/types/lib/uniswap_ops.d.ts +238 -0
- package/dist/types/lib/web3.d.ts +7 -0
- package/dist/types/node.d.ts +9 -0
- package/dist/types/provider/api.d.ts +97 -0
- package/dist/types/provider/leather.d.ts +2 -0
- package/dist/types/provider/local.d.ts +39 -0
- package/dist/types/provider/okx.d.ts +2 -0
- package/dist/types/provider/unisat.d.ts +2 -0
- package/dist/types/provider/xverse.d.ts +2 -0
- package/dist/types/react.d.ts +3 -0
- package/dist/types/types/common.d.ts +33 -0
- package/dist/types/types/global.d.ts +26 -0
- package/dist/types/types/inscription.d.ts +147 -0
- package/dist/types/types/vite-env.d.ts +7 -0
- package/dist/types/types/wallet.d.ts +50 -0
- package/dist/types/vue.d.ts +2 -0
- package/dist/vue.js +13 -0
- package/package.json +133 -0
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
import { SignFunction, SignResponse } from '../provider/api';
|
|
2
|
+
import { PaymentOpts } from '../types/common';
|
|
3
|
+
import { InscribeFees, InscribeMultipleResult, InscribeResult, SendInscriptionResult, InscriptionDetails } from '../types/inscription';
|
|
4
|
+
import { Buffer } from 'node:buffer';
|
|
5
|
+
import { WalletInfo } from '../types/wallet';
|
|
6
|
+
import * as bitcoinjs from 'bitcoinjs-lib';
|
|
7
|
+
interface TapLeafScriptInfo {
|
|
8
|
+
script: Buffer;
|
|
9
|
+
controlBlock: Buffer;
|
|
10
|
+
leafVersion: number;
|
|
11
|
+
}
|
|
12
|
+
interface UtxoInfo {
|
|
13
|
+
utxo: string;
|
|
14
|
+
script_type: 'pubkeyhash' | 'scripthash' | 'witness_v0_keyhash' | 'witness_v0_scripthash' | 'witness_v1_taproot' | 'pubkey' | 'anchor' | 'witness_unknown' | 'nulldata' | 'multisig' | 'nonstandard';
|
|
15
|
+
value: number;
|
|
16
|
+
tapLeafScript?: Array<TapLeafScriptInfo>;
|
|
17
|
+
wallet?: WalletInfo;
|
|
18
|
+
witnessUtxoScript?: Buffer;
|
|
19
|
+
sequence?: number;
|
|
20
|
+
finalScriptWitness?: Buffer;
|
|
21
|
+
}
|
|
22
|
+
interface UtxoInfoWithWallet {
|
|
23
|
+
utxo: string;
|
|
24
|
+
script_type: 'pubkeyhash' | 'scripthash' | 'witness_v0_keyhash' | 'witness_v0_scripthash' | 'witness_v1_taproot' | 'pubkey' | 'anchor' | 'witness_unknown' | 'nulldata' | 'multisig' | 'nonstandard';
|
|
25
|
+
value: number;
|
|
26
|
+
tapLeafScript?: Array<TapLeafScriptInfo>;
|
|
27
|
+
wallet: WalletInfo;
|
|
28
|
+
witnessUtxoScript?: Buffer;
|
|
29
|
+
sequence?: number;
|
|
30
|
+
finalScriptWitness?: Buffer;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Calculate the fees for inscribing multiple inscriptions with the given details, fee rate, postage, payment address, and payment amount.
|
|
34
|
+
*
|
|
35
|
+
* @param inscriptionDetailsArray - An array of InscriptionDetails instances containing the details of each inscription to be minted.
|
|
36
|
+
* @param feeRate - The fee rate in satoshis per virtual byte to be used for the fee calculation.
|
|
37
|
+
* @param postage - The postage amount in satoshis to be included in the fee calculation, or null to use the default dust value.
|
|
38
|
+
* @param paymentOpts - An object containing the payment address and payment amount, or null if no payment is required.
|
|
39
|
+
* @returns A promise that resolves to an object containing the total fee, commit fee, reveal fee, postage, and secret for the inscriptions.
|
|
40
|
+
*/
|
|
41
|
+
export declare function getInscribeMultipleFee(inscriptionDetailsArray: InscriptionDetails[], feeRate: number, postage: number | null, paymentOpts?: PaymentOpts): Promise<InscribeFees>;
|
|
42
|
+
export declare function inscribeWithParent(inscriptionDetails: InscriptionDetails, parentInscriptionId: string, feeRate: number, postage: number | null, dryRun: boolean, paymentOpts?: PaymentOpts): Promise<InscribeResult>;
|
|
43
|
+
export declare function inscribeMultiple(inscriptionDetailsArray: InscriptionDetails[], feeRate: number, postage: number | null, dryRun: boolean, paymentOpts?: PaymentOpts): Promise<InscribeMultipleResult>;
|
|
44
|
+
interface BuildTransactionResult {
|
|
45
|
+
tx: bitcoinjs.Transaction;
|
|
46
|
+
tx_fee: number;
|
|
47
|
+
}
|
|
48
|
+
export declare function buildTransaction(utxoInfos: UtxoInfo[], forceInUtxos: UtxoInfoWithWallet[], payerWallet: WalletInfo, opReturnWallets: WalletInfo[], outputWallet: WalletInfo | null, changeWallet: WalletInfo, feeRate: number, amount: number, paymentWallet: WalletInfo | null, payment: number | null): BuildTransactionResult;
|
|
49
|
+
interface TransactionInOuts {
|
|
50
|
+
ins: {
|
|
51
|
+
hash: Buffer;
|
|
52
|
+
index: number;
|
|
53
|
+
}[];
|
|
54
|
+
outs: {
|
|
55
|
+
value: number;
|
|
56
|
+
script: Buffer;
|
|
57
|
+
}[];
|
|
58
|
+
}
|
|
59
|
+
export declare function buildPsbtFromTx(tx: TransactionInOuts, cardinalUtxos: UtxoInfo[], payerWallet: WalletInfo, forceInUtxos: UtxoInfoWithWallet[]): Promise<bitcoinjs.Psbt>;
|
|
60
|
+
export interface ReclaimInput {
|
|
61
|
+
utxo: string;
|
|
62
|
+
value: number;
|
|
63
|
+
script_type: UtxoInfo['script_type'];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Builds an unsigned combined commit tx that reclaims transfer inscriptions
|
|
67
|
+
* back to the inscription wallet while paying for a new taproot commit
|
|
68
|
+
* output in the same transaction.
|
|
69
|
+
*
|
|
70
|
+
* Output layout:
|
|
71
|
+
* - outputs `0..n-1`: one self-send per reclaim input, 1:1 with the
|
|
72
|
+
* reclaim inputs (same index, same value), so the ordinal sat carried
|
|
73
|
+
* by each reclaim input flows onto its own output.
|
|
74
|
+
* - output `n`: the taproot commit output, funded purely by the cardinal
|
|
75
|
+
* utxos (never by reclaimed sats).
|
|
76
|
+
* - any trailing output: payer change.
|
|
77
|
+
*
|
|
78
|
+
* The candidate utxo set is passed in by the caller; the only network access
|
|
79
|
+
* is the PSBT-building step, which looks up each spent input's prevout tx
|
|
80
|
+
* (mirrors buildCommitTx).
|
|
81
|
+
*/
|
|
82
|
+
export declare function buildReclaimCommitTx(cardinalUtxos: UtxoInfo[], reclaimInputs: ReclaimInput[], payerWallet: WalletInfo, inscriptionWallet: WalletInfo, secret: string, inscriptionDetails: InscriptionDetails, feeRate: number, postage: number): Promise<{
|
|
83
|
+
unsignedCommitTx: bitcoinjs.Transaction;
|
|
84
|
+
unsignedPsbtHex: string;
|
|
85
|
+
commitVout: number;
|
|
86
|
+
commitOutputValue: number;
|
|
87
|
+
commitFee: number;
|
|
88
|
+
revealFee: number;
|
|
89
|
+
}>;
|
|
90
|
+
/**
|
|
91
|
+
* Builds, signs, and validates a full reclaim commit+reveal pair offline: creates
|
|
92
|
+
* a fresh secret, builds the reclaim commit tx (Task 1), signs its PSBT with the
|
|
93
|
+
* caller-supplied signFunc, builds the reveal tx spending the relocated commit
|
|
94
|
+
* output, and checks both signed txes with the mempool-accept validator before
|
|
95
|
+
* returning them for the caller to broadcast.
|
|
96
|
+
*
|
|
97
|
+
* Pure w.r.t. network selection: all utxos are passed in by the caller. Network
|
|
98
|
+
* access (prevout lookups, mempool-accept validation) is delegated to the same
|
|
99
|
+
* helpers buildCommitTx-based flows already use.
|
|
100
|
+
*/
|
|
101
|
+
export declare function assembleReclaimCommitAndReveal(cardinalUtxos: UtxoInfo[], reclaimInputs: ReclaimInput[], payerWallet: WalletInfo, inscriptionWallet: WalletInfo, inscriptionDetails: InscriptionDetails, feeRate: number, postage: number, signFunc: SignFunction): Promise<{
|
|
102
|
+
commitTxId: string;
|
|
103
|
+
signedCommitTxHex: string;
|
|
104
|
+
revealTxId: string;
|
|
105
|
+
signedRevealTxHex: string;
|
|
106
|
+
inscriptionId: string;
|
|
107
|
+
commitVout: number;
|
|
108
|
+
postage: number;
|
|
109
|
+
secret: string;
|
|
110
|
+
}>;
|
|
111
|
+
/**
|
|
112
|
+
* Fetches the connected wallets' cardinal utxos and delegates to
|
|
113
|
+
* assembleReclaimCommitAndReveal to build, sign, and validate the reclaim
|
|
114
|
+
* commit+reveal pair, then broadcasts both txes unless dryRun is set.
|
|
115
|
+
*/
|
|
116
|
+
export declare function mintWithReclaimsAll(inscriptionDetails: InscriptionDetails, reclaimInputs: ReclaimInput[], feeRate: number, postage: number | null, dryRun: boolean, signFunc: SignFunction): Promise<{
|
|
117
|
+
commitTxId: string;
|
|
118
|
+
signedCommitTxHex: string;
|
|
119
|
+
revealTxId: string;
|
|
120
|
+
signedRevealTxHex: string;
|
|
121
|
+
inscriptionId: string;
|
|
122
|
+
commitVout: number;
|
|
123
|
+
postage: number;
|
|
124
|
+
secret: string;
|
|
125
|
+
}>;
|
|
126
|
+
/**
|
|
127
|
+
* Estimates the fees for a reclaim mint by building the unsigned reclaim
|
|
128
|
+
* commit tx (Task 1) and a fee-sizing reveal tx offline, without signing or
|
|
129
|
+
* broadcasting. Mirrors mintWithExtraInputInCommitFeeRate.
|
|
130
|
+
*/
|
|
131
|
+
export declare function mintWithReclaimsCheckFees(inscriptionDetails: InscriptionDetails, reclaimInputs: ReclaimInput[], feeRate: number, postage: number | null): Promise<{
|
|
132
|
+
unsigned_commit_tx_hex: string;
|
|
133
|
+
signed_reveal_tx_hex: string;
|
|
134
|
+
inscription_id: string;
|
|
135
|
+
total_fee: number;
|
|
136
|
+
commit_vout: number;
|
|
137
|
+
}>;
|
|
138
|
+
/**
|
|
139
|
+
* Resolves reclaim inscriptions (transfer inscriptions to reclaim toward the
|
|
140
|
+
* base-deposit sufficiency check) into `ReclaimInput`s for
|
|
141
|
+
* `buildReclaimCommitTx`/`mintWithReclaimsAll`/`mintWithReclaimsCheckFees`.
|
|
142
|
+
*
|
|
143
|
+
* Looks up each inscription's current UTXO via `getInscriptionDetails` and
|
|
144
|
+
* enforces that it sits at sat offset 0 of its satpoint, which the reclaim
|
|
145
|
+
* commit tx assumes when self-sending the reclaim input.
|
|
146
|
+
*/
|
|
147
|
+
export declare function resolveReclaimInputs(reclaimInscriptions: {
|
|
148
|
+
inscriptionId: string;
|
|
149
|
+
amount: bigint;
|
|
150
|
+
}[], ordinalsAddress: string): Promise<ReclaimInput[]>;
|
|
151
|
+
/**
|
|
152
|
+
* Builds a transaction with multiple outputs. This is used for batch minting or batch sending.
|
|
153
|
+
*
|
|
154
|
+
* @param utxoArray - array of UTXOs to select from
|
|
155
|
+
* @param forceInUtxos - array of UTXOs that must be included in the transaction (e.g. for minting, the UTXO with the inscription must be included)
|
|
156
|
+
* @param payerWallet - the wallet that will pay for the transaction (must be the same for all inputs)
|
|
157
|
+
* @param outputWallets - array of wallets to send the outputs to (must be the same length as amounts)
|
|
158
|
+
* @param amounts - array of amounts to send to each output wallet (must be the same length as outputWallets)
|
|
159
|
+
* @param changeWallet - the wallet to send the change to
|
|
160
|
+
* @param feeRate - the fee rate in sat/vbyte
|
|
161
|
+
*
|
|
162
|
+
* @returns an object containing the built transaction and the fee paid for the transaction
|
|
163
|
+
*/
|
|
164
|
+
export declare function buildTransactionMultiOutput(utxoArray: UtxoInfo[], forceInUtxos: UtxoInfoWithWallet[], payerWallet: WalletInfo, outputWallets: WalletInfo[], amounts: number[], changeWallet: WalletInfo, feeRate: number): BuildTransactionResult;
|
|
165
|
+
interface SendMultiInscriptionWithBufferResult {
|
|
166
|
+
txid: string;
|
|
167
|
+
signed_tx_hex: string;
|
|
168
|
+
output_utxos: string[];
|
|
169
|
+
output_values: number[];
|
|
170
|
+
buffer_utxo: string;
|
|
171
|
+
buffer_output_value: number;
|
|
172
|
+
}
|
|
173
|
+
export declare function sendMultiInscriptionWithBuffer(inscriptionIds: string[], targetPostages: number[], targetAddr: string, bufferValue: number, feeRate: number, paymentAddr: string | null, payment: number | null, dryRun: boolean): Promise<SendMultiInscriptionWithBufferResult>;
|
|
174
|
+
/**
|
|
175
|
+
* Sends an inscription to a target address with specified postage and fee rate. This function is used for sending a single inscription, but it can also be used for batch sending by calling it multiple times with different inscription IDs and the same target address.
|
|
176
|
+
*
|
|
177
|
+
* @param inscriptionId - the ID of the inscription to send
|
|
178
|
+
* @param targetWallet - the wallet to send the inscription to (only the address field is used)
|
|
179
|
+
* @param targetPostage - the amount of satoshis to send with the inscription (must be greater than or equal to the dust value for the target wallet)
|
|
180
|
+
* @param feeRate - the fee rate in sat/vbyte to use for the transaction
|
|
181
|
+
* @param dryRun - if true, the transaction will not be broadcasted and the signed transaction hex will be returned for inspection
|
|
182
|
+
* @param signFunc - the function to use for signing the transaction, which takes the unsigned PSBT hex, payer address, inscription address, and an array of input indexes that belong to the inscription wallet, and returns an object containing the signed transaction hex and transaction ID
|
|
183
|
+
*
|
|
184
|
+
* @returns an object containing the transaction ID, signed transaction hex, vout index of the output containing the inscription, and the value of the output containing the inscription
|
|
185
|
+
*/
|
|
186
|
+
export declare function sendInscriptionAll(inscriptionId: string, targetWallet: WalletInfo, targetPostage: number | null, feeRate: number, dryRun: boolean, signFunc: SignFunction): Promise<SendInscriptionResult>;
|
|
187
|
+
/**
|
|
188
|
+
* Sends multiple inscriptions in one transaction with a buffer output and returns the fee paid for the transaction. This is used for batch minting or batch sending when the user wants to know the fee before actually sending the transaction.
|
|
189
|
+
*
|
|
190
|
+
* @param inscriptionIds - array of inscription IDs to send
|
|
191
|
+
* @param targetPostages - array of target postages for each inscription
|
|
192
|
+
* @param targetAddr - address to send the inscriptions to
|
|
193
|
+
* @param bufferValue - value of the buffer output
|
|
194
|
+
* @param feeRate - fee rate in sat/vbyte
|
|
195
|
+
* @param paymentAddr - address to send the payment to (if payment is not null)
|
|
196
|
+
* @param payment - amount to pay (if payment is not null)
|
|
197
|
+
*
|
|
198
|
+
* @returns the fee paid for the transaction in satoshis
|
|
199
|
+
*/
|
|
200
|
+
export declare function getMultiInscriptionWithBufferFeeRate(inscriptionIds: string[], targetPostages: number[], targetAddr: string, bufferValue: number, feeRate: number, paymentAddr: string | null, payment: number | null): Promise<number>;
|
|
201
|
+
/**
|
|
202
|
+
* Mints an inscription by building and signing the commit and reveal transactions. The commit transaction is built using the buildCommitTx function, and the reveal transaction is built using the buildRevealTx function. The function also validates the transactions before broadcasting them to the network. If dryRun is true, the transactions will not be broadcasted and the signed transaction hex will be returned for inspection.
|
|
203
|
+
*
|
|
204
|
+
* @param inscriptionDetails - details of the inscription to mint, including content type, content length, and the actual content in hex format
|
|
205
|
+
* @param feeRate - fee rate in sat/vbyte to use for the transactions
|
|
206
|
+
* @param postage - postage amount in satoshis to use for the transactions
|
|
207
|
+
* @param paymentAddr - address to send the payment to (if payment is not null)
|
|
208
|
+
* @param payment - amount to pay (if payment is not null)
|
|
209
|
+
* @param dryRun - if true, the transactions will not be broadcasted and the signed transaction hex will be returned for inspection
|
|
210
|
+
* @param signFunc - function to sign the transactions
|
|
211
|
+
*
|
|
212
|
+
* @returns an object containing the commit transaction ID, signed commit transaction hex, reveal transaction ID, signed reveal transaction hex, inscription ID, postage used, and the secret token used for minting
|
|
213
|
+
*/
|
|
214
|
+
export declare function mintAll(inscriptionDetails: InscriptionDetails, feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, dryRun: boolean, signFunc: SignFunction): Promise<{
|
|
215
|
+
commit_txid: string;
|
|
216
|
+
signed_commit_tx_hex: string;
|
|
217
|
+
reveal_txid: string;
|
|
218
|
+
signed_reveal_tx_hex: string;
|
|
219
|
+
inscription_id: string;
|
|
220
|
+
postage: number;
|
|
221
|
+
secret: string;
|
|
222
|
+
}>;
|
|
223
|
+
/**
|
|
224
|
+
* Mints an inscription using the connected payment wallet for both the commit and reveal transactions. This function is a wrapper around the mintAll function that simplifies the minting process when the user wants to use the same wallet for both transactions. It retrieves the connected wallets, builds and signs the transactions, validates them, and broadcasts them to the network. If dryRun is true, it returns the signed transaction hex without broadcasting.
|
|
225
|
+
*
|
|
226
|
+
* @param inscriptionDetails - details of the inscription to mint, including content type, content length, and the actual content in hex format
|
|
227
|
+
* @param feeRate - fee rate in sat/vbyte to use for the transactions
|
|
228
|
+
* @param postage - postage amount in satoshis to use for the transactions
|
|
229
|
+
* @param paymentAddr - address to send the payment to (if payment is not null)
|
|
230
|
+
* @param payment - amount to pay (if payment is not null)
|
|
231
|
+
* @param dryRun - if true, the transactions will not be broadcasted and the signed transaction hex will be returned for inspection
|
|
232
|
+
* @param signFunc - function to sign the transactions
|
|
233
|
+
*
|
|
234
|
+
* @returns an object containing the commit transaction ID, signed commit transaction hex, reveal transaction ID, signed reveal transaction hex, inscription ID, postage used, and the secret token used for minting
|
|
235
|
+
*/
|
|
236
|
+
export declare function mintAllPaymentWallet(inscriptionDetails: InscriptionDetails, feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, dryRun: boolean, signFunc: SignFunction): Promise<InscribeResult>;
|
|
237
|
+
interface InscribeCheckFeesResult {
|
|
238
|
+
commit_fee: number;
|
|
239
|
+
reveal_fee: number;
|
|
240
|
+
total_fee: number;
|
|
241
|
+
unsigned_commit_tx_hex: string;
|
|
242
|
+
signed_reveal_tx_hex: string;
|
|
243
|
+
inscription_id: string;
|
|
244
|
+
postage: number;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Checks the fees for minting an inscription by building the commit and reveal transactions without signing or broadcasting them. This function is useful for users who want to estimate the fees before actually minting the inscription. It returns the estimated commit fee, reveal fee, total fee, unsigned commit transaction hex, signed reveal transaction hex, inscription ID, and postage used.
|
|
248
|
+
*
|
|
249
|
+
* @param inscriptionDetails - details of the inscription to mint, including content type, content length, and the actual content in hex format
|
|
250
|
+
* @param feeRate - fee rate in sat/vbyte to use for the transactions
|
|
251
|
+
* @param postage - postage amount in satoshis to use for the transactions
|
|
252
|
+
* @param paymentAddr - address to send the payment to (if payment is not null)
|
|
253
|
+
* @param payment - amount to pay (if payment is not null)
|
|
254
|
+
*
|
|
255
|
+
* @returns an object containing the estimated commit fee, reveal fee, total fee, unsigned commit transaction hex, signed reveal transaction hex, inscription ID, and postage used
|
|
256
|
+
*/
|
|
257
|
+
export declare function mintAllCheckFees(inscriptionDetails: InscriptionDetails, feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null): Promise<InscribeCheckFeesResult>;
|
|
258
|
+
/**
|
|
259
|
+
* Sends an inscription to a target address using an OP_RETURN output. This function builds a transaction that spends the inscription UTXO and creates an OP_RETURN output with the inscription data, along with a target output with the specified postage. It then signs and broadcasts the transaction. If dryRun is true, it returns the signed transaction hex without broadcasting.
|
|
260
|
+
*
|
|
261
|
+
* @param inscriptionId - ID of the inscription to send, in the format of "txid:output_index"
|
|
262
|
+
* @param targetWallet - wallet information of the target address to send the inscription to
|
|
263
|
+
* @param targetPostage - postage amount in satoshis to include in the target output
|
|
264
|
+
* @param feeRate - fee rate in sat/vbyte to use for the transaction
|
|
265
|
+
* @param dryRun - if true, the transaction will not be broadcasted
|
|
266
|
+
* @param signFunc - function to sign the transaction
|
|
267
|
+
*
|
|
268
|
+
* @returns an object containing the transaction ID and signed transaction hex of the sent transaction
|
|
269
|
+
*/
|
|
270
|
+
export declare function sendInscriptionToOpReturnAll(inscriptionId: string, targetWallet: WalletInfo, targetPostage: number | null, feeRate: number, dryRun: boolean, signFunc: SignFunction): Promise<SendInscriptionResult>;
|
|
271
|
+
/**
|
|
272
|
+
* Sends an inscription to a target address using an OP_RETURN output, with the payment wallet as the source of funds for the transaction. This function is similar to sendInscriptionToOpReturnAll, but it specifically uses the payment wallet for funding the transaction, which can be useful in cases where the inscription wallet does not have enough funds to cover the transaction fees. It builds a transaction that spends the inscription UTXO and creates an OP_RETURN output with the inscription data, along with a target output with the specified postage. It then signs and broadcasts the transaction. If dryRun is true, it returns the signed transaction hex without broadcasting.
|
|
273
|
+
*
|
|
274
|
+
* @param inscriptionId - ID of the inscription to send, in the format of "txid:output_index"
|
|
275
|
+
* @param targetWallet - wallet information of the target address to send the inscription to
|
|
276
|
+
* @param targetPostage - postage amount in satoshis to include in the target output
|
|
277
|
+
* @param feeRate - fee rate in sat/vbyte to use for the transaction
|
|
278
|
+
* @param dryRun - if true, the transaction will not be broadcasted
|
|
279
|
+
* @param signFunc - function to sign the transaction
|
|
280
|
+
*
|
|
281
|
+
* @returns an object containing the transaction ID and signed transaction hex of the sent transaction
|
|
282
|
+
*/
|
|
283
|
+
export declare function sendInscriptionInPaymentWalletToOpReturnAll(inscriptionId: string, targetWallet: WalletInfo, targetPostage: number | null, feeRate: number, dryRun: boolean, signFunc: SignFunction): Promise<SendInscriptionResult>;
|
|
284
|
+
/**
|
|
285
|
+
* Mints an inscription with a parent inscription by building and signing the commit and reveal transactions that reference the parent inscription. This function is used when the user wants to create a new inscription that is linked to an existing parent inscription, allowing for hierarchical relationships between inscriptions. It retrieves the connected wallets, builds and signs the transactions, validates them, and broadcasts them to the network. If dryRun is true, it returns the signed transaction hex without broadcasting.
|
|
286
|
+
*
|
|
287
|
+
* @param inscriptionDetails - details of the inscription to mint, including content type, content length, and the actual content in hex format
|
|
288
|
+
* @param parentInscriptionId - ID of the parent inscription to link to, in the format of "txid:output_index"
|
|
289
|
+
* @param feeRate - fee rate in sat/vbyte to use for the transactions
|
|
290
|
+
* @param postage - postage amount in satoshis to use for the transactions
|
|
291
|
+
* @param paymentAddr - address to send the payment to (if payment is not null)
|
|
292
|
+
* @param payment - amount to pay (if payment is not null)
|
|
293
|
+
* @param dryRun - if true, the transactions will not be broadcasted and the signed transaction hex will be returned for inspection
|
|
294
|
+
* @param signFunc - function to sign the transactions
|
|
295
|
+
*
|
|
296
|
+
* @returns an object containing the commit transaction ID, signed commit transaction hex, reveal transaction ID, signed reveal transaction hex, inscription ID, postage used, and the secret token used for minting
|
|
297
|
+
*/
|
|
298
|
+
export declare function mintWithParentAll(inscriptionDetails: InscriptionDetails, parentInscriptionId: string, feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, dryRun: boolean, signFunc: SignFunction): Promise<InscribeResult>;
|
|
299
|
+
interface OutputUtxoInfo {
|
|
300
|
+
wallet: WalletInfo;
|
|
301
|
+
value: number;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Sends an inscription to a target address using an OP_RETURN output, with extra input UTXOs and extra output UTXOs included in the transaction. This function allows for more complex transactions where the user wants to include additional inputs and outputs beyond just the inscription UTXO and the target output. It builds a transaction that spends the inscription UTXO along with the extra input UTXOs, creates an OP_RETURN output with the inscription data, includes a target output with the specified postage, and adds any extra output UTXOs. It then signs and broadcasts the transaction. If dryRun is true, it returns the signed transaction hex without broadcasting.
|
|
305
|
+
*
|
|
306
|
+
* @param inscriptionId - ID of the inscription to send, in the format of "txid:output_index"
|
|
307
|
+
* @param extraInputUtxos - array of extra input UTXOs to include in the transaction, each with its associated wallet information
|
|
308
|
+
* @param targetWallet - wallet information of the target address to send the inscription to
|
|
309
|
+
* @param targetPostage - postage amount in satoshis to include in the target output
|
|
310
|
+
* @param extraOutputUtxos - array of extra output UTXOs to include in the transaction, each with its associated wallet information and value
|
|
311
|
+
* @param feeRate - fee rate in sat/vbyte to use for the transaction
|
|
312
|
+
* @param dryRun - if true, the transaction will not be broadcasted
|
|
313
|
+
* @param signFunc - function to sign the transaction
|
|
314
|
+
*
|
|
315
|
+
* @returns an object containing the transaction ID and signed transaction hex of the sent transaction
|
|
316
|
+
*/
|
|
317
|
+
export declare function sendInscriptionToOpReturnWithExtraInputsAndExtraOutputAll(inscriptionId: string, extraInputUtxos: UtxoInfoWithWallet[], targetWallet: WalletInfo, targetPostage: number, extraOutputUtxos: OutputUtxoInfo[], feeRate: number, dryRun: boolean, signFunc: SignFunction): Promise<SignResponse>;
|
|
318
|
+
interface SendInscriptionFeeRateResult {
|
|
319
|
+
txid: string;
|
|
320
|
+
unsigned_tx_hex: string;
|
|
321
|
+
tx_fee: number;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Calculates the fee for sending an inscription to a target address using an OP_RETURN output, with extra input UTXOs and extra output UTXOs included in the transaction, based on a specified fee rate. This function builds the transaction without signing or broadcasting it, allowing the user to estimate the fees before actually sending the inscription. It returns the transaction ID, unsigned transaction hex, and the calculated transaction fee.
|
|
325
|
+
*
|
|
326
|
+
* @param inscriptionId - ID of the inscription to send, in the format of "txid:output_index"
|
|
327
|
+
* @param extraInputUtxos - array of extra input UTXOs to include in the transaction, each with its associated wallet information
|
|
328
|
+
* @param targetWallet - wallet information of the target address to send the inscription to
|
|
329
|
+
* @param targetPostage - postage amount in satoshis to include in the target output
|
|
330
|
+
* @param extraOutputUtxos - array of extra output UTXOs to include in the transaction, each with its associated wallet information and value
|
|
331
|
+
* @param feeRate - fee rate in sat/vbyte to use for the transaction
|
|
332
|
+
*
|
|
333
|
+
* @returns an object containing the transaction ID, unsigned transaction hex, and calculated transaction fee
|
|
334
|
+
*/
|
|
335
|
+
export declare function sendInscriptionToOpReturnWithExtraInputsAndExtraOutputFeeRate(inscriptionId: string, extraInputUtxos: UtxoInfoWithWallet[], targetWallet: WalletInfo, targetPostage: number, extraOutputUtxos: OutputUtxoInfo[], feeRate: number): Promise<SendInscriptionFeeRateResult>;
|
|
336
|
+
/**
|
|
337
|
+
* Mints an inscription with extra input UTXOs included in the commit transaction. This function builds and signs the commit and reveal transactions for minting an inscription, while allowing the user to include additional input UTXOs in the commit transaction. This can be useful in cases where the user wants to fund the commit transaction with specific UTXOs or needs to include additional inputs for other reasons. The function retrieves the connected wallets, builds and signs the transactions, validates them, and broadcasts them to the network. If dryRun is true, it returns the signed transaction hex without broadcasting.
|
|
338
|
+
*
|
|
339
|
+
* @param inscriptionDetails - details of the inscription to mint, including content type, content length, and the actual content in hex format
|
|
340
|
+
* @param extraInputUtxos - array of extra input UTXOs to include in the commit transaction, each with its associated wallet information
|
|
341
|
+
* @param feeRate - fee rate in sat/vbyte to use for the transactions
|
|
342
|
+
* @param postage - postage amount in satoshis to use for the transactions
|
|
343
|
+
* @param paymentAddr - address to send the payment to (if payment is not null)
|
|
344
|
+
* @param payment - amount to pay (if payment is not null)
|
|
345
|
+
* @param dryRun - if true, the transactions will not be broadcasted and the signed transaction hex will be returned for inspection
|
|
346
|
+
* @param signFunc - function to sign the transactions
|
|
347
|
+
*
|
|
348
|
+
* @returns an object containing the commit transaction ID, signed commit transaction hex, reveal transaction ID, signed reveal transaction hex, inscription ID, postage used, and the secret token used for minting
|
|
349
|
+
*/
|
|
350
|
+
export declare function mintWithExtraInputInCommitAll(inscriptionDetails: InscriptionDetails, extraInputUtxos: UtxoInfoWithWallet[], feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null, dryRun: boolean, signFunc: SignFunction): Promise<InscribeResult>;
|
|
351
|
+
/**
|
|
352
|
+
* Checks the fees for minting an inscription with extra input UTXOs included in the commit transaction by building the commit and reveal transactions without signing or broadcasting them. This function is useful for users who want to estimate the fees before actually minting the inscription with extra inputs. It returns the estimated commit fee, reveal fee, total fee, unsigned commit transaction hex, signed reveal transaction hex, inscription ID, and postage used.
|
|
353
|
+
*
|
|
354
|
+
* @param inscriptionDetails - details of the inscription to mint, including content type, content length, and the actual content in hex format
|
|
355
|
+
* @param extraInputUtxos - array of extra input UTXOs to include in the commit transaction, each with its associated wallet information
|
|
356
|
+
* @param feeRate - fee rate in sat/vbyte to use for the transactions
|
|
357
|
+
* @param postage - postage amount in satoshis to use for the transactions
|
|
358
|
+
* @param paymentAddr - address to send the payment to (if payment is not null)
|
|
359
|
+
* @param payment - amount to pay (if payment is not null)
|
|
360
|
+
*
|
|
361
|
+
* @returns an object containing the estimated commit fee, reveal fee, total fee, unsigned commit transaction hex, signed reveal transaction hex, inscription ID, and postage used
|
|
362
|
+
*/
|
|
363
|
+
export declare function mintWithExtraInputInCommitFeeRate(inscriptionDetails: InscriptionDetails, extraInputUtxos: UtxoInfoWithWallet[], feeRate: number, postage: number | null, paymentAddr: string | null, payment: number | null): Promise<InscribeCheckFeesResult>;
|
|
364
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BISWalletProvider, ConnectCallbacks, ModalTheme } from '../types/common';
|
|
2
|
+
/**
|
|
3
|
+
* NOTE: The modal instance is created once and reused for subsequent calls to showConnect or showError. This ensures that only one modal is present in the DOM at any given time, and it can be easily shown or hidden as needed without creating multiple instances.
|
|
4
|
+
*
|
|
5
|
+
* The create function checks if the modal instance already exists before creating a new one. If it does exist, it simply returns without doing anything. This prevents multiple modals from being created if create is called multiple times.
|
|
6
|
+
*
|
|
7
|
+
* The showConnect, showConnectConfirmation, and showError functions all check if the modal instance exists before attempting to call methods on it. If the modal instance does not exist (e.g., if create has not been called), these functions will simply do nothing, which is a safe fallback behavior.
|
|
8
|
+
*
|
|
9
|
+
* This design allows for a single modal instance to be created and reused throughout the application, ensuring efficient resource usage and consistent user experience.
|
|
10
|
+
*/
|
|
11
|
+
export declare function create(): void;
|
|
12
|
+
export declare function showConnect(callbacks: ConnectCallbacks): void;
|
|
13
|
+
export declare function showConnectConfirmation(_provider: BISWalletProvider): void;
|
|
14
|
+
export declare function showError(msg?: string | null | undefined): void;
|
|
15
|
+
export declare function hide(): void;
|
|
16
|
+
/**
|
|
17
|
+
* Sets the theme for the modal.
|
|
18
|
+
*
|
|
19
|
+
* @param theme The theme to set for the modal, which can be 'light', 'dark', or 'auto'.
|
|
20
|
+
*/
|
|
21
|
+
export declare function setTheme(theme: ModalTheme): void;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { BISProvider, SignFunction } from '../provider/api';
|
|
2
|
+
import { BISSession, BISWallet, BISWalletProvider, BISWalletPurpose } from '../types/common';
|
|
3
|
+
/**
|
|
4
|
+
* Registry of wallet providers, populated per build via `registerProvider`. The
|
|
5
|
+
* browser build registers the extension wallets; the server build registers only
|
|
6
|
+
* the local wallet. Keeping this empty by default means the core no longer
|
|
7
|
+
* statically imports every provider (so each flavour only bundles what it needs).
|
|
8
|
+
*/
|
|
9
|
+
export declare const PROVIDERS: Partial<Record<BISWalletProvider, BISProvider>>;
|
|
10
|
+
/**
|
|
11
|
+
* Registers a wallet provider implementation under its key. Build entries call
|
|
12
|
+
* this at startup to populate the registry for their environment.
|
|
13
|
+
*
|
|
14
|
+
* @param name The provider key (e.g. 'unisat', 'local').
|
|
15
|
+
* @param provider The provider implementation.
|
|
16
|
+
*/
|
|
17
|
+
export declare function registerProvider(name: BISWalletProvider, provider: BISProvider): void;
|
|
18
|
+
/**
|
|
19
|
+
* Gets the list of wallets from the specified provider. The function checks if the provider is supported and then calls the corresponding getWallets function from the provider module to retrieve the list of wallets. If the provider is not supported or if there is an error while fetching the wallets, it throws an error with an appropriate message.
|
|
20
|
+
*
|
|
21
|
+
* @param provider The wallet provider for which to fetch the wallets. This should be one of the registered providers.
|
|
22
|
+
*
|
|
23
|
+
* @returns A promise that resolves to a BISSession object containing the provider, the list of wallets, and a null signature. The function also saves the wallet information to local storage for later use.
|
|
24
|
+
* @throws An error if the provider is not supported or if there is an error while fetching the wallets, with a message indicating the reason for the failure.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getWallets(provider: BISWalletProvider): Promise<BISSession>;
|
|
27
|
+
/**
|
|
28
|
+
* Returns the currently connected ordinals wallet, or undefined if no ordinals wallet is connected. The function retrieves the wallet information from local storage and checks for a wallet with the purpose of 'ordinals'. If such a wallet is found, it is returned; otherwise, the function returns undefined.
|
|
29
|
+
*
|
|
30
|
+
* @returns The currently connected ordinals wallet, or undefined if no ordinals wallet is connected.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getOrdinalsWallet(): BISWallet | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Returns the currently connected payment wallet, or undefined if no payment wallet is connected. The function retrieves the wallet information from local storage and checks for a wallet with the purpose of 'payment'. If such a wallet is found, it is returned; otherwise, the function returns undefined.
|
|
35
|
+
*
|
|
36
|
+
* @returns The currently connected payment wallet, or undefined if no payment wallet is connected.
|
|
37
|
+
*/
|
|
38
|
+
export declare function getPaymentWallet(): BISWallet | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Returns the sign function for the specified wallet provider from the registry.
|
|
41
|
+
*
|
|
42
|
+
* @param provider The wallet provider for which to get the sign function.
|
|
43
|
+
* @returns The provider's sign function.
|
|
44
|
+
* @throws An error if the provider is not registered.
|
|
45
|
+
*/
|
|
46
|
+
export declare function getSignFn(provider: BISWalletProvider): SignFunction;
|
|
47
|
+
/**
|
|
48
|
+
* Signs a message using the currently connected wallet provider, then verifies it
|
|
49
|
+
* against the backend. Returns the signature, or throws if signing or verification fails.
|
|
50
|
+
*
|
|
51
|
+
* @param message The message to sign.
|
|
52
|
+
* @param walletType The wallet purpose to sign with ('payment' | 'ordinals' | 'all').
|
|
53
|
+
* @returns The signature as a hex string.
|
|
54
|
+
*/
|
|
55
|
+
export declare function signMessage(message: string, walletType: BISWalletPurpose): Promise<string>;
|
|
56
|
+
/**
|
|
57
|
+
* Signs a message using the currently connected wallet provider, then verifies it
|
|
58
|
+
* locally (offline). Returns the signature, or throws if signing or verification fails.
|
|
59
|
+
*
|
|
60
|
+
* @param message The message to sign.
|
|
61
|
+
* @param walletType The wallet purpose to sign with ('payment' | 'ordinals' | 'all').
|
|
62
|
+
* @returns The signature as a hex string.
|
|
63
|
+
*/
|
|
64
|
+
export declare function signMessageLocalVerify(message: string, walletType: BISWalletPurpose): Promise<string>;
|
|
65
|
+
/**
|
|
66
|
+
* Signs a message deterministically using the currently connected wallet provider,
|
|
67
|
+
* then verifies it locally. Returns the signature, or throws on failure.
|
|
68
|
+
*
|
|
69
|
+
* @param message The message to sign.
|
|
70
|
+
* @returns The signature as a hex string.
|
|
71
|
+
*/
|
|
72
|
+
export declare function signMessageLocalVerifyDeterministic(message: string): Promise<string>;
|
|
73
|
+
/**
|
|
74
|
+
* Sends Bitcoin using the currently connected wallet provider.
|
|
75
|
+
*
|
|
76
|
+
* @param amountSats The amount to send, in satoshis.
|
|
77
|
+
* @param toAddress The destination address.
|
|
78
|
+
* @param feeRate Optional fee rate in sat/vB. Extension providers estimate the fee themselves and ignore this; the local (WIF) provider requires it.
|
|
79
|
+
* @returns The transaction ID of the sent transaction.
|
|
80
|
+
*/
|
|
81
|
+
export declare function sendBTC(amountSats: number, toAddress: string, feeRate?: number): Promise<string>;
|
|
82
|
+
/**
|
|
83
|
+
* Signs a PSBT using the currently connected wallet provider.
|
|
84
|
+
*
|
|
85
|
+
* @param psbtBase64 The PSBT to sign, base64-encoded.
|
|
86
|
+
* @param broadcast Whether to broadcast the signed transaction.
|
|
87
|
+
* @param inputsToSign The inputs to sign.
|
|
88
|
+
* @param message Optional message passed to providers that support it (ignored by others).
|
|
89
|
+
*/
|
|
90
|
+
export declare function signPSBT(psbtBase64: string, broadcast: boolean, inputsToSign: any[], message?: string): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface KeyValueStore {
|
|
2
|
+
get: (key: string) => string | null;
|
|
3
|
+
set: (key: string, value: string) => void;
|
|
4
|
+
remove: (key: string) => void;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Creates an in-memory key-value store that can be used for storing data during the session. The memoryStorage function returns an object that implements the KeyValueStore interface, allowing you to get, set, and remove key-value pairs using a Map object internally. This is useful for scenarios where you want to store data temporarily without persisting it across sessions, such as during testing or when localStorage is not available.
|
|
8
|
+
*
|
|
9
|
+
* The returned KeyValueStore object provides three methods:
|
|
10
|
+
* - get(key: string): Retrieves the value associated with the specified key. If the key does not exist, it returns null.
|
|
11
|
+
* - set(key: string, value: string): Stores a key-value pair in the memory storage. If the key already exists, it will overwrite the existing value.
|
|
12
|
+
* - remove(key: string): Removes the key-value pair associated with the specified key from the memory storage. If the key does not exist, it does nothing.
|
|
13
|
+
*
|
|
14
|
+
* This in-memory storage is useful for scenarios where you want to store data temporarily during the runtime of an application without needing to persist it across sessions or reloads. It can be particularly helpful for testing purposes or when working in environments where localStorage is not available (e.g., server-side rendering).
|
|
15
|
+
*
|
|
16
|
+
* @returns An object that implements the KeyValueStore interface, providing methods to get, set, and remove key-value pairs in memory.
|
|
17
|
+
*/
|
|
18
|
+
export declare function memoryStorage(): KeyValueStore;
|
|
19
|
+
export declare const browserStorage: KeyValueStore;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BISNetwork } from '../types/common';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the currently selected network (e.g. 'mainnet', 'testnet', 'signet').
|
|
4
|
+
*
|
|
5
|
+
* @returns The currently selected network.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getNetwork(): BISNetwork;
|
|
8
|
+
/**
|
|
9
|
+
* Sets the current network and notifies subscribers. No-op if unchanged.
|
|
10
|
+
*
|
|
11
|
+
* @param newNetwork The network to switch to.
|
|
12
|
+
*/
|
|
13
|
+
export declare function setNetwork(newNetwork: BISNetwork): void;
|
|
14
|
+
/**
|
|
15
|
+
* Subscribes to network changes.
|
|
16
|
+
*
|
|
17
|
+
* @param listener Called with the new network whenever it changes.
|
|
18
|
+
* @returns An unsubscribe function that removes the listener.
|
|
19
|
+
*/
|
|
20
|
+
export declare function subscribeToNetwork(listener: (network: BISNetwork) => void): () => void;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { BISSession } from '../types/common';
|
|
2
|
+
/**
|
|
3
|
+
* Saves the wallet information to local storage. The saveWalletInfo function takes a BISSession object as an argument and stores it in local storage under a specific key (LS_KEY). The data is serialized to a JSON string before being stored. This allows the application to persist wallet information across sessions, enabling users to retain their wallet data even after closing and reopening the application.
|
|
4
|
+
* @param data The BISSession object containing the wallet information to be saved. This object typically includes details about the connected wallet, such as the provider, accounts, and other relevant session data. The function serializes this object to a JSON string and stores it in local storage under the key defined by LS_KEY, allowing for easy retrieval and management of wallet information in the application.
|
|
5
|
+
*/
|
|
6
|
+
export declare function saveWalletInfo(data: BISSession): void;
|
|
7
|
+
/**
|
|
8
|
+
* Retrieves the wallet information from local storage. The getWalletInfo function reads the data stored under the LS_KEY in local storage, parses it from a JSON string back into a BISSession object, and returns it. If no data is found, it returns null. This function allows the application to access the persisted wallet information, enabling features like session restoration and wallet management.
|
|
9
|
+
* @returns The BISSession object containing the wallet information, or null if no data is found. This object typically includes details about the connected wallet, such as the provider, accounts, and other relevant session data.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getWalletInfo(): BISSession | null;
|
|
12
|
+
/**
|
|
13
|
+
* Clears the wallet information from local storage. The clearWalletInfo function removes the data stored under the LS_KEY in local storage, effectively clearing any persisted wallet information. This can be used when a user wants to disconnect their wallet or reset their session, ensuring that no wallet data remains stored in the browser after the operation is performed.
|
|
14
|
+
*/
|
|
15
|
+
export declare function clearWalletInfo(): void;
|
|
16
|
+
export interface BISSwapWalletInfo {
|
|
17
|
+
swapPubkey: string;
|
|
18
|
+
swapPrivkey: string;
|
|
19
|
+
bitcoinAddress: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Saves the swap wallet information securely in IndexedDB. The saveSwapWalletInfo function takes a SwapWalletInfo object containing the swap public key, private key, and associated Bitcoin address. It generates a random encryption key and initialization vector (IV) to encrypt the private key using AES-GCM encryption. The encrypted private key, along with the IV, encryption key, swap public key, and Bitcoin address, are then stored in IndexedDB for secure retrieval later. This approach ensures that sensitive wallet information is protected while still allowing for necessary access when needed.
|
|
23
|
+
*
|
|
24
|
+
* @param data The SwapWalletInfo object containing the swap public key, private key, and associated Bitcoin address. The function encrypts the private key using AES-GCM encryption with a randomly generated key and IV, and then stores the encrypted data along with the necessary information for decryption in IndexedDB. This allows for secure storage of sensitive wallet information while still enabling retrieval when needed.
|
|
25
|
+
*/
|
|
26
|
+
export declare function saveSwapWalletInfo(data: BISSwapWalletInfo): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Reads the swap wallet information from IndexedDB. The readSwapWalletInfo function takes a Bitcoin address as an argument and retrieves the corresponding encrypted wallet information from IndexedDB. It then decrypts the private key using the stored encryption key and IV, returning the swap public key, decrypted private key, and associated Bitcoin address as a SwapWalletInfo object. If no matching record is found or if decryption fails, it returns null. This function allows for secure retrieval of wallet information while ensuring that sensitive data remains protected.
|
|
29
|
+
*
|
|
30
|
+
* @param bitcoinAddressToRead The Bitcoin address for which to read the swap wallet information. The function looks up the encrypted wallet information associated with this Bitcoin address in IndexedDB, decrypts the private key using the stored encryption key and IV, and returns the swap public key, decrypted private key, and Bitcoin address as a SwapWalletInfo object. If no matching record is found or if decryption fails, it returns null, ensuring that sensitive wallet information is handled securely.
|
|
31
|
+
* @returns A promise that resolves to a SwapWalletInfo object containing the swap public key, decrypted private key, and associated Bitcoin address if the information is successfully retrieved and decrypted, or null if no matching record is found or if decryption fails. This allows for secure access to wallet information while maintaining the confidentiality of sensitive data.
|
|
32
|
+
*/
|
|
33
|
+
export declare function readSwapWalletInfo(bitcoinAddressToRead: string): Promise<BISSwapWalletInfo | null>;
|
|
34
|
+
/**
|
|
35
|
+
* Deletes the swap wallet information associated with the given Bitcoin address from IndexedDB. The deleteSwapWalletInfo function takes a Bitcoin address as an argument and removes the corresponding record from IndexedDB, effectively deleting the stored swap wallet information. This can be used when a user wants to remove their wallet data or when it is no longer needed, ensuring that sensitive information is properly cleaned up from storage.
|
|
36
|
+
*
|
|
37
|
+
* @param bitcoinAddress The Bitcoin address for which to delete the swap wallet information. The function looks up the record associated with this Bitcoin address in IndexedDB and deletes it, effectively removing the stored swap wallet information. This allows for proper cleanup of sensitive data when it is no longer needed or when a user wants to remove their wallet information from storage.
|
|
38
|
+
*/
|
|
39
|
+
export declare function deleteSwapWalletInfo(bitcoinAddress: string): Promise<void>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * as wallet from './api/wallet';
|
|
2
|
+
export * as swap from './api/swap';
|
|
3
|
+
export * as brc20 from './api/brc20';
|
|
4
|
+
export * as mint from './api/mint';
|
|
5
|
+
export * as balances from './api/balances';
|
|
6
|
+
export * from './api/helpers';
|
|
7
|
+
export { getNetwork, setNetwork, subscribeToNetwork } from './core/store-network';
|
|
8
|
+
export type { PaymentOpts } from './types/common';
|
|
9
|
+
export * as bitcoinjs from 'bitcoinjs-lib';
|
|
10
|
+
export * as Buff from '@cmdcode/buff-utils';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as bitcoinjs from 'bitcoinjs-lib';
|
|
2
|
+
/**
|
|
3
|
+
* Get the Bitcoin network parameters based on the current network.
|
|
4
|
+
* This is used for address generation and transaction creation.
|
|
5
|
+
*
|
|
6
|
+
* @returns {bitcoinjs.Network} The Bitcoin network parameters for the current network.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getBitcoinNetwork(): bitcoinjs.Network;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ClassValue } from 'clsx';
|
|
2
|
+
/**
|
|
3
|
+
* Utility function to combine class names conditionally. The cn function takes any number of class name inputs
|
|
4
|
+
* and merges them into a single string, resolving conflicts according to Tailwind CSS rules.
|
|
5
|
+
*
|
|
6
|
+
* @param inputs A variable number of class name inputs, which can be strings, arrays, or objects. The clsx function processes these inputs to determine which class names should be included based on their truthiness and structure. The twMerge function then takes the resulting class string and merges any conflicting Tailwind CSS classes according to its rules, ensuring that the final output is a clean and optimized string of class names.
|
|
7
|
+
* @returns {string} A single string of combined class names, with duplicates merged according to Tailwind CSS rules. This function is useful for conditionally applying class names in a clean and efficient way, especially when working with Tailwind CSS, as it ensures that conflicting classes are resolved correctly.
|
|
8
|
+
*/
|
|
9
|
+
export declare function cn(...inputs: ClassValue[]): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The constant-product pool fee, in basis points. Charged by the pool on the way
|
|
3
|
+
* in and already baked into the amounts `getAmountOut`/`getAmountIn` return, via
|
|
4
|
+
* their 997/1000 factor — keep the two in step if either ever changes. The
|
|
5
|
+
* `POOL_FEE_BPS` unit test pins this to that factor, so drift fails the build.
|
|
6
|
+
*/
|
|
7
|
+
export declare const POOL_FEE_BPS = 30n;
|