@dfinity/ckbtc 2.2.1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -15
- package/dist/candid/minter.certified.idl.js +12 -0
- package/dist/candid/minter.d.ts +11 -0
- package/dist/candid/minter.did +9 -1
- package/dist/candid/minter.idl.js +12 -0
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/index.cjs.js.map +3 -3
- package/dist/esm/chunk-D3EDBNHW.js +2 -0
- package/dist/esm/chunk-D3EDBNHW.js.map +7 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/minter.canister.js +1 -1
- package/dist/types/minter.canister.d.ts +12 -3
- package/dist/types/types/minter.params.d.ts +4 -0
- package/package.json +1 -1
- package/dist/esm/chunk-UKFVU33P.js +0 -2
- package/dist/esm/chunk-UKFVU33P.js.map +0 -7
package/README.md
CHANGED
|
@@ -26,10 +26,10 @@ npm i @dfinity/agent @dfinity/candid @dfinity/principal @dfinity/utils
|
|
|
26
26
|
|
|
27
27
|
## Usage
|
|
28
28
|
|
|
29
|
-
The features are available through the class `
|
|
29
|
+
The features are available through the class `CkBTCMinterCanister`. It has to be instantiated with a canister ID.
|
|
30
30
|
|
|
31
31
|
```ts
|
|
32
|
-
import {
|
|
32
|
+
import { CkBTCMinterCanister } from "@dfinity/ckbtc";
|
|
33
33
|
import { createAgent } from "@dfinity/utils";
|
|
34
34
|
|
|
35
35
|
const agent = await createAgent({
|
|
@@ -37,7 +37,7 @@ const agent = await createAgent({
|
|
|
37
37
|
host: HOST,
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
-
const { getBtcAddress } =
|
|
40
|
+
const { getBtcAddress } = CkBTCMinterCanister.create({
|
|
41
41
|
agent,
|
|
42
42
|
canisterId: MY_CKBTC_MINTER_CANISTER_ID,
|
|
43
43
|
});
|
|
@@ -76,7 +76,7 @@ Parameters:
|
|
|
76
76
|
|
|
77
77
|
### :factory: CkBTCMinterCanister
|
|
78
78
|
|
|
79
|
-
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#
|
|
79
|
+
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L42)
|
|
80
80
|
|
|
81
81
|
#### Methods
|
|
82
82
|
|
|
@@ -90,6 +90,7 @@ Parameters:
|
|
|
90
90
|
- [retrieveBtcStatusV2ByAccount](#gear-retrievebtcstatusv2byaccount)
|
|
91
91
|
- [estimateWithdrawalFee](#gear-estimatewithdrawalfee)
|
|
92
92
|
- [getMinterInfo](#gear-getminterinfo)
|
|
93
|
+
- [getKnownUtxos](#gear-getknownutxos)
|
|
93
94
|
|
|
94
95
|
##### :gear: create
|
|
95
96
|
|
|
@@ -97,7 +98,7 @@ Parameters:
|
|
|
97
98
|
| -------- | ------------------------------------------------------------------------ |
|
|
98
99
|
| `create` | `(options: CkBTCMinterCanisterOptions<_SERVICE>) => CkBTCMinterCanister` |
|
|
99
100
|
|
|
100
|
-
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#
|
|
101
|
+
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L43)
|
|
101
102
|
|
|
102
103
|
##### :gear: getBtcAddress
|
|
103
104
|
|
|
@@ -115,7 +116,7 @@ Parameters:
|
|
|
115
116
|
- `params.owner`: The owner for which the BTC address should be generated. If not provided, the `caller` will be use instead.
|
|
116
117
|
- `params.subaccount`: An optional subaccount to compute the address.
|
|
117
118
|
|
|
118
|
-
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#
|
|
119
|
+
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L64)
|
|
119
120
|
|
|
120
121
|
##### :gear: updateBalance
|
|
121
122
|
|
|
@@ -133,7 +134,7 @@ Parameters:
|
|
|
133
134
|
- `params.owner`: The owner of the address. If not provided, the `caller` will be use instead.
|
|
134
135
|
- `params.subaccount`: An optional subaccount of the address.
|
|
135
136
|
|
|
136
|
-
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#
|
|
137
|
+
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L83)
|
|
137
138
|
|
|
138
139
|
##### :gear: getWithdrawalAccount
|
|
139
140
|
|
|
@@ -143,7 +144,7 @@ Returns the account to which the caller should deposit ckBTC before withdrawing
|
|
|
143
144
|
| ---------------------- | ------------------------ |
|
|
144
145
|
| `getWithdrawalAccount` | `() => Promise<Account>` |
|
|
145
146
|
|
|
146
|
-
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#
|
|
147
|
+
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L106)
|
|
147
148
|
|
|
148
149
|
##### :gear: retrieveBtc
|
|
149
150
|
|
|
@@ -167,7 +168,7 @@ Parameters:
|
|
|
167
168
|
- `params.address`: The bitcoin address.
|
|
168
169
|
- `params.amount`: The ckBTC amount.
|
|
169
170
|
|
|
170
|
-
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#
|
|
171
|
+
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L125)
|
|
171
172
|
|
|
172
173
|
##### :gear: retrieveBtcWithApproval
|
|
173
174
|
|
|
@@ -193,7 +194,7 @@ Parameters:
|
|
|
193
194
|
- `params.fromSubaccount`: An optional subaccount from which
|
|
194
195
|
the ckBTC should be transferred.
|
|
195
196
|
|
|
196
|
-
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#
|
|
197
|
+
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L155)
|
|
197
198
|
|
|
198
199
|
##### :gear: retrieveBtcStatus
|
|
199
200
|
|
|
@@ -209,7 +210,7 @@ Parameters:
|
|
|
209
210
|
- `transactionId`: The ID of the corresponding burn transaction.
|
|
210
211
|
- `certified`: query or update call
|
|
211
212
|
|
|
212
|
-
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#
|
|
213
|
+
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L187)
|
|
213
214
|
|
|
214
215
|
##### :gear: retrieveBtcStatusV2ByAccount
|
|
215
216
|
|
|
@@ -224,7 +225,7 @@ Parameters:
|
|
|
224
225
|
- `certified`: query or update call
|
|
225
226
|
- `account`: an optional account to retrieve the statuses. If not provided, statuses for the caller are retrieved.
|
|
226
227
|
|
|
227
|
-
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#
|
|
228
|
+
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L205)
|
|
228
229
|
|
|
229
230
|
##### :gear: estimateWithdrawalFee
|
|
230
231
|
|
|
@@ -240,7 +241,7 @@ Parameters:
|
|
|
240
241
|
- `params.certified`: query or update call
|
|
241
242
|
- `params.amount`: The optional amount for which the fee should be estimated.
|
|
242
243
|
|
|
243
|
-
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#
|
|
244
|
+
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L239)
|
|
244
245
|
|
|
245
246
|
##### :gear: getMinterInfo
|
|
246
247
|
|
|
@@ -252,10 +253,26 @@ Returns internal minter parameters such as the minimal amount to retrieve BTC, m
|
|
|
252
253
|
|
|
253
254
|
Parameters:
|
|
254
255
|
|
|
255
|
-
- `params`: The parameters to get the
|
|
256
|
+
- `params`: The parameters to get the minter info.
|
|
256
257
|
- `params.certified`: query or update call
|
|
257
258
|
|
|
258
|
-
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#
|
|
259
|
+
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L253)
|
|
260
|
+
|
|
261
|
+
##### :gear: getKnownUtxos
|
|
262
|
+
|
|
263
|
+
Returns UTXOs of the given account known by the minter.
|
|
264
|
+
|
|
265
|
+
| Method | Type |
|
|
266
|
+
| --------------- | ----------------------------------------------------------------------------- |
|
|
267
|
+
| `getKnownUtxos` | `({ owner, subaccount, certified, }: GetKnownUtxosParams) => Promise<Utxo[]>` |
|
|
268
|
+
|
|
269
|
+
Parameters:
|
|
270
|
+
|
|
271
|
+
- `params`: The parameters for which the known utxos should be resolved.
|
|
272
|
+
- `params.owner`: The owner of the account. Note that if not provided, the `caller` would be used by the minter instead.
|
|
273
|
+
- `params.subaccount`: An optional subaccount.
|
|
274
|
+
|
|
275
|
+
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L266)
|
|
259
276
|
|
|
260
277
|
<!-- TSDOC_END -->
|
|
261
278
|
|
|
@@ -42,6 +42,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
42
42
|
const DefiniteCanisterSettings = IDL.Record({
|
|
43
43
|
'freezing_threshold' : IDL.Nat,
|
|
44
44
|
'controllers' : IDL.Vec(IDL.Principal),
|
|
45
|
+
'reserved_cycles_limit' : IDL.Nat,
|
|
45
46
|
'memory_allocation' : IDL.Nat,
|
|
46
47
|
'compute_allocation' : IDL.Nat,
|
|
47
48
|
});
|
|
@@ -59,6 +60,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
59
60
|
'query_stats' : QueryStats,
|
|
60
61
|
'idle_cycles_burned_per_day' : IDL.Nat,
|
|
61
62
|
'module_hash' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
63
|
+
'reserved_cycles' : IDL.Nat,
|
|
62
64
|
});
|
|
63
65
|
const Account = IDL.Record({
|
|
64
66
|
'owner' : IDL.Principal,
|
|
@@ -269,6 +271,16 @@ export const idlFactory = ({ IDL }) => {
|
|
|
269
271
|
[IDL.Vec(Event)],
|
|
270
272
|
[],
|
|
271
273
|
),
|
|
274
|
+
'get_known_utxos' : IDL.Func(
|
|
275
|
+
[
|
|
276
|
+
IDL.Record({
|
|
277
|
+
'owner' : IDL.Opt(IDL.Principal),
|
|
278
|
+
'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
279
|
+
}),
|
|
280
|
+
],
|
|
281
|
+
[IDL.Vec(Utxo)],
|
|
282
|
+
[],
|
|
283
|
+
),
|
|
272
284
|
'get_minter_info' : IDL.Func([], [MinterInfo], []),
|
|
273
285
|
'get_withdrawal_account' : IDL.Func([], [Account], []),
|
|
274
286
|
'retrieve_btc' : IDL.Func(
|
package/dist/candid/minter.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export interface CanisterStatusResponse {
|
|
|
23
23
|
query_stats: QueryStats;
|
|
24
24
|
idle_cycles_burned_per_day: bigint;
|
|
25
25
|
module_hash: [] | [Uint8Array | number[]];
|
|
26
|
+
reserved_cycles: bigint;
|
|
26
27
|
}
|
|
27
28
|
export type CanisterStatusType =
|
|
28
29
|
| { stopped: null }
|
|
@@ -31,6 +32,7 @@ export type CanisterStatusType =
|
|
|
31
32
|
export interface DefiniteCanisterSettings {
|
|
32
33
|
freezing_threshold: bigint;
|
|
33
34
|
controllers: Array<Principal>;
|
|
35
|
+
reserved_cycles_limit: bigint;
|
|
34
36
|
memory_allocation: bigint;
|
|
35
37
|
compute_allocation: bigint;
|
|
36
38
|
}
|
|
@@ -261,6 +263,15 @@ export interface _SERVICE {
|
|
|
261
263
|
get_canister_status: ActorMethod<[], CanisterStatusResponse>;
|
|
262
264
|
get_deposit_fee: ActorMethod<[], bigint>;
|
|
263
265
|
get_events: ActorMethod<[{ start: bigint; length: bigint }], Array<Event>>;
|
|
266
|
+
get_known_utxos: ActorMethod<
|
|
267
|
+
[
|
|
268
|
+
{
|
|
269
|
+
owner: [] | [Principal];
|
|
270
|
+
subaccount: [] | [Uint8Array | number[]];
|
|
271
|
+
},
|
|
272
|
+
],
|
|
273
|
+
Array<Utxo>
|
|
274
|
+
>;
|
|
264
275
|
get_minter_info: ActorMethod<[], MinterInfo>;
|
|
265
276
|
get_withdrawal_account: ActorMethod<[], Account>;
|
|
266
277
|
retrieve_btc: ActorMethod<
|
package/dist/candid/minter.did
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated from IC repo commit
|
|
1
|
+
// Generated from IC repo commit 8001dd214 (2024-02-26) 'rs/bitcoin/ckbtc/minter/ckbtc_minter.did' by import-candid
|
|
2
2
|
// Represents an account on the ckBTC ledger.
|
|
3
3
|
type Account = record { owner : principal; subaccount : opt blob };
|
|
4
4
|
|
|
@@ -10,6 +10,7 @@ type CanisterStatusResponse = record {
|
|
|
10
10
|
idle_cycles_burned_per_day : nat;
|
|
11
11
|
module_hash : opt vec nat8;
|
|
12
12
|
query_stats : QueryStats;
|
|
13
|
+
reserved_cycles : nat;
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
type QueryStats = record {
|
|
@@ -26,6 +27,7 @@ type DefiniteCanisterSettings = record {
|
|
|
26
27
|
controllers : vec principal;
|
|
27
28
|
memory_allocation : nat;
|
|
28
29
|
compute_allocation : nat;
|
|
30
|
+
reserved_cycles_limit : nat;
|
|
29
31
|
};
|
|
30
32
|
|
|
31
33
|
type RetrieveBtcArgs = record {
|
|
@@ -384,6 +386,12 @@ service : (minter_arg : MinterArg) -> {
|
|
|
384
386
|
// If the owner is not set, it defaults to the caller's principal.
|
|
385
387
|
get_btc_address : (record { owner: opt principal; subaccount : opt blob }) -> (text);
|
|
386
388
|
|
|
389
|
+
// Returns UTXOs of the given account known by the minter (with no
|
|
390
|
+
// guarantee in the ordering of the returned values).
|
|
391
|
+
//
|
|
392
|
+
// If the owner is not set, it defaults to the caller's principal.
|
|
393
|
+
get_known_utxos: (record { owner: opt principal; subaccount : opt blob }) -> (vec Utxo) query;
|
|
394
|
+
|
|
387
395
|
// Mints ckBTC for newly deposited UTXOs.
|
|
388
396
|
//
|
|
389
397
|
// If the owner is not set, it defaults to the caller's principal.
|
|
@@ -42,6 +42,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
42
42
|
const DefiniteCanisterSettings = IDL.Record({
|
|
43
43
|
'freezing_threshold' : IDL.Nat,
|
|
44
44
|
'controllers' : IDL.Vec(IDL.Principal),
|
|
45
|
+
'reserved_cycles_limit' : IDL.Nat,
|
|
45
46
|
'memory_allocation' : IDL.Nat,
|
|
46
47
|
'compute_allocation' : IDL.Nat,
|
|
47
48
|
});
|
|
@@ -59,6 +60,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
59
60
|
'query_stats' : QueryStats,
|
|
60
61
|
'idle_cycles_burned_per_day' : IDL.Nat,
|
|
61
62
|
'module_hash' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
63
|
+
'reserved_cycles' : IDL.Nat,
|
|
62
64
|
});
|
|
63
65
|
const Account = IDL.Record({
|
|
64
66
|
'owner' : IDL.Principal,
|
|
@@ -269,6 +271,16 @@ export const idlFactory = ({ IDL }) => {
|
|
|
269
271
|
[IDL.Vec(Event)],
|
|
270
272
|
['query'],
|
|
271
273
|
),
|
|
274
|
+
'get_known_utxos' : IDL.Func(
|
|
275
|
+
[
|
|
276
|
+
IDL.Record({
|
|
277
|
+
'owner' : IDL.Opt(IDL.Principal),
|
|
278
|
+
'subaccount' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
279
|
+
}),
|
|
280
|
+
],
|
|
281
|
+
[IDL.Vec(Utxo)],
|
|
282
|
+
['query'],
|
|
283
|
+
),
|
|
272
284
|
'get_minter_info' : IDL.Func([], [MinterInfo], ['query']),
|
|
273
285
|
'get_withdrawal_account' : IDL.Func([], [Account], []),
|
|
274
286
|
'retrieve_btc' : IDL.Func(
|
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var jt=Object.create;var G=Object.defineProperty;var zt=Object.getOwnPropertyDescriptor;var Xt=Object.getOwnPropertyNames;var Qt=Object.getPrototypeOf,Jt=Object.prototype.hasOwnProperty;var A=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Kt=(t,e)=>{for(var r in e)G(t,r,{get:e[r],enumerable:!0})},wt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Xt(e))!Jt.call(t,o)&&o!==r&&G(t,o,{get:()=>e[o],enumerable:!(n=zt(e,o))||n.enumerable});return t};var Rt=(t,e,r)=>(r=t!=null?jt(Qt(t)):{},wt(e||!t||!t.__esModule?G(r,"default",{value:t,enumerable:!0}):r,t)),Yt=t=>wt(G({},"__esModule",{value:!0}),t);var D=A((je,Ot)=>{"use strict";var ie="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";Ot.exports=ie});var Pt=A((ze,Bt)=>{"use strict";var ce=D(),ae=t=>{if(!t||typeof t!="string")throw new Error(`Expected base58 string but got \u201C${t}\u201D`);if(t.match(/[IOl0]/gmu))throw new Error(`Invalid base58 character \u201C${t.match(/[IOl0]/gmu)}\u201D`);let e=t.match(/^1+/gmu),r=e?e[0].length:0,n=(t.length-r)*(Math.log(58)/Math.log(256))+1>>>0;return new Uint8Array([...new Uint8Array(r),...t.match(/.{1}/gmu).map(o=>ce.indexOf(o)).reduce((o,c)=>(o=o.map(i=>{let s=i*58+c;return c=s>>8,s}),o),new Uint8Array(n)).reverse().filter((o=>c=>o=o||c)(!1))])};Bt.exports=ae});var Et=A((Xe,Ut)=>{"use strict";var Tt=D(),se=()=>{let t=Array(256).fill(-1);for(let e=0;e<Tt.length;++e)t[Tt.charCodeAt(e)]=e;return t};Ut.exports=se});var St=A((Qe,Ft)=>{"use strict";var Ct=D(),ue=Et(),de=ue(),le=t=>{let e=[];for(let r of t){let n=r;for(let o=0;o<e.length;++o){let c=(de[e[o]]<<8)+n;e[o]=Ct.charCodeAt(c%58),n=c/58|0}for(;n;)e.push(Ct.charCodeAt(n%58)),n=n/58|0}for(let r of t){if(r)break;e.push(49)}return e.reverse(),String.fromCharCode(...e)};Ft.exports=le});var qt=A(bt=>{"use strict";bt.base58_to_binary=Pt();bt.binary_to_base58=St()});var $t=A(T=>{"use strict";Object.defineProperty(T,"__esModule",{value:!0});T.bech32m=T.bech32=void 0;var tt="qpzry9x8gf2tvdw0s3jn54khce6mua7l",Wt={};for(let t=0;t<tt.length;t++){let e=tt.charAt(t);Wt[e]=t}function P(t){let e=t>>25;return(t&33554431)<<5^-(e>>0&1)&996825010^-(e>>1&1)&642813549^-(e>>2&1)&513874426^-(e>>3&1)&1027748829^-(e>>4&1)&705979059}function Mt(t){let e=1;for(let r=0;r<t.length;++r){let n=t.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+t+")";e=P(e)^n>>5}e=P(e);for(let r=0;r<t.length;++r){let n=t.charCodeAt(r);e=P(e)^n&31}return e}function gt(t,e,r,n){let o=0,c=0,i=(1<<r)-1,s=[];for(let d=0;d<t.length;++d)for(o=o<<e|t[d],c+=e;c>=r;)c-=r,s.push(o>>c&i);if(n)c>0&&s.push(o<<r-c&i);else{if(c>=e)return"Excess padding";if(o<<r-c&i)return"Non-zero padding"}return s}function pe(t){return gt(t,8,5,!0)}function fe(t){let e=gt(t,5,8,!1);if(Array.isArray(e))return e}function _e(t){let e=gt(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function Gt(t){let e;t==="bech32"?e=1:e=734539939;function r(i,s,d){if(d=d||90,i.length+7+s.length>d)throw new TypeError("Exceeds length limit");i=i.toLowerCase();let l=Mt(i);if(typeof l=="string")throw new Error(l);let u=i+"1";for(let a=0;a<s.length;++a){let p=s[a];if(p>>5)throw new Error("Non 5-bit word");l=P(l)^p,u+=tt.charAt(p)}for(let a=0;a<6;++a)l=P(l);l^=e;for(let a=0;a<6;++a){let p=l>>(5-a)*5&31;u+=tt.charAt(p)}return u}function n(i,s){if(s=s||90,i.length<8)return i+" too short";if(i.length>s)return"Exceeds length limit";let d=i.toLowerCase(),l=i.toUpperCase();if(i!==d&&i!==l)return"Mixed-case string "+i;i=d;let u=i.lastIndexOf("1");if(u===-1)return"No separator character for "+i;if(u===0)return"Missing prefix for "+i;let a=i.slice(0,u),p=i.slice(u+1);if(p.length<6)return"Data too short";let f=Mt(a);if(typeof f=="string")return f;let x=[];for(let m=0;m<p.length;++m){let g=p.charAt(m),h=Wt[g];if(h===void 0)return"Unknown character "+g;f=P(f)^h,!(m+6>=p.length)&&x.push(h)}return f!==e?"Invalid checksum for "+i:{prefix:a,words:x}}function o(i,s){let d=n(i,s);if(typeof d=="object")return d}function c(i,s){let d=n(i,s);if(typeof d=="object")return d;throw new Error(d)}return{decodeUnsafe:o,decode:c,encode:r,toWords:pe,fromWordsUnsafe:fe,fromWords:_e}}T.bech32=Gt("bech32");T.bech32m=Gt("bech32m")});var Re={};Kt(Re,{BtcAddressType:()=>lt,BtcNetwork:()=>dt,CkBTCMinterCanister:()=>Y,MinterAlreadyProcessingError:()=>H,MinterAmountTooLowError:()=>X,MinterGenericError:()=>y,MinterInsufficientAllowanceError:()=>J,MinterInsufficientFundsError:()=>Q,MinterMalformedAddressError:()=>z,MinterNoNewUtxosError:()=>j,MinterRetrieveBtcError:()=>w,MinterTemporaryUnavailableError:()=>$,MinterUpdateBalanceError:()=>M,ParseBtcAddressBadWitnessLengthError:()=>C,ParseBtcAddressError:()=>N,ParseBtcAddressInvalidError:()=>V,ParseBtcAddressMalformedAddressError:()=>k,ParseBtcAddressNoDataError:()=>E,ParseBtcAddressUnexpectedHumanReadablePartError:()=>S,ParseBtcAddressUnsupportedAddressTypeError:()=>O,ParseBtcAddressUnsupportedWitnessVersionError:()=>F,ParseBtcAddressWrongNetworkError:()=>q,createRetrieveBtcError:()=>K,createRetrieveBtcWithApprovalError:()=>_t,createUpdateBalanceError:()=>ft,parseBtcAddress:()=>we});module.exports=Yt(Re);var dt=(n=>(n[n.Mainnet=0]="Mainnet",n[n.Regtest=1]="Regtest",n[n.Testnet=2]="Testnet",n))(dt||{}),lt=(c=>(c[c.P2wpkhV0=0]="P2wpkhV0",c[c.P2pkh=1]="P2pkh",c[c.P2sh=2]="P2sh",c[c.P2wsh=3]="P2wsh",c[c.P2tr=4]="P2tr",c))(lt||{});var N=class extends Error{},V=class extends N{},E=class extends N{},O=class extends N{},C=class extends N{},F=class extends N{},S=class extends N{},k=class extends N{},q=class extends N{};var B=require("@dfinity/utils"),y=class extends Error{},$=class extends y{},H=class extends y{},M=class extends y{},j=class extends M{constructor({pending_utxos:e,required_confirmations:r}){super(),this.pendingUtxos=(0,B.fromNullable)(e)||[],this.requiredConfirmations=r}},w=class extends y{},z=class extends w{},X=class extends w{},Q=class extends w{},J=class extends w{},pt=t=>{if("GenericError"in t){let{GenericError:{error_message:e,error_code:r}}=t;return new y(`${e} (${r})`)}if("TemporarilyUnavailable"in t)return new $(t.TemporarilyUnavailable);if("AlreadyProcessing"in t)return new H},ft=t=>{let e=pt(t);return(0,B.nonNullish)(e)?e:"NoNewUtxos"in t?new j(t.NoNewUtxos):new M(`Unsupported response type in minter.updateBalance ${JSON.stringify(t)}`)},K=t=>{let e=pt(t);return(0,B.nonNullish)(e)?e:"MalformedAddress"in t?new z(t.MalformedAddress):"AmountTooLow"in t?new X(`${t.AmountTooLow}`):"InsufficientFunds"in t?new Q(`${t.InsufficientFunds.balance}`):new w(`Unsupported response type in minter.retrieveBtc ${JSON.stringify(t)}`)},_t=t=>{let e=pt(t);return(0,B.nonNullish)(e)?e:"InsufficientAllowance"in t?new J(`${t.InsufficientAllowance.allowance}`):K(t)};var _=require("@dfinity/utils");var vt=({IDL:t})=>{let e=t.Variant({RestrictedTo:t.Vec(t.Principal),DepositsRestrictedTo:t.Vec(t.Principal),ReadOnly:t.Null,GeneralAvailability:t.Null}),r=t.Record({kyt_principal:t.Opt(t.Principal),mode:t.Opt(e),retrieve_btc_min_amount:t.Opt(t.Nat64),max_time_in_queue_nanos:t.Opt(t.Nat64),min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),n=t.Variant({Mainnet:t.Null,Regtest:t.Null,Testnet:t.Null}),o=t.Record({kyt_principal:t.Opt(t.Principal),ecdsa_key_name:t.Text,mode:e,retrieve_btc_min_amount:t.Nat64,ledger_id:t.Principal,max_time_in_queue_nanos:t.Nat64,btc_network:n,min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),c=t.Variant({Upgrade:t.Opt(r),Init:o}),i=t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),s=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),memory_allocation:t.Nat,compute_allocation:t.Nat}),d=t.Record({response_payload_bytes_total:t.Nat,num_instructions_total:t.Nat,num_calls_total:t.Nat,request_payload_bytes_total:t.Nat}),l=t.Record({status:i,memory_size:t.Nat,cycles:t.Nat,settings:s,query_stats:d,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8))}),u=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),a=t.Record({height:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),p=t.Variant({CallFailed:t.Null,TaintedDestination:t.Record({kyt_fee:t.Nat64,kyt_provider:t.Principal})}),f=t.Variant({p2wsh_v0:t.Vec(t.Nat8),p2tr_v1:t.Vec(t.Nat8),p2sh:t.Vec(t.Nat8),p2wpkh_v0:t.Vec(t.Nat8),p2pkh:t.Vec(t.Nat8)}),x=t.Variant({received_utxos:t.Record({to_account:u,mint_txid:t.Opt(t.Nat64),utxos:t.Vec(a)}),schedule_deposit_reimbursement:t.Record({burn_block_index:t.Nat64,account:u,amount:t.Nat64,reason:p}),sent_transaction:t.Record({fee:t.Opt(t.Nat64),change_output:t.Opt(t.Record({value:t.Nat64,vout:t.Nat32})),txid:t.Vec(t.Nat8),utxos:t.Vec(a),requests:t.Vec(t.Nat64),submitted_at:t.Nat64}),distributed_kyt_fee:t.Record({block_index:t.Nat64,amount:t.Nat64,kyt_provider:t.Principal}),init:o,upgrade:r,retrieve_btc_kyt_failed:t.Record({block_index:t.Nat64,owner:t.Principal,uuid:t.Text,address:t.Text,amount:t.Nat64,kyt_provider:t.Principal}),accepted_retrieve_btc_request:t.Record({received_at:t.Nat64,block_index:t.Nat64,address:f,reimbursement_account:t.Opt(u),amount:t.Nat64,kyt_provider:t.Opt(t.Principal)}),checked_utxo:t.Record({clean:t.Bool,utxo:a,uuid:t.Text,kyt_provider:t.Opt(t.Principal)}),removed_retrieve_btc_request:t.Record({block_index:t.Nat64}),confirmed_transaction:t.Record({txid:t.Vec(t.Nat8)}),replaced_transaction:t.Record({fee:t.Nat64,change_output:t.Record({value:t.Nat64,vout:t.Nat32}),old_txid:t.Vec(t.Nat8),new_txid:t.Vec(t.Nat8),submitted_at:t.Nat64}),ignored_utxo:t.Record({utxo:a}),reimbursed_failed_deposit:t.Record({burn_block_index:t.Nat64,mint_block_index:t.Nat64})}),m=t.Record({retrieve_btc_min_amount:t.Nat64,min_confirmations:t.Nat32,kyt_fee:t.Nat64}),g=t.Record({address:t.Text,amount:t.Nat64}),h=t.Record({block_index:t.Nat64}),et=t.Variant({MalformedAddress:t.Text,GenericError:t.Record({error_message:t.Text,error_code:t.Nat64}),TemporarilyUnavailable:t.Text,AlreadyProcessing:t.Null,AmountTooLow:t.Nat64,InsufficientFunds:t.Record({balance:t.Nat64})}),rt=t.Variant({Signing:t.Null,Confirmed:t.Record({txid:t.Vec(t.Nat8)}),Sending:t.Record({txid:t.Vec(t.Nat8)}),AmountTooLow:t.Null,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Pending:t.Null}),nt=t.Record({account:u,amount:t.Nat64,reason:p}),ot=t.Record({account:u,mint_block_index:t.Nat64,amount:t.Nat64,reason:p}),U=t.Variant({Signing:t.Null,Confirmed:t.Record({txid:t.Vec(t.Nat8)}),Sending:t.Record({txid:t.Vec(t.Nat8)}),AmountTooLow:t.Null,WillReimburse:nt,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Reimbursed:ot,Pending:t.Null}),it=t.Record({from_subaccount:t.Opt(t.Vec(t.Nat8)),address:t.Text,amount:t.Nat64}),ct=t.Variant({MalformedAddress:t.Text,GenericError:t.Record({error_message:t.Text,error_code:t.Nat64}),TemporarilyUnavailable:t.Text,InsufficientAllowance:t.Record({allowance:t.Nat64}),AlreadyProcessing:t.Null,AmountTooLow:t.Nat64,InsufficientFunds:t.Record({balance:t.Nat64})}),at=t.Variant({ValueTooSmall:a,Tainted:a,Minted:t.Record({minted_amount:t.Nat64,block_index:t.Nat64,utxo:a}),Checked:a}),st=t.Record({confirmations:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),ut=t.Variant({GenericError:t.Record({error_message:t.Text,error_code:t.Nat64}),TemporarilyUnavailable:t.Text,AlreadyProcessing:t.Null,NoNewUtxos:t.Record({required_confirmations:t.Nat32,pending_utxos:t.Opt(t.Vec(st)),current_confirmations:t.Opt(t.Nat32)})});return t.Service({estimate_withdrawal_fee:t.Func([t.Record({amount:t.Opt(t.Nat64)})],[t.Record({minter_fee:t.Nat64,bitcoin_fee:t.Nat64})],[]),get_btc_address:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Text],[]),get_canister_status:t.Func([],[l],[]),get_deposit_fee:t.Func([],[t.Nat64],[]),get_events:t.Func([t.Record({start:t.Nat64,length:t.Nat64})],[t.Vec(x)],[]),get_minter_info:t.Func([],[m],[]),get_withdrawal_account:t.Func([],[u],[]),retrieve_btc:t.Func([g],[t.Variant({Ok:h,Err:et})],[]),retrieve_btc_status:t.Func([t.Record({block_index:t.Nat64})],[rt],[]),retrieve_btc_status_v2:t.Func([t.Record({block_index:t.Nat64})],[U],[]),retrieve_btc_status_v2_by_account:t.Func([t.Opt(u)],[t.Vec(t.Record({block_index:t.Nat64,status_v2:t.Opt(U)}))],[]),retrieve_btc_with_approval:t.Func([it],[t.Variant({Ok:h,Err:ct})],[]),update_balance:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Variant({Ok:t.Vec(at),Err:ut})],[])})};var kt=({IDL:t})=>{let e=t.Variant({RestrictedTo:t.Vec(t.Principal),DepositsRestrictedTo:t.Vec(t.Principal),ReadOnly:t.Null,GeneralAvailability:t.Null}),r=t.Record({kyt_principal:t.Opt(t.Principal),mode:t.Opt(e),retrieve_btc_min_amount:t.Opt(t.Nat64),max_time_in_queue_nanos:t.Opt(t.Nat64),min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),n=t.Variant({Mainnet:t.Null,Regtest:t.Null,Testnet:t.Null}),o=t.Record({kyt_principal:t.Opt(t.Principal),ecdsa_key_name:t.Text,mode:e,retrieve_btc_min_amount:t.Nat64,ledger_id:t.Principal,max_time_in_queue_nanos:t.Nat64,btc_network:n,min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),c=t.Variant({Upgrade:t.Opt(r),Init:o}),i=t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),s=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),memory_allocation:t.Nat,compute_allocation:t.Nat}),d=t.Record({response_payload_bytes_total:t.Nat,num_instructions_total:t.Nat,num_calls_total:t.Nat,request_payload_bytes_total:t.Nat}),l=t.Record({status:i,memory_size:t.Nat,cycles:t.Nat,settings:s,query_stats:d,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8))}),u=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),a=t.Record({height:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),p=t.Variant({CallFailed:t.Null,TaintedDestination:t.Record({kyt_fee:t.Nat64,kyt_provider:t.Principal})}),f=t.Variant({p2wsh_v0:t.Vec(t.Nat8),p2tr_v1:t.Vec(t.Nat8),p2sh:t.Vec(t.Nat8),p2wpkh_v0:t.Vec(t.Nat8),p2pkh:t.Vec(t.Nat8)}),x=t.Variant({received_utxos:t.Record({to_account:u,mint_txid:t.Opt(t.Nat64),utxos:t.Vec(a)}),schedule_deposit_reimbursement:t.Record({burn_block_index:t.Nat64,account:u,amount:t.Nat64,reason:p}),sent_transaction:t.Record({fee:t.Opt(t.Nat64),change_output:t.Opt(t.Record({value:t.Nat64,vout:t.Nat32})),txid:t.Vec(t.Nat8),utxos:t.Vec(a),requests:t.Vec(t.Nat64),submitted_at:t.Nat64}),distributed_kyt_fee:t.Record({block_index:t.Nat64,amount:t.Nat64,kyt_provider:t.Principal}),init:o,upgrade:r,retrieve_btc_kyt_failed:t.Record({block_index:t.Nat64,owner:t.Principal,uuid:t.Text,address:t.Text,amount:t.Nat64,kyt_provider:t.Principal}),accepted_retrieve_btc_request:t.Record({received_at:t.Nat64,block_index:t.Nat64,address:f,reimbursement_account:t.Opt(u),amount:t.Nat64,kyt_provider:t.Opt(t.Principal)}),checked_utxo:t.Record({clean:t.Bool,utxo:a,uuid:t.Text,kyt_provider:t.Opt(t.Principal)}),removed_retrieve_btc_request:t.Record({block_index:t.Nat64}),confirmed_transaction:t.Record({txid:t.Vec(t.Nat8)}),replaced_transaction:t.Record({fee:t.Nat64,change_output:t.Record({value:t.Nat64,vout:t.Nat32}),old_txid:t.Vec(t.Nat8),new_txid:t.Vec(t.Nat8),submitted_at:t.Nat64}),ignored_utxo:t.Record({utxo:a}),reimbursed_failed_deposit:t.Record({burn_block_index:t.Nat64,mint_block_index:t.Nat64})}),m=t.Record({retrieve_btc_min_amount:t.Nat64,min_confirmations:t.Nat32,kyt_fee:t.Nat64}),g=t.Record({address:t.Text,amount:t.Nat64}),h=t.Record({block_index:t.Nat64}),et=t.Variant({MalformedAddress:t.Text,GenericError:t.Record({error_message:t.Text,error_code:t.Nat64}),TemporarilyUnavailable:t.Text,AlreadyProcessing:t.Null,AmountTooLow:t.Nat64,InsufficientFunds:t.Record({balance:t.Nat64})}),rt=t.Variant({Signing:t.Null,Confirmed:t.Record({txid:t.Vec(t.Nat8)}),Sending:t.Record({txid:t.Vec(t.Nat8)}),AmountTooLow:t.Null,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Pending:t.Null}),nt=t.Record({account:u,amount:t.Nat64,reason:p}),ot=t.Record({account:u,mint_block_index:t.Nat64,amount:t.Nat64,reason:p}),U=t.Variant({Signing:t.Null,Confirmed:t.Record({txid:t.Vec(t.Nat8)}),Sending:t.Record({txid:t.Vec(t.Nat8)}),AmountTooLow:t.Null,WillReimburse:nt,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Reimbursed:ot,Pending:t.Null}),it=t.Record({from_subaccount:t.Opt(t.Vec(t.Nat8)),address:t.Text,amount:t.Nat64}),ct=t.Variant({MalformedAddress:t.Text,GenericError:t.Record({error_message:t.Text,error_code:t.Nat64}),TemporarilyUnavailable:t.Text,InsufficientAllowance:t.Record({allowance:t.Nat64}),AlreadyProcessing:t.Null,AmountTooLow:t.Nat64,InsufficientFunds:t.Record({balance:t.Nat64})}),at=t.Variant({ValueTooSmall:a,Tainted:a,Minted:t.Record({minted_amount:t.Nat64,block_index:t.Nat64,utxo:a}),Checked:a}),st=t.Record({confirmations:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),ut=t.Variant({GenericError:t.Record({error_message:t.Text,error_code:t.Nat64}),TemporarilyUnavailable:t.Text,AlreadyProcessing:t.Null,NoNewUtxos:t.Record({required_confirmations:t.Nat32,pending_utxos:t.Opt(t.Vec(st)),current_confirmations:t.Opt(t.Nat32)})});return t.Service({estimate_withdrawal_fee:t.Func([t.Record({amount:t.Opt(t.Nat64)})],[t.Record({minter_fee:t.Nat64,bitcoin_fee:t.Nat64})],["query"]),get_btc_address:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Text],[]),get_canister_status:t.Func([],[l],[]),get_deposit_fee:t.Func([],[t.Nat64],["query"]),get_events:t.Func([t.Record({start:t.Nat64,length:t.Nat64})],[t.Vec(x)],["query"]),get_minter_info:t.Func([],[m],["query"]),get_withdrawal_account:t.Func([],[u],[]),retrieve_btc:t.Func([g],[t.Variant({Ok:h,Err:et})],[]),retrieve_btc_status:t.Func([t.Record({block_index:t.Nat64})],[rt],["query"]),retrieve_btc_status_v2:t.Func([t.Record({block_index:t.Nat64})],[U],["query"]),retrieve_btc_status_v2_by_account:t.Func([t.Opt(u)],[t.Vec(t.Record({block_index:t.Nat64,status_v2:t.Opt(U)}))],["query"]),retrieve_btc_with_approval:t.Func([it],[t.Variant({Ok:h,Err:ct})],[]),update_balance:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Variant({Ok:t.Vec(at),Err:ut})],[])})};var Y=class t extends _.Canister{constructor(){super(...arguments);this.getBtcAddress=({owner:r,subaccount:n})=>this.caller({certified:!0}).get_btc_address({owner:(0,_.toNullable)(r),subaccount:(0,_.toNullable)(n)});this.updateBalance=async({owner:r,subaccount:n})=>{let o=await this.caller({certified:!0}).update_balance({owner:(0,_.toNullable)(r),subaccount:(0,_.toNullable)(n)});if("Err"in o)throw ft(o.Err);return o.Ok};this.getWithdrawalAccount=()=>this.caller({certified:!0}).get_withdrawal_account();this.retrieveBtc=async r=>{let n=await this.caller({certified:!0}).retrieve_btc(r);if("Err"in n)throw K(n.Err);return n.Ok};this.retrieveBtcWithApproval=async({address:r,amount:n,fromSubaccount:o})=>{let c=await this.caller({certified:!0}).retrieve_btc_with_approval({address:r,amount:n,from_subaccount:(0,_.toNullable)(o)});if("Err"in c)throw _t(c.Err);return c.Ok};this.retrieveBtcStatus=async({transactionId:r,certified:n})=>this.caller({certified:n}).retrieve_btc_status({block_index:r});this.retrieveBtcStatusV2ByAccount=async({account:r,certified:n})=>{let{retrieve_btc_status_v2_by_account:o}=this.caller({certified:n});return(await o((0,_.isNullish)(r)?[]:[{owner:r.owner,subaccount:(0,_.toNullable)(r.subaccount)}])).map(({block_index:i,status_v2:s})=>({id:i,status:(0,_.fromNullable)(s)}))};this.estimateWithdrawalFee=async({certified:r,amount:n})=>this.caller({certified:r}).estimate_withdrawal_fee({amount:(0,_.toNullable)(n)});this.getMinterInfo=async({certified:r})=>this.caller({certified:r}).get_minter_info()}static create(r){let{service:n,certifiedService:o,canisterId:c}=(0,_.createServices)({options:r,idlFactory:kt,certifiedIdlFactory:vt});return new t(c,n,o)}};var yt=require("@dfinity/utils");function Zt(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function It(t,...e){if(!Zt(t))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function mt(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function At(t,e){It(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}function Lt(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var I=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),b=(t,e)=>t<<32-e|t>>>e,Dt=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Dt)throw new Error("Non little-endian hardware is not supported");function te(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function xt(t){if(typeof t=="string"&&(t=te(t)),!Lt(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}var Z=class{clone(){return this._cloneInto()}},Fe={}.toString;function Vt(t){let e=n=>t().update(xt(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function ee(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let o=BigInt(32),c=BigInt(4294967295),i=Number(r>>o&c),s=Number(r&c),d=n?4:0,l=n?0:4;t.setUint32(e+d,i,n),t.setUint32(e+l,s,n)}var L=class extends Z{constructor(e,r,n,o){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=I(this.buffer)}update(e){mt(this);let{view:r,buffer:n,blockLen:o}=this;e=xt(e);let c=e.length;for(let i=0;i<c;){let s=Math.min(o-this.pos,c-i);if(s===o){let d=I(e);for(;o<=c-i;i+=o)this.process(d,i);continue}n.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){mt(this),At(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:c}=this,{pos:i}=this;r[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let a=i;a<o;a++)r[a]=0;ee(n,o-8,BigInt(this.length*8),c),this.process(n,0);let s=I(e),d=this.outputLen;if(d%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=d/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let a=0;a<l;a++)s.setUint32(4*a,u[a],c)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:c,destroyed:i,pos:s}=this;return e.length=o,e.pos=s,e.finished=c,e.destroyed=i,o%r&&e.buffer.set(n),e}};var re=(t,e,r)=>t&e^~t&r,ne=(t,e,r)=>t&e^t&r^e&r,oe=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),R=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),v=new Uint32Array(64),ht=class extends L{constructor(){super(64,32,8,!1),this.A=R[0]|0,this.B=R[1]|0,this.C=R[2]|0,this.D=R[3]|0,this.E=R[4]|0,this.F=R[5]|0,this.G=R[6]|0,this.H=R[7]|0}get(){let{A:e,B:r,C:n,D:o,E:c,F:i,G:s,H:d}=this;return[e,r,n,o,c,i,s,d]}set(e,r,n,o,c,i,s,d){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=c|0,this.F=i|0,this.G=s|0,this.H=d|0}process(e,r){for(let a=0;a<16;a++,r+=4)v[a]=e.getUint32(r,!1);for(let a=16;a<64;a++){let p=v[a-15],f=v[a-2],x=b(p,7)^b(p,18)^p>>>3,m=b(f,17)^b(f,19)^f>>>10;v[a]=m+v[a-7]+x+v[a-16]|0}let{A:n,B:o,C:c,D:i,E:s,F:d,G:l,H:u}=this;for(let a=0;a<64;a++){let p=b(s,6)^b(s,11)^b(s,25),f=u+p+re(s,d,l)+oe[a]+v[a]|0,m=(b(n,2)^b(n,13)^b(n,22))+ne(n,o,c)|0;u=l,l=d,d=s,s=i+f|0,i=c,c=o,o=n,n=f+m|0}n=n+this.A|0,o=o+this.B|0,c=c+this.C|0,i=i+this.D|0,s=s+this.E|0,d=d+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(n,o,c,i,s,d,l,u)}roundClean(){v.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Nt=Vt(()=>new ht);var Ht=Rt(qt()),W=Rt($t());var me=0,xe=5,he=111,Ne=196,be={[me]:{type:1,networks:[0]},[he]:{type:1,networks:[2,1]},[xe]:{type:2,networks:[0]},[Ne]:{type:2,networks:[2,1]}},ge=({address:t,network:e})=>{let n=(u=>{try{return(0,Ht.base58_to_binary)(u)}catch{throw new V}})(t),{length:o}=n;if(o!==25)throw new k(`Expected the address to be 25 bytes, got ${o}.`);(u=>{let a=u.slice(o-4,o),p=u.slice(0,o-4),f=Nt.create();f.update(p);let x=Nt.create();x.update(f.digest());let m=x.digest().slice(0,4);if(a.some((g,h)=>g!==m[h]))throw new k(`Checksum mismatch expected ${a}, got ${m}.`)})(n);let i=n[0],s=be[i];if((0,yt.isNullish)(s))throw new O;let{type:d,networks:l}=s;if(!l.includes(e))throw new q;return{address:t,network:e,type:d,parser:"base58"}},ye=({address:t,network:e})=>{let r=u=>{try{return u.startsWith("bc1p")||u.startsWith("tb1p")||u.startsWith("bcrt1p")?W.bech32m.decode(u):W.bech32.decode(u)}catch{throw new k}},{prefix:n,words:o}=r(t),i={bc:0,tb:2,bcrt:1}[n];if((0,yt.isNullish)(i))throw new V;if(i!==e)throw new S;let[s,...d]=o;if(s>1)throw new F;switch(W.bech32.fromWords(d).length){case 20:return{address:t,network:e,type:0,parser:"bip-173"};case 32:return{address:t,network:e,type:s===0?3:4,parser:"bip-173"};default:throw new C}},we=({address:t,network:e=0})=>{switch(t.charAt(0)){case"1":case"2":case"3":case"m":case"n":return ge({address:t,network:e});case"b":case"B":case"t":case"T":return ye({address:t,network:e});case"":throw new E;default:throw new O}};0&&(module.exports={BtcAddressType,BtcNetwork,CkBTCMinterCanister,MinterAlreadyProcessingError,MinterAmountTooLowError,MinterGenericError,MinterInsufficientAllowanceError,MinterInsufficientFundsError,MinterMalformedAddressError,MinterNoNewUtxosError,MinterRetrieveBtcError,MinterTemporaryUnavailableError,MinterUpdateBalanceError,ParseBtcAddressBadWitnessLengthError,ParseBtcAddressError,ParseBtcAddressInvalidError,ParseBtcAddressMalformedAddressError,ParseBtcAddressNoDataError,ParseBtcAddressUnexpectedHumanReadablePartError,ParseBtcAddressUnsupportedAddressTypeError,ParseBtcAddressUnsupportedWitnessVersionError,ParseBtcAddressWrongNetworkError,createRetrieveBtcError,createRetrieveBtcWithApprovalError,createUpdateBalanceError,parseBtcAddress});
|
|
1
|
+
"use strict";var jt=Object.create;var G=Object.defineProperty;var zt=Object.getOwnPropertyDescriptor;var Xt=Object.getOwnPropertyNames;var Kt=Object.getPrototypeOf,Qt=Object.prototype.hasOwnProperty;var A=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Jt=(t,e)=>{for(var r in e)G(t,r,{get:e[r],enumerable:!0})},wt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Xt(e))!Qt.call(t,o)&&o!==r&&G(t,o,{get:()=>e[o],enumerable:!(n=zt(e,o))||n.enumerable});return t};var Rt=(t,e,r)=>(r=t!=null?jt(Kt(t)):{},wt(e||!t||!t.__esModule?G(r,"default",{value:t,enumerable:!0}):r,t)),Yt=t=>wt(G({},"__esModule",{value:!0}),t);var D=A((je,Ot)=>{"use strict";var ie="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";Ot.exports=ie});var Pt=A((ze,Bt)=>{"use strict";var ce=D(),ae=t=>{if(!t||typeof t!="string")throw new Error(`Expected base58 string but got \u201C${t}\u201D`);if(t.match(/[IOl0]/gmu))throw new Error(`Invalid base58 character \u201C${t.match(/[IOl0]/gmu)}\u201D`);let e=t.match(/^1+/gmu),r=e?e[0].length:0,n=(t.length-r)*(Math.log(58)/Math.log(256))+1>>>0;return new Uint8Array([...new Uint8Array(r),...t.match(/.{1}/gmu).map(o=>ce.indexOf(o)).reduce((o,c)=>(o=o.map(i=>{let s=i*58+c;return c=s>>8,s}),o),new Uint8Array(n)).reverse().filter((o=>c=>o=o||c)(!1))])};Bt.exports=ae});var Et=A((Xe,Ut)=>{"use strict";var Tt=D(),se=()=>{let t=Array(256).fill(-1);for(let e=0;e<Tt.length;++e)t[Tt.charCodeAt(e)]=e;return t};Ut.exports=se});var St=A((Ke,Ft)=>{"use strict";var Ct=D(),ue=Et(),de=ue(),le=t=>{let e=[];for(let r of t){let n=r;for(let o=0;o<e.length;++o){let c=(de[e[o]]<<8)+n;e[o]=Ct.charCodeAt(c%58),n=c/58|0}for(;n;)e.push(Ct.charCodeAt(n%58)),n=n/58|0}for(let r of t){if(r)break;e.push(49)}return e.reverse(),String.fromCharCode(...e)};Ft.exports=le});var qt=A(bt=>{"use strict";bt.base58_to_binary=Pt();bt.binary_to_base58=St()});var $t=A(T=>{"use strict";Object.defineProperty(T,"__esModule",{value:!0});T.bech32m=T.bech32=void 0;var tt="qpzry9x8gf2tvdw0s3jn54khce6mua7l",Wt={};for(let t=0;t<tt.length;t++){let e=tt.charAt(t);Wt[e]=t}function P(t){let e=t>>25;return(t&33554431)<<5^-(e>>0&1)&996825010^-(e>>1&1)&642813549^-(e>>2&1)&513874426^-(e>>3&1)&1027748829^-(e>>4&1)&705979059}function Mt(t){let e=1;for(let r=0;r<t.length;++r){let n=t.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+t+")";e=P(e)^n>>5}e=P(e);for(let r=0;r<t.length;++r){let n=t.charCodeAt(r);e=P(e)^n&31}return e}function gt(t,e,r,n){let o=0,c=0,i=(1<<r)-1,s=[];for(let d=0;d<t.length;++d)for(o=o<<e|t[d],c+=e;c>=r;)c-=r,s.push(o>>c&i);if(n)c>0&&s.push(o<<r-c&i);else{if(c>=e)return"Excess padding";if(o<<r-c&i)return"Non-zero padding"}return s}function pe(t){return gt(t,8,5,!0)}function fe(t){let e=gt(t,5,8,!1);if(Array.isArray(e))return e}function _e(t){let e=gt(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function Gt(t){let e;t==="bech32"?e=1:e=734539939;function r(i,s,d){if(d=d||90,i.length+7+s.length>d)throw new TypeError("Exceeds length limit");i=i.toLowerCase();let l=Mt(i);if(typeof l=="string")throw new Error(l);let u=i+"1";for(let a=0;a<s.length;++a){let p=s[a];if(p>>5)throw new Error("Non 5-bit word");l=P(l)^p,u+=tt.charAt(p)}for(let a=0;a<6;++a)l=P(l);l^=e;for(let a=0;a<6;++a){let p=l>>(5-a)*5&31;u+=tt.charAt(p)}return u}function n(i,s){if(s=s||90,i.length<8)return i+" too short";if(i.length>s)return"Exceeds length limit";let d=i.toLowerCase(),l=i.toUpperCase();if(i!==d&&i!==l)return"Mixed-case string "+i;i=d;let u=i.lastIndexOf("1");if(u===-1)return"No separator character for "+i;if(u===0)return"Missing prefix for "+i;let a=i.slice(0,u),p=i.slice(u+1);if(p.length<6)return"Data too short";let f=Mt(a);if(typeof f=="string")return f;let x=[];for(let m=0;m<p.length;++m){let g=p.charAt(m),h=Wt[g];if(h===void 0)return"Unknown character "+g;f=P(f)^h,!(m+6>=p.length)&&x.push(h)}return f!==e?"Invalid checksum for "+i:{prefix:a,words:x}}function o(i,s){let d=n(i,s);if(typeof d=="object")return d}function c(i,s){let d=n(i,s);if(typeof d=="object")return d;throw new Error(d)}return{decodeUnsafe:o,decode:c,encode:r,toWords:pe,fromWordsUnsafe:fe,fromWords:_e}}T.bech32=Gt("bech32");T.bech32m=Gt("bech32m")});var Re={};Jt(Re,{BtcAddressType:()=>lt,BtcNetwork:()=>dt,CkBTCMinterCanister:()=>Y,MinterAlreadyProcessingError:()=>H,MinterAmountTooLowError:()=>X,MinterGenericError:()=>y,MinterInsufficientAllowanceError:()=>Q,MinterInsufficientFundsError:()=>K,MinterMalformedAddressError:()=>z,MinterNoNewUtxosError:()=>j,MinterRetrieveBtcError:()=>w,MinterTemporaryUnavailableError:()=>$,MinterUpdateBalanceError:()=>M,ParseBtcAddressBadWitnessLengthError:()=>C,ParseBtcAddressError:()=>N,ParseBtcAddressInvalidError:()=>V,ParseBtcAddressMalformedAddressError:()=>k,ParseBtcAddressNoDataError:()=>E,ParseBtcAddressUnexpectedHumanReadablePartError:()=>S,ParseBtcAddressUnsupportedAddressTypeError:()=>O,ParseBtcAddressUnsupportedWitnessVersionError:()=>F,ParseBtcAddressWrongNetworkError:()=>q,createRetrieveBtcError:()=>J,createRetrieveBtcWithApprovalError:()=>_t,createUpdateBalanceError:()=>ft,parseBtcAddress:()=>we});module.exports=Yt(Re);var dt=(n=>(n[n.Mainnet=0]="Mainnet",n[n.Regtest=1]="Regtest",n[n.Testnet=2]="Testnet",n))(dt||{}),lt=(c=>(c[c.P2wpkhV0=0]="P2wpkhV0",c[c.P2pkh=1]="P2pkh",c[c.P2sh=2]="P2sh",c[c.P2wsh=3]="P2wsh",c[c.P2tr=4]="P2tr",c))(lt||{});var N=class extends Error{},V=class extends N{},E=class extends N{},O=class extends N{},C=class extends N{},F=class extends N{},S=class extends N{},k=class extends N{},q=class extends N{};var B=require("@dfinity/utils"),y=class extends Error{},$=class extends y{},H=class extends y{},M=class extends y{},j=class extends M{constructor({pending_utxos:e,required_confirmations:r}){super(),this.pendingUtxos=(0,B.fromNullable)(e)||[],this.requiredConfirmations=r}},w=class extends y{},z=class extends w{},X=class extends w{},K=class extends w{},Q=class extends w{},pt=t=>{if("GenericError"in t){let{GenericError:{error_message:e,error_code:r}}=t;return new y(`${e} (${r})`)}if("TemporarilyUnavailable"in t)return new $(t.TemporarilyUnavailable);if("AlreadyProcessing"in t)return new H},ft=t=>{let e=pt(t);return(0,B.nonNullish)(e)?e:"NoNewUtxos"in t?new j(t.NoNewUtxos):new M(`Unsupported response type in minter.updateBalance ${JSON.stringify(t)}`)},J=t=>{let e=pt(t);return(0,B.nonNullish)(e)?e:"MalformedAddress"in t?new z(t.MalformedAddress):"AmountTooLow"in t?new X(`${t.AmountTooLow}`):"InsufficientFunds"in t?new K(`${t.InsufficientFunds.balance}`):new w(`Unsupported response type in minter.retrieveBtc ${JSON.stringify(t)}`)},_t=t=>{let e=pt(t);return(0,B.nonNullish)(e)?e:"InsufficientAllowance"in t?new Q(`${t.InsufficientAllowance.allowance}`):J(t)};var _=require("@dfinity/utils");var vt=({IDL:t})=>{let e=t.Variant({RestrictedTo:t.Vec(t.Principal),DepositsRestrictedTo:t.Vec(t.Principal),ReadOnly:t.Null,GeneralAvailability:t.Null}),r=t.Record({kyt_principal:t.Opt(t.Principal),mode:t.Opt(e),retrieve_btc_min_amount:t.Opt(t.Nat64),max_time_in_queue_nanos:t.Opt(t.Nat64),min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),n=t.Variant({Mainnet:t.Null,Regtest:t.Null,Testnet:t.Null}),o=t.Record({kyt_principal:t.Opt(t.Principal),ecdsa_key_name:t.Text,mode:e,retrieve_btc_min_amount:t.Nat64,ledger_id:t.Principal,max_time_in_queue_nanos:t.Nat64,btc_network:n,min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),c=t.Variant({Upgrade:t.Opt(r),Init:o}),i=t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),s=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,memory_allocation:t.Nat,compute_allocation:t.Nat}),d=t.Record({response_payload_bytes_total:t.Nat,num_instructions_total:t.Nat,num_calls_total:t.Nat,request_payload_bytes_total:t.Nat}),l=t.Record({status:i,memory_size:t.Nat,cycles:t.Nat,settings:s,query_stats:d,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8)),reserved_cycles:t.Nat}),u=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),a=t.Record({height:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),p=t.Variant({CallFailed:t.Null,TaintedDestination:t.Record({kyt_fee:t.Nat64,kyt_provider:t.Principal})}),f=t.Variant({p2wsh_v0:t.Vec(t.Nat8),p2tr_v1:t.Vec(t.Nat8),p2sh:t.Vec(t.Nat8),p2wpkh_v0:t.Vec(t.Nat8),p2pkh:t.Vec(t.Nat8)}),x=t.Variant({received_utxos:t.Record({to_account:u,mint_txid:t.Opt(t.Nat64),utxos:t.Vec(a)}),schedule_deposit_reimbursement:t.Record({burn_block_index:t.Nat64,account:u,amount:t.Nat64,reason:p}),sent_transaction:t.Record({fee:t.Opt(t.Nat64),change_output:t.Opt(t.Record({value:t.Nat64,vout:t.Nat32})),txid:t.Vec(t.Nat8),utxos:t.Vec(a),requests:t.Vec(t.Nat64),submitted_at:t.Nat64}),distributed_kyt_fee:t.Record({block_index:t.Nat64,amount:t.Nat64,kyt_provider:t.Principal}),init:o,upgrade:r,retrieve_btc_kyt_failed:t.Record({block_index:t.Nat64,owner:t.Principal,uuid:t.Text,address:t.Text,amount:t.Nat64,kyt_provider:t.Principal}),accepted_retrieve_btc_request:t.Record({received_at:t.Nat64,block_index:t.Nat64,address:f,reimbursement_account:t.Opt(u),amount:t.Nat64,kyt_provider:t.Opt(t.Principal)}),checked_utxo:t.Record({clean:t.Bool,utxo:a,uuid:t.Text,kyt_provider:t.Opt(t.Principal)}),removed_retrieve_btc_request:t.Record({block_index:t.Nat64}),confirmed_transaction:t.Record({txid:t.Vec(t.Nat8)}),replaced_transaction:t.Record({fee:t.Nat64,change_output:t.Record({value:t.Nat64,vout:t.Nat32}),old_txid:t.Vec(t.Nat8),new_txid:t.Vec(t.Nat8),submitted_at:t.Nat64}),ignored_utxo:t.Record({utxo:a}),reimbursed_failed_deposit:t.Record({burn_block_index:t.Nat64,mint_block_index:t.Nat64})}),m=t.Record({retrieve_btc_min_amount:t.Nat64,min_confirmations:t.Nat32,kyt_fee:t.Nat64}),g=t.Record({address:t.Text,amount:t.Nat64}),h=t.Record({block_index:t.Nat64}),et=t.Variant({MalformedAddress:t.Text,GenericError:t.Record({error_message:t.Text,error_code:t.Nat64}),TemporarilyUnavailable:t.Text,AlreadyProcessing:t.Null,AmountTooLow:t.Nat64,InsufficientFunds:t.Record({balance:t.Nat64})}),rt=t.Variant({Signing:t.Null,Confirmed:t.Record({txid:t.Vec(t.Nat8)}),Sending:t.Record({txid:t.Vec(t.Nat8)}),AmountTooLow:t.Null,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Pending:t.Null}),nt=t.Record({account:u,amount:t.Nat64,reason:p}),ot=t.Record({account:u,mint_block_index:t.Nat64,amount:t.Nat64,reason:p}),U=t.Variant({Signing:t.Null,Confirmed:t.Record({txid:t.Vec(t.Nat8)}),Sending:t.Record({txid:t.Vec(t.Nat8)}),AmountTooLow:t.Null,WillReimburse:nt,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Reimbursed:ot,Pending:t.Null}),it=t.Record({from_subaccount:t.Opt(t.Vec(t.Nat8)),address:t.Text,amount:t.Nat64}),ct=t.Variant({MalformedAddress:t.Text,GenericError:t.Record({error_message:t.Text,error_code:t.Nat64}),TemporarilyUnavailable:t.Text,InsufficientAllowance:t.Record({allowance:t.Nat64}),AlreadyProcessing:t.Null,AmountTooLow:t.Nat64,InsufficientFunds:t.Record({balance:t.Nat64})}),at=t.Variant({ValueTooSmall:a,Tainted:a,Minted:t.Record({minted_amount:t.Nat64,block_index:t.Nat64,utxo:a}),Checked:a}),st=t.Record({confirmations:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),ut=t.Variant({GenericError:t.Record({error_message:t.Text,error_code:t.Nat64}),TemporarilyUnavailable:t.Text,AlreadyProcessing:t.Null,NoNewUtxos:t.Record({required_confirmations:t.Nat32,pending_utxos:t.Opt(t.Vec(st)),current_confirmations:t.Opt(t.Nat32)})});return t.Service({estimate_withdrawal_fee:t.Func([t.Record({amount:t.Opt(t.Nat64)})],[t.Record({minter_fee:t.Nat64,bitcoin_fee:t.Nat64})],[]),get_btc_address:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Text],[]),get_canister_status:t.Func([],[l],[]),get_deposit_fee:t.Func([],[t.Nat64],[]),get_events:t.Func([t.Record({start:t.Nat64,length:t.Nat64})],[t.Vec(x)],[]),get_known_utxos:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Vec(a)],[]),get_minter_info:t.Func([],[m],[]),get_withdrawal_account:t.Func([],[u],[]),retrieve_btc:t.Func([g],[t.Variant({Ok:h,Err:et})],[]),retrieve_btc_status:t.Func([t.Record({block_index:t.Nat64})],[rt],[]),retrieve_btc_status_v2:t.Func([t.Record({block_index:t.Nat64})],[U],[]),retrieve_btc_status_v2_by_account:t.Func([t.Opt(u)],[t.Vec(t.Record({block_index:t.Nat64,status_v2:t.Opt(U)}))],[]),retrieve_btc_with_approval:t.Func([it],[t.Variant({Ok:h,Err:ct})],[]),update_balance:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Variant({Ok:t.Vec(at),Err:ut})],[])})};var kt=({IDL:t})=>{let e=t.Variant({RestrictedTo:t.Vec(t.Principal),DepositsRestrictedTo:t.Vec(t.Principal),ReadOnly:t.Null,GeneralAvailability:t.Null}),r=t.Record({kyt_principal:t.Opt(t.Principal),mode:t.Opt(e),retrieve_btc_min_amount:t.Opt(t.Nat64),max_time_in_queue_nanos:t.Opt(t.Nat64),min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),n=t.Variant({Mainnet:t.Null,Regtest:t.Null,Testnet:t.Null}),o=t.Record({kyt_principal:t.Opt(t.Principal),ecdsa_key_name:t.Text,mode:e,retrieve_btc_min_amount:t.Nat64,ledger_id:t.Principal,max_time_in_queue_nanos:t.Nat64,btc_network:n,min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),c=t.Variant({Upgrade:t.Opt(r),Init:o}),i=t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),s=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,memory_allocation:t.Nat,compute_allocation:t.Nat}),d=t.Record({response_payload_bytes_total:t.Nat,num_instructions_total:t.Nat,num_calls_total:t.Nat,request_payload_bytes_total:t.Nat}),l=t.Record({status:i,memory_size:t.Nat,cycles:t.Nat,settings:s,query_stats:d,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8)),reserved_cycles:t.Nat}),u=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),a=t.Record({height:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),p=t.Variant({CallFailed:t.Null,TaintedDestination:t.Record({kyt_fee:t.Nat64,kyt_provider:t.Principal})}),f=t.Variant({p2wsh_v0:t.Vec(t.Nat8),p2tr_v1:t.Vec(t.Nat8),p2sh:t.Vec(t.Nat8),p2wpkh_v0:t.Vec(t.Nat8),p2pkh:t.Vec(t.Nat8)}),x=t.Variant({received_utxos:t.Record({to_account:u,mint_txid:t.Opt(t.Nat64),utxos:t.Vec(a)}),schedule_deposit_reimbursement:t.Record({burn_block_index:t.Nat64,account:u,amount:t.Nat64,reason:p}),sent_transaction:t.Record({fee:t.Opt(t.Nat64),change_output:t.Opt(t.Record({value:t.Nat64,vout:t.Nat32})),txid:t.Vec(t.Nat8),utxos:t.Vec(a),requests:t.Vec(t.Nat64),submitted_at:t.Nat64}),distributed_kyt_fee:t.Record({block_index:t.Nat64,amount:t.Nat64,kyt_provider:t.Principal}),init:o,upgrade:r,retrieve_btc_kyt_failed:t.Record({block_index:t.Nat64,owner:t.Principal,uuid:t.Text,address:t.Text,amount:t.Nat64,kyt_provider:t.Principal}),accepted_retrieve_btc_request:t.Record({received_at:t.Nat64,block_index:t.Nat64,address:f,reimbursement_account:t.Opt(u),amount:t.Nat64,kyt_provider:t.Opt(t.Principal)}),checked_utxo:t.Record({clean:t.Bool,utxo:a,uuid:t.Text,kyt_provider:t.Opt(t.Principal)}),removed_retrieve_btc_request:t.Record({block_index:t.Nat64}),confirmed_transaction:t.Record({txid:t.Vec(t.Nat8)}),replaced_transaction:t.Record({fee:t.Nat64,change_output:t.Record({value:t.Nat64,vout:t.Nat32}),old_txid:t.Vec(t.Nat8),new_txid:t.Vec(t.Nat8),submitted_at:t.Nat64}),ignored_utxo:t.Record({utxo:a}),reimbursed_failed_deposit:t.Record({burn_block_index:t.Nat64,mint_block_index:t.Nat64})}),m=t.Record({retrieve_btc_min_amount:t.Nat64,min_confirmations:t.Nat32,kyt_fee:t.Nat64}),g=t.Record({address:t.Text,amount:t.Nat64}),h=t.Record({block_index:t.Nat64}),et=t.Variant({MalformedAddress:t.Text,GenericError:t.Record({error_message:t.Text,error_code:t.Nat64}),TemporarilyUnavailable:t.Text,AlreadyProcessing:t.Null,AmountTooLow:t.Nat64,InsufficientFunds:t.Record({balance:t.Nat64})}),rt=t.Variant({Signing:t.Null,Confirmed:t.Record({txid:t.Vec(t.Nat8)}),Sending:t.Record({txid:t.Vec(t.Nat8)}),AmountTooLow:t.Null,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Pending:t.Null}),nt=t.Record({account:u,amount:t.Nat64,reason:p}),ot=t.Record({account:u,mint_block_index:t.Nat64,amount:t.Nat64,reason:p}),U=t.Variant({Signing:t.Null,Confirmed:t.Record({txid:t.Vec(t.Nat8)}),Sending:t.Record({txid:t.Vec(t.Nat8)}),AmountTooLow:t.Null,WillReimburse:nt,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Reimbursed:ot,Pending:t.Null}),it=t.Record({from_subaccount:t.Opt(t.Vec(t.Nat8)),address:t.Text,amount:t.Nat64}),ct=t.Variant({MalformedAddress:t.Text,GenericError:t.Record({error_message:t.Text,error_code:t.Nat64}),TemporarilyUnavailable:t.Text,InsufficientAllowance:t.Record({allowance:t.Nat64}),AlreadyProcessing:t.Null,AmountTooLow:t.Nat64,InsufficientFunds:t.Record({balance:t.Nat64})}),at=t.Variant({ValueTooSmall:a,Tainted:a,Minted:t.Record({minted_amount:t.Nat64,block_index:t.Nat64,utxo:a}),Checked:a}),st=t.Record({confirmations:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),ut=t.Variant({GenericError:t.Record({error_message:t.Text,error_code:t.Nat64}),TemporarilyUnavailable:t.Text,AlreadyProcessing:t.Null,NoNewUtxos:t.Record({required_confirmations:t.Nat32,pending_utxos:t.Opt(t.Vec(st)),current_confirmations:t.Opt(t.Nat32)})});return t.Service({estimate_withdrawal_fee:t.Func([t.Record({amount:t.Opt(t.Nat64)})],[t.Record({minter_fee:t.Nat64,bitcoin_fee:t.Nat64})],["query"]),get_btc_address:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Text],[]),get_canister_status:t.Func([],[l],[]),get_deposit_fee:t.Func([],[t.Nat64],["query"]),get_events:t.Func([t.Record({start:t.Nat64,length:t.Nat64})],[t.Vec(x)],["query"]),get_known_utxos:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Vec(a)],["query"]),get_minter_info:t.Func([],[m],["query"]),get_withdrawal_account:t.Func([],[u],[]),retrieve_btc:t.Func([g],[t.Variant({Ok:h,Err:et})],[]),retrieve_btc_status:t.Func([t.Record({block_index:t.Nat64})],[rt],["query"]),retrieve_btc_status_v2:t.Func([t.Record({block_index:t.Nat64})],[U],["query"]),retrieve_btc_status_v2_by_account:t.Func([t.Opt(u)],[t.Vec(t.Record({block_index:t.Nat64,status_v2:t.Opt(U)}))],["query"]),retrieve_btc_with_approval:t.Func([it],[t.Variant({Ok:h,Err:ct})],[]),update_balance:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Variant({Ok:t.Vec(at),Err:ut})],[])})};var Y=class t extends _.Canister{constructor(){super(...arguments);this.getBtcAddress=({owner:r,subaccount:n})=>this.caller({certified:!0}).get_btc_address({owner:(0,_.toNullable)(r),subaccount:(0,_.toNullable)(n)});this.updateBalance=async({owner:r,subaccount:n})=>{let o=await this.caller({certified:!0}).update_balance({owner:(0,_.toNullable)(r),subaccount:(0,_.toNullable)(n)});if("Err"in o)throw ft(o.Err);return o.Ok};this.getWithdrawalAccount=()=>this.caller({certified:!0}).get_withdrawal_account();this.retrieveBtc=async r=>{let n=await this.caller({certified:!0}).retrieve_btc(r);if("Err"in n)throw J(n.Err);return n.Ok};this.retrieveBtcWithApproval=async({address:r,amount:n,fromSubaccount:o})=>{let c=await this.caller({certified:!0}).retrieve_btc_with_approval({address:r,amount:n,from_subaccount:(0,_.toNullable)(o)});if("Err"in c)throw _t(c.Err);return c.Ok};this.retrieveBtcStatus=async({transactionId:r,certified:n})=>this.caller({certified:n}).retrieve_btc_status({block_index:r});this.retrieveBtcStatusV2ByAccount=async({account:r,certified:n})=>{let{retrieve_btc_status_v2_by_account:o}=this.caller({certified:n});return(await o((0,_.isNullish)(r)?[]:[{owner:r.owner,subaccount:(0,_.toNullable)(r.subaccount)}])).map(({block_index:i,status_v2:s})=>({id:i,status:(0,_.fromNullable)(s)}))};this.estimateWithdrawalFee=async({certified:r,amount:n})=>this.caller({certified:r}).estimate_withdrawal_fee({amount:(0,_.toNullable)(n)});this.getMinterInfo=async({certified:r})=>this.caller({certified:r}).get_minter_info();this.getKnownUtxos=({owner:r,subaccount:n,certified:o})=>{let{get_known_utxos:c}=this.caller({certified:o});return c({owner:(0,_.toNullable)(r),subaccount:(0,_.toNullable)(n)})}}static create(r){let{service:n,certifiedService:o,canisterId:c}=(0,_.createServices)({options:r,idlFactory:kt,certifiedIdlFactory:vt});return new t(c,n,o)}};var yt=require("@dfinity/utils");function Zt(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function It(t,...e){if(!Zt(t))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function mt(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function At(t,e){It(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}function Lt(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var I=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),b=(t,e)=>t<<32-e|t>>>e,Dt=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Dt)throw new Error("Non little-endian hardware is not supported");function te(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function xt(t){if(typeof t=="string"&&(t=te(t)),!Lt(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}var Z=class{clone(){return this._cloneInto()}},Fe={}.toString;function Vt(t){let e=n=>t().update(xt(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function ee(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let o=BigInt(32),c=BigInt(4294967295),i=Number(r>>o&c),s=Number(r&c),d=n?4:0,l=n?0:4;t.setUint32(e+d,i,n),t.setUint32(e+l,s,n)}var L=class extends Z{constructor(e,r,n,o){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=I(this.buffer)}update(e){mt(this);let{view:r,buffer:n,blockLen:o}=this;e=xt(e);let c=e.length;for(let i=0;i<c;){let s=Math.min(o-this.pos,c-i);if(s===o){let d=I(e);for(;o<=c-i;i+=o)this.process(d,i);continue}n.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){mt(this),At(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:c}=this,{pos:i}=this;r[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let a=i;a<o;a++)r[a]=0;ee(n,o-8,BigInt(this.length*8),c),this.process(n,0);let s=I(e),d=this.outputLen;if(d%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=d/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let a=0;a<l;a++)s.setUint32(4*a,u[a],c)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:c,destroyed:i,pos:s}=this;return e.length=o,e.pos=s,e.finished=c,e.destroyed=i,o%r&&e.buffer.set(n),e}};var re=(t,e,r)=>t&e^~t&r,ne=(t,e,r)=>t&e^t&r^e&r,oe=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),R=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),v=new Uint32Array(64),ht=class extends L{constructor(){super(64,32,8,!1),this.A=R[0]|0,this.B=R[1]|0,this.C=R[2]|0,this.D=R[3]|0,this.E=R[4]|0,this.F=R[5]|0,this.G=R[6]|0,this.H=R[7]|0}get(){let{A:e,B:r,C:n,D:o,E:c,F:i,G:s,H:d}=this;return[e,r,n,o,c,i,s,d]}set(e,r,n,o,c,i,s,d){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=c|0,this.F=i|0,this.G=s|0,this.H=d|0}process(e,r){for(let a=0;a<16;a++,r+=4)v[a]=e.getUint32(r,!1);for(let a=16;a<64;a++){let p=v[a-15],f=v[a-2],x=b(p,7)^b(p,18)^p>>>3,m=b(f,17)^b(f,19)^f>>>10;v[a]=m+v[a-7]+x+v[a-16]|0}let{A:n,B:o,C:c,D:i,E:s,F:d,G:l,H:u}=this;for(let a=0;a<64;a++){let p=b(s,6)^b(s,11)^b(s,25),f=u+p+re(s,d,l)+oe[a]+v[a]|0,m=(b(n,2)^b(n,13)^b(n,22))+ne(n,o,c)|0;u=l,l=d,d=s,s=i+f|0,i=c,c=o,o=n,n=f+m|0}n=n+this.A|0,o=o+this.B|0,c=c+this.C|0,i=i+this.D|0,s=s+this.E|0,d=d+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(n,o,c,i,s,d,l,u)}roundClean(){v.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Nt=Vt(()=>new ht);var Ht=Rt(qt()),W=Rt($t());var me=0,xe=5,he=111,Ne=196,be={[me]:{type:1,networks:[0]},[he]:{type:1,networks:[2,1]},[xe]:{type:2,networks:[0]},[Ne]:{type:2,networks:[2,1]}},ge=({address:t,network:e})=>{let n=(u=>{try{return(0,Ht.base58_to_binary)(u)}catch{throw new V}})(t),{length:o}=n;if(o!==25)throw new k(`Expected the address to be 25 bytes, got ${o}.`);(u=>{let a=u.slice(o-4,o),p=u.slice(0,o-4),f=Nt.create();f.update(p);let x=Nt.create();x.update(f.digest());let m=x.digest().slice(0,4);if(a.some((g,h)=>g!==m[h]))throw new k(`Checksum mismatch expected ${a}, got ${m}.`)})(n);let i=n[0],s=be[i];if((0,yt.isNullish)(s))throw new O;let{type:d,networks:l}=s;if(!l.includes(e))throw new q;return{address:t,network:e,type:d,parser:"base58"}},ye=({address:t,network:e})=>{let r=u=>{try{return u.startsWith("bc1p")||u.startsWith("tb1p")||u.startsWith("bcrt1p")?W.bech32m.decode(u):W.bech32.decode(u)}catch{throw new k}},{prefix:n,words:o}=r(t),i={bc:0,tb:2,bcrt:1}[n];if((0,yt.isNullish)(i))throw new V;if(i!==e)throw new S;let[s,...d]=o;if(s>1)throw new F;switch(W.bech32.fromWords(d).length){case 20:return{address:t,network:e,type:0,parser:"bip-173"};case 32:return{address:t,network:e,type:s===0?3:4,parser:"bip-173"};default:throw new C}},we=({address:t,network:e=0})=>{switch(t.charAt(0)){case"1":case"2":case"3":case"m":case"n":return ge({address:t,network:e});case"b":case"B":case"t":case"T":return ye({address:t,network:e});case"":throw new E;default:throw new O}};0&&(module.exports={BtcAddressType,BtcNetwork,CkBTCMinterCanister,MinterAlreadyProcessingError,MinterAmountTooLowError,MinterGenericError,MinterInsufficientAllowanceError,MinterInsufficientFundsError,MinterMalformedAddressError,MinterNoNewUtxosError,MinterRetrieveBtcError,MinterTemporaryUnavailableError,MinterUpdateBalanceError,ParseBtcAddressBadWitnessLengthError,ParseBtcAddressError,ParseBtcAddressInvalidError,ParseBtcAddressMalformedAddressError,ParseBtcAddressNoDataError,ParseBtcAddressUnexpectedHumanReadablePartError,ParseBtcAddressUnsupportedAddressTypeError,ParseBtcAddressUnsupportedWitnessVersionError,ParseBtcAddressWrongNetworkError,createRetrieveBtcError,createRetrieveBtcWithApprovalError,createUpdateBalanceError,parseBtcAddress});
|
|
2
2
|
/*! Bundled license information:
|
|
3
3
|
|
|
4
4
|
@noble/hashes/esm/utils.js:
|