@dfinity/ckbtc 3.1.4 → 3.1.5

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.
@@ -10,8 +10,9 @@ export const idlFactory = ({ IDL }) => {
10
10
  'kyt_principal' : IDL.Opt(IDL.Principal),
11
11
  'mode' : IDL.Opt(Mode),
12
12
  'retrieve_btc_min_amount' : IDL.Opt(IDL.Nat64),
13
- 'new_kyt_principal' : IDL.Opt(IDL.Principal),
14
13
  'max_time_in_queue_nanos' : IDL.Opt(IDL.Nat64),
14
+ 'check_fee' : IDL.Opt(IDL.Nat64),
15
+ 'btc_checker_principal' : IDL.Opt(IDL.Principal),
15
16
  'min_confirmations' : IDL.Opt(IDL.Nat32),
16
17
  'kyt_fee' : IDL.Opt(IDL.Nat64),
17
18
  });
@@ -25,10 +26,11 @@ export const idlFactory = ({ IDL }) => {
25
26
  'ecdsa_key_name' : IDL.Text,
26
27
  'mode' : Mode,
27
28
  'retrieve_btc_min_amount' : IDL.Nat64,
28
- 'new_kyt_principal' : IDL.Opt(IDL.Principal),
29
29
  'ledger_id' : IDL.Principal,
30
30
  'max_time_in_queue_nanos' : IDL.Nat64,
31
31
  'btc_network' : BtcNetwork,
32
+ 'check_fee' : IDL.Opt(IDL.Nat64),
33
+ 'btc_checker_principal' : IDL.Opt(IDL.Principal),
32
34
  'min_confirmations' : IDL.Opt(IDL.Nat32),
33
35
  'kyt_fee' : IDL.Opt(IDL.Nat64),
34
36
  });
@@ -86,6 +88,10 @@ export const idlFactory = ({ IDL }) => {
86
88
  'kyt_provider' : IDL.Principal,
87
89
  }),
88
90
  });
91
+ const SuspendedReason = IDL.Variant({
92
+ 'ValueTooSmall' : IDL.Null,
93
+ 'Quarantined' : IDL.Null,
94
+ });
89
95
  const BitcoinAddress = IDL.Variant({
90
96
  'p2wsh_v0' : IDL.Vec(IDL.Nat8),
91
97
  'p2tr_v1' : IDL.Vec(IDL.Nat8),
@@ -130,6 +136,11 @@ export const idlFactory = ({ IDL }) => {
130
136
  'amount' : IDL.Nat64,
131
137
  'kyt_provider' : IDL.Principal,
132
138
  }),
139
+ 'suspended_utxo' : IDL.Record({
140
+ 'utxo' : Utxo,
141
+ 'account' : Account,
142
+ 'reason' : SuspendedReason,
143
+ }),
133
144
  'accepted_retrieve_btc_request' : IDL.Record({
134
145
  'received_at' : IDL.Nat64,
135
146
  'block_index' : IDL.Nat64,
@@ -153,6 +164,7 @@ export const idlFactory = ({ IDL }) => {
153
164
  'new_txid' : IDL.Vec(IDL.Nat8),
154
165
  'submitted_at' : IDL.Nat64,
155
166
  }),
167
+ 'checked_utxo_v2' : IDL.Record({ 'utxo' : Utxo, 'account' : Account }),
156
168
  'ignored_utxo' : IDL.Record({ 'utxo' : Utxo }),
157
169
  'reimbursed_failed_deposit' : IDL.Record({
158
170
  'burn_block_index' : IDL.Nat64,
@@ -238,6 +250,12 @@ export const idlFactory = ({ IDL }) => {
238
250
  }),
239
251
  'Checked' : Utxo,
240
252
  });
253
+ const Timestamp = IDL.Nat64;
254
+ const SuspendedUtxo = IDL.Record({
255
+ 'utxo' : Utxo,
256
+ 'earliest_retry' : Timestamp,
257
+ 'reason' : SuspendedReason,
258
+ });
241
259
  const PendingUtxo = IDL.Record({
242
260
  'confirmations' : IDL.Nat32,
243
261
  'value' : IDL.Nat64,
@@ -251,6 +269,7 @@ export const idlFactory = ({ IDL }) => {
251
269
  'TemporarilyUnavailable' : IDL.Text,
252
270
  'AlreadyProcessing' : IDL.Null,
253
271
  'NoNewUtxos' : IDL.Record({
272
+ 'suspended_utxos' : IDL.Opt(IDL.Vec(SuspendedUtxo)),
254
273
  'required_confirmations' : IDL.Nat32,
255
274
  'pending_utxos' : IDL.Opt(IDL.Vec(PendingUtxo)),
256
275
  'current_confirmations' : IDL.Opt(IDL.Nat32),
@@ -356,8 +375,9 @@ export const init = ({ IDL }) => {
356
375
  'kyt_principal' : IDL.Opt(IDL.Principal),
357
376
  'mode' : IDL.Opt(Mode),
358
377
  'retrieve_btc_min_amount' : IDL.Opt(IDL.Nat64),
359
- 'new_kyt_principal' : IDL.Opt(IDL.Principal),
360
378
  'max_time_in_queue_nanos' : IDL.Opt(IDL.Nat64),
379
+ 'check_fee' : IDL.Opt(IDL.Nat64),
380
+ 'btc_checker_principal' : IDL.Opt(IDL.Principal),
361
381
  'min_confirmations' : IDL.Opt(IDL.Nat32),
362
382
  'kyt_fee' : IDL.Opt(IDL.Nat64),
363
383
  });
@@ -371,10 +391,11 @@ export const init = ({ IDL }) => {
371
391
  'ecdsa_key_name' : IDL.Text,
372
392
  'mode' : Mode,
373
393
  'retrieve_btc_min_amount' : IDL.Nat64,
374
- 'new_kyt_principal' : IDL.Opt(IDL.Principal),
375
394
  'ledger_id' : IDL.Principal,
376
395
  'max_time_in_queue_nanos' : IDL.Nat64,
377
396
  'btc_network' : BtcNetwork,
397
+ 'check_fee' : IDL.Opt(IDL.Nat64),
398
+ 'btc_checker_principal' : IDL.Opt(IDL.Principal),
378
399
  'min_confirmations' : IDL.Opt(IDL.Nat32),
379
400
  'kyt_fee' : IDL.Opt(IDL.Nat64),
380
401
  });
@@ -84,6 +84,13 @@ export type Event =
84
84
  kyt_provider: Principal;
85
85
  };
86
86
  }
87
+ | {
88
+ suspended_utxo: {
89
+ utxo: Utxo;
90
+ account: Account;
91
+ reason: SuspendedReason;
92
+ };
93
+ }
87
94
  | {
88
95
  accepted_retrieve_btc_request: {
89
96
  received_at: bigint;
@@ -113,6 +120,7 @@ export type Event =
113
120
  submitted_at: bigint;
114
121
  };
115
122
  }
123
+ | { checked_utxo_v2: { utxo: Utxo; account: Account } }
116
124
  | { ignored_utxo: { utxo: Utxo } }
117
125
  | {
118
126
  reimbursed_failed_deposit: {
@@ -125,10 +133,11 @@ export interface InitArgs {
125
133
  ecdsa_key_name: string;
126
134
  mode: Mode;
127
135
  retrieve_btc_min_amount: bigint;
128
- new_kyt_principal: [] | [Principal];
129
136
  ledger_id: Principal;
130
137
  max_time_in_queue_nanos: bigint;
131
138
  btc_network: BtcNetwork;
139
+ check_fee: [] | [bigint];
140
+ btc_checker_principal: [] | [Principal];
132
141
  min_confirmations: [] | [number];
133
142
  kyt_fee: [] | [bigint];
134
143
  }
@@ -214,6 +223,13 @@ export type RetrieveBtcWithApprovalError =
214
223
  | { AlreadyProcessing: null }
215
224
  | { AmountTooLow: bigint }
216
225
  | { InsufficientFunds: { balance: bigint } };
226
+ export type SuspendedReason = { ValueTooSmall: null } | { Quarantined: null };
227
+ export interface SuspendedUtxo {
228
+ utxo: Utxo;
229
+ earliest_retry: Timestamp;
230
+ reason: SuspendedReason;
231
+ }
232
+ export type Timestamp = bigint;
217
233
  export type UpdateBalanceError =
218
234
  | {
219
235
  GenericError: { error_message: string; error_code: bigint };
@@ -222,6 +238,7 @@ export type UpdateBalanceError =
222
238
  | { AlreadyProcessing: null }
223
239
  | {
224
240
  NoNewUtxos: {
241
+ suspended_utxos: [] | [Array<SuspendedUtxo>];
225
242
  required_confirmations: number;
226
243
  pending_utxos: [] | [Array<PendingUtxo>];
227
244
  current_confirmations: [] | [number];
@@ -231,8 +248,9 @@ export interface UpgradeArgs {
231
248
  kyt_principal: [] | [Principal];
232
249
  mode: [] | [Mode];
233
250
  retrieve_btc_min_amount: [] | [bigint];
234
- new_kyt_principal: [] | [Principal];
235
251
  max_time_in_queue_nanos: [] | [bigint];
252
+ check_fee: [] | [bigint];
253
+ btc_checker_principal: [] | [Principal];
236
254
  min_confirmations: [] | [number];
237
255
  kyt_fee: [] | [bigint];
238
256
  }
@@ -1,4 +1,4 @@
1
- // Generated from IC repo commit 5d20289 (2024-11-21 tags: release-2024-11-21_03-11-24.04-base-kernel) 'rs/bitcoin/ckbtc/minter/ckbtc_minter.did' by import-candid
1
+ // Generated from IC repo commit d9fe207 (2024-12-06 tags: release-2024-12-06_03-16-base) '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
 
@@ -100,17 +100,15 @@ type RetrieveBtcOk = record {
100
100
  // The result of an [update_balance] call.
101
101
  type UtxoStatus = variant {
102
102
  // The minter ignored this UTXO because UTXO's value is too small to pay
103
- // the KYT fees. This state is final, retrying [update_balance] call will
104
- // have no effect on this UTXO.
103
+ // the check fees.
105
104
  ValueTooSmall : Utxo;
106
- // The KYT provider considered this UTXO to be tainted. This UTXO state is
107
- // final, retrying [update_balance] call will have no effect on this UTXO.
105
+ // The Bitcoin checker considered this UTXO to be tainted.
108
106
  Tainted : Utxo;
109
- // The UTXO passed the KYT check, but the minter failed to mint ckBTC
107
+ // The UTXO passed the Bitcoin check, but the minter failed to mint ckBTC
110
108
  // because the Ledger was unavailable. Retrying the [update_balance] call
111
109
  // should eventually advance the UTXO to the [Minted] state.
112
110
  Checked : Utxo;
113
- // The UTXO passed the KYT check, and ckBTC has been minted.
111
+ // The UTXO passed the Bitcoin check, and ckBTC has been minted.
114
112
  Minted : record {
115
113
  block_index : nat64;
116
114
  minted_amount : nat64;
@@ -125,12 +123,22 @@ type PendingUtxo = record {
125
123
  confirmations: nat32;
126
124
  };
127
125
 
126
+ // Number of nanoseconds since the Unix Epoch
127
+ type Timestamp = nat64;
128
+
129
+ type SuspendedUtxo = record {
130
+ utxo : Utxo;
131
+ reason : SuspendedReason;
132
+ earliest_retry: Timestamp;
133
+ };
134
+
128
135
  type UpdateBalanceError = variant {
129
136
  // There are no new UTXOs to process.
130
137
  NoNewUtxos : record {
131
138
  current_confirmations: opt nat32;
132
139
  required_confirmations: nat32;
133
140
  pending_utxos: opt vec PendingUtxo;
141
+ suspended_utxos: opt vec SuspendedUtxo;
134
142
  };
135
143
  // The minter is already processing another update balance request for the caller.
136
144
  AlreadyProcessing;
@@ -189,14 +197,17 @@ type InitArgs = record {
189
197
  /// The minter's operation mode.
190
198
  mode : Mode;
191
199
 
192
- /// The fee paid per check by the KYT canister.
200
+ /// The fee paid per Bitcoin check.
201
+ check_fee : opt nat64;
202
+
203
+ /// The fee paid per check by the KYT canister (deprecated, use check_fee instead).
193
204
  kyt_fee : opt nat64;
194
205
 
195
- /// The canister id of the KYT canister.
196
- kyt_principal: opt principal;
206
+ /// The canister id of the Bitcoin checker canister.
207
+ btc_checker_principal: opt principal;
197
208
 
198
- /// The canister id of the new KYT canister.
199
- new_kyt_principal: opt principal;
209
+ /// The canister id of the KYT canister (deprecated, use btc_checker_principal instead).
210
+ kyt_principal: opt principal;
200
211
  };
201
212
 
202
213
  // The upgrade parameters of the minter canister.
@@ -215,14 +226,17 @@ type UpgradeArgs = record {
215
226
  /// If set, overrides the current minter's operation mode.
216
227
  mode : opt Mode;
217
228
 
218
- /// The fee per check by the KYT canister.
229
+ /// The fee per Bitcoin check.
230
+ check_fee : opt nat64;
231
+
232
+ /// The fee paid per check by the KYT canister (deprecated, use check_fee instead).
219
233
  kyt_fee : opt nat64;
220
234
 
221
- /// The principal of the KYT canister.
222
- kyt_principal : opt principal;
235
+ /// The principal of the Bitcoin checker canister.
236
+ btc_checker_principal : opt principal;
223
237
 
224
- /// The principal of the new KYT canister.
225
- new_kyt_principal : opt principal;
238
+ /// The canister id of the KYT canister (deprecated, use btc_checker_principal instead).
239
+ kyt_principal: opt principal;
226
240
  };
227
241
 
228
242
  type RetrieveBtcStatus = variant {
@@ -292,7 +306,7 @@ type RetrieveBtcStatusV2 = variant {
292
306
  // transaction for this request. The payload contains the
293
307
  // identifier of the transaction on the Bitcoin network.
294
308
  Confirmed : record { txid : blob };
295
- /// The retrieve bitcoin request has been reimbursed.
309
+ /// The retrieve Bitcoin request has been reimbursed.
296
310
  Reimbursed : ReimbursedDeposit;
297
311
  /// The minter will try to reimburse this transaction.
298
312
  WillReimburse : ReimbursementRequest;
@@ -314,9 +328,10 @@ type BitcoinAddress = variant {
314
328
 
315
329
  type MinterInfo = record {
316
330
  min_confirmations : nat32;
317
- // This fee is based on the `retrieve_btc_min_amount` setting during canister
331
+ // This amount is based on the `retrieve_btc_min_amount` setting during canister
318
332
  // initialization or upgrades, but may vary according to current network fees.
319
333
  retrieve_btc_min_amount : nat64;
334
+ // The same as `check_fee`, but the old name is kept here to be backward compatible.
320
335
  kyt_fee : nat64;
321
336
  };
322
337
 
@@ -328,6 +343,14 @@ type ReimbursementReason = variant {
328
343
  };
329
344
  };
330
345
 
346
+ type SuspendedReason = variant {
347
+ // The minter ignored this UTXO because UTXO's value is too small to pay
348
+ // the check fees.
349
+ ValueTooSmall;
350
+ // The Bitcoin checker considered this UTXO to be tainted.
351
+ Quarantined;
352
+ };
353
+
331
354
  type Event = variant {
332
355
  init : InitArgs;
333
356
  upgrade : UpgradeArgs;
@@ -368,7 +391,12 @@ type Event = variant {
368
391
  clean : bool;
369
392
  kyt_provider : opt principal;
370
393
  };
394
+ checked_utxo_v2 : record {
395
+ utxo : Utxo;
396
+ account : Account;
397
+ };
371
398
  ignored_utxo : record { utxo: Utxo; };
399
+ suspended_utxo : record { utxo: Utxo; account: Account; reason: SuspendedReason };
372
400
  retrieve_btc_kyt_failed : record {
373
401
  address : text;
374
402
  amount : nat64;
@@ -394,7 +422,7 @@ type MinterArg = variant {
394
422
  service : (minter_arg : MinterArg) -> {
395
423
  // Section "Convert BTC to ckBTC" {{{
396
424
 
397
- // Returns the bitcoin address to which the owner should send BTC
425
+ // Returns the Bitcoin address to which the owner should send BTC
398
426
  // before converting the amount to ckBTC using the [update_balance]
399
427
  // endpoint.
400
428
  //
@@ -10,8 +10,9 @@ export const idlFactory = ({ IDL }) => {
10
10
  'kyt_principal' : IDL.Opt(IDL.Principal),
11
11
  'mode' : IDL.Opt(Mode),
12
12
  'retrieve_btc_min_amount' : IDL.Opt(IDL.Nat64),
13
- 'new_kyt_principal' : IDL.Opt(IDL.Principal),
14
13
  'max_time_in_queue_nanos' : IDL.Opt(IDL.Nat64),
14
+ 'check_fee' : IDL.Opt(IDL.Nat64),
15
+ 'btc_checker_principal' : IDL.Opt(IDL.Principal),
15
16
  'min_confirmations' : IDL.Opt(IDL.Nat32),
16
17
  'kyt_fee' : IDL.Opt(IDL.Nat64),
17
18
  });
@@ -25,10 +26,11 @@ export const idlFactory = ({ IDL }) => {
25
26
  'ecdsa_key_name' : IDL.Text,
26
27
  'mode' : Mode,
27
28
  'retrieve_btc_min_amount' : IDL.Nat64,
28
- 'new_kyt_principal' : IDL.Opt(IDL.Principal),
29
29
  'ledger_id' : IDL.Principal,
30
30
  'max_time_in_queue_nanos' : IDL.Nat64,
31
31
  'btc_network' : BtcNetwork,
32
+ 'check_fee' : IDL.Opt(IDL.Nat64),
33
+ 'btc_checker_principal' : IDL.Opt(IDL.Principal),
32
34
  'min_confirmations' : IDL.Opt(IDL.Nat32),
33
35
  'kyt_fee' : IDL.Opt(IDL.Nat64),
34
36
  });
@@ -86,6 +88,10 @@ export const idlFactory = ({ IDL }) => {
86
88
  'kyt_provider' : IDL.Principal,
87
89
  }),
88
90
  });
91
+ const SuspendedReason = IDL.Variant({
92
+ 'ValueTooSmall' : IDL.Null,
93
+ 'Quarantined' : IDL.Null,
94
+ });
89
95
  const BitcoinAddress = IDL.Variant({
90
96
  'p2wsh_v0' : IDL.Vec(IDL.Nat8),
91
97
  'p2tr_v1' : IDL.Vec(IDL.Nat8),
@@ -130,6 +136,11 @@ export const idlFactory = ({ IDL }) => {
130
136
  'amount' : IDL.Nat64,
131
137
  'kyt_provider' : IDL.Principal,
132
138
  }),
139
+ 'suspended_utxo' : IDL.Record({
140
+ 'utxo' : Utxo,
141
+ 'account' : Account,
142
+ 'reason' : SuspendedReason,
143
+ }),
133
144
  'accepted_retrieve_btc_request' : IDL.Record({
134
145
  'received_at' : IDL.Nat64,
135
146
  'block_index' : IDL.Nat64,
@@ -153,6 +164,7 @@ export const idlFactory = ({ IDL }) => {
153
164
  'new_txid' : IDL.Vec(IDL.Nat8),
154
165
  'submitted_at' : IDL.Nat64,
155
166
  }),
167
+ 'checked_utxo_v2' : IDL.Record({ 'utxo' : Utxo, 'account' : Account }),
156
168
  'ignored_utxo' : IDL.Record({ 'utxo' : Utxo }),
157
169
  'reimbursed_failed_deposit' : IDL.Record({
158
170
  'burn_block_index' : IDL.Nat64,
@@ -238,6 +250,12 @@ export const idlFactory = ({ IDL }) => {
238
250
  }),
239
251
  'Checked' : Utxo,
240
252
  });
253
+ const Timestamp = IDL.Nat64;
254
+ const SuspendedUtxo = IDL.Record({
255
+ 'utxo' : Utxo,
256
+ 'earliest_retry' : Timestamp,
257
+ 'reason' : SuspendedReason,
258
+ });
241
259
  const PendingUtxo = IDL.Record({
242
260
  'confirmations' : IDL.Nat32,
243
261
  'value' : IDL.Nat64,
@@ -251,6 +269,7 @@ export const idlFactory = ({ IDL }) => {
251
269
  'TemporarilyUnavailable' : IDL.Text,
252
270
  'AlreadyProcessing' : IDL.Null,
253
271
  'NoNewUtxos' : IDL.Record({
272
+ 'suspended_utxos' : IDL.Opt(IDL.Vec(SuspendedUtxo)),
254
273
  'required_confirmations' : IDL.Nat32,
255
274
  'pending_utxos' : IDL.Opt(IDL.Vec(PendingUtxo)),
256
275
  'current_confirmations' : IDL.Opt(IDL.Nat32),
@@ -356,8 +375,9 @@ export const init = ({ IDL }) => {
356
375
  'kyt_principal' : IDL.Opt(IDL.Principal),
357
376
  'mode' : IDL.Opt(Mode),
358
377
  'retrieve_btc_min_amount' : IDL.Opt(IDL.Nat64),
359
- 'new_kyt_principal' : IDL.Opt(IDL.Principal),
360
378
  'max_time_in_queue_nanos' : IDL.Opt(IDL.Nat64),
379
+ 'check_fee' : IDL.Opt(IDL.Nat64),
380
+ 'btc_checker_principal' : IDL.Opt(IDL.Principal),
361
381
  'min_confirmations' : IDL.Opt(IDL.Nat32),
362
382
  'kyt_fee' : IDL.Opt(IDL.Nat64),
363
383
  });
@@ -371,10 +391,11 @@ export const init = ({ IDL }) => {
371
391
  'ecdsa_key_name' : IDL.Text,
372
392
  'mode' : Mode,
373
393
  'retrieve_btc_min_amount' : IDL.Nat64,
374
- 'new_kyt_principal' : IDL.Opt(IDL.Principal),
375
394
  'ledger_id' : IDL.Principal,
376
395
  'max_time_in_queue_nanos' : IDL.Nat64,
377
396
  'btc_network' : BtcNetwork,
397
+ 'check_fee' : IDL.Opt(IDL.Nat64),
398
+ 'btc_checker_principal' : IDL.Opt(IDL.Principal),
378
399
  'min_confirmations' : IDL.Opt(IDL.Nat32),
379
400
  'kyt_fee' : IDL.Opt(IDL.Nat64),
380
401
  });
@@ -1,4 +1,4 @@
1
- "use strict";var te=Object.create;var Q=Object.defineProperty;var ee=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var ne=Object.getPrototypeOf,oe=Object.prototype.hasOwnProperty;var B=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ie=(t,e)=>{for(var r in e)Q(t,r,{get:e[r],enumerable:!0})},At=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of re(e))!oe.call(t,o)&&o!==r&&Q(t,o,{get:()=>e[o],enumerable:!(n=ee(e,o))||n.enumerable});return t};var Bt=(t,e,r)=>(r=t!=null?te(ne(t)):{},At(e||!t||!t.__esModule?Q(r,"default",{value:t,enumerable:!0}):r,t)),ae=t=>At(Q({},"__esModule",{value:!0}),t);var at=B((ir,Gt)=>{"use strict";var de="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";Gt.exports=de});var zt=B((ar,Wt)=>{"use strict";var pe=at(),fe=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=>pe.indexOf(o)).reduce((o,a)=>(o=o.map(i=>{let s=i*58+a;return a=s>>8,s}),o),new Uint8Array(n)).reverse().filter((o=>a=>o=o||a)(!1))])};Wt.exports=fe});var jt=B((cr,$t)=>{"use strict";var Ht=at(),me=()=>{let t=Array(256).fill(-1);for(let e=0;e<Ht.length;++e)t[Ht.charCodeAt(e)]=e;return t};$t.exports=me});var Kt=B((sr,Xt)=>{"use strict";var Qt=at(),xe=jt(),be=xe(),he=t=>{let e=[];for(let r of t){let n=r;for(let o=0;o<e.length;++o){let a=(be[e[o]]<<8)+n;e[o]=Qt.charCodeAt(a%58),n=a/58|0}for(;n;)e.push(Qt.charCodeAt(n%58)),n=n/58|0}for(let r of t){if(r)break;e.push(49)}return e.reverse(),String.fromCharCode(...e)};Xt.exports=he});var Jt=B(vt=>{"use strict";vt.base58_to_binary=zt();vt.binary_to_base58=Kt()});var Lt=B(q=>{"use strict";Object.defineProperty(q,"__esModule",{value:!0});q.bech32m=q.bech32=void 0;var ct="qpzry9x8gf2tvdw0s3jn54khce6mua7l",Zt={};for(let t=0;t<ct.length;t++){let e=ct.charAt(t);Zt[e]=t}function E(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 Yt(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=E(e)^n>>5}e=E(e);for(let r=0;r<t.length;++r){let n=t.charCodeAt(r);e=E(e)^n&31}return e}function Vt(t,e,r,n){let o=0,a=0,i=(1<<r)-1,s=[];for(let l=0;l<t.length;++l)for(o=o<<e|t[l],a+=e;a>=r;)a-=r,s.push(o>>a&i);if(n)a>0&&s.push(o<<r-a&i);else{if(a>=e)return"Excess padding";if(o<<r-a&i)return"Non-zero padding"}return s}function Ne(t){return Vt(t,8,5,!0)}function ge(t){let e=Vt(t,5,8,!1);if(Array.isArray(e))return e}function ye(t){let e=Vt(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function It(t){let e;t==="bech32"?e=1:e=734539939;function r(i,s,l){if(l=l||90,i.length+7+s.length>l)throw new TypeError("Exceeds length limit");i=i.toLowerCase();let d=Yt(i);if(typeof d=="string")throw new Error(d);let _=i+"1";for(let c=0;c<s.length;++c){let u=s[c];if(u>>5)throw new Error("Non 5-bit word");d=E(d)^u,_+=ct.charAt(u)}for(let c=0;c<6;++c)d=E(d);d^=e;for(let c=0;c<6;++c){let u=d>>(5-c)*5&31;_+=ct.charAt(u)}return _}function n(i,s){if(s=s||90,i.length<8)return i+" too short";if(i.length>s)return"Exceeds length limit";let l=i.toLowerCase(),d=i.toUpperCase();if(i!==l&&i!==d)return"Mixed-case string "+i;i=l;let _=i.lastIndexOf("1");if(_===-1)return"No separator character for "+i;if(_===0)return"Missing prefix for "+i;let c=i.slice(0,_),u=i.slice(_+1);if(u.length<6)return"Data too short";let p=Yt(c);if(typeof p=="string")return p;let m=[];for(let f=0;f<u.length;++f){let h=u.charAt(f),b=Zt[h];if(b===void 0)return"Unknown character "+h;p=E(p)^b,!(f+6>=u.length)&&m.push(b)}return p!==e?"Invalid checksum for "+i:{prefix:c,words:m}}function o(i,s){let l=n(i,s);if(typeof l=="object")return l}function a(i,s){let l=n(i,s);if(typeof l=="object")return l;throw new Error(l)}return{decodeUnsafe:o,decode:a,encode:r,toWords:Ne,fromWordsUnsafe:ge,fromWords:ye}}q.bech32=It("bech32");q.bech32m=It("bech32m")});var Be={};ie(Be,{BitcoinCanister:()=>X,BtcAddressType:()=>bt,BtcNetwork:()=>xt,CkBTCMinterCanister:()=>rt,MinterAlreadyProcessingError:()=>Y,MinterAmountTooLowError:()=>L,MinterGenericError:()=>w,MinterInsufficientAllowanceError:()=>tt,MinterInsufficientFundsError:()=>D,MinterMalformedAddressError:()=>I,MinterNoNewUtxosError:()=>Z,MinterRetrieveBtcError:()=>R,MinterTemporaryUnavailableError:()=>J,MinterUpdateBalanceError:()=>$,ParseBtcAddressBadWitnessLengthError:()=>G,ParseBtcAddressError:()=>g,ParseBtcAddressInvalidError:()=>U,ParseBtcAddressMalformedAddressError:()=>A,ParseBtcAddressNoDataError:()=>M,ParseBtcAddressUnexpectedHumanReadablePartError:()=>z,ParseBtcAddressUnsupportedAddressTypeError:()=>C,ParseBtcAddressUnsupportedWitnessVersionError:()=>W,ParseBtcAddressWrongNetworkError:()=>H,createRetrieveBtcError:()=>et,createRetrieveBtcWithApprovalError:()=>gt,createUpdateBalanceError:()=>Nt,parseBtcAddress:()=>Ae,toGetBalanceParams:()=>mt,toGetUtxosParams:()=>ft});module.exports=ae(Be);var K=require("@dfinity/utils");var Tt=({IDL:t})=>{let e=t.Variant({disabled:t.Null,enabled:t.Null}),r=t.Record({get_current_fee_percentiles:t.Nat,get_utxos_maximum:t.Nat,get_block_headers_cycles_per_ten_instructions:t.Nat,get_current_fee_percentiles_maximum:t.Nat,send_transaction_per_byte:t.Nat,get_balance:t.Nat,get_utxos_cycles_per_ten_instructions:t.Nat,get_block_headers_base:t.Nat,get_utxos_base:t.Nat,get_balance_maximum:t.Nat,send_transaction_base:t.Nat,get_block_headers_maximum:t.Nat}),n=t.Variant({mainnet:t.Null,regtest:t.Null,testnet:t.Null}),o=t.Record({api_access:t.Opt(e),lazily_evaluate_fee_percentiles:t.Opt(e),blocks_source:t.Opt(t.Principal),fees:t.Opt(r),watchdog_canister:t.Opt(t.Opt(t.Principal)),network:t.Opt(n),stability_threshold:t.Opt(t.Nat),syncing:t.Opt(e),burn_cycles:t.Opt(e),disable_api_if_not_fully_synced:t.Opt(e)}),a=t.Text,i=t.Record({network:n,address:a,min_confirmations:t.Opt(t.Nat32)}),s=t.Nat64,l=t.Nat32,d=t.Record({start_height:l,end_height:t.Opt(l),network:n}),_=t.Vec(t.Nat8),c=t.Record({tip_height:l,block_headers:t.Vec(_)}),u=t.Record({network:n}),p=t.Nat64,m=t.Record({network:n,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:a}),f=t.Vec(t.Nat8),h=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),b=t.Record({height:l,value:s,outpoint:h}),N=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:l,tip_block_hash:f,utxos:t.Vec(b)}),v=t.Record({transaction:t.Vec(t.Nat8),network:n}),V=t.Record({api_access:e,lazily_evaluate_fee_percentiles:e,blocks_source:t.Principal,fees:r,watchdog_canister:t.Opt(t.Principal),network:n,stability_threshold:t.Nat,syncing:e,burn_cycles:e,disable_api_if_not_fully_synced:e}),P=t.Record({api_access:t.Opt(e),lazily_evaluate_fee_percentiles:t.Opt(e),fees:t.Opt(r),watchdog_canister:t.Opt(t.Opt(t.Principal)),stability_threshold:t.Opt(t.Nat),syncing:t.Opt(e),burn_cycles:t.Opt(e),disable_api_if_not_fully_synced:t.Opt(e)});return t.Service({bitcoin_get_balance:t.Func([i],[s],[]),bitcoin_get_balance_query:t.Func([i],[s],[]),bitcoin_get_block_headers:t.Func([d],[c],[]),bitcoin_get_current_fee_percentiles:t.Func([u],[t.Vec(p)],[]),bitcoin_get_utxos:t.Func([m],[N],[]),bitcoin_get_utxos_query:t.Func([m],[N],[]),bitcoin_send_transaction:t.Func([v],[],[]),get_config:t.Func([],[V],[]),set_config:t.Func([P],[],[])})};var Ut=({IDL:t})=>{let e=t.Variant({disabled:t.Null,enabled:t.Null}),r=t.Record({get_current_fee_percentiles:t.Nat,get_utxos_maximum:t.Nat,get_block_headers_cycles_per_ten_instructions:t.Nat,get_current_fee_percentiles_maximum:t.Nat,send_transaction_per_byte:t.Nat,get_balance:t.Nat,get_utxos_cycles_per_ten_instructions:t.Nat,get_block_headers_base:t.Nat,get_utxos_base:t.Nat,get_balance_maximum:t.Nat,send_transaction_base:t.Nat,get_block_headers_maximum:t.Nat}),n=t.Variant({mainnet:t.Null,regtest:t.Null,testnet:t.Null}),o=t.Record({api_access:t.Opt(e),lazily_evaluate_fee_percentiles:t.Opt(e),blocks_source:t.Opt(t.Principal),fees:t.Opt(r),watchdog_canister:t.Opt(t.Opt(t.Principal)),network:t.Opt(n),stability_threshold:t.Opt(t.Nat),syncing:t.Opt(e),burn_cycles:t.Opt(e),disable_api_if_not_fully_synced:t.Opt(e)}),a=t.Text,i=t.Record({network:n,address:a,min_confirmations:t.Opt(t.Nat32)}),s=t.Nat64,l=t.Nat32,d=t.Record({start_height:l,end_height:t.Opt(l),network:n}),_=t.Vec(t.Nat8),c=t.Record({tip_height:l,block_headers:t.Vec(_)}),u=t.Record({network:n}),p=t.Nat64,m=t.Record({network:n,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:a}),f=t.Vec(t.Nat8),h=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),b=t.Record({height:l,value:s,outpoint:h}),N=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:l,tip_block_hash:f,utxos:t.Vec(b)}),v=t.Record({transaction:t.Vec(t.Nat8),network:n}),V=t.Record({api_access:e,lazily_evaluate_fee_percentiles:e,blocks_source:t.Principal,fees:r,watchdog_canister:t.Opt(t.Principal),network:n,stability_threshold:t.Nat,syncing:e,burn_cycles:e,disable_api_if_not_fully_synced:e}),P=t.Record({api_access:t.Opt(e),lazily_evaluate_fee_percentiles:t.Opt(e),fees:t.Opt(r),watchdog_canister:t.Opt(t.Opt(t.Principal)),stability_threshold:t.Opt(t.Nat),syncing:t.Opt(e),burn_cycles:t.Opt(e),disable_api_if_not_fully_synced:t.Opt(e)});return t.Service({bitcoin_get_balance:t.Func([i],[s],[]),bitcoin_get_balance_query:t.Func([i],[s],["query"]),bitcoin_get_block_headers:t.Func([d],[c],[]),bitcoin_get_current_fee_percentiles:t.Func([u],[t.Vec(p)],[]),bitcoin_get_utxos:t.Func([m],[N],[]),bitcoin_get_utxos_query:t.Func([m],[N],["query"]),bitcoin_send_transaction:t.Func([v],[],[]),get_config:t.Func([],[V],["query"]),set_config:t.Func([P],[],[])})};var T=require("@dfinity/utils"),ce={mainnet:{mainnet:null},testnet:{testnet:null},regtest:{regtest:null}},ft=({network:t,filter:e,...r})=>({filter:(0,T.nonNullish)(e)?(0,T.toNullable)("minConfirmations"in e?{min_confirmations:e.minConfirmations}:{page:e.page}):(0,T.toNullable)(),network:t==="testnet"?{testnet:null}:{mainnet:null},...r}),mt=({network:t,minConfirmations:e,...r})=>({min_confirmations:(0,T.toNullable)(e),network:ce[t],...r});var X=class t extends K.Canister{constructor(){super(...arguments);this.getUtxosQuery=({...r})=>{let{bitcoin_get_utxos_query:n}=this.caller({certified:!1});return n(ft(r))};this.getBalanceQuery=({...r})=>{let{bitcoin_get_balance_query:n}=this.caller({certified:!1});return n(mt(r))}}static create(r){let{service:n,certifiedService:o,canisterId:a}=(0,K.createServices)({options:r,idlFactory:Ut,certifiedIdlFactory:Tt});return new t(a,n,o)}};var xt=(n=>(n[n.Mainnet=0]="Mainnet",n[n.Regtest=1]="Regtest",n[n.Testnet=2]="Testnet",n))(xt||{}),bt=(a=>(a[a.P2wpkhV0=0]="P2wpkhV0",a[a.P2pkh=1]="P2pkh",a[a.P2sh=2]="P2sh",a[a.P2wsh=3]="P2wsh",a[a.P2tr=4]="P2tr",a))(bt||{});var g=class extends Error{},U=class extends g{},M=class extends g{},C=class extends g{},G=class extends g{},W=class extends g{},z=class extends g{},A=class extends g{},H=class extends g{};var F=require("@dfinity/utils"),w=class extends Error{},J=class extends w{},Y=class extends w{},$=class extends w{},Z=class extends ${constructor({pending_utxos:e,required_confirmations:r}){super(),this.pendingUtxos=(0,F.fromNullable)(e)||[],this.requiredConfirmations=r}},R=class extends w{},I=class extends R{},L=class extends R{},D=class extends R{},tt=class extends R{},ht=t=>{if("GenericError"in t){let{GenericError:{error_message:e,error_code:r}}=t;return new w(`${e} (${r})`)}if("TemporarilyUnavailable"in t)return new J(t.TemporarilyUnavailable);if("AlreadyProcessing"in t)return new Y},Nt=t=>{let e=ht(t);return(0,F.nonNullish)(e)?e:"NoNewUtxos"in t?new Z(t.NoNewUtxos):new $(`Unsupported response type in minter.updateBalance ${JSON.stringify(t)}`)},et=t=>{let e=ht(t);return(0,F.nonNullish)(e)?e:"MalformedAddress"in t?new I(t.MalformedAddress):"AmountTooLow"in t?new L(`${t.AmountTooLow}`):"InsufficientFunds"in t?new D(`${t.InsufficientFunds.balance}`):new R(`Unsupported response type in minter.retrieveBtc ${JSON.stringify(t)}`)},gt=t=>{let e=ht(t);return(0,F.nonNullish)(e)?e:"InsufficientAllowance"in t?new tt(`${t.InsufficientAllowance.allowance}`):et(t)};var x=require("@dfinity/utils");var Ct=({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),new_kyt_principal:t.Opt(t.Principal),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,new_kyt_principal:t.Opt(t.Principal),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)}),a=t.Variant({Upgrade:t.Opt(r),Init:o}),i=t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),s=t.Variant({controllers:t.Null,public:t.Null}),l=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,log_visibility:s,wasm_memory_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}),_=t.Record({status:i,memory_size:t.Nat,cycles:t.Nat,settings:l,query_stats:d,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8)),reserved_cycles:t.Nat}),c=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),u=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})}),m=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)}),f=t.Variant({received_utxos:t.Record({to_account:c,mint_txid:t.Opt(t.Nat64),utxos:t.Vec(u)}),schedule_deposit_reimbursement:t.Record({burn_block_index:t.Nat64,account:c,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(u),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:m,reimbursement_account:t.Opt(c),amount:t.Nat64,kyt_provider:t.Opt(t.Principal)}),checked_utxo:t.Record({clean:t.Bool,utxo:u,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:u}),reimbursed_failed_deposit:t.Record({burn_block_index:t.Nat64,mint_block_index:t.Nat64})}),h=t.Record({retrieve_btc_min_amount:t.Nat64,min_confirmations:t.Nat32,kyt_fee:t.Nat64}),b=t.Record({address:t.Text,amount:t.Nat64}),N=t.Record({block_index:t.Nat64}),v=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})}),V=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}),P=t.Record({account:c,amount:t.Nat64,reason:p}),st=t.Record({account:c,mint_block_index:t.Nat64,amount:t.Nat64,reason:p}),S=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:P,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Reimbursed:st,Pending:t.Null}),lt=t.Record({from_subaccount:t.Opt(t.Vec(t.Nat8)),address:t.Text,amount:t.Nat64}),ut=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})}),_t=t.Variant({ValueTooSmall:u,Tainted:u,Minted:t.Record({minted_amount:t.Nat64,block_index:t.Nat64,utxo:u}),Checked:u}),dt=t.Record({confirmations:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),pt=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(dt)),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([],[_],[]),get_deposit_fee:t.Func([],[t.Nat64],[]),get_events:t.Func([t.Record({start:t.Nat64,length:t.Nat64})],[t.Vec(f)],[]),get_known_utxos:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Vec(u)],[]),get_minter_info:t.Func([],[h],[]),get_withdrawal_account:t.Func([],[c],[]),retrieve_btc:t.Func([b],[t.Variant({Ok:N,Err:v})],[]),retrieve_btc_status:t.Func([t.Record({block_index:t.Nat64})],[V],[]),retrieve_btc_status_v2:t.Func([t.Record({block_index:t.Nat64})],[S],[]),retrieve_btc_status_v2_by_account:t.Func([t.Opt(c)],[t.Vec(t.Record({block_index:t.Nat64,status_v2:t.Opt(S)}))],[]),retrieve_btc_with_approval:t.Func([lt],[t.Variant({Ok:N,Err:ut})],[]),update_balance:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Variant({Ok:t.Vec(_t),Err:pt})],[])})};var Ft=({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),new_kyt_principal:t.Opt(t.Principal),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,new_kyt_principal:t.Opt(t.Principal),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)}),a=t.Variant({Upgrade:t.Opt(r),Init:o}),i=t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),s=t.Variant({controllers:t.Null,public:t.Null}),l=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,log_visibility:s,wasm_memory_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}),_=t.Record({status:i,memory_size:t.Nat,cycles:t.Nat,settings:l,query_stats:d,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8)),reserved_cycles:t.Nat}),c=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),u=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})}),m=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)}),f=t.Variant({received_utxos:t.Record({to_account:c,mint_txid:t.Opt(t.Nat64),utxos:t.Vec(u)}),schedule_deposit_reimbursement:t.Record({burn_block_index:t.Nat64,account:c,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(u),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:m,reimbursement_account:t.Opt(c),amount:t.Nat64,kyt_provider:t.Opt(t.Principal)}),checked_utxo:t.Record({clean:t.Bool,utxo:u,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:u}),reimbursed_failed_deposit:t.Record({burn_block_index:t.Nat64,mint_block_index:t.Nat64})}),h=t.Record({retrieve_btc_min_amount:t.Nat64,min_confirmations:t.Nat32,kyt_fee:t.Nat64}),b=t.Record({address:t.Text,amount:t.Nat64}),N=t.Record({block_index:t.Nat64}),v=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})}),V=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}),P=t.Record({account:c,amount:t.Nat64,reason:p}),st=t.Record({account:c,mint_block_index:t.Nat64,amount:t.Nat64,reason:p}),S=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:P,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Reimbursed:st,Pending:t.Null}),lt=t.Record({from_subaccount:t.Opt(t.Vec(t.Nat8)),address:t.Text,amount:t.Nat64}),ut=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})}),_t=t.Variant({ValueTooSmall:u,Tainted:u,Minted:t.Record({minted_amount:t.Nat64,block_index:t.Nat64,utxo:u}),Checked:u}),dt=t.Record({confirmations:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),pt=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(dt)),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([],[_],[]),get_deposit_fee:t.Func([],[t.Nat64],["query"]),get_events:t.Func([t.Record({start:t.Nat64,length:t.Nat64})],[t.Vec(f)],["query"]),get_known_utxos:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Vec(u)],["query"]),get_minter_info:t.Func([],[h],["query"]),get_withdrawal_account:t.Func([],[c],[]),retrieve_btc:t.Func([b],[t.Variant({Ok:N,Err:v})],[]),retrieve_btc_status:t.Func([t.Record({block_index:t.Nat64})],[V],["query"]),retrieve_btc_status_v2:t.Func([t.Record({block_index:t.Nat64})],[S],["query"]),retrieve_btc_status_v2_by_account:t.Func([t.Opt(c)],[t.Vec(t.Record({block_index:t.Nat64,status_v2:t.Opt(S)}))],["query"]),retrieve_btc_with_approval:t.Func([lt],[t.Variant({Ok:N,Err:ut})],[]),update_balance:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Variant({Ok:t.Vec(_t),Err:pt})],[])})};var rt=class t extends x.Canister{constructor(){super(...arguments);this.getBtcAddress=({owner:r,subaccount:n})=>this.caller({certified:!0}).get_btc_address({owner:(0,x.toNullable)(r),subaccount:(0,x.toNullable)(n)});this.updateBalance=async({owner:r,subaccount:n})=>{let o=await this.caller({certified:!0}).update_balance({owner:(0,x.toNullable)(r),subaccount:(0,x.toNullable)(n)});if("Err"in o)throw Nt(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 et(n.Err);return n.Ok};this.retrieveBtcWithApproval=async({address:r,amount:n,fromSubaccount:o})=>{let a=await this.caller({certified:!0}).retrieve_btc_with_approval({address:r,amount:n,from_subaccount:(0,x.toNullable)(o)});if("Err"in a)throw gt(a.Err);return a.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,x.isNullish)(r)?[]:[{owner:r.owner,subaccount:(0,x.toNullable)(r.subaccount)}])).map(({block_index:i,status_v2:s})=>({id:i,status:(0,x.fromNullable)(s)}))};this.estimateWithdrawalFee=async({certified:r,amount:n})=>this.caller({certified:r}).estimate_withdrawal_fee({amount:(0,x.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:a}=this.caller({certified:o});return a({owner:(0,x.toNullable)(r),subaccount:(0,x.toNullable)(n)})}}static create(r){let{service:n,certifiedService:o,canisterId:a}=(0,x.createServices)({options:r,idlFactory:Ft,certifiedIdlFactory:Ct});return new t(a,n,o)}};var Pt=require("@dfinity/utils");function se(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function yt(t,...e){if(!se(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function wt(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 Et(t,e){yt(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var ot=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),y=(t,e)=>t<<32-e|t>>>e;var Ze=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function le(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Rt(t){return typeof t=="string"&&(t=le(t)),yt(t),t}var nt=class{clone(){return this._cloneInto()}},Ie={}.toString;function qt(t){let e=n=>t().update(Rt(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function ue(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let o=BigInt(32),a=BigInt(4294967295),i=Number(r>>o&a),s=Number(r&a),l=n?4:0,d=n?0:4;t.setUint32(e+l,i,n),t.setUint32(e+d,s,n)}var St=(t,e,r)=>t&e^~t&r,Mt=(t,e,r)=>t&e^t&r^e&r,it=class extends nt{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=ot(this.buffer)}update(e){wt(this);let{view:r,buffer:n,blockLen:o}=this;e=Rt(e);let a=e.length;for(let i=0;i<a;){let s=Math.min(o-this.pos,a-i);if(s===o){let l=ot(e);for(;o<=a-i;i+=o)this.process(l,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){wt(this),Et(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:a}=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 c=i;c<o;c++)r[c]=0;ue(n,o-8,BigInt(this.length*8),a),this.process(n,0);let s=ot(e),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let d=l/4,_=this.get();if(d>_.length)throw new Error("_sha2: outputLen bigger than state");for(let c=0;c<d;c++)s.setUint32(4*c,_[c],a)}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:a,destroyed:i,pos:s}=this;return e.length=o,e.pos=s,e.finished=a,e.destroyed=i,o%r&&e.buffer.set(n),e}};var _e=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]),k=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),O=new Uint32Array(64),kt=class extends it{constructor(){super(64,32,8,!1),this.A=k[0]|0,this.B=k[1]|0,this.C=k[2]|0,this.D=k[3]|0,this.E=k[4]|0,this.F=k[5]|0,this.G=k[6]|0,this.H=k[7]|0}get(){let{A:e,B:r,C:n,D:o,E:a,F:i,G:s,H:l}=this;return[e,r,n,o,a,i,s,l]}set(e,r,n,o,a,i,s,l){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=a|0,this.F=i|0,this.G=s|0,this.H=l|0}process(e,r){for(let c=0;c<16;c++,r+=4)O[c]=e.getUint32(r,!1);for(let c=16;c<64;c++){let u=O[c-15],p=O[c-2],m=y(u,7)^y(u,18)^u>>>3,f=y(p,17)^y(p,19)^p>>>10;O[c]=f+O[c-7]+m+O[c-16]|0}let{A:n,B:o,C:a,D:i,E:s,F:l,G:d,H:_}=this;for(let c=0;c<64;c++){let u=y(s,6)^y(s,11)^y(s,25),p=_+u+St(s,l,d)+_e[c]+O[c]|0,f=(y(n,2)^y(n,13)^y(n,22))+Mt(n,o,a)|0;_=d,d=l,l=s,s=i+p|0,i=a,a=o,o=n,n=p+f|0}n=n+this.A|0,o=o+this.B|0,a=a+this.C|0,i=i+this.D|0,s=s+this.E|0,l=l+this.F|0,d=d+this.G|0,_=_+this.H|0,this.set(n,o,a,i,s,l,d,_)}roundClean(){O.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Ot=qt(()=>new kt);var Dt=Bt(Jt()),j=Bt(Lt());var we=0,Re=5,ke=111,Oe=196,ve={[we]:{type:1,networks:[0]},[ke]:{type:1,networks:[2,1]},[Re]:{type:2,networks:[0]},[Oe]:{type:2,networks:[2,1]}},Ve=({address:t,network:e})=>{let n=(_=>{try{return(0,Dt.base58_to_binary)(_)}catch{throw new U}})(t),{length:o}=n;if(o!==25)throw new A(`Expected the address to be 25 bytes, got ${o}.`);(_=>{let c=_.slice(o-4,o),u=_.slice(0,o-4),p=Ot.create();p.update(u);let m=Ot.create();m.update(p.digest());let f=m.digest().slice(0,4);if(c.some((h,b)=>h!==f[b]))throw new A(`Checksum mismatch expected ${c}, got ${f}.`)})(n);let i=n[0],s=ve[i];if((0,Pt.isNullish)(s))throw new C;let{type:l,networks:d}=s;if(!d.includes(e))throw new H;return{address:t,network:e,type:l,parser:"base58"}},Pe=({address:t,network:e})=>{let r=_=>{try{return _.startsWith("bc1p")||_.startsWith("tb1p")||_.startsWith("bcrt1p")?j.bech32m.decode(_):j.bech32.decode(_)}catch{throw new A}},{prefix:n,words:o}=r(t),i={bc:0,tb:2,bcrt:1}[n];if((0,Pt.isNullish)(i))throw new U;if(i!==e)throw new z;let[s,...l]=o;if(s>1)throw new W;switch(j.bech32.fromWords(l).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 G}},Ae=({address:t,network:e=0})=>{switch(t.charAt(0)){case"1":case"2":case"3":case"m":case"n":return Ve({address:t,network:e});case"b":case"B":case"t":case"T":return Pe({address:t,network:e});case"":throw new M;default:throw new C}};0&&(module.exports={BitcoinCanister,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,toGetBalanceParams,toGetUtxosParams});
1
+ "use strict";var ne=Object.create;var Q=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var ce=Object.getOwnPropertyNames;var ae=Object.getPrototypeOf,ie=Object.prototype.hasOwnProperty;var B=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),se=(t,e)=>{for(var r in e)Q(t,r,{get:e[r],enumerable:!0})},Ut=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ce(e))!ie.call(t,o)&&o!==r&&Q(t,o,{get:()=>e[o],enumerable:!(n=oe(e,o))||n.enumerable});return t};var Ct=(t,e,r)=>(r=t!=null?ne(ae(t)):{},Ut(e||!t||!t.__esModule?Q(r,"default",{value:t,enumerable:!0}):r,t)),le=t=>Ut(Q({},"__esModule",{value:!0}),t);var at=B((sr,Ht)=>{"use strict";var me="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";Ht.exports=me});var jt=B((lr,$t)=>{"use strict";var xe=at(),he=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=>xe.indexOf(o)).reduce((o,a)=>(o=o.map(c=>{let s=c*58+a;return a=s>>8,s}),o),new Uint8Array(n)).reverse().filter((o=>a=>o=o||a)(!1))])};$t.exports=he});var Kt=B((ur,Xt)=>{"use strict";var Qt=at(),be=()=>{let t=Array(256).fill(-1);for(let e=0;e<Qt.length;++e)t[Qt.charCodeAt(e)]=e;return t};Xt.exports=be});var Zt=B((_r,Yt)=>{"use strict";var Jt=at(),Ne=Kt(),ge=Ne(),ye=t=>{let e=[];for(let r of t){let n=r;for(let o=0;o<e.length;++o){let a=(ge[e[o]]<<8)+n;e[o]=Jt.charCodeAt(a%58),n=a/58|0}for(;n;)e.push(Jt.charCodeAt(n%58)),n=n/58|0}for(let r of t){if(r)break;e.push(49)}return e.reverse(),String.fromCharCode(...e)};Yt.exports=ye});var It=B(At=>{"use strict";At.base58_to_binary=jt();At.binary_to_base58=Zt()});var ee=B(S=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0});S.bech32m=S.bech32=void 0;var it="qpzry9x8gf2tvdw0s3jn54khce6mua7l",Dt={};for(let t=0;t<it.length;t++){let e=it.charAt(t);Dt[e]=t}function E(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 Lt(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=E(e)^n>>5}e=E(e);for(let r=0;r<t.length;++r){let n=t.charCodeAt(r);e=E(e)^n&31}return e}function Bt(t,e,r,n){let o=0,a=0,c=(1<<r)-1,s=[];for(let l=0;l<t.length;++l)for(o=o<<e|t[l],a+=e;a>=r;)a-=r,s.push(o>>a&c);if(n)a>0&&s.push(o<<r-a&c);else{if(a>=e)return"Excess padding";if(o<<r-a&c)return"Non-zero padding"}return s}function we(t){return Bt(t,8,5,!0)}function Re(t){let e=Bt(t,5,8,!1);if(Array.isArray(e))return e}function ke(t){let e=Bt(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function te(t){let e;t==="bech32"?e=1:e=734539939;function r(c,s,l){if(l=l||90,c.length+7+s.length>l)throw new TypeError("Exceeds length limit");c=c.toLowerCase();let d=Lt(c);if(typeof d=="string")throw new Error(d);let _=c+"1";for(let i=0;i<s.length;++i){let u=s[i];if(u>>5)throw new Error("Non 5-bit word");d=E(d)^u,_+=it.charAt(u)}for(let i=0;i<6;++i)d=E(d);d^=e;for(let i=0;i<6;++i){let u=d>>(5-i)*5&31;_+=it.charAt(u)}return _}function n(c,s){if(s=s||90,c.length<8)return c+" too short";if(c.length>s)return"Exceeds length limit";let l=c.toLowerCase(),d=c.toUpperCase();if(c!==l&&c!==d)return"Mixed-case string "+c;c=l;let _=c.lastIndexOf("1");if(_===-1)return"No separator character for "+c;if(_===0)return"Missing prefix for "+c;let i=c.slice(0,_),u=c.slice(_+1);if(u.length<6)return"Data too short";let p=Lt(i);if(typeof p=="string")return p;let f=[];for(let m=0;m<u.length;++m){let b=u.charAt(m),h=Dt[b];if(h===void 0)return"Unknown character "+b;p=E(p)^h,!(m+6>=u.length)&&f.push(h)}return p!==e?"Invalid checksum for "+c:{prefix:i,words:f}}function o(c,s){let l=n(c,s);if(typeof l=="object")return l}function a(c,s){let l=n(c,s);if(typeof l=="object")return l;throw new Error(l)}return{decodeUnsafe:o,decode:a,encode:r,toWords:we,fromWordsUnsafe:Re,fromWords:ke}}S.bech32=te("bech32");S.bech32m=te("bech32m")});var Ce={};se(Ce,{BitcoinCanister:()=>X,BtcAddressType:()=>gt,BtcNetwork:()=>Nt,CkBTCMinterCanister:()=>rt,MinterAlreadyProcessingError:()=>Y,MinterAmountTooLowError:()=>L,MinterGenericError:()=>R,MinterInsufficientAllowanceError:()=>tt,MinterInsufficientFundsError:()=>D,MinterMalformedAddressError:()=>I,MinterNoNewUtxosError:()=>Z,MinterRetrieveBtcError:()=>k,MinterTemporaryUnavailableError:()=>J,MinterUpdateBalanceError:()=>$,ParseBtcAddressBadWitnessLengthError:()=>G,ParseBtcAddressError:()=>N,ParseBtcAddressInvalidError:()=>U,ParseBtcAddressMalformedAddressError:()=>A,ParseBtcAddressNoDataError:()=>M,ParseBtcAddressUnexpectedHumanReadablePartError:()=>z,ParseBtcAddressUnsupportedAddressTypeError:()=>C,ParseBtcAddressUnsupportedWitnessVersionError:()=>W,ParseBtcAddressWrongNetworkError:()=>H,createRetrieveBtcError:()=>et,createRetrieveBtcWithApprovalError:()=>Rt,createUpdateBalanceError:()=>wt,parseBtcAddress:()=>Ue,toGetBalanceParams:()=>bt,toGetUtxosParams:()=>ht});module.exports=le(Ce);var K=require("@dfinity/utils");var Ft=({IDL:t})=>{let e=t.Variant({disabled:t.Null,enabled:t.Null}),r=t.Record({get_current_fee_percentiles:t.Nat,get_utxos_maximum:t.Nat,get_block_headers_cycles_per_ten_instructions:t.Nat,get_current_fee_percentiles_maximum:t.Nat,send_transaction_per_byte:t.Nat,get_balance:t.Nat,get_utxos_cycles_per_ten_instructions:t.Nat,get_block_headers_base:t.Nat,get_utxos_base:t.Nat,get_balance_maximum:t.Nat,send_transaction_base:t.Nat,get_block_headers_maximum:t.Nat}),n=t.Variant({mainnet:t.Null,regtest:t.Null,testnet:t.Null}),o=t.Record({api_access:t.Opt(e),lazily_evaluate_fee_percentiles:t.Opt(e),blocks_source:t.Opt(t.Principal),fees:t.Opt(r),watchdog_canister:t.Opt(t.Opt(t.Principal)),network:t.Opt(n),stability_threshold:t.Opt(t.Nat),syncing:t.Opt(e),burn_cycles:t.Opt(e),disable_api_if_not_fully_synced:t.Opt(e)}),a=t.Text,c=t.Record({network:n,address:a,min_confirmations:t.Opt(t.Nat32)}),s=t.Nat64,l=t.Nat32,d=t.Record({start_height:l,end_height:t.Opt(l),network:n}),_=t.Vec(t.Nat8),i=t.Record({tip_height:l,block_headers:t.Vec(_)}),u=t.Record({network:n}),p=t.Nat64,f=t.Record({network:n,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:a}),m=t.Vec(t.Nat8),b=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),h=t.Record({height:l,value:s,outpoint:b}),y=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:l,tip_block_hash:m,utxos:t.Vec(h)}),w=t.Record({transaction:t.Vec(t.Nat8),network:n}),V=t.Record({api_access:e,lazily_evaluate_fee_percentiles:e,blocks_source:t.Principal,fees:r,watchdog_canister:t.Opt(t.Principal),network:n,stability_threshold:t.Nat,syncing:e,burn_cycles:e,disable_api_if_not_fully_synced:e}),P=t.Record({api_access:t.Opt(e),lazily_evaluate_fee_percentiles:t.Opt(e),fees:t.Opt(r),watchdog_canister:t.Opt(t.Opt(t.Principal)),stability_threshold:t.Opt(t.Nat),syncing:t.Opt(e),burn_cycles:t.Opt(e),disable_api_if_not_fully_synced:t.Opt(e)});return t.Service({bitcoin_get_balance:t.Func([c],[s],[]),bitcoin_get_balance_query:t.Func([c],[s],[]),bitcoin_get_block_headers:t.Func([d],[i],[]),bitcoin_get_current_fee_percentiles:t.Func([u],[t.Vec(p)],[]),bitcoin_get_utxos:t.Func([f],[y],[]),bitcoin_get_utxos_query:t.Func([f],[y],[]),bitcoin_send_transaction:t.Func([w],[],[]),get_config:t.Func([],[V],[]),set_config:t.Func([P],[],[])})};var Et=({IDL:t})=>{let e=t.Variant({disabled:t.Null,enabled:t.Null}),r=t.Record({get_current_fee_percentiles:t.Nat,get_utxos_maximum:t.Nat,get_block_headers_cycles_per_ten_instructions:t.Nat,get_current_fee_percentiles_maximum:t.Nat,send_transaction_per_byte:t.Nat,get_balance:t.Nat,get_utxos_cycles_per_ten_instructions:t.Nat,get_block_headers_base:t.Nat,get_utxos_base:t.Nat,get_balance_maximum:t.Nat,send_transaction_base:t.Nat,get_block_headers_maximum:t.Nat}),n=t.Variant({mainnet:t.Null,regtest:t.Null,testnet:t.Null}),o=t.Record({api_access:t.Opt(e),lazily_evaluate_fee_percentiles:t.Opt(e),blocks_source:t.Opt(t.Principal),fees:t.Opt(r),watchdog_canister:t.Opt(t.Opt(t.Principal)),network:t.Opt(n),stability_threshold:t.Opt(t.Nat),syncing:t.Opt(e),burn_cycles:t.Opt(e),disable_api_if_not_fully_synced:t.Opt(e)}),a=t.Text,c=t.Record({network:n,address:a,min_confirmations:t.Opt(t.Nat32)}),s=t.Nat64,l=t.Nat32,d=t.Record({start_height:l,end_height:t.Opt(l),network:n}),_=t.Vec(t.Nat8),i=t.Record({tip_height:l,block_headers:t.Vec(_)}),u=t.Record({network:n}),p=t.Nat64,f=t.Record({network:n,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:a}),m=t.Vec(t.Nat8),b=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),h=t.Record({height:l,value:s,outpoint:b}),y=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:l,tip_block_hash:m,utxos:t.Vec(h)}),w=t.Record({transaction:t.Vec(t.Nat8),network:n}),V=t.Record({api_access:e,lazily_evaluate_fee_percentiles:e,blocks_source:t.Principal,fees:r,watchdog_canister:t.Opt(t.Principal),network:n,stability_threshold:t.Nat,syncing:e,burn_cycles:e,disable_api_if_not_fully_synced:e}),P=t.Record({api_access:t.Opt(e),lazily_evaluate_fee_percentiles:t.Opt(e),fees:t.Opt(r),watchdog_canister:t.Opt(t.Opt(t.Principal)),stability_threshold:t.Opt(t.Nat),syncing:t.Opt(e),burn_cycles:t.Opt(e),disable_api_if_not_fully_synced:t.Opt(e)});return t.Service({bitcoin_get_balance:t.Func([c],[s],[]),bitcoin_get_balance_query:t.Func([c],[s],["query"]),bitcoin_get_block_headers:t.Func([d],[i],[]),bitcoin_get_current_fee_percentiles:t.Func([u],[t.Vec(p)],[]),bitcoin_get_utxos:t.Func([f],[y],[]),bitcoin_get_utxos_query:t.Func([f],[y],["query"]),bitcoin_send_transaction:t.Func([w],[],[]),get_config:t.Func([],[V],["query"]),set_config:t.Func([P],[],[])})};var T=require("@dfinity/utils"),ue={mainnet:{mainnet:null},testnet:{testnet:null},regtest:{regtest:null}},ht=({network:t,filter:e,...r})=>({filter:(0,T.nonNullish)(e)?(0,T.toNullable)("minConfirmations"in e?{min_confirmations:e.minConfirmations}:{page:e.page}):(0,T.toNullable)(),network:t==="testnet"?{testnet:null}:{mainnet:null},...r}),bt=({network:t,minConfirmations:e,...r})=>({min_confirmations:(0,T.toNullable)(e),network:ue[t],...r});var X=class t extends K.Canister{constructor(){super(...arguments);this.getUtxosQuery=({...r})=>{let{bitcoin_get_utxos_query:n}=this.caller({certified:!1});return n(ht(r))};this.getBalanceQuery=({...r})=>{let{bitcoin_get_balance_query:n}=this.caller({certified:!1});return n(bt(r))}}static create(r){let{service:n,certifiedService:o,canisterId:a}=(0,K.createServices)({options:r,idlFactory:Et,certifiedIdlFactory:Ft});return new t(a,n,o)}};var Nt=(n=>(n[n.Mainnet=0]="Mainnet",n[n.Regtest=1]="Regtest",n[n.Testnet=2]="Testnet",n))(Nt||{}),gt=(a=>(a[a.P2wpkhV0=0]="P2wpkhV0",a[a.P2pkh=1]="P2pkh",a[a.P2sh=2]="P2sh",a[a.P2wsh=3]="P2wsh",a[a.P2tr=4]="P2tr",a))(gt||{});var N=class extends Error{},U=class extends N{},M=class extends N{},C=class extends N{},G=class extends N{},W=class extends N{},z=class extends N{},A=class extends N{},H=class extends N{};var F=require("@dfinity/utils"),R=class extends Error{},J=class extends R{},Y=class extends R{},$=class extends R{},Z=class extends ${constructor({pending_utxos:e,required_confirmations:r}){super(),this.pendingUtxos=(0,F.fromNullable)(e)||[],this.requiredConfirmations=r}},k=class extends R{},I=class extends k{},L=class extends k{},D=class extends k{},tt=class extends k{},yt=t=>{if("GenericError"in t){let{GenericError:{error_message:e,error_code:r}}=t;return new R(`${e} (${r})`)}if("TemporarilyUnavailable"in t)return new J(t.TemporarilyUnavailable);if("AlreadyProcessing"in t)return new Y},wt=t=>{let e=yt(t);return(0,F.nonNullish)(e)?e:"NoNewUtxos"in t?new Z(t.NoNewUtxos):new $(`Unsupported response type in minter.updateBalance ${JSON.stringify(t)}`)},et=t=>{let e=yt(t);return(0,F.nonNullish)(e)?e:"MalformedAddress"in t?new I(t.MalformedAddress):"AmountTooLow"in t?new L(`${t.AmountTooLow}`):"InsufficientFunds"in t?new D(`${t.InsufficientFunds.balance}`):new k(`Unsupported response type in minter.retrieveBtc ${JSON.stringify(t)}`)},Rt=t=>{let e=yt(t);return(0,F.nonNullish)(e)?e:"InsufficientAllowance"in t?new tt(`${t.InsufficientAllowance.allowance}`):et(t)};var x=require("@dfinity/utils");var St=({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),check_fee:t.Opt(t.Nat64),btc_checker_principal:t.Opt(t.Principal),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,check_fee:t.Opt(t.Nat64),btc_checker_principal:t.Opt(t.Principal),min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),a=t.Variant({Upgrade:t.Opt(r),Init:o}),c=t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),s=t.Variant({controllers:t.Null,public:t.Null}),l=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,log_visibility:s,wasm_memory_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}),_=t.Record({status:c,memory_size:t.Nat,cycles:t.Nat,settings:l,query_stats:d,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8)),reserved_cycles:t.Nat}),i=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),u=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({ValueTooSmall:t.Null,Quarantined:t.Null}),m=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)}),b=t.Variant({received_utxos:t.Record({to_account:i,mint_txid:t.Opt(t.Nat64),utxos:t.Vec(u)}),schedule_deposit_reimbursement:t.Record({burn_block_index:t.Nat64,account:i,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(u),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}),suspended_utxo:t.Record({utxo:u,account:i,reason:f}),accepted_retrieve_btc_request:t.Record({received_at:t.Nat64,block_index:t.Nat64,address:m,reimbursement_account:t.Opt(i),amount:t.Nat64,kyt_provider:t.Opt(t.Principal)}),checked_utxo:t.Record({clean:t.Bool,utxo:u,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}),checked_utxo_v2:t.Record({utxo:u,account:i}),ignored_utxo:t.Record({utxo:u}),reimbursed_failed_deposit:t.Record({burn_block_index:t.Nat64,mint_block_index:t.Nat64})}),h=t.Record({retrieve_btc_min_amount:t.Nat64,min_confirmations:t.Nat32,kyt_fee:t.Nat64}),y=t.Record({address:t.Text,amount:t.Nat64}),w=t.Record({block_index:t.Nat64}),V=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})}),P=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}),st=t.Record({account:i,amount:t.Nat64,reason:p}),lt=t.Record({account:i,mint_block_index:t.Nat64,amount:t.Nat64,reason:p}),q=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:st,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Reimbursed:lt,Pending:t.Null}),ut=t.Record({from_subaccount:t.Opt(t.Vec(t.Nat8)),address:t.Text,amount:t.Nat64}),_t=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})}),dt=t.Variant({ValueTooSmall:u,Tainted:u,Minted:t.Record({minted_amount:t.Nat64,block_index:t.Nat64,utxo:u}),Checked:u}),pt=t.Nat64,ft=t.Record({utxo:u,earliest_retry:pt,reason:f}),mt=t.Record({confirmations:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),xt=t.Variant({GenericError:t.Record({error_message:t.Text,error_code:t.Nat64}),TemporarilyUnavailable:t.Text,AlreadyProcessing:t.Null,NoNewUtxos:t.Record({suspended_utxos:t.Opt(t.Vec(ft)),required_confirmations:t.Nat32,pending_utxos:t.Opt(t.Vec(mt)),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([],[_],[]),get_deposit_fee:t.Func([],[t.Nat64],[]),get_events:t.Func([t.Record({start:t.Nat64,length:t.Nat64})],[t.Vec(b)],[]),get_known_utxos:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Vec(u)],[]),get_minter_info:t.Func([],[h],[]),get_withdrawal_account:t.Func([],[i],[]),retrieve_btc:t.Func([y],[t.Variant({Ok:w,Err:V})],[]),retrieve_btc_status:t.Func([t.Record({block_index:t.Nat64})],[P],[]),retrieve_btc_status_v2:t.Func([t.Record({block_index:t.Nat64})],[q],[]),retrieve_btc_status_v2_by_account:t.Func([t.Opt(i)],[t.Vec(t.Record({block_index:t.Nat64,status_v2:t.Opt(q)}))],[]),retrieve_btc_with_approval:t.Func([ut],[t.Variant({Ok:w,Err:_t})],[]),update_balance:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Variant({Ok:t.Vec(dt),Err:xt})],[])})};var qt=({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),check_fee:t.Opt(t.Nat64),btc_checker_principal:t.Opt(t.Principal),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,check_fee:t.Opt(t.Nat64),btc_checker_principal:t.Opt(t.Principal),min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),a=t.Variant({Upgrade:t.Opt(r),Init:o}),c=t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),s=t.Variant({controllers:t.Null,public:t.Null}),l=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,log_visibility:s,wasm_memory_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}),_=t.Record({status:c,memory_size:t.Nat,cycles:t.Nat,settings:l,query_stats:d,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8)),reserved_cycles:t.Nat}),i=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),u=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({ValueTooSmall:t.Null,Quarantined:t.Null}),m=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)}),b=t.Variant({received_utxos:t.Record({to_account:i,mint_txid:t.Opt(t.Nat64),utxos:t.Vec(u)}),schedule_deposit_reimbursement:t.Record({burn_block_index:t.Nat64,account:i,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(u),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}),suspended_utxo:t.Record({utxo:u,account:i,reason:f}),accepted_retrieve_btc_request:t.Record({received_at:t.Nat64,block_index:t.Nat64,address:m,reimbursement_account:t.Opt(i),amount:t.Nat64,kyt_provider:t.Opt(t.Principal)}),checked_utxo:t.Record({clean:t.Bool,utxo:u,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}),checked_utxo_v2:t.Record({utxo:u,account:i}),ignored_utxo:t.Record({utxo:u}),reimbursed_failed_deposit:t.Record({burn_block_index:t.Nat64,mint_block_index:t.Nat64})}),h=t.Record({retrieve_btc_min_amount:t.Nat64,min_confirmations:t.Nat32,kyt_fee:t.Nat64}),y=t.Record({address:t.Text,amount:t.Nat64}),w=t.Record({block_index:t.Nat64}),V=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})}),P=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}),st=t.Record({account:i,amount:t.Nat64,reason:p}),lt=t.Record({account:i,mint_block_index:t.Nat64,amount:t.Nat64,reason:p}),q=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:st,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Reimbursed:lt,Pending:t.Null}),ut=t.Record({from_subaccount:t.Opt(t.Vec(t.Nat8)),address:t.Text,amount:t.Nat64}),_t=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})}),dt=t.Variant({ValueTooSmall:u,Tainted:u,Minted:t.Record({minted_amount:t.Nat64,block_index:t.Nat64,utxo:u}),Checked:u}),pt=t.Nat64,ft=t.Record({utxo:u,earliest_retry:pt,reason:f}),mt=t.Record({confirmations:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),xt=t.Variant({GenericError:t.Record({error_message:t.Text,error_code:t.Nat64}),TemporarilyUnavailable:t.Text,AlreadyProcessing:t.Null,NoNewUtxos:t.Record({suspended_utxos:t.Opt(t.Vec(ft)),required_confirmations:t.Nat32,pending_utxos:t.Opt(t.Vec(mt)),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([],[_],[]),get_deposit_fee:t.Func([],[t.Nat64],["query"]),get_events:t.Func([t.Record({start:t.Nat64,length:t.Nat64})],[t.Vec(b)],["query"]),get_known_utxos:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Vec(u)],["query"]),get_minter_info:t.Func([],[h],["query"]),get_withdrawal_account:t.Func([],[i],[]),retrieve_btc:t.Func([y],[t.Variant({Ok:w,Err:V})],[]),retrieve_btc_status:t.Func([t.Record({block_index:t.Nat64})],[P],["query"]),retrieve_btc_status_v2:t.Func([t.Record({block_index:t.Nat64})],[q],["query"]),retrieve_btc_status_v2_by_account:t.Func([t.Opt(i)],[t.Vec(t.Record({block_index:t.Nat64,status_v2:t.Opt(q)}))],["query"]),retrieve_btc_with_approval:t.Func([ut],[t.Variant({Ok:w,Err:_t})],[]),update_balance:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Variant({Ok:t.Vec(dt),Err:xt})],[])})};var rt=class t extends x.Canister{constructor(){super(...arguments);this.getBtcAddress=({owner:r,subaccount:n})=>this.caller({certified:!0}).get_btc_address({owner:(0,x.toNullable)(r),subaccount:(0,x.toNullable)(n)});this.updateBalance=async({owner:r,subaccount:n})=>{let o=await this.caller({certified:!0}).update_balance({owner:(0,x.toNullable)(r),subaccount:(0,x.toNullable)(n)});if("Err"in o)throw wt(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 et(n.Err);return n.Ok};this.retrieveBtcWithApproval=async({address:r,amount:n,fromSubaccount:o})=>{let a=await this.caller({certified:!0}).retrieve_btc_with_approval({address:r,amount:n,from_subaccount:(0,x.toNullable)(o)});if("Err"in a)throw Rt(a.Err);return a.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,x.isNullish)(r)?[]:[{owner:r.owner,subaccount:(0,x.toNullable)(r.subaccount)}])).map(({block_index:c,status_v2:s})=>({id:c,status:(0,x.fromNullable)(s)}))};this.estimateWithdrawalFee=async({certified:r,amount:n})=>this.caller({certified:r}).estimate_withdrawal_fee({amount:(0,x.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:a}=this.caller({certified:o});return a({owner:(0,x.toNullable)(r),subaccount:(0,x.toNullable)(n)})}}static create(r){let{service:n,certifiedService:o,canisterId:a}=(0,x.createServices)({options:r,idlFactory:qt,certifiedIdlFactory:St});return new t(a,n,o)}};var Tt=require("@dfinity/utils");function _e(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function kt(t,...e){if(!_e(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function Ot(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 Mt(t,e){kt(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var ot=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),g=(t,e)=>t<<32-e|t>>>e;var De=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function de(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function vt(t){return typeof t=="string"&&(t=de(t)),kt(t),t}var nt=class{clone(){return this._cloneInto()}},tr={}.toString;function Gt(t){let e=n=>t().update(vt(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function pe(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let o=BigInt(32),a=BigInt(4294967295),c=Number(r>>o&a),s=Number(r&a),l=n?4:0,d=n?0:4;t.setUint32(e+l,c,n),t.setUint32(e+d,s,n)}var Wt=(t,e,r)=>t&e^~t&r,zt=(t,e,r)=>t&e^t&r^e&r,ct=class extends nt{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=ot(this.buffer)}update(e){Ot(this);let{view:r,buffer:n,blockLen:o}=this;e=vt(e);let a=e.length;for(let c=0;c<a;){let s=Math.min(o-this.pos,a-c);if(s===o){let l=ot(e);for(;o<=a-c;c+=o)this.process(l,c);continue}n.set(e.subarray(c,c+s),this.pos),this.pos+=s,c+=s,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ot(this),Mt(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:a}=this,{pos:c}=this;r[c++]=128,this.buffer.subarray(c).fill(0),this.padOffset>o-c&&(this.process(n,0),c=0);for(let i=c;i<o;i++)r[i]=0;pe(n,o-8,BigInt(this.length*8),a),this.process(n,0);let s=ot(e),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let d=l/4,_=this.get();if(d>_.length)throw new Error("_sha2: outputLen bigger than state");for(let i=0;i<d;i++)s.setUint32(4*i,_[i],a)}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:a,destroyed:c,pos:s}=this;return e.length=o,e.pos=s,e.finished=a,e.destroyed=c,o%r&&e.buffer.set(n),e}};var fe=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]),O=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),v=new Uint32Array(64),Vt=class extends ct{constructor(){super(64,32,8,!1),this.A=O[0]|0,this.B=O[1]|0,this.C=O[2]|0,this.D=O[3]|0,this.E=O[4]|0,this.F=O[5]|0,this.G=O[6]|0,this.H=O[7]|0}get(){let{A:e,B:r,C:n,D:o,E:a,F:c,G:s,H:l}=this;return[e,r,n,o,a,c,s,l]}set(e,r,n,o,a,c,s,l){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=a|0,this.F=c|0,this.G=s|0,this.H=l|0}process(e,r){for(let i=0;i<16;i++,r+=4)v[i]=e.getUint32(r,!1);for(let i=16;i<64;i++){let u=v[i-15],p=v[i-2],f=g(u,7)^g(u,18)^u>>>3,m=g(p,17)^g(p,19)^p>>>10;v[i]=m+v[i-7]+f+v[i-16]|0}let{A:n,B:o,C:a,D:c,E:s,F:l,G:d,H:_}=this;for(let i=0;i<64;i++){let u=g(s,6)^g(s,11)^g(s,25),p=_+u+Wt(s,l,d)+fe[i]+v[i]|0,m=(g(n,2)^g(n,13)^g(n,22))+zt(n,o,a)|0;_=d,d=l,l=s,s=c+p|0,c=a,a=o,o=n,n=p+m|0}n=n+this.A|0,o=o+this.B|0,a=a+this.C|0,c=c+this.D|0,s=s+this.E|0,l=l+this.F|0,d=d+this.G|0,_=_+this.H|0,this.set(n,o,a,c,s,l,d,_)}roundClean(){v.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Pt=Gt(()=>new Vt);var re=Ct(It()),j=Ct(ee());var Oe=0,ve=5,Ve=111,Pe=196,Ae={[Oe]:{type:1,networks:[0]},[Ve]:{type:1,networks:[2,1]},[ve]:{type:2,networks:[0]},[Pe]:{type:2,networks:[2,1]}},Be=({address:t,network:e})=>{let n=(_=>{try{return(0,re.base58_to_binary)(_)}catch{throw new U}})(t),{length:o}=n;if(o!==25)throw new A(`Expected the address to be 25 bytes, got ${o}.`);(_=>{let i=_.slice(o-4,o),u=_.slice(0,o-4),p=Pt.create();p.update(u);let f=Pt.create();f.update(p.digest());let m=f.digest().slice(0,4);if(i.some((b,h)=>b!==m[h]))throw new A(`Checksum mismatch expected ${i}, got ${m}.`)})(n);let c=n[0],s=Ae[c];if((0,Tt.isNullish)(s))throw new C;let{type:l,networks:d}=s;if(!d.includes(e))throw new H;return{address:t,network:e,type:l,parser:"base58"}},Te=({address:t,network:e})=>{let r=_=>{try{return _.startsWith("bc1p")||_.startsWith("tb1p")||_.startsWith("bcrt1p")?j.bech32m.decode(_):j.bech32.decode(_)}catch{throw new A}},{prefix:n,words:o}=r(t),c={bc:0,tb:2,bcrt:1}[n];if((0,Tt.isNullish)(c))throw new U;if(c!==e)throw new z;let[s,...l]=o;if(s>1)throw new W;switch(j.bech32.fromWords(l).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 G}},Ue=({address:t,network:e=0})=>{switch(t.charAt(0)){case"1":case"2":case"3":case"m":case"n":return Be({address:t,network:e});case"b":case"B":case"t":case"T":return Te({address:t,network:e});case"":throw new M;default:throw new C}};0&&(module.exports={BitcoinCanister,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,toGetBalanceParams,toGetUtxosParams});
2
2
  /*! Bundled license information:
3
3
 
4
4
  @noble/hashes/esm/utils.js: