@dfinity/ckbtc 6.0.1 → 7.0.0-beta-2025-12-18

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 CHANGED
@@ -29,10 +29,10 @@ npm i @icp-sdk/core @dfinity/utils
29
29
 
30
30
  ## Usage
31
31
 
32
- The features are available through the class `CkBTCMinterCanister`. It has to be instantiated with a canister ID.
32
+ The features are available through the class `CkBtcMinterCanister`. It has to be instantiated with a canister ID.
33
33
 
34
34
  ```ts
35
- import { CkBTCMinterCanister } from "@dfinity/ckbtc";
35
+ import { CkBtcMinterCanister } from "@dfinity/ckbtc";
36
36
  import { createAgent } from "@dfinity/utils";
37
37
 
38
38
  const agent = await createAgent({
@@ -40,7 +40,7 @@ const agent = await createAgent({
40
40
  host: HOST,
41
41
  });
42
42
 
43
- const { getBtcAddress } = CkBTCMinterCanister.create({
43
+ const { getBtcAddress } = CkBtcMinterCanister.create({
44
44
  agent,
45
45
  canisterId: MY_CKBTC_MINTER_CANISTER_ID,
46
46
  });
package/dist/index.d.ts CHANGED
@@ -1,15 +1,27 @@
1
+ import type { BitcoinDid, CkBtcMinterDid } from "@icp-sdk/canisters/ckbtc";
2
+ export type block_hash = BitcoinDid.block_hash;
3
+ export type block_height = BitcoinDid.block_height;
4
+ export type get_utxos_response = BitcoinDid.get_utxos_response;
5
+ export type outpoint = BitcoinDid.outpoint;
6
+ export type satoshi = BitcoinDid.satoshi;
7
+ export type utxo = BitcoinDid.utxo;
8
+ export type Account = CkBtcMinterDid.Account;
9
+ export type MinterInfo = CkBtcMinterDid.MinterInfo;
10
+ export type PendingUtxo = CkBtcMinterDid.PendingUtxo;
11
+ export type ReimbursedDeposit = CkBtcMinterDid.ReimbursedDeposit;
12
+ export type ReimbursementRequest = CkBtcMinterDid.ReimbursementRequest;
13
+ export type RetrieveBtcOk = CkBtcMinterDid.RetrieveBtcOk;
14
+ export type RetrieveBtcStatus = CkBtcMinterDid.RetrieveBtcStatus;
15
+ export type RetrieveBtcStatusV2 = CkBtcMinterDid.RetrieveBtcStatusV2;
16
+ export type Utxo = CkBtcMinterDid.Utxo;
17
+ export type UtxoStatus = CkBtcMinterDid.UtxoStatus;
18
+ export type WithdrawalAccount = CkBtcMinterDid.Account;
1
19
  /**
2
- * @module api/ckbtc
20
+ * @deprecated Use "@icp-sdk/canisters/ckbtc" directly instead
3
21
  */
4
- export { BitcoinCanister } from "./bitcoin.canister";
5
- export type { block_hash, block_height, get_utxos_response, outpoint, satoshi, utxo, } from "./candid/bitcoin";
6
- export type { Account, MinterInfo, PendingUtxo, ReimbursedDeposit, ReimbursementRequest, RetrieveBtcOk, RetrieveBtcStatus, RetrieveBtcStatusV2, Utxo, UtxoStatus, Account as WithdrawalAccount, } from "./candid/minter";
7
- export * from "./enums/btc.enums";
8
- export * from "./errors/btc.errors";
9
- export * from "./errors/minter.errors";
10
- export { CkBTCMinterCanister } from "./minter.canister";
11
- export * from "./types/bitcoin.params";
12
- export * from "./types/btc";
13
- export * from "./types/minter.params";
14
- export * from "./types/minter.responses";
15
- export * from "./utils/btc.utils";
22
+ export * from "@icp-sdk/canisters/ckbtc";
23
+ /**
24
+ * Legacy re-export for backward compatibility.
25
+ * @deprecated Use "@icp-sdk/canisters/ckbtc" directly instead
26
+ */
27
+ export { CkBtcMinterCanister as CkBTCMinterCanister, type CkBtcCanisterOptions as CkBTCCanisterOptions, } from "@icp-sdk/canisters/ckbtc";
package/dist/index.js CHANGED
@@ -1,7 +1,2 @@
1
- var Yt=Object.create;var At=Object.defineProperty;var Zt=Object.getOwnPropertyDescriptor;var It=Object.getOwnPropertyNames;var Lt=Object.getPrototypeOf,Dt=Object.prototype.hasOwnProperty;var te=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var ee=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of It(e))!Dt.call(t,o)&&o!==r&&At(t,o,{get:()=>e[o],enumerable:!(n=Zt(e,o))||n.enumerable});return t};var re=(t,e,r)=>(r=t!=null?Yt(Lt(t)):{},ee(e||!t||!t.__esModule?At(r,"default",{value:t,enumerable:!0}):r,t));var Xt=te(T=>{"use strict";Object.defineProperty(T,"__esModule",{value:!0});T.bech32m=T.bech32=void 0;var J="qpzry9x8gf2tvdw0s3jn54khce6mua7l",jt={};for(let t=0;t<J.length;t++){let e=J.charAt(t);jt[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 $t(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 Vt(t,e,r,n){let o=0,c=0,a=(1<<r)-1,i=[];for(let s=0;s<t.length;++s)for(o=o<<e|t[s],c+=e;c>=r;)c-=r,i.push(o>>c&a);if(n)c>0&&i.push(o<<r-c&a);else{if(c>=e)return"Excess padding";if(o<<r-c&a)return"Non-zero padding"}return i}function be(t){return Vt(t,8,5,!0)}function Ne(t){let e=Vt(t,5,8,!1);if(Array.isArray(e))return e}function ge(t){let e=Vt(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function Kt(t){let e;t==="bech32"?e=1:e=734539939;function r(a,i,s){if(s=s||90,a.length+7+i.length>s)throw new TypeError("Exceeds length limit");a=a.toLowerCase();let p=$t(a);if(typeof p=="string")throw new Error(p);let _=a+"1";for(let l=0;l<i.length;++l){let d=i[l];if(d>>5!==0)throw new Error("Non 5-bit word");p=P(p)^d,_+=J.charAt(d)}for(let l=0;l<6;++l)p=P(p);p^=e;for(let l=0;l<6;++l){let d=p>>(5-l)*5&31;_+=J.charAt(d)}return _}function n(a,i){if(i=i||90,a.length<8)return a+" too short";if(a.length>i)return"Exceeds length limit";let s=a.toLowerCase(),p=a.toUpperCase();if(a!==s&&a!==p)return"Mixed-case string "+a;a=s;let _=a.lastIndexOf("1");if(_===-1)return"No separator character for "+a;if(_===0)return"Missing prefix for "+a;let l=a.slice(0,_),d=a.slice(_+1);if(d.length<6)return"Data too short";let u=$t(l);if(typeof u=="string")return u;let f=[];for(let h=0;h<d.length;++h){let x=d.charAt(h),m=jt[x];if(m===void 0)return"Unknown character "+x;u=P(u)^m,!(h+6>=d.length)&&f.push(m)}return u!==e?"Invalid checksum for "+a:{prefix:l,words:f}}function o(a,i){let s=n(a,i);if(typeof s=="object")return s}function c(a,i){let s=n(a,i);if(typeof s=="object")return s;throw new Error(s)}return{decodeUnsafe:o,decode:c,encode:r,toWords:be,fromWordsUnsafe:Ne,fromWords:ge}}T.bech32=Kt("bech32");T.bech32m=Kt("bech32m")});import{Canister as ae,createServices as ce}from"@dfinity/utils";var Bt=({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)}),c=t.Text,a=t.Record({network:n,address:c,min_confirmations:t.Opt(t.Nat32)}),i=t.Nat64,s=t.Nat32,p=t.Record({start_height:s,end_height:t.Opt(s),network:n}),_=t.Vec(t.Nat8),l=t.Record({tip_height:s,block_headers:t.Vec(_)}),d=t.Record({network:n}),u=t.Nat64,f=t.Record({network:n,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:c}),h=t.Vec(t.Nat8),x=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),m=t.Record({height:s,value:i,outpoint:x}),g=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:s,tip_block_hash:h,utxos:t.Vec(m)}),y=t.Record({transaction:t.Vec(t.Nat8),network:n}),O=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}),v=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([a],[i],[]),bitcoin_get_balance_query:t.Func([a],[i],[]),bitcoin_get_block_headers:t.Func([p],[l],[]),bitcoin_get_current_fee_percentiles:t.Func([d],[t.Vec(u)],[]),bitcoin_get_utxos:t.Func([f],[g],[]),bitcoin_get_utxos_query:t.Func([f],[g],[]),bitcoin_send_transaction:t.Func([y],[],[]),get_config:t.Func([],[O],[]),set_config:t.Func([v],[],[])})};var Pt=({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)}),c=t.Text,a=t.Record({network:n,address:c,min_confirmations:t.Opt(t.Nat32)}),i=t.Nat64,s=t.Nat32,p=t.Record({start_height:s,end_height:t.Opt(s),network:n}),_=t.Vec(t.Nat8),l=t.Record({tip_height:s,block_headers:t.Vec(_)}),d=t.Record({network:n}),u=t.Nat64,f=t.Record({network:n,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:c}),h=t.Vec(t.Nat8),x=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),m=t.Record({height:s,value:i,outpoint:x}),g=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:s,tip_block_hash:h,utxos:t.Vec(m)}),y=t.Record({transaction:t.Vec(t.Nat8),network:n}),O=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}),v=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([a],[i],[]),bitcoin_get_balance_query:t.Func([a],[i],["query"]),bitcoin_get_block_headers:t.Func([p],[l],[]),bitcoin_get_current_fee_percentiles:t.Func([d],[t.Vec(u)],[]),bitcoin_get_utxos:t.Func([f],[g],[]),bitcoin_get_utxos_query:t.Func([f],[g],["query"]),bitcoin_send_transaction:t.Func([y],[],[]),get_config:t.Func([],[O],["query"]),set_config:t.Func([v],[],[])})};import{nonNullish as ne,toNullable as lt}from"@dfinity/utils";var oe={mainnet:{mainnet:null},testnet:{testnet:null},regtest:{regtest:null}},Tt=({network:t,filter:e,...r})=>({filter:ne(e)?lt("minConfirmations"in e?{min_confirmations:e.minConfirmations}:{page:e.page}):lt(),network:t==="testnet"?{testnet:null}:{mainnet:null},...r}),Ut=({network:t,minConfirmations:e,...r})=>({min_confirmations:lt(e),network:oe[t],...r});var ut=class t extends ae{static create(e){let{service:r,certifiedService:n,canisterId:o}=ce({options:e,idlFactory:Pt,certifiedIdlFactory:Bt});return new t(o,r,n)}getUtxosQuery=({...e})=>{let{bitcoin_get_utxos_query:r}=this.caller({certified:!1});return r(Tt(e))};getBalanceQuery=({...e})=>{let{bitcoin_get_balance_query:r}=this.caller({certified:!1});return r(Ut(e))}};var Ft=(n=>(n[n.Mainnet=0]="Mainnet",n[n.Regtest=1]="Regtest",n[n.Testnet=2]="Testnet",n))(Ft||{}),Et=(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))(Et||{});var N=class extends Error{},E=class extends N{},q=class extends N{},S=class extends N{},G=class extends N{},W=class extends N{},M=class extends N{},B=class extends N{},z=class extends N{};import{fromNullable as ie,nonNullish as bt}from"@dfinity/utils";var V=class extends Error{},dt=class extends V{},_t=class extends V{},Q=class extends V{},pt=class extends Q{pendingUtxos;requiredConfirmations;constructor({pending_utxos:e,required_confirmations:r}){super(),this.pendingUtxos=ie(e)??[],this.requiredConfirmations=r}},A=class extends V{},ft=class extends A{},ht=class extends A{},xt=class extends A{},mt=class extends A{},Nt=t=>{if("GenericError"in t){let{GenericError:{error_message:e,error_code:r}}=t;return new V(`${e} (${r})`)}if("TemporarilyUnavailable"in t)return new dt(t.TemporarilyUnavailable);if("AlreadyProcessing"in t)return new _t},St=t=>{let e=Nt(t);return bt(e)?e:"NoNewUtxos"in t?new pt(t.NoNewUtxos):new Q(`Unsupported response type in minter.updateBalance ${JSON.stringify(t)}`)},gt=t=>{let e=Nt(t);return bt(e)?e:"MalformedAddress"in t?new ft(t.MalformedAddress):"AmountTooLow"in t?new ht(`${t.AmountTooLow}`):"InsufficientFunds"in t?new xt(`${t.InsufficientFunds.balance}`):new A(`Unsupported response type in minter.retrieveBtc ${JSON.stringify(t)}`)},Ct=t=>{let e=Nt(t);return bt(e)?e:"InsufficientAllowance"in t?new mt(`${t.InsufficientAllowance.allowance}`):gt(t)};import{Canister as se,createServices as le,fromNullable as ue,isNullish as de,toNullable as w}from"@dfinity/utils";var Ht=({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({get_utxos_cache_expiration_seconds:t.Opt(t.Nat64),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({get_utxos_cache_expiration_seconds:t.Opt(t.Nat64),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)}),c=t.Variant({Upgrade:t.Opt(r),Init:o}),a=t.Record({wasm_binary_size:t.Nat,wasm_chunk_store_size:t.Nat,canister_history_size:t.Nat,stable_memory_size:t.Nat,snapshots_size:t.Nat,wasm_memory_size:t.Nat,global_memory_size:t.Nat,custom_sections_size:t.Nat}),i=t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),s=t.Variant({controllers:t.Null,public:t.Null,allowed_viewers:t.Vec(t.Principal)}),p=t.Record({freezing_threshold:t.Nat,wasm_memory_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}),_=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({memory_metrics:a,status:i,memory_size:t.Nat,cycles:t.Nat,settings:p,query_stats:_,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8)),reserved_cycles:t.Nat}),d=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})}),f=t.Variant({CallFailed:t.Null,TaintedDestination:t.Record({kyt_fee:t.Nat64,kyt_provider:t.Principal})}),h=t.Record({minter_fee:t.Nat64,bitcoin_fee:t.Nat64}),x=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)}),g=t.Variant({too_many_inputs:t.Record({max_num_inputs:t.Nat64,num_inputs:t.Nat64})}),y=t.Variant({invalid_transaction:g}),O=t.Variant({to_cancel:t.Record({reason:y}),to_retry:t.Null}),v=t.Variant({received_utxos:t.Record({to_account:d,mint_txid:t.Opt(t.Nat64),utxos:t.Vec(u)}),schedule_deposit_reimbursement:t.Record({burn_block_index:t.Nat64,account:d,amount:t.Nat64,reason:f}),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),withdrawal_fee:t.Opt(h),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:d,reason:x}),accepted_retrieve_btc_request:t.Record({received_at:t.Nat64,block_index:t.Nat64,address:m,reimbursement_account:t.Opt(d),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)}),schedule_withdrawal_reimbursement:t.Record({burn_block_index:t.Nat64,account:d,amount:t.Nat64,reason:y}),quarantined_withdrawal_reimbursement:t.Record({burn_block_index:t.Nat64}),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}),new_utxos:t.Opt(t.Vec(u)),old_txid:t.Vec(t.Nat8),withdrawal_fee:t.Opt(h),new_txid:t.Vec(t.Nat8),submitted_at:t.Nat64,reason:t.Opt(O)}),checked_utxo_v2:t.Record({utxo:u,account:d}),ignored_utxo:t.Record({utxo:u}),checked_utxo_mint_unknown:t.Record({utxo:u,account:d}),reimbursed_failed_deposit:t.Record({burn_block_index:t.Nat64,mint_block_index:t.Nat64}),reimbursed_withdrawal:t.Record({burn_block_index:t.Nat64,mint_block_index:t.Nat64})}),Y=t.Record({timestamp:t.Opt(t.Nat64),payload:v}),Z=t.Record({retrieve_btc_min_amount:t.Nat64,min_confirmations:t.Nat32,kyt_fee:t.Nat64}),I=t.Record({address:t.Text,amount:t.Nat64}),U=t.Record({block_index:t.Nat64}),L=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})}),D=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}),tt=t.Record({account:d,amount:t.Nat64,reason:f}),et=t.Record({account:d,mint_block_index:t.Nat64,amount:t.Nat64,reason:f}),F=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:tt,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Reimbursed:et,Pending:t.Null}),rt=t.Record({from_subaccount:t.Opt(t.Vec(t.Nat8)),address:t.Text,amount:t.Nat64}),nt=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})}),ot=t.Variant({ValueTooSmall:u,Tainted:u,Minted:t.Record({minted_amount:t.Nat64,block_index:t.Nat64,utxo:u}),Checked:u}),at=t.Nat64,ct=t.Record({utxo:u,earliest_retry:at,reason:x}),it=t.Record({confirmations:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),st=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(ct)),required_confirmations:t.Nat32,pending_utxos:t.Opt(t.Vec(it)),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(Y)],[]),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([],[Z],[]),get_withdrawal_account:t.Func([],[d],[]),retrieve_btc:t.Func([I],[t.Variant({Ok:U,Err:L})],[]),retrieve_btc_status:t.Func([t.Record({block_index:t.Nat64})],[D],[]),retrieve_btc_status_v2:t.Func([t.Record({block_index:t.Nat64})],[F],[]),retrieve_btc_status_v2_by_account:t.Func([t.Opt(d)],[t.Vec(t.Record({block_index:t.Nat64,status_v2:t.Opt(F)}))],[]),retrieve_btc_with_approval:t.Func([rt],[t.Variant({Ok:U,Err:nt})],[]),update_balance:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Variant({Ok:t.Vec(ot),Err:st})],[])})};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({get_utxos_cache_expiration_seconds:t.Opt(t.Nat64),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({get_utxos_cache_expiration_seconds:t.Opt(t.Nat64),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)}),c=t.Variant({Upgrade:t.Opt(r),Init:o}),a=t.Record({wasm_binary_size:t.Nat,wasm_chunk_store_size:t.Nat,canister_history_size:t.Nat,stable_memory_size:t.Nat,snapshots_size:t.Nat,wasm_memory_size:t.Nat,global_memory_size:t.Nat,custom_sections_size:t.Nat}),i=t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),s=t.Variant({controllers:t.Null,public:t.Null,allowed_viewers:t.Vec(t.Principal)}),p=t.Record({freezing_threshold:t.Nat,wasm_memory_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}),_=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({memory_metrics:a,status:i,memory_size:t.Nat,cycles:t.Nat,settings:p,query_stats:_,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8)),reserved_cycles:t.Nat}),d=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})}),f=t.Variant({CallFailed:t.Null,TaintedDestination:t.Record({kyt_fee:t.Nat64,kyt_provider:t.Principal})}),h=t.Record({minter_fee:t.Nat64,bitcoin_fee:t.Nat64}),x=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)}),g=t.Variant({too_many_inputs:t.Record({max_num_inputs:t.Nat64,num_inputs:t.Nat64})}),y=t.Variant({invalid_transaction:g}),O=t.Variant({to_cancel:t.Record({reason:y}),to_retry:t.Null}),v=t.Variant({received_utxos:t.Record({to_account:d,mint_txid:t.Opt(t.Nat64),utxos:t.Vec(u)}),schedule_deposit_reimbursement:t.Record({burn_block_index:t.Nat64,account:d,amount:t.Nat64,reason:f}),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),withdrawal_fee:t.Opt(h),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:d,reason:x}),accepted_retrieve_btc_request:t.Record({received_at:t.Nat64,block_index:t.Nat64,address:m,reimbursement_account:t.Opt(d),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)}),schedule_withdrawal_reimbursement:t.Record({burn_block_index:t.Nat64,account:d,amount:t.Nat64,reason:y}),quarantined_withdrawal_reimbursement:t.Record({burn_block_index:t.Nat64}),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}),new_utxos:t.Opt(t.Vec(u)),old_txid:t.Vec(t.Nat8),withdrawal_fee:t.Opt(h),new_txid:t.Vec(t.Nat8),submitted_at:t.Nat64,reason:t.Opt(O)}),checked_utxo_v2:t.Record({utxo:u,account:d}),ignored_utxo:t.Record({utxo:u}),checked_utxo_mint_unknown:t.Record({utxo:u,account:d}),reimbursed_failed_deposit:t.Record({burn_block_index:t.Nat64,mint_block_index:t.Nat64}),reimbursed_withdrawal:t.Record({burn_block_index:t.Nat64,mint_block_index:t.Nat64})}),Y=t.Record({timestamp:t.Opt(t.Nat64),payload:v}),Z=t.Record({retrieve_btc_min_amount:t.Nat64,min_confirmations:t.Nat32,kyt_fee:t.Nat64}),I=t.Record({address:t.Text,amount:t.Nat64}),U=t.Record({block_index:t.Nat64}),L=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})}),D=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}),tt=t.Record({account:d,amount:t.Nat64,reason:f}),et=t.Record({account:d,mint_block_index:t.Nat64,amount:t.Nat64,reason:f}),F=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:tt,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Reimbursed:et,Pending:t.Null}),rt=t.Record({from_subaccount:t.Opt(t.Vec(t.Nat8)),address:t.Text,amount:t.Nat64}),nt=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})}),ot=t.Variant({ValueTooSmall:u,Tainted:u,Minted:t.Record({minted_amount:t.Nat64,block_index:t.Nat64,utxo:u}),Checked:u}),at=t.Nat64,ct=t.Record({utxo:u,earliest_retry:at,reason:x}),it=t.Record({confirmations:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),st=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(ct)),required_confirmations:t.Nat32,pending_utxos:t.Opt(t.Vec(it)),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(Y)],["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([],[Z],["query"]),get_withdrawal_account:t.Func([],[d],[]),retrieve_btc:t.Func([I],[t.Variant({Ok:U,Err:L})],[]),retrieve_btc_status:t.Func([t.Record({block_index:t.Nat64})],[D],["query"]),retrieve_btc_status_v2:t.Func([t.Record({block_index:t.Nat64})],[F],["query"]),retrieve_btc_status_v2_by_account:t.Func([t.Opt(d)],[t.Vec(t.Record({block_index:t.Nat64,status_v2:t.Opt(F)}))],["query"]),retrieve_btc_with_approval:t.Func([rt],[t.Variant({Ok:U,Err:nt})],[]),update_balance:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Variant({Ok:t.Vec(ot),Err:st})],[])})};var yt=class t extends se{static create(e){let{service:r,certifiedService:n,canisterId:o}=le({options:e,idlFactory:qt,certifiedIdlFactory:Ht});return new t(o,r,n)}getBtcAddress=({owner:e,subaccount:r})=>this.caller({certified:!0}).get_btc_address({owner:w(e),subaccount:w(r)});updateBalance=async({owner:e,subaccount:r})=>{let n=await this.caller({certified:!0}).update_balance({owner:w(e),subaccount:w(r)});if("Err"in n)throw St(n.Err);return n.Ok};getWithdrawalAccount=()=>this.caller({certified:!0}).get_withdrawal_account();retrieveBtc=async e=>{let r=await this.caller({certified:!0}).retrieve_btc(e);if("Err"in r)throw gt(r.Err);return r.Ok};retrieveBtcWithApproval=async({address:e,amount:r,fromSubaccount:n})=>{let o=await this.caller({certified:!0}).retrieve_btc_with_approval({address:e,amount:r,from_subaccount:w(n)});if("Err"in o)throw Ct(o.Err);return o.Ok};retrieveBtcStatus=({transactionId:e,certified:r})=>this.caller({certified:r}).retrieve_btc_status({block_index:e});retrieveBtcStatusV2ByAccount=async({account:e,certified:r})=>{let{retrieve_btc_status_v2_by_account:n}=this.caller({certified:r});return(await n(de(e)?[]:[{owner:e.owner,subaccount:w(e.subaccount)}])).map(({block_index:c,status_v2:a})=>({id:c,status:ue(a)}))};estimateWithdrawalFee=({certified:e,amount:r})=>this.caller({certified:e}).estimate_withdrawal_fee({amount:w(r)});getMinterInfo=({certified:e})=>this.caller({certified:e}).get_minter_info();getKnownUtxos=({owner:e,subaccount:r,certified:n})=>{let{get_known_utxos:o}=this.caller({certified:n});return o({owner:w(e),subaccount:w(r)})}};import{isNullish as Jt}from"@dfinity/utils";function _e(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function j(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+", got 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 Gt(t,e){j(t);let r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function C(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function K(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function b(t,e){return t<<32-e|t>>>e}function pe(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function Rt(t){return typeof t=="string"&&(t=pe(t)),j(t),t}var $=class{};function Wt(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 fe(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let o=BigInt(32),c=BigInt(4294967295),a=Number(r>>o&c),i=Number(r&c),s=n?4:0,p=n?0:4;t.setUint32(e+s,a,n),t.setUint32(e+p,i,n)}function Mt(t,e,r){return t&e^~t&r}function zt(t,e,r){return t&e^t&r^e&r}var X=class extends ${constructor(e,r,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(e),this.view=K(this.buffer)}update(e){wt(this),e=Rt(e),j(e);let{view:r,buffer:n,blockLen:o}=this,c=e.length;for(let a=0;a<c;){let i=Math.min(o-this.pos,c-a);if(i===o){let s=K(e);for(;o<=c-a;a+=o)this.process(s,a);continue}n.set(e.subarray(a,a+i),this.pos),this.pos+=i,a+=i,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){wt(this),Gt(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:c}=this,{pos:a}=this;r[a++]=128,C(this.buffer.subarray(a)),this.padOffset>o-a&&(this.process(n,0),a=0);for(let l=a;l<o;l++)r[l]=0;fe(n,o-8,BigInt(this.length*8),c),this.process(n,0);let i=K(e),s=this.outputLen;if(s%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let p=s/4,_=this.get();if(p>_.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<p;l++)i.setUint32(4*l,_[l],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:a,pos:i}=this;return e.destroyed=a,e.finished=c,e.length=o,e.pos=i,o%r&&e.buffer.set(n),e}clone(){return this._cloneInto()}},R=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var he=Uint32Array.from([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(64),kt=class extends X{constructor(e=32){super(64,e,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:a,G:i,H:s}=this;return[e,r,n,o,c,a,i,s]}set(e,r,n,o,c,a,i,s){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=c|0,this.F=a|0,this.G=i|0,this.H=s|0}process(e,r){for(let l=0;l<16;l++,r+=4)k[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){let d=k[l-15],u=k[l-2],f=b(d,7)^b(d,18)^d>>>3,h=b(u,17)^b(u,19)^u>>>10;k[l]=h+k[l-7]+f+k[l-16]|0}let{A:n,B:o,C:c,D:a,E:i,F:s,G:p,H:_}=this;for(let l=0;l<64;l++){let d=b(i,6)^b(i,11)^b(i,25),u=_+d+Mt(i,s,p)+he[l]+k[l]|0,h=(b(n,2)^b(n,13)^b(n,22))+zt(n,o,c)|0;_=p,p=s,s=i,i=a+u|0,a=c,c=o,o=n,n=u+h|0}n=n+this.A|0,o=o+this.B|0,c=c+this.C|0,a=a+this.D|0,i=i+this.E|0,s=s+this.F|0,p=p+this.G|0,_=_+this.H|0,this.set(n,o,c,a,i,s,p,_)}roundClean(){C(k)}destroy(){this.set(0,0,0,0,0,0,0,0),C(this.buffer)}};var Ot=Wt(()=>new kt);var xe="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Qt=xe;function me(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=>Qt.indexOf(o)).reduce((o,c)=>(o=o.map(a=>{let i=a*58+c;return c=i>>8,i}),o),new Uint8Array(n)).reverse().filter((o=>c=>o=o||c)(!1))])}var vt=me;var H=re(Xt(),1);var ye=0,we=5,Re=111,ke=196,Oe={[ye]:{type:1,networks:[0]},[Re]:{type:1,networks:[2,1]},[we]:{type:2,networks:[0]},[ke]:{type:2,networks:[2,1]}},ve=({address:t,network:e})=>{let n=(_=>{try{return vt(_)}catch{throw new E}})(t),{length:o}=n;if(o!==25)throw new B(`Expected the address to be 25 bytes, got ${o}.`);(_=>{let l=_.slice(o-4,o),d=_.slice(0,o-4),u=Ot.create();u.update(d);let f=Ot.create();f.update(u.digest());let h=f.digest().slice(0,4);if(l.some((x,m)=>x!==h[m]))throw new B(`Checksum mismatch expected ${l}, got ${h}.`)})(n);let[a]=n,i=Oe[a];if(Jt(i))throw new S;let{type:s,networks:p}=i;if(!p.includes(e))throw new z;return{address:t,network:e,type:s,parser:"base58"}},Ve=({address:t,network:e})=>{let r=_=>{try{return _.startsWith("bc1p")||_.startsWith("tb1p")||_.startsWith("bcrt1p")?H.bech32m.decode(_):H.bech32.decode(_)}catch{throw new B}},{prefix:n,words:o}=r(t),a={bc:0,tb:2,bcrt:1}[n];if(Jt(a))throw new E;if(a!==e)throw new M;let[i,...s]=o;if(i>1)throw new W;switch(H.bech32.fromWords(s).length){case 20:return{address:t,network:e,type:0,parser:"bip-173"};case 32:return{address:t,network:e,type:i===0?3:4,parser:"bip-173"};default:throw new G}},hr=({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 Ve({address:t,network:e});case"":throw new q;default:throw new S}};export{ut as BitcoinCanister,Et as BtcAddressType,Ft as BtcNetwork,yt as CkBTCMinterCanister,_t as MinterAlreadyProcessingError,ht as MinterAmountTooLowError,V as MinterGenericError,mt as MinterInsufficientAllowanceError,xt as MinterInsufficientFundsError,ft as MinterMalformedAddressError,pt as MinterNoNewUtxosError,A as MinterRetrieveBtcError,dt as MinterTemporaryUnavailableError,Q as MinterUpdateBalanceError,G as ParseBtcAddressBadWitnessLengthError,N as ParseBtcAddressError,E as ParseBtcAddressInvalidError,B as ParseBtcAddressMalformedAddressError,q as ParseBtcAddressNoDataError,M as ParseBtcAddressUnexpectedHumanReadablePartError,S as ParseBtcAddressUnsupportedAddressTypeError,W as ParseBtcAddressUnsupportedWitnessVersionError,z as ParseBtcAddressWrongNetworkError,gt as createRetrieveBtcError,Ct as createRetrieveBtcWithApprovalError,St as createUpdateBalanceError,hr as parseBtcAddress,Ut as toGetBalanceParams,Tt as toGetUtxosParams};
2
- /*! Bundled license information:
3
-
4
- @noble/hashes/esm/utils.js:
5
- (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
6
- */
1
+ export*from"@icp-sdk/canisters/ckbtc";import{CkBtcMinterCanister as o}from"@icp-sdk/canisters/ckbtc";export{o as CkBTCMinterCanister};
7
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../node_modules/bech32/dist/index.js", "../src/bitcoin.canister.ts", "../src/candid/bitcoin.certified.idl.js", "../src/candid/bitcoin.idl.js", "../src/types/bitcoin.params.ts", "../src/enums/btc.enums.ts", "../src/errors/btc.errors.ts", "../src/errors/minter.errors.ts", "../src/minter.canister.ts", "../src/candid/minter.certified.idl.js", "../src/candid/minter.idl.js", "../src/utils/btc.utils.ts", "../../../node_modules/@noble/hashes/src/utils.ts", "../../../node_modules/@noble/hashes/src/_md.ts", "../../../node_modules/@noble/hashes/src/sha2.ts", "../node_modules/base58-js/base58_chars.js", "../node_modules/base58-js/base58_to_binary.js"],
4
- "sourcesContent": ["'use strict';\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.bech32m = exports.bech32 = void 0;\nconst ALPHABET = 'qpzry9x8gf2tvdw0s3jn54khce6mua7l';\nconst ALPHABET_MAP = {};\nfor (let z = 0; z < ALPHABET.length; z++) {\n const x = ALPHABET.charAt(z);\n ALPHABET_MAP[x] = z;\n}\nfunction polymodStep(pre) {\n const b = pre >> 25;\n return (((pre & 0x1ffffff) << 5) ^\n (-((b >> 0) & 1) & 0x3b6a57b2) ^\n (-((b >> 1) & 1) & 0x26508e6d) ^\n (-((b >> 2) & 1) & 0x1ea119fa) ^\n (-((b >> 3) & 1) & 0x3d4233dd) ^\n (-((b >> 4) & 1) & 0x2a1462b3));\n}\nfunction prefixChk(prefix) {\n let chk = 1;\n for (let i = 0; i < prefix.length; ++i) {\n const c = prefix.charCodeAt(i);\n if (c < 33 || c > 126)\n return 'Invalid prefix (' + prefix + ')';\n chk = polymodStep(chk) ^ (c >> 5);\n }\n chk = polymodStep(chk);\n for (let i = 0; i < prefix.length; ++i) {\n const v = prefix.charCodeAt(i);\n chk = polymodStep(chk) ^ (v & 0x1f);\n }\n return chk;\n}\nfunction convert(data, inBits, outBits, pad) {\n let value = 0;\n let bits = 0;\n const maxV = (1 << outBits) - 1;\n const result = [];\n for (let i = 0; i < data.length; ++i) {\n value = (value << inBits) | data[i];\n bits += inBits;\n while (bits >= outBits) {\n bits -= outBits;\n result.push((value >> bits) & maxV);\n }\n }\n if (pad) {\n if (bits > 0) {\n result.push((value << (outBits - bits)) & maxV);\n }\n }\n else {\n if (bits >= inBits)\n return 'Excess padding';\n if ((value << (outBits - bits)) & maxV)\n return 'Non-zero padding';\n }\n return result;\n}\nfunction toWords(bytes) {\n return convert(bytes, 8, 5, true);\n}\nfunction fromWordsUnsafe(words) {\n const res = convert(words, 5, 8, false);\n if (Array.isArray(res))\n return res;\n}\nfunction fromWords(words) {\n const res = convert(words, 5, 8, false);\n if (Array.isArray(res))\n return res;\n throw new Error(res);\n}\nfunction getLibraryFromEncoding(encoding) {\n let ENCODING_CONST;\n if (encoding === 'bech32') {\n ENCODING_CONST = 1;\n }\n else {\n ENCODING_CONST = 0x2bc830a3;\n }\n function encode(prefix, words, LIMIT) {\n LIMIT = LIMIT || 90;\n if (prefix.length + 7 + words.length > LIMIT)\n throw new TypeError('Exceeds length limit');\n prefix = prefix.toLowerCase();\n // determine chk mod\n let chk = prefixChk(prefix);\n if (typeof chk === 'string')\n throw new Error(chk);\n let result = prefix + '1';\n for (let i = 0; i < words.length; ++i) {\n const x = words[i];\n if (x >> 5 !== 0)\n throw new Error('Non 5-bit word');\n chk = polymodStep(chk) ^ x;\n result += ALPHABET.charAt(x);\n }\n for (let i = 0; i < 6; ++i) {\n chk = polymodStep(chk);\n }\n chk ^= ENCODING_CONST;\n for (let i = 0; i < 6; ++i) {\n const v = (chk >> ((5 - i) * 5)) & 0x1f;\n result += ALPHABET.charAt(v);\n }\n return result;\n }\n function __decode(str, LIMIT) {\n LIMIT = LIMIT || 90;\n if (str.length < 8)\n return str + ' too short';\n if (str.length > LIMIT)\n return 'Exceeds length limit';\n // don't allow mixed case\n const lowered = str.toLowerCase();\n const uppered = str.toUpperCase();\n if (str !== lowered && str !== uppered)\n return 'Mixed-case string ' + str;\n str = lowered;\n const split = str.lastIndexOf('1');\n if (split === -1)\n return 'No separator character for ' + str;\n if (split === 0)\n return 'Missing prefix for ' + str;\n const prefix = str.slice(0, split);\n const wordChars = str.slice(split + 1);\n if (wordChars.length < 6)\n return 'Data too short';\n let chk = prefixChk(prefix);\n if (typeof chk === 'string')\n return chk;\n const words = [];\n for (let i = 0; i < wordChars.length; ++i) {\n const c = wordChars.charAt(i);\n const v = ALPHABET_MAP[c];\n if (v === undefined)\n return 'Unknown character ' + c;\n chk = polymodStep(chk) ^ v;\n // not in the checksum?\n if (i + 6 >= wordChars.length)\n continue;\n words.push(v);\n }\n if (chk !== ENCODING_CONST)\n return 'Invalid checksum for ' + str;\n return { prefix, words };\n }\n function decodeUnsafe(str, LIMIT) {\n const res = __decode(str, LIMIT);\n if (typeof res === 'object')\n return res;\n }\n function decode(str, LIMIT) {\n const res = __decode(str, LIMIT);\n if (typeof res === 'object')\n return res;\n throw new Error(res);\n }\n return {\n decodeUnsafe,\n decode,\n encode,\n toWords,\n fromWordsUnsafe,\n fromWords,\n };\n}\nexports.bech32 = getLibraryFromEncoding('bech32');\nexports.bech32m = getLibraryFromEncoding('bech32m');\n", "import { Canister, createServices } from \"@dfinity/utils\";\nimport type {\n _SERVICE as BitcoinService,\n get_utxos_response,\n satoshi,\n} from \"./candid/bitcoin\";\nimport { idlFactory as certifiedIdlFactory } from \"./candid/bitcoin.certified.idl\";\nimport { idlFactory } from \"./candid/bitcoin.idl\";\nimport {\n toGetBalanceParams,\n toGetUtxosParams,\n type GetBalanceParams,\n type GetUtxosParams,\n} from \"./types/bitcoin.params\";\nimport type { CkBTCCanisterOptions } from \"./types/canister.options\";\n\nexport class BitcoinCanister extends Canister<BitcoinService> {\n static create(options: CkBTCCanisterOptions<BitcoinService>) {\n const { service, certifiedService, canisterId } =\n createServices<BitcoinService>({\n options,\n idlFactory,\n certifiedIdlFactory,\n });\n\n return new BitcoinCanister(canisterId, service, certifiedService);\n }\n\n /**\n * Given a `get_utxos_request`, which must specify a Bitcoin address and a Bitcoin network (`mainnet`, `testnet` or `regtest`), the function returns all unspent transaction outputs (UTXOs) associated with the provided address in the specified Bitcoin network based on the current view of the Bitcoin blockchain available to the Bitcoin component.\n *\n * \u26A0\uFE0F Note that this method does not support certified calls because only canisters are allowed to get UTXOs via update calls.\n *\n * @link https://internetcomputer.org/docs/current/references/ic-interface-spec#ic-bitcoin_get_utxos\n *\n * @param {Object} params\n * @param {BitcoinNetwork} params.network Tesnet or mainnet.\n * @param {Object} params.filter The optional filter parameter can be used to restrict the set of returned UTXOs, either providing a minimum number of confirmations or a page reference when pagination is used for addresses with many UTXOs.\n * @param {string} params.address A Bitcoin address.\n * @returns {Promise<bitcoin_get_utxos_result>} The UTXOs are returned sorted by block height in descending order.\n */\n getUtxosQuery = ({\n ...params\n }: GetUtxosParams): Promise<get_utxos_response> => {\n const { bitcoin_get_utxos_query } = this.caller({\n certified: false,\n });\n return bitcoin_get_utxos_query(toGetUtxosParams(params));\n };\n\n /**\n * Given a `get_balance_request`, which must specify a Bitcoin address and a Bitcoin network (`mainnet`, `testnet` or `regtest`), the function returns the current balance of this address in `Satoshi` (10^8 Satoshi = 1 Bitcoin) in the specified Bitcoin network.\n *\n * \u26A0\uFE0F Note that this method does not support certified calls because only canisters are allowed to get Bitcoin balance via update calls.\n *\n * @link https://internetcomputer.org/docs/current/references/ic-interface-spec#ic-bitcoin_get_balance\n *\n * @param {Object} params\n * @param {BitcoinNetwork} params.network Tesnet or mainnet.\n * @param {Object} params.min_confirmations The optional filter parameter can be used to limit the set of considered UTXOs for the calculation of the balance to those with at least the provided number of confirmations in the same manner as for the `bitcoin_get_utxos` call.\n * @param {string} params.address A Bitcoin address.\n * @returns {Promise<satoshi>} The balance is returned in `Satoshi` (10^8 Satoshi = 1 Bitcoin).\n */\n getBalanceQuery = ({ ...params }: GetBalanceParams): Promise<satoshi> => {\n const { bitcoin_get_balance_query } = this.caller({\n certified: false,\n });\n return bitcoin_get_balance_query(toGetBalanceParams(params));\n };\n}\n", "/* eslint-disable */\n\n// @ts-nocheck\n\n// This file was automatically generated by @icp-sdk/bindgen@0.2.0.\n// You should NOT make any changes in this file as it will be overwritten.\n// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.\n\nexport const idlFactory = ({ IDL }) => {\n const flag = IDL.Variant({ disabled: IDL.Null, enabled: IDL.Null });\n const fees = IDL.Record({\n get_current_fee_percentiles: IDL.Nat,\n get_utxos_maximum: IDL.Nat,\n get_block_headers_cycles_per_ten_instructions: IDL.Nat,\n get_current_fee_percentiles_maximum: IDL.Nat,\n send_transaction_per_byte: IDL.Nat,\n get_balance: IDL.Nat,\n get_utxos_cycles_per_ten_instructions: IDL.Nat,\n get_block_headers_base: IDL.Nat,\n get_utxos_base: IDL.Nat,\n get_balance_maximum: IDL.Nat,\n send_transaction_base: IDL.Nat,\n get_block_headers_maximum: IDL.Nat,\n });\n const network = IDL.Variant({\n mainnet: IDL.Null,\n regtest: IDL.Null,\n testnet: IDL.Null,\n });\n const init_config = IDL.Record({\n api_access: IDL.Opt(flag),\n lazily_evaluate_fee_percentiles: IDL.Opt(flag),\n blocks_source: IDL.Opt(IDL.Principal),\n fees: IDL.Opt(fees),\n watchdog_canister: IDL.Opt(IDL.Opt(IDL.Principal)),\n network: IDL.Opt(network),\n stability_threshold: IDL.Opt(IDL.Nat),\n syncing: IDL.Opt(flag),\n burn_cycles: IDL.Opt(flag),\n disable_api_if_not_fully_synced: IDL.Opt(flag),\n });\n const address = IDL.Text;\n const get_balance_request = IDL.Record({\n network: network,\n address: address,\n min_confirmations: IDL.Opt(IDL.Nat32),\n });\n const satoshi = IDL.Nat64;\n const block_height = IDL.Nat32;\n const get_block_headers_request = IDL.Record({\n start_height: block_height,\n end_height: IDL.Opt(block_height),\n network: network,\n });\n const block_header = IDL.Vec(IDL.Nat8);\n const get_block_headers_response = IDL.Record({\n tip_height: block_height,\n block_headers: IDL.Vec(block_header),\n });\n const get_current_fee_percentiles_request = IDL.Record({\n network: network,\n });\n const millisatoshi_per_byte = IDL.Nat64;\n const get_utxos_request = IDL.Record({\n network: network,\n filter: IDL.Opt(\n IDL.Variant({\n page: IDL.Vec(IDL.Nat8),\n min_confirmations: IDL.Nat32,\n }),\n ),\n address: address,\n });\n const block_hash = IDL.Vec(IDL.Nat8);\n const outpoint = IDL.Record({\n txid: IDL.Vec(IDL.Nat8),\n vout: IDL.Nat32,\n });\n const utxo = IDL.Record({\n height: block_height,\n value: satoshi,\n outpoint: outpoint,\n });\n const get_utxos_response = IDL.Record({\n next_page: IDL.Opt(IDL.Vec(IDL.Nat8)),\n tip_height: block_height,\n tip_block_hash: block_hash,\n utxos: IDL.Vec(utxo),\n });\n const send_transaction_request = IDL.Record({\n transaction: IDL.Vec(IDL.Nat8),\n network: network,\n });\n const config = IDL.Record({\n api_access: flag,\n lazily_evaluate_fee_percentiles: flag,\n blocks_source: IDL.Principal,\n fees: fees,\n watchdog_canister: IDL.Opt(IDL.Principal),\n network: network,\n stability_threshold: IDL.Nat,\n syncing: flag,\n burn_cycles: flag,\n disable_api_if_not_fully_synced: flag,\n });\n const set_config_request = IDL.Record({\n api_access: IDL.Opt(flag),\n lazily_evaluate_fee_percentiles: IDL.Opt(flag),\n fees: IDL.Opt(fees),\n watchdog_canister: IDL.Opt(IDL.Opt(IDL.Principal)),\n stability_threshold: IDL.Opt(IDL.Nat),\n syncing: IDL.Opt(flag),\n burn_cycles: IDL.Opt(flag),\n disable_api_if_not_fully_synced: IDL.Opt(flag),\n });\n\n return IDL.Service({\n bitcoin_get_balance: IDL.Func([get_balance_request], [satoshi], []),\n bitcoin_get_balance_query: IDL.Func([get_balance_request], [satoshi], []),\n bitcoin_get_block_headers: IDL.Func(\n [get_block_headers_request],\n [get_block_headers_response],\n [],\n ),\n bitcoin_get_current_fee_percentiles: IDL.Func(\n [get_current_fee_percentiles_request],\n [IDL.Vec(millisatoshi_per_byte)],\n [],\n ),\n bitcoin_get_utxos: IDL.Func([get_utxos_request], [get_utxos_response], []),\n bitcoin_get_utxos_query: IDL.Func(\n [get_utxos_request],\n [get_utxos_response],\n [],\n ),\n bitcoin_send_transaction: IDL.Func([send_transaction_request], [], []),\n get_config: IDL.Func([], [config], []),\n set_config: IDL.Func([set_config_request], [], []),\n });\n};\n\nexport const init = ({ IDL }) => {\n const flag = IDL.Variant({ disabled: IDL.Null, enabled: IDL.Null });\n const fees = IDL.Record({\n get_current_fee_percentiles: IDL.Nat,\n get_utxos_maximum: IDL.Nat,\n get_block_headers_cycles_per_ten_instructions: IDL.Nat,\n get_current_fee_percentiles_maximum: IDL.Nat,\n send_transaction_per_byte: IDL.Nat,\n get_balance: IDL.Nat,\n get_utxos_cycles_per_ten_instructions: IDL.Nat,\n get_block_headers_base: IDL.Nat,\n get_utxos_base: IDL.Nat,\n get_balance_maximum: IDL.Nat,\n send_transaction_base: IDL.Nat,\n get_block_headers_maximum: IDL.Nat,\n });\n const network = IDL.Variant({\n mainnet: IDL.Null,\n regtest: IDL.Null,\n testnet: IDL.Null,\n });\n const init_config = IDL.Record({\n api_access: IDL.Opt(flag),\n lazily_evaluate_fee_percentiles: IDL.Opt(flag),\n blocks_source: IDL.Opt(IDL.Principal),\n fees: IDL.Opt(fees),\n watchdog_canister: IDL.Opt(IDL.Opt(IDL.Principal)),\n network: IDL.Opt(network),\n stability_threshold: IDL.Opt(IDL.Nat),\n syncing: IDL.Opt(flag),\n burn_cycles: IDL.Opt(flag),\n disable_api_if_not_fully_synced: IDL.Opt(flag),\n });\n\n return [init_config];\n};\n", "/* eslint-disable */\n\n// @ts-nocheck\n\n// This file was automatically generated by @icp-sdk/bindgen@0.2.0.\n// You should NOT make any changes in this file as it will be overwritten.\n// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.\n\nexport const idlFactory = ({ IDL }) => {\n const flag = IDL.Variant({ disabled: IDL.Null, enabled: IDL.Null });\n const fees = IDL.Record({\n get_current_fee_percentiles: IDL.Nat,\n get_utxos_maximum: IDL.Nat,\n get_block_headers_cycles_per_ten_instructions: IDL.Nat,\n get_current_fee_percentiles_maximum: IDL.Nat,\n send_transaction_per_byte: IDL.Nat,\n get_balance: IDL.Nat,\n get_utxos_cycles_per_ten_instructions: IDL.Nat,\n get_block_headers_base: IDL.Nat,\n get_utxos_base: IDL.Nat,\n get_balance_maximum: IDL.Nat,\n send_transaction_base: IDL.Nat,\n get_block_headers_maximum: IDL.Nat,\n });\n const network = IDL.Variant({\n mainnet: IDL.Null,\n regtest: IDL.Null,\n testnet: IDL.Null,\n });\n const init_config = IDL.Record({\n api_access: IDL.Opt(flag),\n lazily_evaluate_fee_percentiles: IDL.Opt(flag),\n blocks_source: IDL.Opt(IDL.Principal),\n fees: IDL.Opt(fees),\n watchdog_canister: IDL.Opt(IDL.Opt(IDL.Principal)),\n network: IDL.Opt(network),\n stability_threshold: IDL.Opt(IDL.Nat),\n syncing: IDL.Opt(flag),\n burn_cycles: IDL.Opt(flag),\n disable_api_if_not_fully_synced: IDL.Opt(flag),\n });\n const address = IDL.Text;\n const get_balance_request = IDL.Record({\n network: network,\n address: address,\n min_confirmations: IDL.Opt(IDL.Nat32),\n });\n const satoshi = IDL.Nat64;\n const block_height = IDL.Nat32;\n const get_block_headers_request = IDL.Record({\n start_height: block_height,\n end_height: IDL.Opt(block_height),\n network: network,\n });\n const block_header = IDL.Vec(IDL.Nat8);\n const get_block_headers_response = IDL.Record({\n tip_height: block_height,\n block_headers: IDL.Vec(block_header),\n });\n const get_current_fee_percentiles_request = IDL.Record({\n network: network,\n });\n const millisatoshi_per_byte = IDL.Nat64;\n const get_utxos_request = IDL.Record({\n network: network,\n filter: IDL.Opt(\n IDL.Variant({\n page: IDL.Vec(IDL.Nat8),\n min_confirmations: IDL.Nat32,\n }),\n ),\n address: address,\n });\n const block_hash = IDL.Vec(IDL.Nat8);\n const outpoint = IDL.Record({\n txid: IDL.Vec(IDL.Nat8),\n vout: IDL.Nat32,\n });\n const utxo = IDL.Record({\n height: block_height,\n value: satoshi,\n outpoint: outpoint,\n });\n const get_utxos_response = IDL.Record({\n next_page: IDL.Opt(IDL.Vec(IDL.Nat8)),\n tip_height: block_height,\n tip_block_hash: block_hash,\n utxos: IDL.Vec(utxo),\n });\n const send_transaction_request = IDL.Record({\n transaction: IDL.Vec(IDL.Nat8),\n network: network,\n });\n const config = IDL.Record({\n api_access: flag,\n lazily_evaluate_fee_percentiles: flag,\n blocks_source: IDL.Principal,\n fees: fees,\n watchdog_canister: IDL.Opt(IDL.Principal),\n network: network,\n stability_threshold: IDL.Nat,\n syncing: flag,\n burn_cycles: flag,\n disable_api_if_not_fully_synced: flag,\n });\n const set_config_request = IDL.Record({\n api_access: IDL.Opt(flag),\n lazily_evaluate_fee_percentiles: IDL.Opt(flag),\n fees: IDL.Opt(fees),\n watchdog_canister: IDL.Opt(IDL.Opt(IDL.Principal)),\n stability_threshold: IDL.Opt(IDL.Nat),\n syncing: IDL.Opt(flag),\n burn_cycles: IDL.Opt(flag),\n disable_api_if_not_fully_synced: IDL.Opt(flag),\n });\n\n return IDL.Service({\n bitcoin_get_balance: IDL.Func([get_balance_request], [satoshi], []),\n bitcoin_get_balance_query: IDL.Func(\n [get_balance_request],\n [satoshi],\n [\"query\"],\n ),\n bitcoin_get_block_headers: IDL.Func(\n [get_block_headers_request],\n [get_block_headers_response],\n [],\n ),\n bitcoin_get_current_fee_percentiles: IDL.Func(\n [get_current_fee_percentiles_request],\n [IDL.Vec(millisatoshi_per_byte)],\n [],\n ),\n bitcoin_get_utxos: IDL.Func([get_utxos_request], [get_utxos_response], []),\n bitcoin_get_utxos_query: IDL.Func(\n [get_utxos_request],\n [get_utxos_response],\n [\"query\"],\n ),\n bitcoin_send_transaction: IDL.Func([send_transaction_request], [], []),\n get_config: IDL.Func([], [config], [\"query\"]),\n set_config: IDL.Func([set_config_request], [], []),\n });\n};\n\nexport const init = ({ IDL }) => {\n const flag = IDL.Variant({ disabled: IDL.Null, enabled: IDL.Null });\n const fees = IDL.Record({\n get_current_fee_percentiles: IDL.Nat,\n get_utxos_maximum: IDL.Nat,\n get_block_headers_cycles_per_ten_instructions: IDL.Nat,\n get_current_fee_percentiles_maximum: IDL.Nat,\n send_transaction_per_byte: IDL.Nat,\n get_balance: IDL.Nat,\n get_utxos_cycles_per_ten_instructions: IDL.Nat,\n get_block_headers_base: IDL.Nat,\n get_utxos_base: IDL.Nat,\n get_balance_maximum: IDL.Nat,\n send_transaction_base: IDL.Nat,\n get_block_headers_maximum: IDL.Nat,\n });\n const network = IDL.Variant({\n mainnet: IDL.Null,\n regtest: IDL.Null,\n testnet: IDL.Null,\n });\n const init_config = IDL.Record({\n api_access: IDL.Opt(flag),\n lazily_evaluate_fee_percentiles: IDL.Opt(flag),\n blocks_source: IDL.Opt(IDL.Principal),\n fees: IDL.Opt(fees),\n watchdog_canister: IDL.Opt(IDL.Opt(IDL.Principal)),\n network: IDL.Opt(network),\n stability_threshold: IDL.Opt(IDL.Nat),\n syncing: IDL.Opt(flag),\n burn_cycles: IDL.Opt(flag),\n disable_api_if_not_fully_synced: IDL.Opt(flag),\n });\n\n return [init_config];\n};\n", "import { nonNullish, toNullable, type QueryParams } from \"@dfinity/utils\";\nimport type {\n get_balance_request,\n get_utxos_request,\n network,\n} from \"../candid/bitcoin\";\n\nexport type BitcoinNetwork = \"testnet\" | \"mainnet\" | \"regtest\";\n\nconst mapBitcoinNetwork: Record<BitcoinNetwork, network> = {\n mainnet: { mainnet: null },\n testnet: { testnet: null },\n regtest: { regtest: null },\n};\n\nexport type GetUtxosParams = Omit<get_utxos_request, \"network\" | \"filter\"> & {\n network: BitcoinNetwork;\n filter?: { page: Uint8Array } | { minConfirmations: number };\n} & Omit<QueryParams, \"certified\">;\n\nexport const toGetUtxosParams = ({\n network,\n filter,\n ...rest\n}: GetUtxosParams): get_utxos_request => ({\n filter: nonNullish(filter)\n ? toNullable(\n \"minConfirmations\" in filter\n ? { min_confirmations: filter.minConfirmations }\n : { page: filter.page },\n )\n : toNullable(),\n network: network === \"testnet\" ? { testnet: null } : { mainnet: null },\n ...rest,\n});\n\nexport type GetBalanceParams = Omit<\n get_balance_request,\n \"network\" | \"min_confirmations\"\n> & {\n network: BitcoinNetwork;\n minConfirmations?: number;\n} & Omit<QueryParams, \"certified\">;\n\nexport const toGetBalanceParams = ({\n network,\n minConfirmations,\n ...rest\n}: GetBalanceParams): get_balance_request => ({\n min_confirmations: toNullable(minConfirmations),\n network: mapBitcoinNetwork[network],\n ...rest,\n});\n", "// As defined on Bitcoin network.\n// e.g. https://developer.bitcoin.org/examples/testing.html\nexport enum BtcNetwork {\n Mainnet,\n Regtest,\n Testnet,\n}\n\n// See https://github.com/dfinity/ic/blob/a8da3aa23dc6f8f4708cb0cb8edce84c5bd8f225/rs/bitcoin/ckbtc/minter/src/address.rs#L18\nexport enum BtcAddressType {\n P2wpkhV0,\n P2pkh,\n P2sh,\n P2wsh,\n P2tr,\n}\n", "export class ParseBtcAddressError extends Error {}\nexport class ParseBtcAddressInvalidError extends ParseBtcAddressError {}\nexport class ParseBtcAddressNoDataError extends ParseBtcAddressError {}\nexport class ParseBtcAddressUnsupportedAddressTypeError extends ParseBtcAddressError {}\nexport class ParseBtcAddressBadWitnessLengthError extends ParseBtcAddressError {}\nexport class ParseBtcAddressUnsupportedWitnessVersionError extends ParseBtcAddressError {}\nexport class ParseBtcAddressUnexpectedHumanReadablePartError extends ParseBtcAddressError {}\nexport class ParseBtcAddressMalformedAddressError extends ParseBtcAddressError {}\nexport class ParseBtcAddressWrongNetworkError extends ParseBtcAddressError {}\n", "import { fromNullable, nonNullish } from \"@dfinity/utils\";\nimport type {\n PendingUtxo,\n RetrieveBtcError,\n RetrieveBtcWithApprovalError,\n UpdateBalanceError,\n} from \"../candid/minter\";\n\nexport class MinterGenericError extends Error {}\nexport class MinterTemporaryUnavailableError extends MinterGenericError {}\nexport class MinterAlreadyProcessingError extends MinterGenericError {}\n\nexport class MinterUpdateBalanceError extends MinterGenericError {}\nexport class MinterNoNewUtxosError extends MinterUpdateBalanceError {\n readonly pendingUtxos: PendingUtxo[];\n readonly requiredConfirmations: number;\n constructor({\n pending_utxos,\n required_confirmations,\n }: {\n pending_utxos: [] | [PendingUtxo[]];\n required_confirmations: number;\n }) {\n super();\n this.pendingUtxos = fromNullable(pending_utxos) ?? [];\n this.requiredConfirmations = required_confirmations;\n }\n}\n\nexport class MinterRetrieveBtcError extends MinterGenericError {}\nexport class MinterMalformedAddressError extends MinterRetrieveBtcError {}\nexport class MinterAmountTooLowError extends MinterRetrieveBtcError {}\nexport class MinterInsufficientFundsError extends MinterRetrieveBtcError {}\nexport class MinterInsufficientAllowanceError extends MinterRetrieveBtcError {}\n\nconst mapGenericError = (\n Err: UpdateBalanceError | RetrieveBtcError | RetrieveBtcWithApprovalError,\n): MinterGenericError | undefined => {\n if (\"GenericError\" in Err) {\n const {\n GenericError: { error_message, error_code },\n } = Err;\n return new MinterGenericError(`${error_message} (${error_code})`);\n }\n\n if (\"TemporarilyUnavailable\" in Err) {\n return new MinterTemporaryUnavailableError(Err.TemporarilyUnavailable);\n }\n\n if (\"AlreadyProcessing\" in Err) {\n return new MinterAlreadyProcessingError();\n }\n\n return undefined;\n};\n\nexport const createUpdateBalanceError = (\n Err: UpdateBalanceError,\n): MinterGenericError => {\n const error = mapGenericError(Err);\n\n if (nonNullish(error)) {\n return error;\n }\n\n if (\"NoNewUtxos\" in Err) {\n return new MinterNoNewUtxosError(Err.NoNewUtxos);\n }\n\n // Handle types added in the backend but not yet added in the frontend\n return new MinterUpdateBalanceError(\n `Unsupported response type in minter.updateBalance ${JSON.stringify(Err)}`,\n );\n};\n\nexport const createRetrieveBtcError = (\n Err: RetrieveBtcError,\n): MinterGenericError => {\n const error = mapGenericError(Err);\n\n if (nonNullish(error)) {\n return error;\n }\n\n if (\"MalformedAddress\" in Err) {\n return new MinterMalformedAddressError(Err.MalformedAddress);\n }\n\n if (\"AmountTooLow\" in Err) {\n return new MinterAmountTooLowError(`${Err.AmountTooLow}`);\n }\n\n if (\"InsufficientFunds\" in Err) {\n return new MinterInsufficientFundsError(`${Err.InsufficientFunds.balance}`);\n }\n\n // Handle types added in the backend but not yet added in the frontend\n return new MinterRetrieveBtcError(\n `Unsupported response type in minter.retrieveBtc ${JSON.stringify(Err)}`,\n );\n};\n\nexport const createRetrieveBtcWithApprovalError = (\n Err: RetrieveBtcWithApprovalError,\n): MinterGenericError => {\n const error = mapGenericError(Err);\n\n if (nonNullish(error)) {\n return error;\n }\n\n if (\"InsufficientAllowance\" in Err) {\n return new MinterInsufficientAllowanceError(\n `${Err.InsufficientAllowance.allowance}`,\n );\n }\n\n return createRetrieveBtcError(Err);\n};\n", "import {\n Canister,\n createServices,\n fromNullable,\n isNullish,\n toNullable,\n type QueryParams,\n} from \"@dfinity/utils\";\nimport type {\n _SERVICE as CkBTCMinterService,\n MinterInfo,\n RetrieveBtcOk,\n RetrieveBtcStatus,\n Utxo,\n Account as WithdrawalAccount,\n} from \"./candid/minter\";\nimport { idlFactory as certifiedIdlFactory } from \"./candid/minter.certified.idl\";\nimport { idlFactory } from \"./candid/minter.idl\";\nimport {\n createRetrieveBtcError,\n createRetrieveBtcWithApprovalError,\n createUpdateBalanceError,\n} from \"./errors/minter.errors\";\nimport type { CkBTCCanisterOptions } from \"./types/canister.options\";\nimport type {\n EstimateWithdrawalFeeParams,\n GetBTCAddressParams,\n GetKnownUtxosParams,\n RetrieveBtcParams,\n RetrieveBtcStatusV2ByAccountParams,\n UpdateBalanceParams,\n} from \"./types/minter.params\";\nimport type {\n EstimateWithdrawalFee,\n RetrieveBtcResponse,\n RetrieveBtcStatusV2WithId,\n RetrieveBtcWithApprovalResponse,\n UpdateBalanceOk,\n UpdateBalanceResponse,\n} from \"./types/minter.responses\";\n\nexport class CkBTCMinterCanister extends Canister<CkBTCMinterService> {\n static create(options: CkBTCCanisterOptions<CkBTCMinterService>) {\n const { service, certifiedService, canisterId } =\n createServices<CkBTCMinterService>({\n options,\n idlFactory,\n certifiedIdlFactory,\n });\n\n return new CkBTCMinterCanister(canisterId, service, certifiedService);\n }\n\n /**\n * Returns a BTC address for a given account.\n *\n * Note: an update call is required by the Minter canister.\n *\n * @param {GetBTCAddressParams} params The parameters for which a BTC address should be resolved.\n * @param {Principal} params.owner The owner for which the BTC address should be generated. If not provided, the `caller` will be use instead.\n * @param {Uint8Array} params.subaccount An optional subaccount to compute the address.\n * @returns {Promise<string>} The BTC address of the given account.\n */\n getBtcAddress = ({\n owner,\n subaccount,\n }: GetBTCAddressParams): Promise<string> =>\n this.caller({ certified: true }).get_btc_address({\n owner: toNullable(owner),\n subaccount: toNullable(subaccount),\n });\n\n /**\n * Notify the minter about the bitcoin transfer.\n *\n * Upon successful notification, new ckBTC should be available on the targeted address.\n *\n * @param {UpdateBalanceParams} params The parameters are the address to which bitcoin where transferred.\n * @param {Principal} params.owner The owner of the address. If not provided, the `caller` will be use instead.\n * @param {Principal} params.subaccount An optional subaccount of the address.\n * @returns {Promise<UpdateBalanceOk>} The result of the balance update.\n */\n updateBalance = async ({\n owner,\n subaccount,\n }: UpdateBalanceParams): Promise<UpdateBalanceOk> => {\n const response: UpdateBalanceResponse = await this.caller({\n certified: true,\n }).update_balance({\n owner: toNullable(owner),\n subaccount: toNullable(subaccount),\n });\n\n if (\"Err\" in response) {\n throw createUpdateBalanceError(response.Err);\n }\n\n return response.Ok;\n };\n\n /**\n * Returns the account to which the caller should deposit ckBTC before withdrawing BTC using the [retrieveBtc] endpoint.\n *\n * @returns {Promise<Account>} The account to which ckBTC needs to be transferred. Provide corresponding information to map an Icrc1 account.\n */\n getWithdrawalAccount = (): Promise<WithdrawalAccount> =>\n this.caller({ certified: true }).get_withdrawal_account();\n\n /**\n * Submits a request to convert ckBTC to BTC.\n *\n * Note:\n *\n * The BTC retrieval process is slow. Instead of synchronously waiting for a BTC transaction to settle, this method returns a request ([block_index]) that the caller can use to query the request status.\n *\n * Preconditions:\n *\n * The caller deposited the requested amount in ckBTC to the account that the [getWithdrawalAccount] endpoint returns.\n *\n * @param {RetrieveBtcParams} params The parameters are the bitcoin address and amount to convert.\n * @param {string} params.address The bitcoin address.\n * @param {bigint} params.amount The ckBTC amount.\n * @returns {Promise<RetrieveBtcOk>} The result or the operation.\n */\n retrieveBtc = async (params: RetrieveBtcParams): Promise<RetrieveBtcOk> => {\n const response: RetrieveBtcResponse = await this.caller({\n certified: true,\n }).retrieve_btc(params);\n\n if (\"Err\" in response) {\n throw createRetrieveBtcError(response.Err);\n }\n\n return response.Ok;\n };\n\n /**\n * Submits a request to convert ckBTC to BTC after making an ICRC-2 approval.\n *\n * # Note\n *\n * The BTC retrieval process is slow. Instead of synchronously waiting for a BTC transaction to settle, this method returns a request ([block_index]) that the caller can use to query the request status.\n *\n * # Preconditions\n *\n * The caller allowed the minter's principal to spend its funds using\n * [icrc2_approve] on the ckBTC ledger.\n *\n * @param {string} params.address The bitcoin address.\n * @param {bigint} params.amount The ckBTC amount.\n * @param {Uint8Array} params.fromSubaccount An optional subaccount from which\n * the ckBTC should be transferred.\n * @returns {Promise<RetrieveBtcOk>} The result or the operation.\n */\n retrieveBtcWithApproval = async ({\n address,\n amount,\n fromSubaccount,\n }: {\n address: string;\n amount: bigint;\n fromSubaccount?: Uint8Array;\n }): Promise<RetrieveBtcOk> => {\n const response: RetrieveBtcWithApprovalResponse = await this.caller({\n certified: true,\n }).retrieve_btc_with_approval({\n address,\n amount,\n from_subaccount: toNullable(fromSubaccount),\n });\n\n if (\"Err\" in response) {\n throw createRetrieveBtcWithApprovalError(response.Err);\n }\n\n return response.Ok;\n };\n\n /**\n * Returns the status of a specific BTC withdrawal based on the transaction ID\n * of the corresponding burn transaction.\n *\n * @param {bigint} transactionId The ID of the corresponding burn transaction.\n * @param {boolean} certified query or update call\n * @returns {Promise<RetrieveBtcStatus>} The status of the BTC retrieval request.\n */\n retrieveBtcStatus = ({\n transactionId,\n certified,\n }: {\n transactionId: bigint;\n certified: boolean;\n }): Promise<RetrieveBtcStatus> =>\n this.caller({\n certified,\n }).retrieve_btc_status({ block_index: transactionId });\n\n /**\n * Returns the status of all BTC withdrawals for an account.\n *\n * @param {boolean} certified query or update call\n * @param {MinterAccount} account an optional account to retrieve the statuses. If not provided, statuses for the caller are retrieved.\n * @returns {Promise<RetrieveBtcStatusV2WithId[]>} The statuses of the BTC retrieval requests.\n */\n retrieveBtcStatusV2ByAccount = async ({\n account,\n certified,\n }: RetrieveBtcStatusV2ByAccountParams): Promise<\n RetrieveBtcStatusV2WithId[]\n > => {\n const { retrieve_btc_status_v2_by_account } = this.caller({\n certified,\n });\n\n const statuses = await retrieve_btc_status_v2_by_account(\n isNullish(account)\n ? []\n : [\n {\n owner: account.owner,\n subaccount: toNullable(account.subaccount),\n },\n ],\n );\n\n return statuses.map(({ block_index, status_v2 }) => ({\n id: block_index,\n status: fromNullable(status_v2),\n }));\n };\n\n /**\n * Returns an estimation of the user's fee (in Satoshi) for a retrieve_btc request based on the current status of the Bitcoin network and the fee related to the minter.\n *\n * @param {RetrieveBtcParams} params The parameters to estimate the fee.\n * @param {boolean} params.certified query or update call\n * @param {bigint | undefined} params.amount The optional amount for which the fee should be estimated.\n */\n estimateWithdrawalFee = ({\n certified,\n amount,\n }: EstimateWithdrawalFeeParams): Promise<EstimateWithdrawalFee> =>\n this.caller({\n certified,\n }).estimate_withdrawal_fee({ amount: toNullable(amount) });\n\n /**\n * Returns internal minter parameters such as the minimal amount to retrieve BTC, minimal number of confirmations or KYT fee.\n *\n * @param {QueryParams} params The parameters to get the minter info.\n * @param {boolean} params.certified query or update call\n */\n getMinterInfo = ({ certified }: QueryParams): Promise<MinterInfo> =>\n this.caller({\n certified,\n }).get_minter_info();\n\n /**\n * Returns UTXOs of the given account known by the minter.\n *\n * @param {GetKnownUtxosParams} params The parameters for which the known utxos should be resolved.\n * @param {Principal} params.owner The owner of the account. Note that if not provided, the `caller` would be used by the minter instead.\n * @param {Uint8Array} params.subaccount An optional subaccount.\n * @returns {Promise<Utxo[]>} The known utxos (with no guarantee in the ordering).\n */\n getKnownUtxos = ({\n owner,\n subaccount,\n certified,\n }: GetKnownUtxosParams): Promise<Utxo[]> => {\n const { get_known_utxos } = this.caller({ certified });\n\n return get_known_utxos({\n owner: toNullable(owner),\n subaccount: toNullable(subaccount),\n });\n };\n}\n", "/* eslint-disable */\n\n// @ts-nocheck\n\n// This file was automatically generated by @icp-sdk/bindgen@0.2.0.\n// You should NOT make any changes in this file as it will be overwritten.\n// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.\n\nexport const idlFactory = ({ IDL }) => {\n const Mode = IDL.Variant({\n RestrictedTo: IDL.Vec(IDL.Principal),\n DepositsRestrictedTo: IDL.Vec(IDL.Principal),\n ReadOnly: IDL.Null,\n GeneralAvailability: IDL.Null,\n });\n const UpgradeArgs = IDL.Record({\n get_utxos_cache_expiration_seconds: IDL.Opt(IDL.Nat64),\n kyt_principal: IDL.Opt(IDL.Principal),\n mode: IDL.Opt(Mode),\n retrieve_btc_min_amount: IDL.Opt(IDL.Nat64),\n max_time_in_queue_nanos: IDL.Opt(IDL.Nat64),\n check_fee: IDL.Opt(IDL.Nat64),\n btc_checker_principal: IDL.Opt(IDL.Principal),\n min_confirmations: IDL.Opt(IDL.Nat32),\n kyt_fee: IDL.Opt(IDL.Nat64),\n });\n const BtcNetwork = IDL.Variant({\n Mainnet: IDL.Null,\n Regtest: IDL.Null,\n Testnet: IDL.Null,\n });\n const InitArgs = IDL.Record({\n get_utxos_cache_expiration_seconds: IDL.Opt(IDL.Nat64),\n kyt_principal: IDL.Opt(IDL.Principal),\n ecdsa_key_name: IDL.Text,\n mode: Mode,\n retrieve_btc_min_amount: IDL.Nat64,\n ledger_id: IDL.Principal,\n max_time_in_queue_nanos: IDL.Nat64,\n btc_network: BtcNetwork,\n check_fee: IDL.Opt(IDL.Nat64),\n btc_checker_principal: IDL.Opt(IDL.Principal),\n min_confirmations: IDL.Opt(IDL.Nat32),\n kyt_fee: IDL.Opt(IDL.Nat64),\n });\n const MinterArg = IDL.Variant({\n Upgrade: IDL.Opt(UpgradeArgs),\n Init: InitArgs,\n });\n const MemoryMetrics = IDL.Record({\n wasm_binary_size: IDL.Nat,\n wasm_chunk_store_size: IDL.Nat,\n canister_history_size: IDL.Nat,\n stable_memory_size: IDL.Nat,\n snapshots_size: IDL.Nat,\n wasm_memory_size: IDL.Nat,\n global_memory_size: IDL.Nat,\n custom_sections_size: IDL.Nat,\n });\n const CanisterStatusType = IDL.Variant({\n stopped: IDL.Null,\n stopping: IDL.Null,\n running: IDL.Null,\n });\n const LogVisibility = IDL.Variant({\n controllers: IDL.Null,\n public: IDL.Null,\n allowed_viewers: IDL.Vec(IDL.Principal),\n });\n const DefiniteCanisterSettings = IDL.Record({\n freezing_threshold: IDL.Nat,\n wasm_memory_threshold: IDL.Nat,\n controllers: IDL.Vec(IDL.Principal),\n reserved_cycles_limit: IDL.Nat,\n log_visibility: LogVisibility,\n wasm_memory_limit: IDL.Nat,\n memory_allocation: IDL.Nat,\n compute_allocation: IDL.Nat,\n });\n const QueryStats = IDL.Record({\n response_payload_bytes_total: IDL.Nat,\n num_instructions_total: IDL.Nat,\n num_calls_total: IDL.Nat,\n request_payload_bytes_total: IDL.Nat,\n });\n const CanisterStatusResponse = IDL.Record({\n memory_metrics: MemoryMetrics,\n status: CanisterStatusType,\n memory_size: IDL.Nat,\n cycles: IDL.Nat,\n settings: DefiniteCanisterSettings,\n query_stats: QueryStats,\n idle_cycles_burned_per_day: IDL.Nat,\n module_hash: IDL.Opt(IDL.Vec(IDL.Nat8)),\n reserved_cycles: IDL.Nat,\n });\n const Account = IDL.Record({\n owner: IDL.Principal,\n subaccount: IDL.Opt(IDL.Vec(IDL.Nat8)),\n });\n const Utxo = IDL.Record({\n height: IDL.Nat32,\n value: IDL.Nat64,\n outpoint: IDL.Record({ txid: IDL.Vec(IDL.Nat8), vout: IDL.Nat32 }),\n });\n const ReimbursementReason = IDL.Variant({\n CallFailed: IDL.Null,\n TaintedDestination: IDL.Record({\n kyt_fee: IDL.Nat64,\n kyt_provider: IDL.Principal,\n }),\n });\n const WithdrawalFee = IDL.Record({\n minter_fee: IDL.Nat64,\n bitcoin_fee: IDL.Nat64,\n });\n const SuspendedReason = IDL.Variant({\n ValueTooSmall: IDL.Null,\n Quarantined: IDL.Null,\n });\n const BitcoinAddress = IDL.Variant({\n p2wsh_v0: IDL.Vec(IDL.Nat8),\n p2tr_v1: IDL.Vec(IDL.Nat8),\n p2sh: IDL.Vec(IDL.Nat8),\n p2wpkh_v0: IDL.Vec(IDL.Nat8),\n p2pkh: IDL.Vec(IDL.Nat8),\n });\n const InvalidTransactionError = IDL.Variant({\n too_many_inputs: IDL.Record({\n max_num_inputs: IDL.Nat64,\n num_inputs: IDL.Nat64,\n }),\n });\n const WithdrawalReimbursementReason = IDL.Variant({\n invalid_transaction: InvalidTransactionError,\n });\n const ReplacedReason = IDL.Variant({\n to_cancel: IDL.Record({ reason: WithdrawalReimbursementReason }),\n to_retry: IDL.Null,\n });\n const EventType = IDL.Variant({\n received_utxos: IDL.Record({\n to_account: Account,\n mint_txid: IDL.Opt(IDL.Nat64),\n utxos: IDL.Vec(Utxo),\n }),\n schedule_deposit_reimbursement: IDL.Record({\n burn_block_index: IDL.Nat64,\n account: Account,\n amount: IDL.Nat64,\n reason: ReimbursementReason,\n }),\n sent_transaction: IDL.Record({\n fee: IDL.Opt(IDL.Nat64),\n change_output: IDL.Opt(IDL.Record({ value: IDL.Nat64, vout: IDL.Nat32 })),\n txid: IDL.Vec(IDL.Nat8),\n withdrawal_fee: IDL.Opt(WithdrawalFee),\n utxos: IDL.Vec(Utxo),\n requests: IDL.Vec(IDL.Nat64),\n submitted_at: IDL.Nat64,\n }),\n distributed_kyt_fee: IDL.Record({\n block_index: IDL.Nat64,\n amount: IDL.Nat64,\n kyt_provider: IDL.Principal,\n }),\n init: InitArgs,\n upgrade: UpgradeArgs,\n retrieve_btc_kyt_failed: IDL.Record({\n block_index: IDL.Nat64,\n owner: IDL.Principal,\n uuid: IDL.Text,\n address: IDL.Text,\n amount: IDL.Nat64,\n kyt_provider: IDL.Principal,\n }),\n suspended_utxo: IDL.Record({\n utxo: Utxo,\n account: Account,\n reason: SuspendedReason,\n }),\n accepted_retrieve_btc_request: IDL.Record({\n received_at: IDL.Nat64,\n block_index: IDL.Nat64,\n address: BitcoinAddress,\n reimbursement_account: IDL.Opt(Account),\n amount: IDL.Nat64,\n kyt_provider: IDL.Opt(IDL.Principal),\n }),\n checked_utxo: IDL.Record({\n clean: IDL.Bool,\n utxo: Utxo,\n uuid: IDL.Text,\n kyt_provider: IDL.Opt(IDL.Principal),\n }),\n schedule_withdrawal_reimbursement: IDL.Record({\n burn_block_index: IDL.Nat64,\n account: Account,\n amount: IDL.Nat64,\n reason: WithdrawalReimbursementReason,\n }),\n quarantined_withdrawal_reimbursement: IDL.Record({\n burn_block_index: IDL.Nat64,\n }),\n removed_retrieve_btc_request: IDL.Record({ block_index: IDL.Nat64 }),\n confirmed_transaction: IDL.Record({ txid: IDL.Vec(IDL.Nat8) }),\n replaced_transaction: IDL.Record({\n fee: IDL.Nat64,\n change_output: IDL.Record({ value: IDL.Nat64, vout: IDL.Nat32 }),\n new_utxos: IDL.Opt(IDL.Vec(Utxo)),\n old_txid: IDL.Vec(IDL.Nat8),\n withdrawal_fee: IDL.Opt(WithdrawalFee),\n new_txid: IDL.Vec(IDL.Nat8),\n submitted_at: IDL.Nat64,\n reason: IDL.Opt(ReplacedReason),\n }),\n checked_utxo_v2: IDL.Record({ utxo: Utxo, account: Account }),\n ignored_utxo: IDL.Record({ utxo: Utxo }),\n checked_utxo_mint_unknown: IDL.Record({\n utxo: Utxo,\n account: Account,\n }),\n reimbursed_failed_deposit: IDL.Record({\n burn_block_index: IDL.Nat64,\n mint_block_index: IDL.Nat64,\n }),\n reimbursed_withdrawal: IDL.Record({\n burn_block_index: IDL.Nat64,\n mint_block_index: IDL.Nat64,\n }),\n });\n const Event = IDL.Record({\n timestamp: IDL.Opt(IDL.Nat64),\n payload: EventType,\n });\n const MinterInfo = IDL.Record({\n retrieve_btc_min_amount: IDL.Nat64,\n min_confirmations: IDL.Nat32,\n kyt_fee: IDL.Nat64,\n });\n const RetrieveBtcArgs = IDL.Record({\n address: IDL.Text,\n amount: IDL.Nat64,\n });\n const RetrieveBtcOk = IDL.Record({ block_index: IDL.Nat64 });\n const RetrieveBtcError = IDL.Variant({\n MalformedAddress: IDL.Text,\n GenericError: IDL.Record({\n error_message: IDL.Text,\n error_code: IDL.Nat64,\n }),\n TemporarilyUnavailable: IDL.Text,\n AlreadyProcessing: IDL.Null,\n AmountTooLow: IDL.Nat64,\n InsufficientFunds: IDL.Record({ balance: IDL.Nat64 }),\n });\n const RetrieveBtcStatus = IDL.Variant({\n Signing: IDL.Null,\n Confirmed: IDL.Record({ txid: IDL.Vec(IDL.Nat8) }),\n Sending: IDL.Record({ txid: IDL.Vec(IDL.Nat8) }),\n AmountTooLow: IDL.Null,\n Unknown: IDL.Null,\n Submitted: IDL.Record({ txid: IDL.Vec(IDL.Nat8) }),\n Pending: IDL.Null,\n });\n const ReimbursementRequest = IDL.Record({\n account: Account,\n amount: IDL.Nat64,\n reason: ReimbursementReason,\n });\n const ReimbursedDeposit = IDL.Record({\n account: Account,\n mint_block_index: IDL.Nat64,\n amount: IDL.Nat64,\n reason: ReimbursementReason,\n });\n const RetrieveBtcStatusV2 = IDL.Variant({\n Signing: IDL.Null,\n Confirmed: IDL.Record({ txid: IDL.Vec(IDL.Nat8) }),\n Sending: IDL.Record({ txid: IDL.Vec(IDL.Nat8) }),\n AmountTooLow: IDL.Null,\n WillReimburse: ReimbursementRequest,\n Unknown: IDL.Null,\n Submitted: IDL.Record({ txid: IDL.Vec(IDL.Nat8) }),\n Reimbursed: ReimbursedDeposit,\n Pending: IDL.Null,\n });\n const RetrieveBtcWithApprovalArgs = IDL.Record({\n from_subaccount: IDL.Opt(IDL.Vec(IDL.Nat8)),\n address: IDL.Text,\n amount: IDL.Nat64,\n });\n const RetrieveBtcWithApprovalError = IDL.Variant({\n MalformedAddress: IDL.Text,\n GenericError: IDL.Record({\n error_message: IDL.Text,\n error_code: IDL.Nat64,\n }),\n TemporarilyUnavailable: IDL.Text,\n InsufficientAllowance: IDL.Record({ allowance: IDL.Nat64 }),\n AlreadyProcessing: IDL.Null,\n AmountTooLow: IDL.Nat64,\n InsufficientFunds: IDL.Record({ balance: IDL.Nat64 }),\n });\n const UtxoStatus = IDL.Variant({\n ValueTooSmall: Utxo,\n Tainted: Utxo,\n Minted: IDL.Record({\n minted_amount: IDL.Nat64,\n block_index: IDL.Nat64,\n utxo: Utxo,\n }),\n Checked: Utxo,\n });\n const Timestamp = IDL.Nat64;\n const SuspendedUtxo = IDL.Record({\n utxo: Utxo,\n earliest_retry: Timestamp,\n reason: SuspendedReason,\n });\n const PendingUtxo = IDL.Record({\n confirmations: IDL.Nat32,\n value: IDL.Nat64,\n outpoint: IDL.Record({ txid: IDL.Vec(IDL.Nat8), vout: IDL.Nat32 }),\n });\n const UpdateBalanceError = IDL.Variant({\n GenericError: IDL.Record({\n error_message: IDL.Text,\n error_code: IDL.Nat64,\n }),\n TemporarilyUnavailable: IDL.Text,\n AlreadyProcessing: IDL.Null,\n NoNewUtxos: IDL.Record({\n suspended_utxos: IDL.Opt(IDL.Vec(SuspendedUtxo)),\n required_confirmations: IDL.Nat32,\n pending_utxos: IDL.Opt(IDL.Vec(PendingUtxo)),\n current_confirmations: IDL.Opt(IDL.Nat32),\n }),\n });\n\n return IDL.Service({\n estimate_withdrawal_fee: IDL.Func(\n [IDL.Record({ amount: IDL.Opt(IDL.Nat64) })],\n [IDL.Record({ minter_fee: IDL.Nat64, bitcoin_fee: IDL.Nat64 })],\n [],\n ),\n get_btc_address: IDL.Func(\n [\n IDL.Record({\n owner: IDL.Opt(IDL.Principal),\n subaccount: IDL.Opt(IDL.Vec(IDL.Nat8)),\n }),\n ],\n [IDL.Text],\n [],\n ),\n get_canister_status: IDL.Func([], [CanisterStatusResponse], []),\n get_deposit_fee: IDL.Func([], [IDL.Nat64], []),\n get_events: IDL.Func(\n [IDL.Record({ start: IDL.Nat64, length: IDL.Nat64 })],\n [IDL.Vec(Event)],\n [],\n ),\n get_known_utxos: IDL.Func(\n [\n IDL.Record({\n owner: IDL.Opt(IDL.Principal),\n subaccount: IDL.Opt(IDL.Vec(IDL.Nat8)),\n }),\n ],\n [IDL.Vec(Utxo)],\n [],\n ),\n get_minter_info: IDL.Func([], [MinterInfo], []),\n get_withdrawal_account: IDL.Func([], [Account], []),\n retrieve_btc: IDL.Func(\n [RetrieveBtcArgs],\n [IDL.Variant({ Ok: RetrieveBtcOk, Err: RetrieveBtcError })],\n [],\n ),\n retrieve_btc_status: IDL.Func(\n [IDL.Record({ block_index: IDL.Nat64 })],\n [RetrieveBtcStatus],\n [],\n ),\n retrieve_btc_status_v2: IDL.Func(\n [IDL.Record({ block_index: IDL.Nat64 })],\n [RetrieveBtcStatusV2],\n [],\n ),\n retrieve_btc_status_v2_by_account: IDL.Func(\n [IDL.Opt(Account)],\n [\n IDL.Vec(\n IDL.Record({\n block_index: IDL.Nat64,\n status_v2: IDL.Opt(RetrieveBtcStatusV2),\n }),\n ),\n ],\n [],\n ),\n retrieve_btc_with_approval: IDL.Func(\n [RetrieveBtcWithApprovalArgs],\n [\n IDL.Variant({\n Ok: RetrieveBtcOk,\n Err: RetrieveBtcWithApprovalError,\n }),\n ],\n [],\n ),\n update_balance: IDL.Func(\n [\n IDL.Record({\n owner: IDL.Opt(IDL.Principal),\n subaccount: IDL.Opt(IDL.Vec(IDL.Nat8)),\n }),\n ],\n [\n IDL.Variant({\n Ok: IDL.Vec(UtxoStatus),\n Err: UpdateBalanceError,\n }),\n ],\n [],\n ),\n });\n};\n\nexport const init = ({ IDL }) => {\n const Mode = IDL.Variant({\n RestrictedTo: IDL.Vec(IDL.Principal),\n DepositsRestrictedTo: IDL.Vec(IDL.Principal),\n ReadOnly: IDL.Null,\n GeneralAvailability: IDL.Null,\n });\n const UpgradeArgs = IDL.Record({\n get_utxos_cache_expiration_seconds: IDL.Opt(IDL.Nat64),\n kyt_principal: IDL.Opt(IDL.Principal),\n mode: IDL.Opt(Mode),\n retrieve_btc_min_amount: IDL.Opt(IDL.Nat64),\n max_time_in_queue_nanos: IDL.Opt(IDL.Nat64),\n check_fee: IDL.Opt(IDL.Nat64),\n btc_checker_principal: IDL.Opt(IDL.Principal),\n min_confirmations: IDL.Opt(IDL.Nat32),\n kyt_fee: IDL.Opt(IDL.Nat64),\n });\n const BtcNetwork = IDL.Variant({\n Mainnet: IDL.Null,\n Regtest: IDL.Null,\n Testnet: IDL.Null,\n });\n const InitArgs = IDL.Record({\n get_utxos_cache_expiration_seconds: IDL.Opt(IDL.Nat64),\n kyt_principal: IDL.Opt(IDL.Principal),\n ecdsa_key_name: IDL.Text,\n mode: Mode,\n retrieve_btc_min_amount: IDL.Nat64,\n ledger_id: IDL.Principal,\n max_time_in_queue_nanos: IDL.Nat64,\n btc_network: BtcNetwork,\n check_fee: IDL.Opt(IDL.Nat64),\n btc_checker_principal: IDL.Opt(IDL.Principal),\n min_confirmations: IDL.Opt(IDL.Nat32),\n kyt_fee: IDL.Opt(IDL.Nat64),\n });\n const MinterArg = IDL.Variant({\n Upgrade: IDL.Opt(UpgradeArgs),\n Init: InitArgs,\n });\n\n return [MinterArg];\n};\n", "/* eslint-disable */\n\n// @ts-nocheck\n\n// This file was automatically generated by @icp-sdk/bindgen@0.2.0.\n// You should NOT make any changes in this file as it will be overwritten.\n// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.\n\nexport const idlFactory = ({ IDL }) => {\n const Mode = IDL.Variant({\n RestrictedTo: IDL.Vec(IDL.Principal),\n DepositsRestrictedTo: IDL.Vec(IDL.Principal),\n ReadOnly: IDL.Null,\n GeneralAvailability: IDL.Null,\n });\n const UpgradeArgs = IDL.Record({\n get_utxos_cache_expiration_seconds: IDL.Opt(IDL.Nat64),\n kyt_principal: IDL.Opt(IDL.Principal),\n mode: IDL.Opt(Mode),\n retrieve_btc_min_amount: IDL.Opt(IDL.Nat64),\n max_time_in_queue_nanos: IDL.Opt(IDL.Nat64),\n check_fee: IDL.Opt(IDL.Nat64),\n btc_checker_principal: IDL.Opt(IDL.Principal),\n min_confirmations: IDL.Opt(IDL.Nat32),\n kyt_fee: IDL.Opt(IDL.Nat64),\n });\n const BtcNetwork = IDL.Variant({\n Mainnet: IDL.Null,\n Regtest: IDL.Null,\n Testnet: IDL.Null,\n });\n const InitArgs = IDL.Record({\n get_utxos_cache_expiration_seconds: IDL.Opt(IDL.Nat64),\n kyt_principal: IDL.Opt(IDL.Principal),\n ecdsa_key_name: IDL.Text,\n mode: Mode,\n retrieve_btc_min_amount: IDL.Nat64,\n ledger_id: IDL.Principal,\n max_time_in_queue_nanos: IDL.Nat64,\n btc_network: BtcNetwork,\n check_fee: IDL.Opt(IDL.Nat64),\n btc_checker_principal: IDL.Opt(IDL.Principal),\n min_confirmations: IDL.Opt(IDL.Nat32),\n kyt_fee: IDL.Opt(IDL.Nat64),\n });\n const MinterArg = IDL.Variant({\n Upgrade: IDL.Opt(UpgradeArgs),\n Init: InitArgs,\n });\n const MemoryMetrics = IDL.Record({\n wasm_binary_size: IDL.Nat,\n wasm_chunk_store_size: IDL.Nat,\n canister_history_size: IDL.Nat,\n stable_memory_size: IDL.Nat,\n snapshots_size: IDL.Nat,\n wasm_memory_size: IDL.Nat,\n global_memory_size: IDL.Nat,\n custom_sections_size: IDL.Nat,\n });\n const CanisterStatusType = IDL.Variant({\n stopped: IDL.Null,\n stopping: IDL.Null,\n running: IDL.Null,\n });\n const LogVisibility = IDL.Variant({\n controllers: IDL.Null,\n public: IDL.Null,\n allowed_viewers: IDL.Vec(IDL.Principal),\n });\n const DefiniteCanisterSettings = IDL.Record({\n freezing_threshold: IDL.Nat,\n wasm_memory_threshold: IDL.Nat,\n controllers: IDL.Vec(IDL.Principal),\n reserved_cycles_limit: IDL.Nat,\n log_visibility: LogVisibility,\n wasm_memory_limit: IDL.Nat,\n memory_allocation: IDL.Nat,\n compute_allocation: IDL.Nat,\n });\n const QueryStats = IDL.Record({\n response_payload_bytes_total: IDL.Nat,\n num_instructions_total: IDL.Nat,\n num_calls_total: IDL.Nat,\n request_payload_bytes_total: IDL.Nat,\n });\n const CanisterStatusResponse = IDL.Record({\n memory_metrics: MemoryMetrics,\n status: CanisterStatusType,\n memory_size: IDL.Nat,\n cycles: IDL.Nat,\n settings: DefiniteCanisterSettings,\n query_stats: QueryStats,\n idle_cycles_burned_per_day: IDL.Nat,\n module_hash: IDL.Opt(IDL.Vec(IDL.Nat8)),\n reserved_cycles: IDL.Nat,\n });\n const Account = IDL.Record({\n owner: IDL.Principal,\n subaccount: IDL.Opt(IDL.Vec(IDL.Nat8)),\n });\n const Utxo = IDL.Record({\n height: IDL.Nat32,\n value: IDL.Nat64,\n outpoint: IDL.Record({ txid: IDL.Vec(IDL.Nat8), vout: IDL.Nat32 }),\n });\n const ReimbursementReason = IDL.Variant({\n CallFailed: IDL.Null,\n TaintedDestination: IDL.Record({\n kyt_fee: IDL.Nat64,\n kyt_provider: IDL.Principal,\n }),\n });\n const WithdrawalFee = IDL.Record({\n minter_fee: IDL.Nat64,\n bitcoin_fee: IDL.Nat64,\n });\n const SuspendedReason = IDL.Variant({\n ValueTooSmall: IDL.Null,\n Quarantined: IDL.Null,\n });\n const BitcoinAddress = IDL.Variant({\n p2wsh_v0: IDL.Vec(IDL.Nat8),\n p2tr_v1: IDL.Vec(IDL.Nat8),\n p2sh: IDL.Vec(IDL.Nat8),\n p2wpkh_v0: IDL.Vec(IDL.Nat8),\n p2pkh: IDL.Vec(IDL.Nat8),\n });\n const InvalidTransactionError = IDL.Variant({\n too_many_inputs: IDL.Record({\n max_num_inputs: IDL.Nat64,\n num_inputs: IDL.Nat64,\n }),\n });\n const WithdrawalReimbursementReason = IDL.Variant({\n invalid_transaction: InvalidTransactionError,\n });\n const ReplacedReason = IDL.Variant({\n to_cancel: IDL.Record({ reason: WithdrawalReimbursementReason }),\n to_retry: IDL.Null,\n });\n const EventType = IDL.Variant({\n received_utxos: IDL.Record({\n to_account: Account,\n mint_txid: IDL.Opt(IDL.Nat64),\n utxos: IDL.Vec(Utxo),\n }),\n schedule_deposit_reimbursement: IDL.Record({\n burn_block_index: IDL.Nat64,\n account: Account,\n amount: IDL.Nat64,\n reason: ReimbursementReason,\n }),\n sent_transaction: IDL.Record({\n fee: IDL.Opt(IDL.Nat64),\n change_output: IDL.Opt(IDL.Record({ value: IDL.Nat64, vout: IDL.Nat32 })),\n txid: IDL.Vec(IDL.Nat8),\n withdrawal_fee: IDL.Opt(WithdrawalFee),\n utxos: IDL.Vec(Utxo),\n requests: IDL.Vec(IDL.Nat64),\n submitted_at: IDL.Nat64,\n }),\n distributed_kyt_fee: IDL.Record({\n block_index: IDL.Nat64,\n amount: IDL.Nat64,\n kyt_provider: IDL.Principal,\n }),\n init: InitArgs,\n upgrade: UpgradeArgs,\n retrieve_btc_kyt_failed: IDL.Record({\n block_index: IDL.Nat64,\n owner: IDL.Principal,\n uuid: IDL.Text,\n address: IDL.Text,\n amount: IDL.Nat64,\n kyt_provider: IDL.Principal,\n }),\n suspended_utxo: IDL.Record({\n utxo: Utxo,\n account: Account,\n reason: SuspendedReason,\n }),\n accepted_retrieve_btc_request: IDL.Record({\n received_at: IDL.Nat64,\n block_index: IDL.Nat64,\n address: BitcoinAddress,\n reimbursement_account: IDL.Opt(Account),\n amount: IDL.Nat64,\n kyt_provider: IDL.Opt(IDL.Principal),\n }),\n checked_utxo: IDL.Record({\n clean: IDL.Bool,\n utxo: Utxo,\n uuid: IDL.Text,\n kyt_provider: IDL.Opt(IDL.Principal),\n }),\n schedule_withdrawal_reimbursement: IDL.Record({\n burn_block_index: IDL.Nat64,\n account: Account,\n amount: IDL.Nat64,\n reason: WithdrawalReimbursementReason,\n }),\n quarantined_withdrawal_reimbursement: IDL.Record({\n burn_block_index: IDL.Nat64,\n }),\n removed_retrieve_btc_request: IDL.Record({ block_index: IDL.Nat64 }),\n confirmed_transaction: IDL.Record({ txid: IDL.Vec(IDL.Nat8) }),\n replaced_transaction: IDL.Record({\n fee: IDL.Nat64,\n change_output: IDL.Record({ value: IDL.Nat64, vout: IDL.Nat32 }),\n new_utxos: IDL.Opt(IDL.Vec(Utxo)),\n old_txid: IDL.Vec(IDL.Nat8),\n withdrawal_fee: IDL.Opt(WithdrawalFee),\n new_txid: IDL.Vec(IDL.Nat8),\n submitted_at: IDL.Nat64,\n reason: IDL.Opt(ReplacedReason),\n }),\n checked_utxo_v2: IDL.Record({ utxo: Utxo, account: Account }),\n ignored_utxo: IDL.Record({ utxo: Utxo }),\n checked_utxo_mint_unknown: IDL.Record({\n utxo: Utxo,\n account: Account,\n }),\n reimbursed_failed_deposit: IDL.Record({\n burn_block_index: IDL.Nat64,\n mint_block_index: IDL.Nat64,\n }),\n reimbursed_withdrawal: IDL.Record({\n burn_block_index: IDL.Nat64,\n mint_block_index: IDL.Nat64,\n }),\n });\n const Event = IDL.Record({\n timestamp: IDL.Opt(IDL.Nat64),\n payload: EventType,\n });\n const MinterInfo = IDL.Record({\n retrieve_btc_min_amount: IDL.Nat64,\n min_confirmations: IDL.Nat32,\n kyt_fee: IDL.Nat64,\n });\n const RetrieveBtcArgs = IDL.Record({\n address: IDL.Text,\n amount: IDL.Nat64,\n });\n const RetrieveBtcOk = IDL.Record({ block_index: IDL.Nat64 });\n const RetrieveBtcError = IDL.Variant({\n MalformedAddress: IDL.Text,\n GenericError: IDL.Record({\n error_message: IDL.Text,\n error_code: IDL.Nat64,\n }),\n TemporarilyUnavailable: IDL.Text,\n AlreadyProcessing: IDL.Null,\n AmountTooLow: IDL.Nat64,\n InsufficientFunds: IDL.Record({ balance: IDL.Nat64 }),\n });\n const RetrieveBtcStatus = IDL.Variant({\n Signing: IDL.Null,\n Confirmed: IDL.Record({ txid: IDL.Vec(IDL.Nat8) }),\n Sending: IDL.Record({ txid: IDL.Vec(IDL.Nat8) }),\n AmountTooLow: IDL.Null,\n Unknown: IDL.Null,\n Submitted: IDL.Record({ txid: IDL.Vec(IDL.Nat8) }),\n Pending: IDL.Null,\n });\n const ReimbursementRequest = IDL.Record({\n account: Account,\n amount: IDL.Nat64,\n reason: ReimbursementReason,\n });\n const ReimbursedDeposit = IDL.Record({\n account: Account,\n mint_block_index: IDL.Nat64,\n amount: IDL.Nat64,\n reason: ReimbursementReason,\n });\n const RetrieveBtcStatusV2 = IDL.Variant({\n Signing: IDL.Null,\n Confirmed: IDL.Record({ txid: IDL.Vec(IDL.Nat8) }),\n Sending: IDL.Record({ txid: IDL.Vec(IDL.Nat8) }),\n AmountTooLow: IDL.Null,\n WillReimburse: ReimbursementRequest,\n Unknown: IDL.Null,\n Submitted: IDL.Record({ txid: IDL.Vec(IDL.Nat8) }),\n Reimbursed: ReimbursedDeposit,\n Pending: IDL.Null,\n });\n const RetrieveBtcWithApprovalArgs = IDL.Record({\n from_subaccount: IDL.Opt(IDL.Vec(IDL.Nat8)),\n address: IDL.Text,\n amount: IDL.Nat64,\n });\n const RetrieveBtcWithApprovalError = IDL.Variant({\n MalformedAddress: IDL.Text,\n GenericError: IDL.Record({\n error_message: IDL.Text,\n error_code: IDL.Nat64,\n }),\n TemporarilyUnavailable: IDL.Text,\n InsufficientAllowance: IDL.Record({ allowance: IDL.Nat64 }),\n AlreadyProcessing: IDL.Null,\n AmountTooLow: IDL.Nat64,\n InsufficientFunds: IDL.Record({ balance: IDL.Nat64 }),\n });\n const UtxoStatus = IDL.Variant({\n ValueTooSmall: Utxo,\n Tainted: Utxo,\n Minted: IDL.Record({\n minted_amount: IDL.Nat64,\n block_index: IDL.Nat64,\n utxo: Utxo,\n }),\n Checked: Utxo,\n });\n const Timestamp = IDL.Nat64;\n const SuspendedUtxo = IDL.Record({\n utxo: Utxo,\n earliest_retry: Timestamp,\n reason: SuspendedReason,\n });\n const PendingUtxo = IDL.Record({\n confirmations: IDL.Nat32,\n value: IDL.Nat64,\n outpoint: IDL.Record({ txid: IDL.Vec(IDL.Nat8), vout: IDL.Nat32 }),\n });\n const UpdateBalanceError = IDL.Variant({\n GenericError: IDL.Record({\n error_message: IDL.Text,\n error_code: IDL.Nat64,\n }),\n TemporarilyUnavailable: IDL.Text,\n AlreadyProcessing: IDL.Null,\n NoNewUtxos: IDL.Record({\n suspended_utxos: IDL.Opt(IDL.Vec(SuspendedUtxo)),\n required_confirmations: IDL.Nat32,\n pending_utxos: IDL.Opt(IDL.Vec(PendingUtxo)),\n current_confirmations: IDL.Opt(IDL.Nat32),\n }),\n });\n\n return IDL.Service({\n estimate_withdrawal_fee: IDL.Func(\n [IDL.Record({ amount: IDL.Opt(IDL.Nat64) })],\n [IDL.Record({ minter_fee: IDL.Nat64, bitcoin_fee: IDL.Nat64 })],\n [\"query\"],\n ),\n get_btc_address: IDL.Func(\n [\n IDL.Record({\n owner: IDL.Opt(IDL.Principal),\n subaccount: IDL.Opt(IDL.Vec(IDL.Nat8)),\n }),\n ],\n [IDL.Text],\n [],\n ),\n get_canister_status: IDL.Func([], [CanisterStatusResponse], []),\n get_deposit_fee: IDL.Func([], [IDL.Nat64], [\"query\"]),\n get_events: IDL.Func(\n [IDL.Record({ start: IDL.Nat64, length: IDL.Nat64 })],\n [IDL.Vec(Event)],\n [\"query\"],\n ),\n get_known_utxos: IDL.Func(\n [\n IDL.Record({\n owner: IDL.Opt(IDL.Principal),\n subaccount: IDL.Opt(IDL.Vec(IDL.Nat8)),\n }),\n ],\n [IDL.Vec(Utxo)],\n [\"query\"],\n ),\n get_minter_info: IDL.Func([], [MinterInfo], [\"query\"]),\n get_withdrawal_account: IDL.Func([], [Account], []),\n retrieve_btc: IDL.Func(\n [RetrieveBtcArgs],\n [IDL.Variant({ Ok: RetrieveBtcOk, Err: RetrieveBtcError })],\n [],\n ),\n retrieve_btc_status: IDL.Func(\n [IDL.Record({ block_index: IDL.Nat64 })],\n [RetrieveBtcStatus],\n [\"query\"],\n ),\n retrieve_btc_status_v2: IDL.Func(\n [IDL.Record({ block_index: IDL.Nat64 })],\n [RetrieveBtcStatusV2],\n [\"query\"],\n ),\n retrieve_btc_status_v2_by_account: IDL.Func(\n [IDL.Opt(Account)],\n [\n IDL.Vec(\n IDL.Record({\n block_index: IDL.Nat64,\n status_v2: IDL.Opt(RetrieveBtcStatusV2),\n }),\n ),\n ],\n [\"query\"],\n ),\n retrieve_btc_with_approval: IDL.Func(\n [RetrieveBtcWithApprovalArgs],\n [\n IDL.Variant({\n Ok: RetrieveBtcOk,\n Err: RetrieveBtcWithApprovalError,\n }),\n ],\n [],\n ),\n update_balance: IDL.Func(\n [\n IDL.Record({\n owner: IDL.Opt(IDL.Principal),\n subaccount: IDL.Opt(IDL.Vec(IDL.Nat8)),\n }),\n ],\n [\n IDL.Variant({\n Ok: IDL.Vec(UtxoStatus),\n Err: UpdateBalanceError,\n }),\n ],\n [],\n ),\n });\n};\n\nexport const init = ({ IDL }) => {\n const Mode = IDL.Variant({\n RestrictedTo: IDL.Vec(IDL.Principal),\n DepositsRestrictedTo: IDL.Vec(IDL.Principal),\n ReadOnly: IDL.Null,\n GeneralAvailability: IDL.Null,\n });\n const UpgradeArgs = IDL.Record({\n get_utxos_cache_expiration_seconds: IDL.Opt(IDL.Nat64),\n kyt_principal: IDL.Opt(IDL.Principal),\n mode: IDL.Opt(Mode),\n retrieve_btc_min_amount: IDL.Opt(IDL.Nat64),\n max_time_in_queue_nanos: IDL.Opt(IDL.Nat64),\n check_fee: IDL.Opt(IDL.Nat64),\n btc_checker_principal: IDL.Opt(IDL.Principal),\n min_confirmations: IDL.Opt(IDL.Nat32),\n kyt_fee: IDL.Opt(IDL.Nat64),\n });\n const BtcNetwork = IDL.Variant({\n Mainnet: IDL.Null,\n Regtest: IDL.Null,\n Testnet: IDL.Null,\n });\n const InitArgs = IDL.Record({\n get_utxos_cache_expiration_seconds: IDL.Opt(IDL.Nat64),\n kyt_principal: IDL.Opt(IDL.Principal),\n ecdsa_key_name: IDL.Text,\n mode: Mode,\n retrieve_btc_min_amount: IDL.Nat64,\n ledger_id: IDL.Principal,\n max_time_in_queue_nanos: IDL.Nat64,\n btc_network: BtcNetwork,\n check_fee: IDL.Opt(IDL.Nat64),\n btc_checker_principal: IDL.Opt(IDL.Principal),\n min_confirmations: IDL.Opt(IDL.Nat32),\n kyt_fee: IDL.Opt(IDL.Nat64),\n });\n const MinterArg = IDL.Variant({\n Upgrade: IDL.Opt(UpgradeArgs),\n Init: InitArgs,\n });\n\n return [MinterArg];\n};\n", "import { isNullish } from \"@dfinity/utils\";\nimport { sha256 } from \"@noble/hashes/sha2\";\nimport { base58_to_binary } from \"base58-js\";\nimport { bech32, bech32m, type Decoded } from \"bech32\";\nimport { BtcAddressType, BtcNetwork } from \"../enums/btc.enums\";\nimport {\n ParseBtcAddressBadWitnessLengthError,\n ParseBtcAddressInvalidError,\n ParseBtcAddressMalformedAddressError,\n ParseBtcAddressNoDataError,\n ParseBtcAddressUnexpectedHumanReadablePartError,\n ParseBtcAddressUnsupportedAddressTypeError,\n ParseBtcAddressUnsupportedWitnessVersionError,\n ParseBtcAddressWrongNetworkError,\n} from \"../errors/btc.errors\";\nimport type { BtcAddress, BtcAddressInfo } from \"../types/btc\";\n\n// See https://en.bitcoin.it/wiki/List_of_address_prefixes\nconst BTC_MAINNET_PREFIX = 0; // or 0x00\nconst BTC_MAINNET_P2SH_PREFIX = 5; // or 0x05\nconst BTC_TESTNET_PREFIX = 111; // or 0x6f\nconst BTC_TESTNET_P2SH_PREFIX = 196; // or 0xc4\n\nconst Base58AddressTypes: Record<\n number,\n { type: BtcAddressType; networks: BtcNetwork[] }\n> = {\n [BTC_MAINNET_PREFIX]: {\n type: BtcAddressType.P2pkh,\n networks: [BtcNetwork.Mainnet],\n },\n\n [BTC_TESTNET_PREFIX]: {\n type: BtcAddressType.P2pkh,\n networks: [BtcNetwork.Testnet, BtcNetwork.Regtest],\n },\n\n [BTC_MAINNET_P2SH_PREFIX]: {\n type: BtcAddressType.P2sh,\n networks: [BtcNetwork.Mainnet],\n },\n\n [BTC_TESTNET_P2SH_PREFIX]: {\n type: BtcAddressType.P2sh,\n networks: [BtcNetwork.Testnet, BtcNetwork.Regtest],\n },\n};\n\nconst parseBase58Address = ({\n address,\n network,\n}: Required<BtcAddress>): BtcAddressInfo => {\n const decodeBase58 = (address: string): Uint8Array => {\n try {\n return base58_to_binary(address);\n } catch (_error: unknown) {\n throw new ParseBtcAddressInvalidError();\n }\n };\n\n const decoded: Uint8Array = decodeBase58(address);\n\n const { length } = decoded;\n\n if (length !== 25) {\n throw new ParseBtcAddressMalformedAddressError(\n `Expected the address to be 25 bytes, got ${length}.`,\n );\n }\n\n const validateBase58Checksum = (decoded: Uint8Array) => {\n const expectedChecksum = decoded.slice(length - 4, length);\n const body = decoded.slice(0, length - 4);\n\n const bodyHash = sha256.create();\n bodyHash.update(body);\n\n const checksumHash = sha256.create();\n checksumHash.update(bodyHash.digest());\n\n const checksum = checksumHash.digest().slice(0, 4);\n\n if (\n expectedChecksum.some(\n (value: number, index: number) => value !== checksum[index],\n )\n ) {\n throw new ParseBtcAddressMalformedAddressError(\n `Checksum mismatch expected ${expectedChecksum}, got ${checksum}.`,\n );\n }\n };\n\n validateBase58Checksum(decoded);\n\n const [version] = decoded;\n\n const versionNetwork = Base58AddressTypes[version];\n\n if (isNullish(versionNetwork)) {\n throw new ParseBtcAddressUnsupportedAddressTypeError();\n }\n\n const { type, networks } = versionNetwork;\n\n if (!networks.includes(network)) {\n throw new ParseBtcAddressWrongNetworkError();\n }\n\n return {\n address,\n network,\n type,\n parser: \"base58\",\n };\n};\n\nconst parseBip173Address = ({\n address,\n network,\n}: Required<BtcAddress>): BtcAddressInfo => {\n const decodeBech32 = (address: string): Decoded => {\n try {\n if (\n address.startsWith(\"bc1p\") ||\n address.startsWith(\"tb1p\") ||\n address.startsWith(\"bcrt1p\")\n ) {\n return bech32m.decode(address);\n }\n\n return bech32.decode(address);\n } catch (_error: unknown) {\n throw new ParseBtcAddressMalformedAddressError();\n }\n };\n\n const { prefix, words } = decodeBech32(address);\n\n const mapPrefixToNetwork: Record<string, BtcNetwork> = {\n bc: BtcNetwork.Mainnet,\n tb: BtcNetwork.Testnet,\n bcrt: BtcNetwork.Regtest,\n };\n\n const decodedNetwork: BtcNetwork | undefined = mapPrefixToNetwork[prefix];\n\n if (isNullish(decodedNetwork)) {\n throw new ParseBtcAddressInvalidError();\n }\n\n if (decodedNetwork !== network) {\n throw new ParseBtcAddressUnexpectedHumanReadablePartError();\n }\n\n const [witnessVersion, ...rest] = words;\n\n if (witnessVersion > 1) {\n throw new ParseBtcAddressUnsupportedWitnessVersionError();\n }\n\n const data = bech32.fromWords(rest);\n\n switch (data.length) {\n case 20:\n return {\n address,\n network,\n type: BtcAddressType.P2wpkhV0,\n parser: \"bip-173\",\n };\n case 32:\n return {\n address,\n network,\n type: witnessVersion === 0 ? BtcAddressType.P2wsh : BtcAddressType.P2tr,\n parser: \"bip-173\",\n };\n default:\n throw new ParseBtcAddressBadWitnessLengthError();\n }\n};\n\n/**\n * Parse a Bitcoin address.\n *\n * Parse implementation follows strategy implemented in [Minter canister](https://github.com/dfinity/ic/blob/a8da3aa23dc6f8f4708cb0cb8edce84c5bd8f225/rs/bitcoin/ckbtc/minter/src/address.rs#L54).\n *\n * Credits: Parts of JavaScript code and test values from [bitcoin-address-validation](https://github.com/ruigomeseu/bitcoin-address-validation).\n *\n * @param {BtcAddress} params The Bitcoin address and network to parse\n * @param {string} params.address\n * @param {BtcNetwork} params.network Optional. Default BtcNetwork is Mainnet\n */\nexport const parseBtcAddress = ({\n address,\n network = BtcNetwork.Mainnet,\n}: BtcAddress): BtcAddressInfo => {\n switch (address.charAt(0)) {\n case \"1\":\n case \"2\":\n case \"3\":\n case \"m\":\n case \"n\":\n return parseBase58Address({ address, network });\n case \"b\":\n case \"B\":\n case \"t\":\n case \"T\":\n return parseBip173Address({ address, network });\n case \"\":\n throw new ParseBtcAddressNoDataError();\n default:\n throw new ParseBtcAddressUnsupportedAddressTypeError();\n }\n};\n", "/**\n * Utilities for hex, bytes, CSPRNG.\n * @module\n */\n/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */\n\n// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.\n// node.js versions earlier than v19 don't declare it in global scope.\n// For node.js, package.json#exports field mapping rewrites import\n// from `crypto` to `cryptoNode`, which imports native module.\n// Makes the utils un-importable in browsers without a bundler.\n// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.\nimport { crypto } from '@noble/hashes/crypto';\n\n/** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */\nexport function isBytes(a: unknown): a is Uint8Array {\n return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');\n}\n\n/** Asserts something is positive integer. */\nexport function anumber(n: number): void {\n if (!Number.isSafeInteger(n) || n < 0) throw new Error('positive integer expected, got ' + n);\n}\n\n/** Asserts something is Uint8Array. */\nexport function abytes(b: Uint8Array | undefined, ...lengths: number[]): void {\n if (!isBytes(b)) throw new Error('Uint8Array expected');\n if (lengths.length > 0 && !lengths.includes(b.length))\n throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length);\n}\n\n/** Asserts something is hash */\nexport function ahash(h: IHash): void {\n if (typeof h !== 'function' || typeof h.create !== 'function')\n throw new Error('Hash should be wrapped by utils.createHasher');\n anumber(h.outputLen);\n anumber(h.blockLen);\n}\n\n/** Asserts a hash instance has not been destroyed / finished */\nexport function aexists(instance: any, checkFinished = true): void {\n if (instance.destroyed) throw new Error('Hash instance has been destroyed');\n if (checkFinished && instance.finished) throw new Error('Hash#digest() has already been called');\n}\n\n/** Asserts output is properly-sized byte array */\nexport function aoutput(out: any, instance: any): void {\n abytes(out);\n const min = instance.outputLen;\n if (out.length < min) {\n throw new Error('digestInto() expects output buffer of length at least ' + min);\n }\n}\n\n/** Generic type encompassing 8/16/32-byte arrays - but not 64-byte. */\n// prettier-ignore\nexport type TypedArray = Int8Array | Uint8ClampedArray | Uint8Array |\n Uint16Array | Int16Array | Uint32Array | Int32Array;\n\n/** Cast u8 / u16 / u32 to u8. */\nexport function u8(arr: TypedArray): Uint8Array {\n return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);\n}\n\n/** Cast u8 / u16 / u32 to u32. */\nexport function u32(arr: TypedArray): Uint32Array {\n return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));\n}\n\n/** Zeroize a byte array. Warning: JS provides no guarantees. */\nexport function clean(...arrays: TypedArray[]): void {\n for (let i = 0; i < arrays.length; i++) {\n arrays[i].fill(0);\n }\n}\n\n/** Create DataView of an array for easy byte-level manipulation. */\nexport function createView(arr: TypedArray): DataView {\n return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);\n}\n\n/** The rotate right (circular right shift) operation for uint32 */\nexport function rotr(word: number, shift: number): number {\n return (word << (32 - shift)) | (word >>> shift);\n}\n\n/** The rotate left (circular left shift) operation for uint32 */\nexport function rotl(word: number, shift: number): number {\n return (word << shift) | ((word >>> (32 - shift)) >>> 0);\n}\n\n/** Is current platform little-endian? Most are. Big-Endian platform: IBM */\nexport const isLE: boolean = /* @__PURE__ */ (() =>\n new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)();\n\n/** The byte swap operation for uint32 */\nexport function byteSwap(word: number): number {\n return (\n ((word << 24) & 0xff000000) |\n ((word << 8) & 0xff0000) |\n ((word >>> 8) & 0xff00) |\n ((word >>> 24) & 0xff)\n );\n}\n/** Conditionally byte swap if on a big-endian platform */\nexport const swap8IfBE: (n: number) => number = isLE\n ? (n: number) => n\n : (n: number) => byteSwap(n);\n\n/** @deprecated */\nexport const byteSwapIfBE: typeof swap8IfBE = swap8IfBE;\n/** In place byte swap for Uint32Array */\nexport function byteSwap32(arr: Uint32Array): Uint32Array {\n for (let i = 0; i < arr.length; i++) {\n arr[i] = byteSwap(arr[i]);\n }\n return arr;\n}\n\nexport const swap32IfBE: (u: Uint32Array) => Uint32Array = isLE\n ? (u: Uint32Array) => u\n : byteSwap32;\n\n// Built-in hex conversion https://caniuse.com/mdn-javascript_builtins_uint8array_fromhex\nconst hasHexBuiltin: boolean = /* @__PURE__ */ (() =>\n // @ts-ignore\n typeof Uint8Array.from([]).toHex === 'function' && typeof Uint8Array.fromHex === 'function')();\n\n// Array where index 0xf0 (240) is mapped to string 'f0'\nconst hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) =>\n i.toString(16).padStart(2, '0')\n);\n\n/**\n * Convert byte array to hex string. Uses built-in function, when available.\n * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'\n */\nexport function bytesToHex(bytes: Uint8Array): string {\n abytes(bytes);\n // @ts-ignore\n if (hasHexBuiltin) return bytes.toHex();\n // pre-caching improves the speed 6x\n let hex = '';\n for (let i = 0; i < bytes.length; i++) {\n hex += hexes[bytes[i]];\n }\n return hex;\n}\n\n// We use optimized technique to convert hex string to byte array\nconst asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 } as const;\nfunction asciiToBase16(ch: number): number | undefined {\n if (ch >= asciis._0 && ch <= asciis._9) return ch - asciis._0; // '2' => 50-48\n if (ch >= asciis.A && ch <= asciis.F) return ch - (asciis.A - 10); // 'B' => 66-(65-10)\n if (ch >= asciis.a && ch <= asciis.f) return ch - (asciis.a - 10); // 'b' => 98-(97-10)\n return;\n}\n\n/**\n * Convert hex string to byte array. Uses built-in function, when available.\n * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])\n */\nexport function hexToBytes(hex: string): Uint8Array {\n if (typeof hex !== 'string') throw new Error('hex string expected, got ' + typeof hex);\n // @ts-ignore\n if (hasHexBuiltin) return Uint8Array.fromHex(hex);\n const hl = hex.length;\n const al = hl / 2;\n if (hl % 2) throw new Error('hex string expected, got unpadded hex of length ' + hl);\n const array = new Uint8Array(al);\n for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {\n const n1 = asciiToBase16(hex.charCodeAt(hi));\n const n2 = asciiToBase16(hex.charCodeAt(hi + 1));\n if (n1 === undefined || n2 === undefined) {\n const char = hex[hi] + hex[hi + 1];\n throw new Error('hex string expected, got non-hex character \"' + char + '\" at index ' + hi);\n }\n array[ai] = n1 * 16 + n2; // multiply first octet, e.g. 'a3' => 10*16+3 => 160 + 3 => 163\n }\n return array;\n}\n\n/**\n * There is no setImmediate in browser and setTimeout is slow.\n * Call of async fn will return Promise, which will be fullfiled only on\n * next scheduler queue processing step and this is exactly what we need.\n */\nexport const nextTick = async (): Promise<void> => {};\n\n/** Returns control to thread each 'tick' ms to avoid blocking. */\nexport async function asyncLoop(\n iters: number,\n tick: number,\n cb: (i: number) => void\n): Promise<void> {\n let ts = Date.now();\n for (let i = 0; i < iters; i++) {\n cb(i);\n // Date.now() is not monotonic, so in case if clock goes backwards we return return control too\n const diff = Date.now() - ts;\n if (diff >= 0 && diff < tick) continue;\n await nextTick();\n ts += diff;\n }\n}\n\n// Global symbols, but ts doesn't see them: https://github.com/microsoft/TypeScript/issues/31535\ndeclare const TextEncoder: any;\ndeclare const TextDecoder: any;\n\n/**\n * Converts string to bytes using UTF8 encoding.\n * @example utf8ToBytes('abc') // Uint8Array.from([97, 98, 99])\n */\nexport function utf8ToBytes(str: string): Uint8Array {\n if (typeof str !== 'string') throw new Error('string expected');\n return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809\n}\n\n/**\n * Converts bytes to string using UTF8 encoding.\n * @example bytesToUtf8(Uint8Array.from([97, 98, 99])) // 'abc'\n */\nexport function bytesToUtf8(bytes: Uint8Array): string {\n return new TextDecoder().decode(bytes);\n}\n\n/** Accepted input of hash functions. Strings are converted to byte arrays. */\nexport type Input = string | Uint8Array;\n/**\n * Normalizes (non-hex) string or Uint8Array to Uint8Array.\n * Warning: when Uint8Array is passed, it would NOT get copied.\n * Keep in mind for future mutable operations.\n */\nexport function toBytes(data: Input): Uint8Array {\n if (typeof data === 'string') data = utf8ToBytes(data);\n abytes(data);\n return data;\n}\n\n/** KDFs can accept string or Uint8Array for user convenience. */\nexport type KDFInput = string | Uint8Array;\n/**\n * Helper for KDFs: consumes uint8array or string.\n * When string is passed, does utf8 decoding, using TextDecoder.\n */\nexport function kdfInputToBytes(data: KDFInput): Uint8Array {\n if (typeof data === 'string') data = utf8ToBytes(data);\n abytes(data);\n return data;\n}\n\n/** Copies several Uint8Arrays into one. */\nexport function concatBytes(...arrays: Uint8Array[]): Uint8Array {\n let sum = 0;\n for (let i = 0; i < arrays.length; i++) {\n const a = arrays[i];\n abytes(a);\n sum += a.length;\n }\n const res = new Uint8Array(sum);\n for (let i = 0, pad = 0; i < arrays.length; i++) {\n const a = arrays[i];\n res.set(a, pad);\n pad += a.length;\n }\n return res;\n}\n\ntype EmptyObj = {};\nexport function checkOpts<T1 extends EmptyObj, T2 extends EmptyObj>(\n defaults: T1,\n opts?: T2\n): T1 & T2 {\n if (opts !== undefined && {}.toString.call(opts) !== '[object Object]')\n throw new Error('options should be object or undefined');\n const merged = Object.assign(defaults, opts);\n return merged as T1 & T2;\n}\n\n/** Hash interface. */\nexport type IHash = {\n (data: Uint8Array): Uint8Array;\n blockLen: number;\n outputLen: number;\n create: any;\n};\n\n/** For runtime check if class implements interface */\nexport abstract class Hash<T extends Hash<T>> {\n abstract blockLen: number; // Bytes per block\n abstract outputLen: number; // Bytes in output\n abstract update(buf: Input): this;\n // Writes digest into buf\n abstract digestInto(buf: Uint8Array): void;\n abstract digest(): Uint8Array;\n /**\n * Resets internal state. Makes Hash instance unusable.\n * Reset is impossible for keyed hashes if key is consumed into state. If digest is not consumed\n * by user, they will need to manually call `destroy()` when zeroing is necessary.\n */\n abstract destroy(): void;\n /**\n * Clones hash instance. Unsafe: doesn't check whether `to` is valid. Can be used as `clone()`\n * when no options are passed.\n * Reasons to use `_cloneInto` instead of clone: 1) performance 2) reuse instance => all internal\n * buffers are overwritten => causes buffer overwrite which is used for digest in some cases.\n * There are no guarantees for clean-up because it's impossible in JS.\n */\n abstract _cloneInto(to?: T): T;\n // Safe version that clones internal state\n abstract clone(): T;\n}\n\n/**\n * XOF: streaming API to read digest in chunks.\n * Same as 'squeeze' in keccak/k12 and 'seek' in blake3, but more generic name.\n * When hash used in XOF mode it is up to user to call '.destroy' afterwards, since we cannot\n * destroy state, next call can require more bytes.\n */\nexport type HashXOF<T extends Hash<T>> = Hash<T> & {\n xof(bytes: number): Uint8Array; // Read 'bytes' bytes from digest stream\n xofInto(buf: Uint8Array): Uint8Array; // read buf.length bytes from digest stream into buf\n};\n\n/** Hash function */\nexport type CHash = ReturnType<typeof createHasher>;\n/** Hash function with output */\nexport type CHashO = ReturnType<typeof createOptHasher>;\n/** XOF with output */\nexport type CHashXO = ReturnType<typeof createXOFer>;\n\n/** Wraps hash function, creating an interface on top of it */\nexport function createHasher<T extends Hash<T>>(\n hashCons: () => Hash<T>\n): {\n (msg: Input): Uint8Array;\n outputLen: number;\n blockLen: number;\n create(): Hash<T>;\n} {\n const hashC = (msg: Input): Uint8Array => hashCons().update(toBytes(msg)).digest();\n const tmp = hashCons();\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = () => hashCons();\n return hashC;\n}\n\nexport function createOptHasher<H extends Hash<H>, T extends Object>(\n hashCons: (opts?: T) => Hash<H>\n): {\n (msg: Input, opts?: T): Uint8Array;\n outputLen: number;\n blockLen: number;\n create(opts?: T): Hash<H>;\n} {\n const hashC = (msg: Input, opts?: T): Uint8Array => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({} as T);\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts?: T) => hashCons(opts);\n return hashC;\n}\n\nexport function createXOFer<H extends HashXOF<H>, T extends Object>(\n hashCons: (opts?: T) => HashXOF<H>\n): {\n (msg: Input, opts?: T): Uint8Array;\n outputLen: number;\n blockLen: number;\n create(opts?: T): HashXOF<H>;\n} {\n const hashC = (msg: Input, opts?: T): Uint8Array => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({} as T);\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts?: T) => hashCons(opts);\n return hashC;\n}\nexport const wrapConstructor: typeof createHasher = createHasher;\nexport const wrapConstructorWithOpts: typeof createOptHasher = createOptHasher;\nexport const wrapXOFConstructorWithOpts: typeof createXOFer = createXOFer;\n\n/** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */\nexport function randomBytes(bytesLength = 32): Uint8Array {\n if (crypto && typeof crypto.getRandomValues === 'function') {\n return crypto.getRandomValues(new Uint8Array(bytesLength));\n }\n // Legacy Node.js compatibility\n if (crypto && typeof crypto.randomBytes === 'function') {\n return Uint8Array.from(crypto.randomBytes(bytesLength));\n }\n throw new Error('crypto.getRandomValues must be defined');\n}\n", "/**\n * Internal Merkle-Damgard hash utils.\n * @module\n */\nimport { type Input, Hash, abytes, aexists, aoutput, clean, createView, toBytes } from './utils.ts';\n\n/** Polyfill for Safari 14. https://caniuse.com/mdn-javascript_builtins_dataview_setbiguint64 */\nexport function setBigUint64(\n view: DataView,\n byteOffset: number,\n value: bigint,\n isLE: boolean\n): void {\n if (typeof view.setBigUint64 === 'function') return view.setBigUint64(byteOffset, value, isLE);\n const _32n = BigInt(32);\n const _u32_max = BigInt(0xffffffff);\n const wh = Number((value >> _32n) & _u32_max);\n const wl = Number(value & _u32_max);\n const h = isLE ? 4 : 0;\n const l = isLE ? 0 : 4;\n view.setUint32(byteOffset + h, wh, isLE);\n view.setUint32(byteOffset + l, wl, isLE);\n}\n\n/** Choice: a ? b : c */\nexport function Chi(a: number, b: number, c: number): number {\n return (a & b) ^ (~a & c);\n}\n\n/** Majority function, true if any two inputs is true. */\nexport function Maj(a: number, b: number, c: number): number {\n return (a & b) ^ (a & c) ^ (b & c);\n}\n\n/**\n * Merkle-Damgard hash construction base class.\n * Could be used to create MD5, RIPEMD, SHA1, SHA2.\n */\nexport abstract class HashMD<T extends HashMD<T>> extends Hash<T> {\n protected abstract process(buf: DataView, offset: number): void;\n protected abstract get(): number[];\n protected abstract set(...args: number[]): void;\n abstract destroy(): void;\n protected abstract roundClean(): void;\n\n readonly blockLen: number;\n readonly outputLen: number;\n readonly padOffset: number;\n readonly isLE: boolean;\n\n // For partial updates less than block size\n protected buffer: Uint8Array;\n protected view: DataView;\n protected finished = false;\n protected length = 0;\n protected pos = 0;\n protected destroyed = false;\n\n constructor(blockLen: number, outputLen: number, padOffset: number, isLE: boolean) {\n super();\n this.blockLen = blockLen;\n this.outputLen = outputLen;\n this.padOffset = padOffset;\n this.isLE = isLE;\n this.buffer = new Uint8Array(blockLen);\n this.view = createView(this.buffer);\n }\n update(data: Input): this {\n aexists(this);\n data = toBytes(data);\n abytes(data);\n const { view, buffer, blockLen } = this;\n const len = data.length;\n for (let pos = 0; pos < len; ) {\n const take = Math.min(blockLen - this.pos, len - pos);\n // Fast path: we have at least one block in input, cast it to view and process\n if (take === blockLen) {\n const dataView = createView(data);\n for (; blockLen <= len - pos; pos += blockLen) this.process(dataView, pos);\n continue;\n }\n buffer.set(data.subarray(pos, pos + take), this.pos);\n this.pos += take;\n pos += take;\n if (this.pos === blockLen) {\n this.process(view, 0);\n this.pos = 0;\n }\n }\n this.length += data.length;\n this.roundClean();\n return this;\n }\n digestInto(out: Uint8Array): void {\n aexists(this);\n aoutput(out, this);\n this.finished = true;\n // Padding\n // We can avoid allocation of buffer for padding completely if it\n // was previously not allocated here. But it won't change performance.\n const { buffer, view, blockLen, isLE } = this;\n let { pos } = this;\n // append the bit '1' to the message\n buffer[pos++] = 0b10000000;\n clean(this.buffer.subarray(pos));\n // we have less than padOffset left in buffer, so we cannot put length in\n // current block, need process it and pad again\n if (this.padOffset > blockLen - pos) {\n this.process(view, 0);\n pos = 0;\n }\n // Pad until full block byte with zeros\n for (let i = pos; i < blockLen; i++) buffer[i] = 0;\n // Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that\n // You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.\n // So we just write lowest 64 bits of that value.\n setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);\n this.process(view, 0);\n const oview = createView(out);\n const len = this.outputLen;\n // NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT\n if (len % 4) throw new Error('_sha2: outputLen should be aligned to 32bit');\n const outLen = len / 4;\n const state = this.get();\n if (outLen > state.length) throw new Error('_sha2: outputLen bigger than state');\n for (let i = 0; i < outLen; i++) oview.setUint32(4 * i, state[i], isLE);\n }\n digest(): Uint8Array {\n const { buffer, outputLen } = this;\n this.digestInto(buffer);\n const res = buffer.slice(0, outputLen);\n this.destroy();\n return res;\n }\n _cloneInto(to?: T): T {\n to ||= new (this.constructor as any)() as T;\n to.set(...this.get());\n const { blockLen, buffer, length, finished, destroyed, pos } = this;\n to.destroyed = destroyed;\n to.finished = finished;\n to.length = length;\n to.pos = pos;\n if (length % blockLen) to.buffer.set(buffer);\n return to;\n }\n clone(): T {\n return this._cloneInto();\n }\n}\n\n/**\n * Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53.\n * Check out `test/misc/sha2-gen-iv.js` for recomputation guide.\n */\n\n/** Initial SHA256 state. Bits 0..32 of frac part of sqrt of primes 2..19 */\nexport const SHA256_IV: Uint32Array = /* @__PURE__ */ Uint32Array.from([\n 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,\n]);\n\n/** Initial SHA224 state. Bits 32..64 of frac part of sqrt of primes 23..53 */\nexport const SHA224_IV: Uint32Array = /* @__PURE__ */ Uint32Array.from([\n 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4,\n]);\n\n/** Initial SHA384 state. Bits 0..64 of frac part of sqrt of primes 23..53 */\nexport const SHA384_IV: Uint32Array = /* @__PURE__ */ Uint32Array.from([\n 0xcbbb9d5d, 0xc1059ed8, 0x629a292a, 0x367cd507, 0x9159015a, 0x3070dd17, 0x152fecd8, 0xf70e5939,\n 0x67332667, 0xffc00b31, 0x8eb44a87, 0x68581511, 0xdb0c2e0d, 0x64f98fa7, 0x47b5481d, 0xbefa4fa4,\n]);\n\n/** Initial SHA512 state. Bits 0..64 of frac part of sqrt of primes 2..19 */\nexport const SHA512_IV: Uint32Array = /* @__PURE__ */ Uint32Array.from([\n 0x6a09e667, 0xf3bcc908, 0xbb67ae85, 0x84caa73b, 0x3c6ef372, 0xfe94f82b, 0xa54ff53a, 0x5f1d36f1,\n 0x510e527f, 0xade682d1, 0x9b05688c, 0x2b3e6c1f, 0x1f83d9ab, 0xfb41bd6b, 0x5be0cd19, 0x137e2179,\n]);\n", "/**\n * SHA2 hash function. A.k.a. sha256, sha384, sha512, sha512_224, sha512_256.\n * SHA256 is the fastest hash implementable in JS, even faster than Blake3.\n * Check out [RFC 4634](https://datatracker.ietf.org/doc/html/rfc4634) and\n * [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf).\n * @module\n */\nimport { Chi, HashMD, Maj, SHA224_IV, SHA256_IV, SHA384_IV, SHA512_IV } from './_md.ts';\nimport * as u64 from './_u64.ts';\nimport { type CHash, clean, createHasher, rotr } from './utils.ts';\n\n/**\n * Round constants:\n * First 32 bits of fractional parts of the cube roots of the first 64 primes 2..311)\n */\n// prettier-ignore\nconst SHA256_K = /* @__PURE__ */ Uint32Array.from([\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2\n]);\n\n/** Reusable temporary buffer. \"W\" comes straight from spec. */\nconst SHA256_W = /* @__PURE__ */ new Uint32Array(64);\nexport class SHA256 extends HashMD<SHA256> {\n // We cannot use array here since array allows indexing by variable\n // which means optimizer/compiler cannot use registers.\n protected A: number = SHA256_IV[0] | 0;\n protected B: number = SHA256_IV[1] | 0;\n protected C: number = SHA256_IV[2] | 0;\n protected D: number = SHA256_IV[3] | 0;\n protected E: number = SHA256_IV[4] | 0;\n protected F: number = SHA256_IV[5] | 0;\n protected G: number = SHA256_IV[6] | 0;\n protected H: number = SHA256_IV[7] | 0;\n\n constructor(outputLen: number = 32) {\n super(64, outputLen, 8, false);\n }\n protected get(): [number, number, number, number, number, number, number, number] {\n const { A, B, C, D, E, F, G, H } = this;\n return [A, B, C, D, E, F, G, H];\n }\n // prettier-ignore\n protected set(\n A: number, B: number, C: number, D: number, E: number, F: number, G: number, H: number\n ): void {\n this.A = A | 0;\n this.B = B | 0;\n this.C = C | 0;\n this.D = D | 0;\n this.E = E | 0;\n this.F = F | 0;\n this.G = G | 0;\n this.H = H | 0;\n }\n protected process(view: DataView, offset: number): void {\n // Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array\n for (let i = 0; i < 16; i++, offset += 4) SHA256_W[i] = view.getUint32(offset, false);\n for (let i = 16; i < 64; i++) {\n const W15 = SHA256_W[i - 15];\n const W2 = SHA256_W[i - 2];\n const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ (W15 >>> 3);\n const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ (W2 >>> 10);\n SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;\n }\n // Compression function main loop, 64 rounds\n let { A, B, C, D, E, F, G, H } = this;\n for (let i = 0; i < 64; i++) {\n const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);\n const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;\n const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);\n const T2 = (sigma0 + Maj(A, B, C)) | 0;\n H = G;\n G = F;\n F = E;\n E = (D + T1) | 0;\n D = C;\n C = B;\n B = A;\n A = (T1 + T2) | 0;\n }\n // Add the compressed chunk to the current hash value\n A = (A + this.A) | 0;\n B = (B + this.B) | 0;\n C = (C + this.C) | 0;\n D = (D + this.D) | 0;\n E = (E + this.E) | 0;\n F = (F + this.F) | 0;\n G = (G + this.G) | 0;\n H = (H + this.H) | 0;\n this.set(A, B, C, D, E, F, G, H);\n }\n protected roundClean(): void {\n clean(SHA256_W);\n }\n destroy(): void {\n this.set(0, 0, 0, 0, 0, 0, 0, 0);\n clean(this.buffer);\n }\n}\n\nexport class SHA224 extends SHA256 {\n protected A: number = SHA224_IV[0] | 0;\n protected B: number = SHA224_IV[1] | 0;\n protected C: number = SHA224_IV[2] | 0;\n protected D: number = SHA224_IV[3] | 0;\n protected E: number = SHA224_IV[4] | 0;\n protected F: number = SHA224_IV[5] | 0;\n protected G: number = SHA224_IV[6] | 0;\n protected H: number = SHA224_IV[7] | 0;\n constructor() {\n super(28);\n }\n}\n\n// SHA2-512 is slower than sha256 in js because u64 operations are slow.\n\n// Round contants\n// First 32 bits of the fractional parts of the cube roots of the first 80 primes 2..409\n// prettier-ignore\nconst K512 = /* @__PURE__ */ (() => u64.split([\n '0x428a2f98d728ae22', '0x7137449123ef65cd', '0xb5c0fbcfec4d3b2f', '0xe9b5dba58189dbbc',\n '0x3956c25bf348b538', '0x59f111f1b605d019', '0x923f82a4af194f9b', '0xab1c5ed5da6d8118',\n '0xd807aa98a3030242', '0x12835b0145706fbe', '0x243185be4ee4b28c', '0x550c7dc3d5ffb4e2',\n '0x72be5d74f27b896f', '0x80deb1fe3b1696b1', '0x9bdc06a725c71235', '0xc19bf174cf692694',\n '0xe49b69c19ef14ad2', '0xefbe4786384f25e3', '0x0fc19dc68b8cd5b5', '0x240ca1cc77ac9c65',\n '0x2de92c6f592b0275', '0x4a7484aa6ea6e483', '0x5cb0a9dcbd41fbd4', '0x76f988da831153b5',\n '0x983e5152ee66dfab', '0xa831c66d2db43210', '0xb00327c898fb213f', '0xbf597fc7beef0ee4',\n '0xc6e00bf33da88fc2', '0xd5a79147930aa725', '0x06ca6351e003826f', '0x142929670a0e6e70',\n '0x27b70a8546d22ffc', '0x2e1b21385c26c926', '0x4d2c6dfc5ac42aed', '0x53380d139d95b3df',\n '0x650a73548baf63de', '0x766a0abb3c77b2a8', '0x81c2c92e47edaee6', '0x92722c851482353b',\n '0xa2bfe8a14cf10364', '0xa81a664bbc423001', '0xc24b8b70d0f89791', '0xc76c51a30654be30',\n '0xd192e819d6ef5218', '0xd69906245565a910', '0xf40e35855771202a', '0x106aa07032bbd1b8',\n '0x19a4c116b8d2d0c8', '0x1e376c085141ab53', '0x2748774cdf8eeb99', '0x34b0bcb5e19b48a8',\n '0x391c0cb3c5c95a63', '0x4ed8aa4ae3418acb', '0x5b9cca4f7763e373', '0x682e6ff3d6b2b8a3',\n '0x748f82ee5defb2fc', '0x78a5636f43172f60', '0x84c87814a1f0ab72', '0x8cc702081a6439ec',\n '0x90befffa23631e28', '0xa4506cebde82bde9', '0xbef9a3f7b2c67915', '0xc67178f2e372532b',\n '0xca273eceea26619c', '0xd186b8c721c0c207', '0xeada7dd6cde0eb1e', '0xf57d4f7fee6ed178',\n '0x06f067aa72176fba', '0x0a637dc5a2c898a6', '0x113f9804bef90dae', '0x1b710b35131c471b',\n '0x28db77f523047d84', '0x32caab7b40c72493', '0x3c9ebe0a15c9bebc', '0x431d67c49c100d4c',\n '0x4cc5d4becb3e42b6', '0x597f299cfc657e2a', '0x5fcb6fab3ad6faec', '0x6c44198c4a475817'\n].map(n => BigInt(n))))();\nconst SHA512_Kh = /* @__PURE__ */ (() => K512[0])();\nconst SHA512_Kl = /* @__PURE__ */ (() => K512[1])();\n\n// Reusable temporary buffers\nconst SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);\nconst SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);\n\nexport class SHA512 extends HashMD<SHA512> {\n // We cannot use array here since array allows indexing by variable\n // which means optimizer/compiler cannot use registers.\n // h -- high 32 bits, l -- low 32 bits\n protected Ah: number = SHA512_IV[0] | 0;\n protected Al: number = SHA512_IV[1] | 0;\n protected Bh: number = SHA512_IV[2] | 0;\n protected Bl: number = SHA512_IV[3] | 0;\n protected Ch: number = SHA512_IV[4] | 0;\n protected Cl: number = SHA512_IV[5] | 0;\n protected Dh: number = SHA512_IV[6] | 0;\n protected Dl: number = SHA512_IV[7] | 0;\n protected Eh: number = SHA512_IV[8] | 0;\n protected El: number = SHA512_IV[9] | 0;\n protected Fh: number = SHA512_IV[10] | 0;\n protected Fl: number = SHA512_IV[11] | 0;\n protected Gh: number = SHA512_IV[12] | 0;\n protected Gl: number = SHA512_IV[13] | 0;\n protected Hh: number = SHA512_IV[14] | 0;\n protected Hl: number = SHA512_IV[15] | 0;\n\n constructor(outputLen: number = 64) {\n super(128, outputLen, 16, false);\n }\n // prettier-ignore\n protected get(): [\n number, number, number, number, number, number, number, number,\n number, number, number, number, number, number, number, number\n ] {\n const { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;\n return [Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl];\n }\n // prettier-ignore\n protected set(\n Ah: number, Al: number, Bh: number, Bl: number, Ch: number, Cl: number, Dh: number, Dl: number,\n Eh: number, El: number, Fh: number, Fl: number, Gh: number, Gl: number, Hh: number, Hl: number\n ): void {\n this.Ah = Ah | 0;\n this.Al = Al | 0;\n this.Bh = Bh | 0;\n this.Bl = Bl | 0;\n this.Ch = Ch | 0;\n this.Cl = Cl | 0;\n this.Dh = Dh | 0;\n this.Dl = Dl | 0;\n this.Eh = Eh | 0;\n this.El = El | 0;\n this.Fh = Fh | 0;\n this.Fl = Fl | 0;\n this.Gh = Gh | 0;\n this.Gl = Gl | 0;\n this.Hh = Hh | 0;\n this.Hl = Hl | 0;\n }\n protected process(view: DataView, offset: number): void {\n // Extend the first 16 words into the remaining 64 words w[16..79] of the message schedule array\n for (let i = 0; i < 16; i++, offset += 4) {\n SHA512_W_H[i] = view.getUint32(offset);\n SHA512_W_L[i] = view.getUint32((offset += 4));\n }\n for (let i = 16; i < 80; i++) {\n // s0 := (w[i-15] rightrotate 1) xor (w[i-15] rightrotate 8) xor (w[i-15] rightshift 7)\n const W15h = SHA512_W_H[i - 15] | 0;\n const W15l = SHA512_W_L[i - 15] | 0;\n const s0h = u64.rotrSH(W15h, W15l, 1) ^ u64.rotrSH(W15h, W15l, 8) ^ u64.shrSH(W15h, W15l, 7);\n const s0l = u64.rotrSL(W15h, W15l, 1) ^ u64.rotrSL(W15h, W15l, 8) ^ u64.shrSL(W15h, W15l, 7);\n // s1 := (w[i-2] rightrotate 19) xor (w[i-2] rightrotate 61) xor (w[i-2] rightshift 6)\n const W2h = SHA512_W_H[i - 2] | 0;\n const W2l = SHA512_W_L[i - 2] | 0;\n const s1h = u64.rotrSH(W2h, W2l, 19) ^ u64.rotrBH(W2h, W2l, 61) ^ u64.shrSH(W2h, W2l, 6);\n const s1l = u64.rotrSL(W2h, W2l, 19) ^ u64.rotrBL(W2h, W2l, 61) ^ u64.shrSL(W2h, W2l, 6);\n // SHA256_W[i] = s0 + s1 + SHA256_W[i - 7] + SHA256_W[i - 16];\n const SUMl = u64.add4L(s0l, s1l, SHA512_W_L[i - 7], SHA512_W_L[i - 16]);\n const SUMh = u64.add4H(SUMl, s0h, s1h, SHA512_W_H[i - 7], SHA512_W_H[i - 16]);\n SHA512_W_H[i] = SUMh | 0;\n SHA512_W_L[i] = SUMl | 0;\n }\n let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;\n // Compression function main loop, 80 rounds\n for (let i = 0; i < 80; i++) {\n // S1 := (e rightrotate 14) xor (e rightrotate 18) xor (e rightrotate 41)\n const sigma1h = u64.rotrSH(Eh, El, 14) ^ u64.rotrSH(Eh, El, 18) ^ u64.rotrBH(Eh, El, 41);\n const sigma1l = u64.rotrSL(Eh, El, 14) ^ u64.rotrSL(Eh, El, 18) ^ u64.rotrBL(Eh, El, 41);\n //const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;\n const CHIh = (Eh & Fh) ^ (~Eh & Gh);\n const CHIl = (El & Fl) ^ (~El & Gl);\n // T1 = H + sigma1 + Chi(E, F, G) + SHA512_K[i] + SHA512_W[i]\n // prettier-ignore\n const T1ll = u64.add5L(Hl, sigma1l, CHIl, SHA512_Kl[i], SHA512_W_L[i]);\n const T1h = u64.add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh[i], SHA512_W_H[i]);\n const T1l = T1ll | 0;\n // S0 := (a rightrotate 28) xor (a rightrotate 34) xor (a rightrotate 39)\n const sigma0h = u64.rotrSH(Ah, Al, 28) ^ u64.rotrBH(Ah, Al, 34) ^ u64.rotrBH(Ah, Al, 39);\n const sigma0l = u64.rotrSL(Ah, Al, 28) ^ u64.rotrBL(Ah, Al, 34) ^ u64.rotrBL(Ah, Al, 39);\n const MAJh = (Ah & Bh) ^ (Ah & Ch) ^ (Bh & Ch);\n const MAJl = (Al & Bl) ^ (Al & Cl) ^ (Bl & Cl);\n Hh = Gh | 0;\n Hl = Gl | 0;\n Gh = Fh | 0;\n Gl = Fl | 0;\n Fh = Eh | 0;\n Fl = El | 0;\n ({ h: Eh, l: El } = u64.add(Dh | 0, Dl | 0, T1h | 0, T1l | 0));\n Dh = Ch | 0;\n Dl = Cl | 0;\n Ch = Bh | 0;\n Cl = Bl | 0;\n Bh = Ah | 0;\n Bl = Al | 0;\n const All = u64.add3L(T1l, sigma0l, MAJl);\n Ah = u64.add3H(All, T1h, sigma0h, MAJh);\n Al = All | 0;\n }\n // Add the compressed chunk to the current hash value\n ({ h: Ah, l: Al } = u64.add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));\n ({ h: Bh, l: Bl } = u64.add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));\n ({ h: Ch, l: Cl } = u64.add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));\n ({ h: Dh, l: Dl } = u64.add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));\n ({ h: Eh, l: El } = u64.add(this.Eh | 0, this.El | 0, Eh | 0, El | 0));\n ({ h: Fh, l: Fl } = u64.add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));\n ({ h: Gh, l: Gl } = u64.add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));\n ({ h: Hh, l: Hl } = u64.add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));\n this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl);\n }\n protected roundClean(): void {\n clean(SHA512_W_H, SHA512_W_L);\n }\n destroy(): void {\n clean(this.buffer);\n this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);\n }\n}\n\nexport class SHA384 extends SHA512 {\n protected Ah: number = SHA384_IV[0] | 0;\n protected Al: number = SHA384_IV[1] | 0;\n protected Bh: number = SHA384_IV[2] | 0;\n protected Bl: number = SHA384_IV[3] | 0;\n protected Ch: number = SHA384_IV[4] | 0;\n protected Cl: number = SHA384_IV[5] | 0;\n protected Dh: number = SHA384_IV[6] | 0;\n protected Dl: number = SHA384_IV[7] | 0;\n protected Eh: number = SHA384_IV[8] | 0;\n protected El: number = SHA384_IV[9] | 0;\n protected Fh: number = SHA384_IV[10] | 0;\n protected Fl: number = SHA384_IV[11] | 0;\n protected Gh: number = SHA384_IV[12] | 0;\n protected Gl: number = SHA384_IV[13] | 0;\n protected Hh: number = SHA384_IV[14] | 0;\n protected Hl: number = SHA384_IV[15] | 0;\n\n constructor() {\n super(48);\n }\n}\n\n/**\n * Truncated SHA512/256 and SHA512/224.\n * SHA512_IV is XORed with 0xa5a5a5a5a5a5a5a5, then used as \"intermediary\" IV of SHA512/t.\n * Then t hashes string to produce result IV.\n * See `test/misc/sha2-gen-iv.js`.\n */\n\n/** SHA512/224 IV */\nconst T224_IV = /* @__PURE__ */ Uint32Array.from([\n 0x8c3d37c8, 0x19544da2, 0x73e19966, 0x89dcd4d6, 0x1dfab7ae, 0x32ff9c82, 0x679dd514, 0x582f9fcf,\n 0x0f6d2b69, 0x7bd44da8, 0x77e36f73, 0x04c48942, 0x3f9d85a8, 0x6a1d36c8, 0x1112e6ad, 0x91d692a1,\n]);\n\n/** SHA512/256 IV */\nconst T256_IV = /* @__PURE__ */ Uint32Array.from([\n 0x22312194, 0xfc2bf72c, 0x9f555fa3, 0xc84c64c2, 0x2393b86b, 0x6f53b151, 0x96387719, 0x5940eabd,\n 0x96283ee2, 0xa88effe3, 0xbe5e1e25, 0x53863992, 0x2b0199fc, 0x2c85b8aa, 0x0eb72ddc, 0x81c52ca2,\n]);\n\nexport class SHA512_224 extends SHA512 {\n protected Ah: number = T224_IV[0] | 0;\n protected Al: number = T224_IV[1] | 0;\n protected Bh: number = T224_IV[2] | 0;\n protected Bl: number = T224_IV[3] | 0;\n protected Ch: number = T224_IV[4] | 0;\n protected Cl: number = T224_IV[5] | 0;\n protected Dh: number = T224_IV[6] | 0;\n protected Dl: number = T224_IV[7] | 0;\n protected Eh: number = T224_IV[8] | 0;\n protected El: number = T224_IV[9] | 0;\n protected Fh: number = T224_IV[10] | 0;\n protected Fl: number = T224_IV[11] | 0;\n protected Gh: number = T224_IV[12] | 0;\n protected Gl: number = T224_IV[13] | 0;\n protected Hh: number = T224_IV[14] | 0;\n protected Hl: number = T224_IV[15] | 0;\n\n constructor() {\n super(28);\n }\n}\n\nexport class SHA512_256 extends SHA512 {\n protected Ah: number = T256_IV[0] | 0;\n protected Al: number = T256_IV[1] | 0;\n protected Bh: number = T256_IV[2] | 0;\n protected Bl: number = T256_IV[3] | 0;\n protected Ch: number = T256_IV[4] | 0;\n protected Cl: number = T256_IV[5] | 0;\n protected Dh: number = T256_IV[6] | 0;\n protected Dl: number = T256_IV[7] | 0;\n protected Eh: number = T256_IV[8] | 0;\n protected El: number = T256_IV[9] | 0;\n protected Fh: number = T256_IV[10] | 0;\n protected Fl: number = T256_IV[11] | 0;\n protected Gh: number = T256_IV[12] | 0;\n protected Gl: number = T256_IV[13] | 0;\n protected Hh: number = T256_IV[14] | 0;\n protected Hl: number = T256_IV[15] | 0;\n\n constructor() {\n super(32);\n }\n}\n\n/**\n * SHA2-256 hash function from RFC 4634.\n *\n * It is the fastest JS hash, even faster than Blake3.\n * To break sha256 using birthday attack, attackers need to try 2^128 hashes.\n * BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.\n */\nexport const sha256: CHash = /* @__PURE__ */ createHasher(() => new SHA256());\n/** SHA2-224 hash function from RFC 4634 */\nexport const sha224: CHash = /* @__PURE__ */ createHasher(() => new SHA224());\n\n/** SHA2-512 hash function from RFC 4634. */\nexport const sha512: CHash = /* @__PURE__ */ createHasher(() => new SHA512());\n/** SHA2-384 hash function from RFC 4634. */\nexport const sha384: CHash = /* @__PURE__ */ createHasher(() => new SHA384());\n\n/**\n * SHA2-512/256 \"truncated\" hash function, with improved resistance to length extension attacks.\n * See the paper on [truncated SHA512](https://eprint.iacr.org/2010/548.pdf).\n */\nexport const sha512_256: CHash = /* @__PURE__ */ createHasher(() => new SHA512_256());\n/**\n * SHA2-512/224 \"truncated\" hash function, with improved resistance to length extension attacks.\n * See the paper on [truncated SHA512](https://eprint.iacr.org/2010/548.pdf).\n */\nexport const sha512_224: CHash = /* @__PURE__ */ createHasher(() => new SHA512_224());\n", "// @ts-check\n\n/**\n * A string containing all valid Base58 characters:\n * - Digits: 1\u20139 (excluding 0)\n * - Uppercase: A\u2013Z (excluding I and O)\n * - Lowercase: a\u2013z (excluding l)\n *\n * @typedef {string} base58_chars\n * @see https://en.wikipedia.org/wiki/Base58\n */\n\n/** @type {base58_chars} */\nconst base58_chars =\n \"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\";\n\nexport default base58_chars;\n", "// @ts-check\nimport base58_chars from \"./base58_chars.js\";\n\n/**\n * Converts a base58 string to the corresponding binary representation.\n * @param {string} base58String base58 encoded string.\n * @returns {Uint8Array} Binary representation for the base58 string.\n * @example\n * ```js\n * const bin = base58_to_binary(\"6MRy\")\n * console.log(bin)\n * ```\n * Logged output will be Uint8Array(3) [15, 239, 64].\n */\nfunction base58_to_binary(base58String) {\n if (!base58String || typeof base58String !== \"string\")\n throw new Error(`Expected base58 string but got \u201C${base58String}\u201D`);\n if (base58String.match(/[IOl0]/gmu))\n throw new Error(\n `Invalid base58 character \u201C${base58String.match(/[IOl0]/gmu)}\u201D`\n );\n const lz = base58String.match(/^1+/gmu);\n const psz = lz ? lz[0].length : 0;\n const size =\n ((base58String.length - psz) * (Math.log(58) / Math.log(256)) + 1) >>> 0;\n\n return new Uint8Array([\n ...new Uint8Array(psz),\n ...base58String\n .match(/.{1}/gmu)\n .map((i) => base58_chars.indexOf(i))\n .reduce((acc, i) => {\n acc = acc.map((j) => {\n const x = j * 58 + i;\n i = x >> 8;\n return x;\n });\n return acc;\n }, new Uint8Array(size))\n .reverse()\n .filter(\n (\n (lastValue) => (value) =>\n // @ts-ignore\n (lastValue = lastValue || value)\n )(false)\n ),\n ]);\n}\n\nexport default base58_to_binary;\n"],
5
- "mappings": "0hBAAA,IAAAA,GAAAC,GAAAC,GAAA,cACA,OAAO,eAAeA,EAAS,aAAc,CAAE,MAAO,EAAK,CAAC,EAC5DA,EAAQ,QAAUA,EAAQ,OAAS,OACnC,IAAMC,EAAW,mCACXC,GAAe,CAAC,EACtB,QAASC,EAAI,EAAGA,EAAIF,EAAS,OAAQE,IAAK,CACtC,IAAMC,EAAIH,EAAS,OAAOE,CAAC,EAC3BD,GAAaE,CAAC,EAAID,CACtB,CACA,SAASE,EAAYC,EAAK,CACtB,IAAMC,EAAID,GAAO,GACjB,OAAUA,EAAM,WAAc,EACzB,EAAGC,GAAK,EAAK,GAAK,UAClB,EAAGA,GAAK,EAAK,GAAK,UAClB,EAAGA,GAAK,EAAK,GAAK,UAClB,EAAGA,GAAK,EAAK,GAAK,WAClB,EAAGA,GAAK,EAAK,GAAK,SAC3B,CACA,SAASC,GAAUC,EAAQ,CACvB,IAAIC,EAAM,EACV,QAASC,EAAI,EAAGA,EAAIF,EAAO,OAAQ,EAAEE,EAAG,CACpC,IAAMC,EAAIH,EAAO,WAAWE,CAAC,EAC7B,GAAIC,EAAI,IAAMA,EAAI,IACd,MAAO,mBAAqBH,EAAS,IACzCC,EAAML,EAAYK,CAAG,EAAKE,GAAK,CACnC,CACAF,EAAML,EAAYK,CAAG,EACrB,QAASC,EAAI,EAAGA,EAAIF,EAAO,OAAQ,EAAEE,EAAG,CACpC,IAAME,EAAIJ,EAAO,WAAWE,CAAC,EAC7BD,EAAML,EAAYK,CAAG,EAAKG,EAAI,EAClC,CACA,OAAOH,CACX,CACA,SAASI,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K,IACL,IAAK,IACL,IAAK,IACL,IAAK,IACL,IAAK,IACH,OAAOD,GAAmB,CAAE,QAAAC,EAAS,QAAAC,CAAQ,CAAC,EAChD,IAAK,IACL,IAAK,IACL,IAAK,IACL,IAAK,IACH,OAAOqB,GAAmB,CAAE,QAAAtB,EAAS,QAAAC,CAAQ,CAAC,EAChD,IAAK,GACH,MAAM,IAAIgC,EACZ,QACE,MAAM,IAAIf,CACd,CACF",
6
- "names": ["require_dist", "__commonJSMin", "exports", "ALPHABET", "ALPHABET_MAP", "z", "x", "polymodStep", "pre", "b", "prefixChk", "prefix", "chk", "i", "c", "v", "convert", "data", "inBits", "outBits", "pad", "value", "bits", "maxV", "result", "toWords", "bytes", "fromWordsUnsafe", "words", "res", "fromWords", "getLibraryFromEncoding", "encoding", "ENCODING_CONST", "encode", "LIMIT", "__decode", "str", "lowered", "uppered", "split", "wordChars", "decodeUnsafe", "decode", "Canister", "createServices", "idlFactory", "IDL", "flag", "fees", "network", "init_config", "address", "get_balance_request", "satoshi", "block_height", "get_block_headers_request", "block_header", "get_block_headers_response", "get_current_fee_percentiles_request", "millisatoshi_per_byte", "get_utxos_request", "block_hash", "outpoint", "utxo", "get_utxos_response", "send_transaction_request", "config", "set_config_request", "idlFactory", "IDL", "flag", "fees", "network", "init_config", "address", "get_balance_request", "satoshi", "block_height", "get_block_headers_request", "block_header", "get_block_headers_response", "get_current_fee_percentiles_request", "millisatoshi_per_byte", "get_utxos_request", "block_hash", "outpoint", "utxo", "get_utxos_response", "send_transaction_request", "config", "set_config_request", "nonNullish", "toNullable", "mapBitcoinNetwork", "toGetUtxosParams", "network", "filter", "rest", "toGetBalanceParams", "minConfirmations", "BitcoinCanister", "_BitcoinCanister", "Canister", "options", "service", "certifiedService", "canisterId", "createServices", "idlFactory", "params", "bitcoin_get_utxos_query", "toGetUtxosParams", "bitcoin_get_balance_query", "toGetBalanceParams", "BtcNetwork", "BtcAddressType", "ParseBtcAddressError", "ParseBtcAddressInvalidError", "ParseBtcAddressNoDataError", "ParseBtcAddressUnsupportedAddressTypeError", "ParseBtcAddressBadWitnessLengthError", "ParseBtcAddressUnsupportedWitnessVersionError", "ParseBtcAddressUnexpectedHumanReadablePartError", "ParseBtcAddressMalformedAddressError", "ParseBtcAddressWrongNetworkError", "fromNullable", "nonNullish", "MinterGenericError", "MinterTemporaryUnavailableError", "MinterAlreadyProcessingError", "MinterUpdateBalanceError", "MinterNoNewUtxosError", "pending_utxos", "required_confirmations", "MinterRetrieveBtcError", "MinterMalformedAddressError", "MinterAmountTooLowError", "MinterInsufficientFundsError", "MinterInsufficientAllowanceError", "mapGenericError", "Err", "error_message", "error_code", "createUpdateBalanceError", "error", "createRetrieveBtcError", "createRetrieveBtcWithApprovalError", "Canister", "createServices", "fromNullable", "isNullish", "toNullable", "idlFactory", "IDL", "Mode", "UpgradeArgs", "BtcNetwork", "InitArgs", "MinterArg", "MemoryMetrics", "CanisterStatusType", "LogVisibility", "DefiniteCanisterSettings", "QueryStats", "CanisterStatusResponse", "Account", "Utxo", "ReimbursementReason", "WithdrawalFee", "SuspendedReason", "BitcoinAddress", "InvalidTransactionError", "WithdrawalReimbursementReason", "ReplacedReason", "EventType", "Event", "MinterInfo", "RetrieveBtcArgs", "RetrieveBtcOk", "RetrieveBtcError", "RetrieveBtcStatus", "ReimbursementRequest", "ReimbursedDeposit", "RetrieveBtcStatusV2", "RetrieveBtcWithApprovalArgs", "RetrieveBtcWithApprovalError", "UtxoStatus", "Timestamp", "SuspendedUtxo", "PendingUtxo", "UpdateBalanceError", "idlFactory", "IDL", "Mode", "UpgradeArgs", "BtcNetwork", "InitArgs", "MinterArg", "MemoryMetrics", "CanisterStatusType", "LogVisibility", "DefiniteCanisterSettings", "QueryStats", "CanisterStatusResponse", "Account", "Utxo", "ReimbursementReason", "WithdrawalFee", "SuspendedReason", "BitcoinAddress", "InvalidTransactionError", "WithdrawalReimbursementReason", "ReplacedReason", "EventType", "Event", "MinterInfo", "RetrieveBtcArgs", "RetrieveBtcOk", "RetrieveBtcError", "RetrieveBtcStatus", "ReimbursementRequest", "ReimbursedDeposit", "RetrieveBtcStatusV2", "RetrieveBtcWithApprovalArgs", "RetrieveBtcWithApprovalError", "UtxoStatus", "Timestamp", "SuspendedUtxo", "PendingUtxo", "UpdateBalanceError", "CkBTCMinterCanister", "_CkBTCMinterCanister", "Canister", "options", "service", "certifiedService", "canisterId", "createServices", "idlFactory", "owner", "subaccount", "toNullable", "response", "createUpdateBalanceError", "params", "createRetrieveBtcError", "address", "amount", "fromSubaccount", "createRetrieveBtcWithApprovalError", "transactionId", "certified", "account", "retrieve_btc_status_v2_by_account", "isNullish", "block_index", "status_v2", "fromNullable", "get_known_utxos", "isNullish", "isBytes", "a", "abytes", "b", "lengths", "isBytes", "aexists", "instance", "checkFinished", "aoutput", "out", "abytes", "min", "clean", "arrays", "i", "createView", "arr", "rotr", "word", "shift", "utf8ToBytes", "str", "toBytes", "data", "utf8ToBytes", "abytes", "Hash", "createHasher", "hashCons", "hashC", "msg", "toBytes", "tmp", "setBigUint64", "view", "byteOffset", "value", "isLE", "_32n", "_u32_max", "wh", "wl", "h", "l", "Chi", "a", "b", "c", "Maj", "HashMD", "Hash", "blockLen", "outputLen", "padOffset", "createView", "data", "aexists", "toBytes", "abytes", "buffer", "len", "pos", "take", "dataView", "out", "aoutput", "clean", "i", "oview", "outLen", "state", "res", "to", "length", "finished", "destroyed", "SHA256_IV", "SHA256_K", "SHA256_W", "SHA256", "HashMD", "outputLen", "SHA256_IV", "A", "B", "C", "D", "E", "F", "G", "H", "view", "offset", "i", "W15", "W2", "s0", "rotr", "s1", "sigma1", "T1", "Chi", "T2", "Maj", "clean", "sha256", "createHasher", "SHA256", "base58_chars", "base58_chars_default", "base58_to_binary", "base58String", "lz", "psz", "size", "i", "base58_chars_default", "acc", "j", "x", "lastValue", "value", "base58_to_binary_default", "import_bech32", "BTC_MAINNET_PREFIX", "BTC_MAINNET_P2SH_PREFIX", "BTC_TESTNET_PREFIX", "BTC_TESTNET_P2SH_PREFIX", "Base58AddressTypes", "parseBase58Address", "address", "network", "decoded", "base58_to_binary_default", "ParseBtcAddressInvalidError", "length", "ParseBtcAddressMalformedAddressError", "expectedChecksum", "body", "bodyHash", "sha256", "checksumHash", "checksum", "value", "index", "version", "versionNetwork", "isNullish", "ParseBtcAddressUnsupportedAddressTypeError", "type", "networks", "ParseBtcAddressWrongNetworkError", "parseBip173Address", "decodeBech32", "prefix", "words", "decodedNetwork", "ParseBtcAddressUnexpectedHumanReadablePartError", "witnessVersion", "rest", "ParseBtcAddressUnsupportedWitnessVersionError", "ParseBtcAddressBadWitnessLengthError", "parseBtcAddress", "ParseBtcAddressNoDataError"]
3
+ "sources": ["../src/index.ts"],
4
+ "sourcesContent": ["import type { BitcoinDid, CkBtcMinterDid } from \"@icp-sdk/canisters/ckbtc\";\n\nexport type block_hash = BitcoinDid.block_hash;\nexport type block_height = BitcoinDid.block_height;\nexport type get_utxos_response = BitcoinDid.get_utxos_response;\nexport type outpoint = BitcoinDid.outpoint;\nexport type satoshi = BitcoinDid.satoshi;\nexport type utxo = BitcoinDid.utxo;\n\nexport type Account = CkBtcMinterDid.Account;\nexport type MinterInfo = CkBtcMinterDid.MinterInfo;\nexport type PendingUtxo = CkBtcMinterDid.PendingUtxo;\nexport type ReimbursedDeposit = CkBtcMinterDid.ReimbursedDeposit;\nexport type ReimbursementRequest = CkBtcMinterDid.ReimbursementRequest;\nexport type RetrieveBtcOk = CkBtcMinterDid.RetrieveBtcOk;\nexport type RetrieveBtcStatus = CkBtcMinterDid.RetrieveBtcStatus;\nexport type RetrieveBtcStatusV2 = CkBtcMinterDid.RetrieveBtcStatusV2;\nexport type Utxo = CkBtcMinterDid.Utxo;\nexport type UtxoStatus = CkBtcMinterDid.UtxoStatus;\nexport type WithdrawalAccount = CkBtcMinterDid.Account;\n\n/**\n * @deprecated Use \"@icp-sdk/canisters/ckbtc\" directly instead\n */\nexport * from \"@icp-sdk/canisters/ckbtc\";\n\n/**\n * Legacy re-export for backward compatibility.\n * @deprecated Use \"@icp-sdk/canisters/ckbtc\" directly instead\n */\nexport {\n CkBtcMinterCanister as CkBTCMinterCanister,\n type CkBtcCanisterOptions as CkBTCCanisterOptions,\n} from \"@icp-sdk/canisters/ckbtc\";\n"],
5
+ "mappings": "AAwBA,WAAc,2BAMd,OACyB,uBAAvBA,MAEK",
6
+ "names": ["CkBtcMinterCanister"]
7
7
  }