@dfinity/ckbtc 2.1.1 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -76,7 +76,7 @@ Parameters:
76
76
 
77
77
  ### :factory: CkBTCMinterCanister
78
78
 
79
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L38)
79
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L40)
80
80
 
81
81
  #### Methods
82
82
 
@@ -97,7 +97,7 @@ Parameters:
97
97
  | -------- | ------------------------------------------------------------------------ |
98
98
  | `create` | `(options: CkBTCMinterCanisterOptions<_SERVICE>) => CkBTCMinterCanister` |
99
99
 
100
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L39)
100
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L41)
101
101
 
102
102
  ##### :gear: getBtcAddress
103
103
 
@@ -115,7 +115,7 @@ Parameters:
115
115
  - `params.owner`: The owner for which the BTC address should be generated. If not provided, the `caller` will be use instead.
116
116
  - `params.subaccount`: An optional subaccount to compute the address.
117
117
 
118
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L60)
118
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L62)
119
119
 
120
120
  ##### :gear: updateBalance
121
121
 
@@ -133,7 +133,7 @@ Parameters:
133
133
  - `params.owner`: The owner of the address. If not provided, the `caller` will be use instead.
134
134
  - `params.subaccount`: An optional subaccount of the address.
135
135
 
136
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L79)
136
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L81)
137
137
 
138
138
  ##### :gear: getWithdrawalAccount
139
139
 
@@ -143,7 +143,7 @@ Returns the account to which the caller should deposit ckBTC before withdrawing
143
143
  | ---------------------- | ------------------------ |
144
144
  | `getWithdrawalAccount` | `() => Promise<Account>` |
145
145
 
146
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L102)
146
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L104)
147
147
 
148
148
  ##### :gear: retrieveBtc
149
149
 
@@ -167,7 +167,7 @@ Parameters:
167
167
  - `params.address`: The bitcoin address.
168
168
  - `params.amount`: The ckBTC amount.
169
169
 
170
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L121)
170
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L123)
171
171
 
172
172
  ##### :gear: retrieveBtcWithApproval
173
173
 
@@ -193,7 +193,7 @@ Parameters:
193
193
  - `params.fromSubaccount`: An optional subaccount from which
194
194
  the ckBTC should be transferred.
195
195
 
196
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L151)
196
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L153)
197
197
 
198
198
  ##### :gear: retrieveBtcStatus
199
199
 
@@ -209,21 +209,22 @@ Parameters:
209
209
  - `transactionId`: The ID of the corresponding burn transaction.
210
210
  - `certified`: query or update call
211
211
 
212
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L183)
212
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L185)
213
213
 
214
214
  ##### :gear: retrieveBtcStatusV2ByAccount
215
215
 
216
- Returns the status of all BTC withdrawals for the user's main account.
216
+ Returns the status of all BTC withdrawals for an account.
217
217
 
218
- | Method | Type |
219
- | ------------------------------ | ----------------------------------------------------------------------------------- |
220
- | `retrieveBtcStatusV2ByAccount` | `({ certified, }: { certified: boolean; }) => Promise<RetrieveBtcStatusV2WithId[]>` |
218
+ | Method | Type |
219
+ | ------------------------------ | ------------------------------------------------------------------------------------------------------- |
220
+ | `retrieveBtcStatusV2ByAccount` | `({ account, certified, }: RetrieveBtcStatusV2ByAccountParams) => Promise<RetrieveBtcStatusV2WithId[]>` |
221
221
 
222
222
  Parameters:
223
223
 
224
224
  - `certified`: query or update call
225
+ - `account`: an optional account to retrieve the statuses. If not provided, statuses for the caller are retrieved.
225
226
 
226
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L200)
227
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L203)
227
228
 
228
229
  ##### :gear: estimateWithdrawalFee
229
230
 
@@ -239,7 +240,7 @@ Parameters:
239
240
  - `params.certified`: query or update call
240
241
  - `params.amount`: The optional amount for which the fee should be estimated.
241
242
 
242
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L221)
243
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L237)
243
244
 
244
245
  ##### :gear: getMinterInfo
245
246
 
@@ -254,7 +255,7 @@ Parameters:
254
255
  - `params`: The parameters to get the deposit fee.
255
256
  - `params.certified`: query or update call
256
257
 
257
- [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L235)
258
+ [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/minter.canister.ts#L251)
258
259
 
259
260
  <!-- TSDOC_END -->
260
261
 
@@ -1,4 +1,4 @@
1
- "use strict";var jt=Object.create;var G=Object.defineProperty;var zt=Object.getOwnPropertyDescriptor;var Xt=Object.getOwnPropertyNames;var Qt=Object.getPrototypeOf,Jt=Object.prototype.hasOwnProperty;var A=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Kt=(t,e)=>{for(var r in e)G(t,r,{get:e[r],enumerable:!0})},wt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Xt(e))!Jt.call(t,o)&&o!==r&&G(t,o,{get:()=>e[o],enumerable:!(n=zt(e,o))||n.enumerable});return t};var Rt=(t,e,r)=>(r=t!=null?jt(Qt(t)):{},wt(e||!t||!t.__esModule?G(r,"default",{value:t,enumerable:!0}):r,t)),Yt=t=>wt(G({},"__esModule",{value:!0}),t);var D=A((He,Ot)=>{"use strict";var oe="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";Ot.exports=oe});var Pt=A((je,Bt)=>{"use strict";var ie=D(),ae=t=>{if(!t||typeof t!="string")throw new Error(`Expected base58 string but got \u201C${t}\u201D`);if(t.match(/[IOl0]/gmu))throw new Error(`Invalid base58 character \u201C${t.match(/[IOl0]/gmu)}\u201D`);let e=t.match(/^1+/gmu),r=e?e[0].length:0,n=(t.length-r)*(Math.log(58)/Math.log(256))+1>>>0;return new Uint8Array([...new Uint8Array(r),...t.match(/.{1}/gmu).map(o=>ie.indexOf(o)).reduce((o,a)=>(o=o.map(i=>{let s=i*58+a;return a=s>>8,s}),o),new Uint8Array(n)).reverse().filter((o=>a=>o=o||a)(!1))])};Bt.exports=ae});var Et=A((ze,Ut)=>{"use strict";var Tt=D(),ce=()=>{let t=Array(256).fill(-1);for(let e=0;e<Tt.length;++e)t[Tt.charCodeAt(e)]=e;return t};Ut.exports=ce});var St=A((Xe,Ft)=>{"use strict";var Ct=D(),se=Et(),de=se(),ue=t=>{let e=[];for(let r of t){let n=r;for(let o=0;o<e.length;++o){let a=(de[e[o]]<<8)+n;e[o]=Ct.charCodeAt(a%58),n=a/58|0}for(;n;)e.push(Ct.charCodeAt(n%58)),n=n/58|0}for(let r of t){if(r)break;e.push("1".charCodeAt(0))}return e.reverse(),String.fromCharCode(...e)};Ft.exports=ue});var qt=A(bt=>{"use strict";bt.base58_to_binary=Pt();bt.binary_to_base58=St()});var $t=A(T=>{"use strict";Object.defineProperty(T,"__esModule",{value:!0});T.bech32m=T.bech32=void 0;var tt="qpzry9x8gf2tvdw0s3jn54khce6mua7l",Wt={};for(let t=0;t<tt.length;t++){let e=tt.charAt(t);Wt[e]=t}function P(t){let e=t>>25;return(t&33554431)<<5^-(e>>0&1)&996825010^-(e>>1&1)&642813549^-(e>>2&1)&513874426^-(e>>3&1)&1027748829^-(e>>4&1)&705979059}function Mt(t){let e=1;for(let r=0;r<t.length;++r){let n=t.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+t+")";e=P(e)^n>>5}e=P(e);for(let r=0;r<t.length;++r){let n=t.charCodeAt(r);e=P(e)^n&31}return e}function gt(t,e,r,n){let o=0,a=0,i=(1<<r)-1,s=[];for(let u=0;u<t.length;++u)for(o=o<<e|t[u],a+=e;a>=r;)a-=r,s.push(o>>a&i);if(n)a>0&&s.push(o<<r-a&i);else{if(a>=e)return"Excess padding";if(o<<r-a&i)return"Non-zero padding"}return s}function le(t){return gt(t,8,5,!0)}function pe(t){let e=gt(t,5,8,!1);if(Array.isArray(e))return e}function fe(t){let e=gt(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function Gt(t){let e;t==="bech32"?e=1:e=734539939;function r(i,s,u){if(u=u||90,i.length+7+s.length>u)throw new TypeError("Exceeds length limit");i=i.toLowerCase();let l=Mt(i);if(typeof l=="string")throw new Error(l);let d=i+"1";for(let c=0;c<s.length;++c){let p=s[c];if(p>>5)throw new Error("Non 5-bit word");l=P(l)^p,d+=tt.charAt(p)}for(let c=0;c<6;++c)l=P(l);l^=e;for(let c=0;c<6;++c){let p=l>>(5-c)*5&31;d+=tt.charAt(p)}return d}function n(i,s){if(s=s||90,i.length<8)return i+" too short";if(i.length>s)return"Exceeds length limit";let u=i.toLowerCase(),l=i.toUpperCase();if(i!==u&&i!==l)return"Mixed-case string "+i;i=u;let d=i.lastIndexOf("1");if(d===-1)return"No separator character for "+i;if(d===0)return"Missing prefix for "+i;let c=i.slice(0,d),p=i.slice(d+1);if(p.length<6)return"Data too short";let f=Mt(c);if(typeof f=="string")return f;let x=[];for(let _=0;_<p.length;++_){let g=p.charAt(_),h=Wt[g];if(h===void 0)return"Unknown character "+g;f=P(f)^h,!(_+6>=p.length)&&x.push(h)}return f!==e?"Invalid checksum for "+i:{prefix:c,words:x}}function o(i,s){let u=n(i,s);if(typeof u=="object")return u}function a(i,s){let u=n(i,s);if(typeof u=="object")return u;throw new Error(u)}return{decodeUnsafe:o,decode:a,encode:r,toWords:le,fromWordsUnsafe:pe,fromWords:fe}}T.bech32=Gt("bech32");T.bech32m=Gt("bech32m")});var we={};Kt(we,{BtcAddressType:()=>lt,BtcNetwork:()=>ut,CkBTCMinterCanister:()=>Y,MinterAlreadyProcessingError:()=>H,MinterAmountTooLowError:()=>X,MinterGenericError:()=>y,MinterInsufficientAllowanceError:()=>J,MinterInsufficientFundsError:()=>Q,MinterMalformedAddressError:()=>z,MinterNoNewUtxosError:()=>j,MinterRetrieveBtcError:()=>w,MinterTemporaryUnavailableError:()=>$,MinterUpdateBalanceError:()=>M,ParseBtcAddressBadWitnessLengthError:()=>C,ParseBtcAddressError:()=>N,ParseBtcAddressInvalidError:()=>V,ParseBtcAddressMalformedAddressError:()=>k,ParseBtcAddressNoDataError:()=>E,ParseBtcAddressUnexpectedHumanReadablePartError:()=>S,ParseBtcAddressUnsupportedAddressTypeError:()=>O,ParseBtcAddressUnsupportedWitnessVersionError:()=>F,ParseBtcAddressWrongNetworkError:()=>q,createRetrieveBtcError:()=>K,createRetrieveBtcWithApprovalError:()=>_t,createUpdateBalanceError:()=>ft,parseBtcAddress:()=>ye});module.exports=Yt(we);var ut=(n=>(n[n.Mainnet=0]="Mainnet",n[n.Regtest=1]="Regtest",n[n.Testnet=2]="Testnet",n))(ut||{}),lt=(a=>(a[a.P2wpkhV0=0]="P2wpkhV0",a[a.P2pkh=1]="P2pkh",a[a.P2sh=2]="P2sh",a[a.P2wsh=3]="P2wsh",a[a.P2tr=4]="P2tr",a))(lt||{});var N=class extends Error{},V=class extends N{},E=class extends N{},O=class extends N{},C=class extends N{},F=class extends N{},S=class extends N{},k=class extends N{},q=class extends N{};var B=require("@dfinity/utils"),y=class extends Error{},$=class extends y{},H=class extends y{},M=class extends y{},j=class extends M{constructor({pending_utxos:r,required_confirmations:n}){super();this.pendingUtxos=(0,B.fromNullable)(r)||[],this.requiredConfirmations=n}},w=class extends y{},z=class extends w{},X=class extends w{},Q=class extends w{},J=class extends w{},pt=t=>{if("GenericError"in t){let{GenericError:{error_message:e,error_code:r}}=t;return new y(`${e} (${r})`)}if("TemporarilyUnavailable"in t)return new $(t.TemporarilyUnavailable);if("AlreadyProcessing"in t)return new H},ft=t=>{let e=pt(t);return(0,B.nonNullish)(e)?e:"NoNewUtxos"in t?new j(t.NoNewUtxos):new M(`Unsupported response type in minter.updateBalance ${JSON.stringify(t)}`)},K=t=>{let e=pt(t);return(0,B.nonNullish)(e)?e:"MalformedAddress"in t?new z(t.MalformedAddress):"AmountTooLow"in t?new X(`${t.AmountTooLow}`):"InsufficientFunds"in t?new Q(`${t.InsufficientFunds.balance}`):new w(`Unsupported response type in minter.retrieveBtc ${JSON.stringify(t)}`)},_t=t=>{let e=pt(t);return(0,B.nonNullish)(e)?e:"InsufficientAllowance"in t?new J(`${t.InsufficientAllowance.allowance}`):K(t)};var m=require("@dfinity/utils");var vt=({IDL:t})=>{let e=t.Variant({RestrictedTo:t.Vec(t.Principal),DepositsRestrictedTo:t.Vec(t.Principal),ReadOnly:t.Null,GeneralAvailability:t.Null}),r=t.Record({kyt_principal:t.Opt(t.Principal),mode:t.Opt(e),retrieve_btc_min_amount:t.Opt(t.Nat64),max_time_in_queue_nanos:t.Opt(t.Nat64),min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),n=t.Variant({Mainnet:t.Null,Regtest:t.Null,Testnet:t.Null}),o=t.Record({kyt_principal:t.Opt(t.Principal),ecdsa_key_name:t.Text,mode:e,retrieve_btc_min_amount:t.Nat64,ledger_id:t.Principal,max_time_in_queue_nanos:t.Nat64,btc_network:n,min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),a=t.Variant({Upgrade:t.Opt(r),Init:o}),i=t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),s=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),memory_allocation:t.Nat,compute_allocation:t.Nat}),u=t.Record({response_payload_bytes_total:t.Nat,num_instructions_total:t.Nat,num_calls_total:t.Nat,request_payload_bytes_total:t.Nat}),l=t.Record({status:i,memory_size:t.Nat,cycles:t.Nat,settings:s,query_stats:u,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8))}),d=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),c=t.Record({height:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),p=t.Variant({CallFailed:t.Null,TaintedDestination:t.Record({kyt_fee:t.Nat64,kyt_provider:t.Principal})}),f=t.Variant({p2wsh_v0:t.Vec(t.Nat8),p2tr_v1:t.Vec(t.Nat8),p2sh:t.Vec(t.Nat8),p2wpkh_v0:t.Vec(t.Nat8),p2pkh:t.Vec(t.Nat8)}),x=t.Variant({received_utxos:t.Record({to_account:d,mint_txid:t.Opt(t.Nat64),utxos:t.Vec(c)}),schedule_deposit_reimbursement:t.Record({burn_block_index:t.Nat64,account:d,amount:t.Nat64,reason:p}),sent_transaction:t.Record({fee:t.Opt(t.Nat64),change_output:t.Opt(t.Record({value:t.Nat64,vout:t.Nat32})),txid:t.Vec(t.Nat8),utxos:t.Vec(c),requests:t.Vec(t.Nat64),submitted_at:t.Nat64}),distributed_kyt_fee:t.Record({block_index:t.Nat64,amount:t.Nat64,kyt_provider:t.Principal}),init:o,upgrade:r,retrieve_btc_kyt_failed:t.Record({block_index:t.Nat64,owner:t.Principal,uuid:t.Text,address:t.Text,amount:t.Nat64,kyt_provider:t.Principal}),accepted_retrieve_btc_request:t.Record({received_at:t.Nat64,block_index:t.Nat64,address:f,reimbursement_account:t.Opt(d),amount:t.Nat64,kyt_provider:t.Opt(t.Principal)}),checked_utxo:t.Record({clean:t.Bool,utxo:c,uuid:t.Text,kyt_provider:t.Opt(t.Principal)}),removed_retrieve_btc_request:t.Record({block_index:t.Nat64}),confirmed_transaction:t.Record({txid:t.Vec(t.Nat8)}),replaced_transaction:t.Record({fee:t.Nat64,change_output:t.Record({value:t.Nat64,vout:t.Nat32}),old_txid:t.Vec(t.Nat8),new_txid:t.Vec(t.Nat8),submitted_at:t.Nat64}),ignored_utxo:t.Record({utxo:c}),reimbursed_failed_deposit:t.Record({burn_block_index:t.Nat64,mint_block_index:t.Nat64})}),_=t.Record({retrieve_btc_min_amount:t.Nat64,min_confirmations:t.Nat32,kyt_fee:t.Nat64}),g=t.Record({address:t.Text,amount:t.Nat64}),h=t.Record({block_index:t.Nat64}),et=t.Variant({MalformedAddress:t.Text,GenericError:t.Record({error_message:t.Text,error_code:t.Nat64}),TemporarilyUnavailable:t.Text,AlreadyProcessing:t.Null,AmountTooLow:t.Nat64,InsufficientFunds:t.Record({balance:t.Nat64})}),rt=t.Variant({Signing:t.Null,Confirmed:t.Record({txid:t.Vec(t.Nat8)}),Sending:t.Record({txid:t.Vec(t.Nat8)}),AmountTooLow:t.Null,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Pending:t.Null}),nt=t.Record({account:d,amount:t.Nat64,reason:p}),ot=t.Record({account:d,mint_block_index:t.Nat64,amount:t.Nat64,reason:p}),U=t.Variant({Signing:t.Null,Confirmed:t.Record({txid:t.Vec(t.Nat8)}),Sending:t.Record({txid:t.Vec(t.Nat8)}),AmountTooLow:t.Null,WillReimburse:nt,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Reimbursed:ot,Pending:t.Null}),it=t.Record({from_subaccount:t.Opt(t.Vec(t.Nat8)),address:t.Text,amount:t.Nat64}),at=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})}),ct=t.Variant({ValueTooSmall:c,Tainted:c,Minted:t.Record({minted_amount:t.Nat64,block_index:t.Nat64,utxo:c}),Checked:c}),st=t.Record({confirmations:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),dt=t.Variant({GenericError:t.Record({error_message:t.Text,error_code:t.Nat64}),TemporarilyUnavailable:t.Text,AlreadyProcessing:t.Null,NoNewUtxos:t.Record({required_confirmations:t.Nat32,pending_utxos:t.Opt(t.Vec(st)),current_confirmations:t.Opt(t.Nat32)})});return t.Service({estimate_withdrawal_fee:t.Func([t.Record({amount:t.Opt(t.Nat64)})],[t.Record({minter_fee:t.Nat64,bitcoin_fee:t.Nat64})],[]),get_btc_address:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Text],[]),get_canister_status:t.Func([],[l],[]),get_deposit_fee:t.Func([],[t.Nat64],[]),get_events:t.Func([t.Record({start:t.Nat64,length:t.Nat64})],[t.Vec(x)],[]),get_minter_info:t.Func([],[_],[]),get_withdrawal_account:t.Func([],[d],[]),retrieve_btc:t.Func([g],[t.Variant({Ok:h,Err:et})],[]),retrieve_btc_status:t.Func([t.Record({block_index:t.Nat64})],[rt],[]),retrieve_btc_status_v2:t.Func([t.Record({block_index:t.Nat64})],[U],[]),retrieve_btc_status_v2_by_account:t.Func([t.Opt(d)],[t.Vec(t.Record({block_index:t.Nat64,status_v2:t.Opt(U)}))],[]),retrieve_btc_with_approval:t.Func([it],[t.Variant({Ok:h,Err:at})],[]),update_balance:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Variant({Ok:t.Vec(ct),Err:dt})],[])})};var kt=({IDL:t})=>{let e=t.Variant({RestrictedTo:t.Vec(t.Principal),DepositsRestrictedTo:t.Vec(t.Principal),ReadOnly:t.Null,GeneralAvailability:t.Null}),r=t.Record({kyt_principal:t.Opt(t.Principal),mode:t.Opt(e),retrieve_btc_min_amount:t.Opt(t.Nat64),max_time_in_queue_nanos:t.Opt(t.Nat64),min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),n=t.Variant({Mainnet:t.Null,Regtest:t.Null,Testnet:t.Null}),o=t.Record({kyt_principal:t.Opt(t.Principal),ecdsa_key_name:t.Text,mode:e,retrieve_btc_min_amount:t.Nat64,ledger_id:t.Principal,max_time_in_queue_nanos:t.Nat64,btc_network:n,min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),a=t.Variant({Upgrade:t.Opt(r),Init:o}),i=t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),s=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),memory_allocation:t.Nat,compute_allocation:t.Nat}),u=t.Record({response_payload_bytes_total:t.Nat,num_instructions_total:t.Nat,num_calls_total:t.Nat,request_payload_bytes_total:t.Nat}),l=t.Record({status:i,memory_size:t.Nat,cycles:t.Nat,settings:s,query_stats:u,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8))}),d=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),c=t.Record({height:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),p=t.Variant({CallFailed:t.Null,TaintedDestination:t.Record({kyt_fee:t.Nat64,kyt_provider:t.Principal})}),f=t.Variant({p2wsh_v0:t.Vec(t.Nat8),p2tr_v1:t.Vec(t.Nat8),p2sh:t.Vec(t.Nat8),p2wpkh_v0:t.Vec(t.Nat8),p2pkh:t.Vec(t.Nat8)}),x=t.Variant({received_utxos:t.Record({to_account:d,mint_txid:t.Opt(t.Nat64),utxos:t.Vec(c)}),schedule_deposit_reimbursement:t.Record({burn_block_index:t.Nat64,account:d,amount:t.Nat64,reason:p}),sent_transaction:t.Record({fee:t.Opt(t.Nat64),change_output:t.Opt(t.Record({value:t.Nat64,vout:t.Nat32})),txid:t.Vec(t.Nat8),utxos:t.Vec(c),requests:t.Vec(t.Nat64),submitted_at:t.Nat64}),distributed_kyt_fee:t.Record({block_index:t.Nat64,amount:t.Nat64,kyt_provider:t.Principal}),init:o,upgrade:r,retrieve_btc_kyt_failed:t.Record({block_index:t.Nat64,owner:t.Principal,uuid:t.Text,address:t.Text,amount:t.Nat64,kyt_provider:t.Principal}),accepted_retrieve_btc_request:t.Record({received_at:t.Nat64,block_index:t.Nat64,address:f,reimbursement_account:t.Opt(d),amount:t.Nat64,kyt_provider:t.Opt(t.Principal)}),checked_utxo:t.Record({clean:t.Bool,utxo:c,uuid:t.Text,kyt_provider:t.Opt(t.Principal)}),removed_retrieve_btc_request:t.Record({block_index:t.Nat64}),confirmed_transaction:t.Record({txid:t.Vec(t.Nat8)}),replaced_transaction:t.Record({fee:t.Nat64,change_output:t.Record({value:t.Nat64,vout:t.Nat32}),old_txid:t.Vec(t.Nat8),new_txid:t.Vec(t.Nat8),submitted_at:t.Nat64}),ignored_utxo:t.Record({utxo:c}),reimbursed_failed_deposit:t.Record({burn_block_index:t.Nat64,mint_block_index:t.Nat64})}),_=t.Record({retrieve_btc_min_amount:t.Nat64,min_confirmations:t.Nat32,kyt_fee:t.Nat64}),g=t.Record({address:t.Text,amount:t.Nat64}),h=t.Record({block_index:t.Nat64}),et=t.Variant({MalformedAddress:t.Text,GenericError:t.Record({error_message:t.Text,error_code:t.Nat64}),TemporarilyUnavailable:t.Text,AlreadyProcessing:t.Null,AmountTooLow:t.Nat64,InsufficientFunds:t.Record({balance:t.Nat64})}),rt=t.Variant({Signing:t.Null,Confirmed:t.Record({txid:t.Vec(t.Nat8)}),Sending:t.Record({txid:t.Vec(t.Nat8)}),AmountTooLow:t.Null,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Pending:t.Null}),nt=t.Record({account:d,amount:t.Nat64,reason:p}),ot=t.Record({account:d,mint_block_index:t.Nat64,amount:t.Nat64,reason:p}),U=t.Variant({Signing:t.Null,Confirmed:t.Record({txid:t.Vec(t.Nat8)}),Sending:t.Record({txid:t.Vec(t.Nat8)}),AmountTooLow:t.Null,WillReimburse:nt,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Reimbursed:ot,Pending:t.Null}),it=t.Record({from_subaccount:t.Opt(t.Vec(t.Nat8)),address:t.Text,amount:t.Nat64}),at=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})}),ct=t.Variant({ValueTooSmall:c,Tainted:c,Minted:t.Record({minted_amount:t.Nat64,block_index:t.Nat64,utxo:c}),Checked:c}),st=t.Record({confirmations:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),dt=t.Variant({GenericError:t.Record({error_message:t.Text,error_code:t.Nat64}),TemporarilyUnavailable:t.Text,AlreadyProcessing:t.Null,NoNewUtxos:t.Record({required_confirmations:t.Nat32,pending_utxos:t.Opt(t.Vec(st)),current_confirmations:t.Opt(t.Nat32)})});return t.Service({estimate_withdrawal_fee:t.Func([t.Record({amount:t.Opt(t.Nat64)})],[t.Record({minter_fee:t.Nat64,bitcoin_fee:t.Nat64})],["query"]),get_btc_address:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Text],[]),get_canister_status:t.Func([],[l],[]),get_deposit_fee:t.Func([],[t.Nat64],["query"]),get_events:t.Func([t.Record({start:t.Nat64,length:t.Nat64})],[t.Vec(x)],["query"]),get_minter_info:t.Func([],[_],["query"]),get_withdrawal_account:t.Func([],[d],[]),retrieve_btc:t.Func([g],[t.Variant({Ok:h,Err:et})],[]),retrieve_btc_status:t.Func([t.Record({block_index:t.Nat64})],[rt],["query"]),retrieve_btc_status_v2:t.Func([t.Record({block_index:t.Nat64})],[U],["query"]),retrieve_btc_status_v2_by_account:t.Func([t.Opt(d)],[t.Vec(t.Record({block_index:t.Nat64,status_v2:t.Opt(U)}))],["query"]),retrieve_btc_with_approval:t.Func([it],[t.Variant({Ok:h,Err:at})],[]),update_balance:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Variant({Ok:t.Vec(ct),Err:dt})],[])})};var Y=class t extends m.Canister{constructor(){super(...arguments);this.getBtcAddress=({owner:r,subaccount:n})=>this.caller({certified:!0}).get_btc_address({owner:(0,m.toNullable)(r),subaccount:(0,m.toNullable)(n)});this.updateBalance=async({owner:r,subaccount:n})=>{let o=await this.caller({certified:!0}).update_balance({owner:(0,m.toNullable)(r),subaccount:(0,m.toNullable)(n)});if("Err"in o)throw ft(o.Err);return o.Ok};this.getWithdrawalAccount=()=>this.caller({certified:!0}).get_withdrawal_account();this.retrieveBtc=async r=>{let n=await this.caller({certified:!0}).retrieve_btc(r);if("Err"in n)throw K(n.Err);return n.Ok};this.retrieveBtcWithApproval=async({address:r,amount:n,fromSubaccount:o})=>{let a=await this.caller({certified:!0}).retrieve_btc_with_approval({address:r,amount:n,from_subaccount:(0,m.toNullable)(o)});if("Err"in a)throw _t(a.Err);return a.Ok};this.retrieveBtcStatus=async({transactionId:r,certified:n})=>this.caller({certified:n}).retrieve_btc_status({block_index:r});this.retrieveBtcStatusV2ByAccount=async({certified:r})=>(await this.caller({certified:r}).retrieve_btc_status_v2_by_account([])).map(({block_index:o,status_v2:a})=>({id:o,status:(0,m.fromNullable)(a)}));this.estimateWithdrawalFee=async({certified:r,amount:n})=>this.caller({certified:r}).estimate_withdrawal_fee({amount:(0,m.toNullable)(n)});this.getMinterInfo=async({certified:r})=>this.caller({certified:r}).get_minter_info()}static create(r){let{service:n,certifiedService:o,canisterId:a}=(0,m.createServices)({options:r,idlFactory:kt,certifiedIdlFactory:vt});return new t(a,n,o)}};var yt=require("@dfinity/utils");function Zt(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function mt(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function At(t,e){Zt(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var It=t=>t instanceof Uint8Array;var I=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),b=(t,e)=>t<<32-e|t>>>e,Lt=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Lt)throw new Error("Non little-endian hardware is not supported");function Dt(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function xt(t){if(typeof t=="string"&&(t=Dt(t)),!It(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}var Z=class{clone(){return this._cloneInto()}},Ce={}.toString;function Vt(t){let e=n=>t().update(xt(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function te(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let o=BigInt(32),a=BigInt(4294967295),i=Number(r>>o&a),s=Number(r&a),u=n?4:0,l=n?0:4;t.setUint32(e+u,i,n),t.setUint32(e+l,s,n)}var L=class extends Z{constructor(e,r,n,o){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=I(this.buffer)}update(e){mt(this);let{view:r,buffer:n,blockLen:o}=this;e=xt(e);let a=e.length;for(let i=0;i<a;){let s=Math.min(o-this.pos,a-i);if(s===o){let u=I(e);for(;o<=a-i;i+=o)this.process(u,i);continue}n.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){mt(this),At(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:a}=this,{pos:i}=this;r[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let c=i;c<o;c++)r[c]=0;te(n,o-8,BigInt(this.length*8),a),this.process(n,0);let s=I(e),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=u/4,d=this.get();if(l>d.length)throw new Error("_sha2: outputLen bigger than state");for(let c=0;c<l;c++)s.setUint32(4*c,d[c],a)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:a,destroyed:i,pos:s}=this;return e.length=o,e.pos=s,e.finished=a,e.destroyed=i,o%r&&e.buffer.set(n),e}};var ee=(t,e,r)=>t&e^~t&r,re=(t,e,r)=>t&e^t&r^e&r,ne=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),R=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),v=new Uint32Array(64),ht=class extends L{constructor(){super(64,32,8,!1),this.A=R[0]|0,this.B=R[1]|0,this.C=R[2]|0,this.D=R[3]|0,this.E=R[4]|0,this.F=R[5]|0,this.G=R[6]|0,this.H=R[7]|0}get(){let{A:e,B:r,C:n,D:o,E:a,F:i,G:s,H:u}=this;return[e,r,n,o,a,i,s,u]}set(e,r,n,o,a,i,s,u){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=a|0,this.F=i|0,this.G=s|0,this.H=u|0}process(e,r){for(let c=0;c<16;c++,r+=4)v[c]=e.getUint32(r,!1);for(let c=16;c<64;c++){let p=v[c-15],f=v[c-2],x=b(p,7)^b(p,18)^p>>>3,_=b(f,17)^b(f,19)^f>>>10;v[c]=_+v[c-7]+x+v[c-16]|0}let{A:n,B:o,C:a,D:i,E:s,F:u,G:l,H:d}=this;for(let c=0;c<64;c++){let p=b(s,6)^b(s,11)^b(s,25),f=d+p+ee(s,u,l)+ne[c]+v[c]|0,_=(b(n,2)^b(n,13)^b(n,22))+re(n,o,a)|0;d=l,l=u,u=s,s=i+f|0,i=a,a=o,o=n,n=f+_|0}n=n+this.A|0,o=o+this.B|0,a=a+this.C|0,i=i+this.D|0,s=s+this.E|0,u=u+this.F|0,l=l+this.G|0,d=d+this.H|0,this.set(n,o,a,i,s,u,l,d)}roundClean(){v.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Nt=Vt(()=>new ht);var Ht=Rt(qt()),W=Rt($t());var _e=0,me=5,xe=111,he=196,Ne={[_e]:{type:1,networks:[0]},[xe]:{type:1,networks:[2,1]},[me]:{type:2,networks:[0]},[he]:{type:2,networks:[2,1]}},be=({address:t,network:e})=>{let n=(d=>{try{return(0,Ht.base58_to_binary)(d)}catch{throw new V}})(t),{length:o}=n;if(o!==25)throw new k(`Expected the address to be 25 bytes, got ${o}.`);(d=>{let c=d.slice(o-4,o),p=d.slice(0,o-4),f=Nt.create();f.update(p);let x=Nt.create();x.update(f.digest());let _=x.digest().slice(0,4);if(c.some((g,h)=>g!==_[h]))throw new k(`Checksum mismatch expected ${c}, got ${_}.`)})(n);let i=n[0],s=Ne[i];if((0,yt.isNullish)(s))throw new O;let{type:u,networks:l}=s;if(!l.includes(e))throw new q;return{address:t,network:e,type:u,parser:"base58"}},ge=({address:t,network:e})=>{let r=d=>{try{return d.startsWith("bc1p")||d.startsWith("tb1p")||d.startsWith("bcrt1p")?W.bech32m.decode(d):W.bech32.decode(d)}catch{throw new k}},{prefix:n,words:o}=r(t),i={bc:0,tb:2,bcrt:1}[n];if((0,yt.isNullish)(i))throw new V;if(i!==e)throw new S;let[s,...u]=o;if(s>1)throw new F;switch(W.bech32.fromWords(u).length){case 20:return{address:t,network:e,type:0,parser:"bip-173"};case 32:return{address:t,network:e,type:s===0?3:4,parser:"bip-173"};default:throw new C}},ye=({address:t,network:e=0})=>{switch(t.charAt(0)){case"1":case"2":case"3":case"m":case"n":return be({address:t,network:e});case"b":case"B":case"t":case"T":return ge({address:t,network:e});case"":throw new E;default:throw new O}};0&&(module.exports={BtcAddressType,BtcNetwork,CkBTCMinterCanister,MinterAlreadyProcessingError,MinterAmountTooLowError,MinterGenericError,MinterInsufficientAllowanceError,MinterInsufficientFundsError,MinterMalformedAddressError,MinterNoNewUtxosError,MinterRetrieveBtcError,MinterTemporaryUnavailableError,MinterUpdateBalanceError,ParseBtcAddressBadWitnessLengthError,ParseBtcAddressError,ParseBtcAddressInvalidError,ParseBtcAddressMalformedAddressError,ParseBtcAddressNoDataError,ParseBtcAddressUnexpectedHumanReadablePartError,ParseBtcAddressUnsupportedAddressTypeError,ParseBtcAddressUnsupportedWitnessVersionError,ParseBtcAddressWrongNetworkError,createRetrieveBtcError,createRetrieveBtcWithApprovalError,createUpdateBalanceError,parseBtcAddress});
1
+ "use strict";var jt=Object.create;var G=Object.defineProperty;var zt=Object.getOwnPropertyDescriptor;var Xt=Object.getOwnPropertyNames;var Qt=Object.getPrototypeOf,Jt=Object.prototype.hasOwnProperty;var A=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Kt=(t,e)=>{for(var r in e)G(t,r,{get:e[r],enumerable:!0})},wt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Xt(e))!Jt.call(t,o)&&o!==r&&G(t,o,{get:()=>e[o],enumerable:!(n=zt(e,o))||n.enumerable});return t};var Rt=(t,e,r)=>(r=t!=null?jt(Qt(t)):{},wt(e||!t||!t.__esModule?G(r,"default",{value:t,enumerable:!0}):r,t)),Yt=t=>wt(G({},"__esModule",{value:!0}),t);var D=A((He,Ot)=>{"use strict";var oe="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";Ot.exports=oe});var Pt=A((je,Bt)=>{"use strict";var ie=D(),ae=t=>{if(!t||typeof t!="string")throw new Error(`Expected base58 string but got \u201C${t}\u201D`);if(t.match(/[IOl0]/gmu))throw new Error(`Invalid base58 character \u201C${t.match(/[IOl0]/gmu)}\u201D`);let e=t.match(/^1+/gmu),r=e?e[0].length:0,n=(t.length-r)*(Math.log(58)/Math.log(256))+1>>>0;return new Uint8Array([...new Uint8Array(r),...t.match(/.{1}/gmu).map(o=>ie.indexOf(o)).reduce((o,a)=>(o=o.map(i=>{let s=i*58+a;return a=s>>8,s}),o),new Uint8Array(n)).reverse().filter((o=>a=>o=o||a)(!1))])};Bt.exports=ae});var Et=A((ze,Ut)=>{"use strict";var Tt=D(),ce=()=>{let t=Array(256).fill(-1);for(let e=0;e<Tt.length;++e)t[Tt.charCodeAt(e)]=e;return t};Ut.exports=ce});var St=A((Xe,Ft)=>{"use strict";var Ct=D(),se=Et(),de=se(),ue=t=>{let e=[];for(let r of t){let n=r;for(let o=0;o<e.length;++o){let a=(de[e[o]]<<8)+n;e[o]=Ct.charCodeAt(a%58),n=a/58|0}for(;n;)e.push(Ct.charCodeAt(n%58)),n=n/58|0}for(let r of t){if(r)break;e.push(49)}return e.reverse(),String.fromCharCode(...e)};Ft.exports=ue});var qt=A(bt=>{"use strict";bt.base58_to_binary=Pt();bt.binary_to_base58=St()});var $t=A(T=>{"use strict";Object.defineProperty(T,"__esModule",{value:!0});T.bech32m=T.bech32=void 0;var tt="qpzry9x8gf2tvdw0s3jn54khce6mua7l",Wt={};for(let t=0;t<tt.length;t++){let e=tt.charAt(t);Wt[e]=t}function P(t){let e=t>>25;return(t&33554431)<<5^-(e>>0&1)&996825010^-(e>>1&1)&642813549^-(e>>2&1)&513874426^-(e>>3&1)&1027748829^-(e>>4&1)&705979059}function Mt(t){let e=1;for(let r=0;r<t.length;++r){let n=t.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+t+")";e=P(e)^n>>5}e=P(e);for(let r=0;r<t.length;++r){let n=t.charCodeAt(r);e=P(e)^n&31}return e}function gt(t,e,r,n){let o=0,a=0,i=(1<<r)-1,s=[];for(let u=0;u<t.length;++u)for(o=o<<e|t[u],a+=e;a>=r;)a-=r,s.push(o>>a&i);if(n)a>0&&s.push(o<<r-a&i);else{if(a>=e)return"Excess padding";if(o<<r-a&i)return"Non-zero padding"}return s}function le(t){return gt(t,8,5,!0)}function pe(t){let e=gt(t,5,8,!1);if(Array.isArray(e))return e}function fe(t){let e=gt(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function Gt(t){let e;t==="bech32"?e=1:e=734539939;function r(i,s,u){if(u=u||90,i.length+7+s.length>u)throw new TypeError("Exceeds length limit");i=i.toLowerCase();let l=Mt(i);if(typeof l=="string")throw new Error(l);let d=i+"1";for(let c=0;c<s.length;++c){let p=s[c];if(p>>5)throw new Error("Non 5-bit word");l=P(l)^p,d+=tt.charAt(p)}for(let c=0;c<6;++c)l=P(l);l^=e;for(let c=0;c<6;++c){let p=l>>(5-c)*5&31;d+=tt.charAt(p)}return d}function n(i,s){if(s=s||90,i.length<8)return i+" too short";if(i.length>s)return"Exceeds length limit";let u=i.toLowerCase(),l=i.toUpperCase();if(i!==u&&i!==l)return"Mixed-case string "+i;i=u;let d=i.lastIndexOf("1");if(d===-1)return"No separator character for "+i;if(d===0)return"Missing prefix for "+i;let c=i.slice(0,d),p=i.slice(d+1);if(p.length<6)return"Data too short";let f=Mt(c);if(typeof f=="string")return f;let h=[];for(let m=0;m<p.length;++m){let g=p.charAt(m),x=Wt[g];if(x===void 0)return"Unknown character "+g;f=P(f)^x,!(m+6>=p.length)&&h.push(x)}return f!==e?"Invalid checksum for "+i:{prefix:c,words:h}}function o(i,s){let u=n(i,s);if(typeof u=="object")return u}function a(i,s){let u=n(i,s);if(typeof u=="object")return u;throw new Error(u)}return{decodeUnsafe:o,decode:a,encode:r,toWords:le,fromWordsUnsafe:pe,fromWords:fe}}T.bech32=Gt("bech32");T.bech32m=Gt("bech32m")});var we={};Kt(we,{BtcAddressType:()=>lt,BtcNetwork:()=>ut,CkBTCMinterCanister:()=>Y,MinterAlreadyProcessingError:()=>H,MinterAmountTooLowError:()=>X,MinterGenericError:()=>y,MinterInsufficientAllowanceError:()=>J,MinterInsufficientFundsError:()=>Q,MinterMalformedAddressError:()=>z,MinterNoNewUtxosError:()=>j,MinterRetrieveBtcError:()=>w,MinterTemporaryUnavailableError:()=>$,MinterUpdateBalanceError:()=>M,ParseBtcAddressBadWitnessLengthError:()=>C,ParseBtcAddressError:()=>N,ParseBtcAddressInvalidError:()=>V,ParseBtcAddressMalformedAddressError:()=>k,ParseBtcAddressNoDataError:()=>E,ParseBtcAddressUnexpectedHumanReadablePartError:()=>S,ParseBtcAddressUnsupportedAddressTypeError:()=>O,ParseBtcAddressUnsupportedWitnessVersionError:()=>F,ParseBtcAddressWrongNetworkError:()=>q,createRetrieveBtcError:()=>K,createRetrieveBtcWithApprovalError:()=>_t,createUpdateBalanceError:()=>ft,parseBtcAddress:()=>ye});module.exports=Yt(we);var ut=(n=>(n[n.Mainnet=0]="Mainnet",n[n.Regtest=1]="Regtest",n[n.Testnet=2]="Testnet",n))(ut||{}),lt=(a=>(a[a.P2wpkhV0=0]="P2wpkhV0",a[a.P2pkh=1]="P2pkh",a[a.P2sh=2]="P2sh",a[a.P2wsh=3]="P2wsh",a[a.P2tr=4]="P2tr",a))(lt||{});var N=class extends Error{},V=class extends N{},E=class extends N{},O=class extends N{},C=class extends N{},F=class extends N{},S=class extends N{},k=class extends N{},q=class extends N{};var B=require("@dfinity/utils"),y=class extends Error{},$=class extends y{},H=class extends y{},M=class extends y{},j=class extends M{constructor({pending_utxos:e,required_confirmations:r}){super(),this.pendingUtxos=(0,B.fromNullable)(e)||[],this.requiredConfirmations=r}},w=class extends y{},z=class extends w{},X=class extends w{},Q=class extends w{},J=class extends w{},pt=t=>{if("GenericError"in t){let{GenericError:{error_message:e,error_code:r}}=t;return new y(`${e} (${r})`)}if("TemporarilyUnavailable"in t)return new $(t.TemporarilyUnavailable);if("AlreadyProcessing"in t)return new H},ft=t=>{let e=pt(t);return(0,B.nonNullish)(e)?e:"NoNewUtxos"in t?new j(t.NoNewUtxos):new M(`Unsupported response type in minter.updateBalance ${JSON.stringify(t)}`)},K=t=>{let e=pt(t);return(0,B.nonNullish)(e)?e:"MalformedAddress"in t?new z(t.MalformedAddress):"AmountTooLow"in t?new X(`${t.AmountTooLow}`):"InsufficientFunds"in t?new Q(`${t.InsufficientFunds.balance}`):new w(`Unsupported response type in minter.retrieveBtc ${JSON.stringify(t)}`)},_t=t=>{let e=pt(t);return(0,B.nonNullish)(e)?e:"InsufficientAllowance"in t?new J(`${t.InsufficientAllowance.allowance}`):K(t)};var _=require("@dfinity/utils");var vt=({IDL:t})=>{let e=t.Variant({RestrictedTo:t.Vec(t.Principal),DepositsRestrictedTo:t.Vec(t.Principal),ReadOnly:t.Null,GeneralAvailability:t.Null}),r=t.Record({kyt_principal:t.Opt(t.Principal),mode:t.Opt(e),retrieve_btc_min_amount:t.Opt(t.Nat64),max_time_in_queue_nanos:t.Opt(t.Nat64),min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),n=t.Variant({Mainnet:t.Null,Regtest:t.Null,Testnet:t.Null}),o=t.Record({kyt_principal:t.Opt(t.Principal),ecdsa_key_name:t.Text,mode:e,retrieve_btc_min_amount:t.Nat64,ledger_id:t.Principal,max_time_in_queue_nanos:t.Nat64,btc_network:n,min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),a=t.Variant({Upgrade:t.Opt(r),Init:o}),i=t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),s=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),memory_allocation:t.Nat,compute_allocation:t.Nat}),u=t.Record({response_payload_bytes_total:t.Nat,num_instructions_total:t.Nat,num_calls_total:t.Nat,request_payload_bytes_total:t.Nat}),l=t.Record({status:i,memory_size:t.Nat,cycles:t.Nat,settings:s,query_stats:u,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8))}),d=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),c=t.Record({height:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),p=t.Variant({CallFailed:t.Null,TaintedDestination:t.Record({kyt_fee:t.Nat64,kyt_provider:t.Principal})}),f=t.Variant({p2wsh_v0:t.Vec(t.Nat8),p2tr_v1:t.Vec(t.Nat8),p2sh:t.Vec(t.Nat8),p2wpkh_v0:t.Vec(t.Nat8),p2pkh:t.Vec(t.Nat8)}),h=t.Variant({received_utxos:t.Record({to_account:d,mint_txid:t.Opt(t.Nat64),utxos:t.Vec(c)}),schedule_deposit_reimbursement:t.Record({burn_block_index:t.Nat64,account:d,amount:t.Nat64,reason:p}),sent_transaction:t.Record({fee:t.Opt(t.Nat64),change_output:t.Opt(t.Record({value:t.Nat64,vout:t.Nat32})),txid:t.Vec(t.Nat8),utxos:t.Vec(c),requests:t.Vec(t.Nat64),submitted_at:t.Nat64}),distributed_kyt_fee:t.Record({block_index:t.Nat64,amount:t.Nat64,kyt_provider:t.Principal}),init:o,upgrade:r,retrieve_btc_kyt_failed:t.Record({block_index:t.Nat64,owner:t.Principal,uuid:t.Text,address:t.Text,amount:t.Nat64,kyt_provider:t.Principal}),accepted_retrieve_btc_request:t.Record({received_at:t.Nat64,block_index:t.Nat64,address:f,reimbursement_account:t.Opt(d),amount:t.Nat64,kyt_provider:t.Opt(t.Principal)}),checked_utxo:t.Record({clean:t.Bool,utxo:c,uuid:t.Text,kyt_provider:t.Opt(t.Principal)}),removed_retrieve_btc_request:t.Record({block_index:t.Nat64}),confirmed_transaction:t.Record({txid:t.Vec(t.Nat8)}),replaced_transaction:t.Record({fee:t.Nat64,change_output:t.Record({value:t.Nat64,vout:t.Nat32}),old_txid:t.Vec(t.Nat8),new_txid:t.Vec(t.Nat8),submitted_at:t.Nat64}),ignored_utxo:t.Record({utxo:c}),reimbursed_failed_deposit:t.Record({burn_block_index:t.Nat64,mint_block_index:t.Nat64})}),m=t.Record({retrieve_btc_min_amount:t.Nat64,min_confirmations:t.Nat32,kyt_fee:t.Nat64}),g=t.Record({address:t.Text,amount:t.Nat64}),x=t.Record({block_index:t.Nat64}),et=t.Variant({MalformedAddress:t.Text,GenericError:t.Record({error_message:t.Text,error_code:t.Nat64}),TemporarilyUnavailable:t.Text,AlreadyProcessing:t.Null,AmountTooLow:t.Nat64,InsufficientFunds:t.Record({balance:t.Nat64})}),rt=t.Variant({Signing:t.Null,Confirmed:t.Record({txid:t.Vec(t.Nat8)}),Sending:t.Record({txid:t.Vec(t.Nat8)}),AmountTooLow:t.Null,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Pending:t.Null}),nt=t.Record({account:d,amount:t.Nat64,reason:p}),ot=t.Record({account:d,mint_block_index:t.Nat64,amount:t.Nat64,reason:p}),U=t.Variant({Signing:t.Null,Confirmed:t.Record({txid:t.Vec(t.Nat8)}),Sending:t.Record({txid:t.Vec(t.Nat8)}),AmountTooLow:t.Null,WillReimburse:nt,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Reimbursed:ot,Pending:t.Null}),it=t.Record({from_subaccount:t.Opt(t.Vec(t.Nat8)),address:t.Text,amount:t.Nat64}),at=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})}),ct=t.Variant({ValueTooSmall:c,Tainted:c,Minted:t.Record({minted_amount:t.Nat64,block_index:t.Nat64,utxo:c}),Checked:c}),st=t.Record({confirmations:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),dt=t.Variant({GenericError:t.Record({error_message:t.Text,error_code:t.Nat64}),TemporarilyUnavailable:t.Text,AlreadyProcessing:t.Null,NoNewUtxos:t.Record({required_confirmations:t.Nat32,pending_utxos:t.Opt(t.Vec(st)),current_confirmations:t.Opt(t.Nat32)})});return t.Service({estimate_withdrawal_fee:t.Func([t.Record({amount:t.Opt(t.Nat64)})],[t.Record({minter_fee:t.Nat64,bitcoin_fee:t.Nat64})],[]),get_btc_address:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Text],[]),get_canister_status:t.Func([],[l],[]),get_deposit_fee:t.Func([],[t.Nat64],[]),get_events:t.Func([t.Record({start:t.Nat64,length:t.Nat64})],[t.Vec(h)],[]),get_minter_info:t.Func([],[m],[]),get_withdrawal_account:t.Func([],[d],[]),retrieve_btc:t.Func([g],[t.Variant({Ok:x,Err:et})],[]),retrieve_btc_status:t.Func([t.Record({block_index:t.Nat64})],[rt],[]),retrieve_btc_status_v2:t.Func([t.Record({block_index:t.Nat64})],[U],[]),retrieve_btc_status_v2_by_account:t.Func([t.Opt(d)],[t.Vec(t.Record({block_index:t.Nat64,status_v2:t.Opt(U)}))],[]),retrieve_btc_with_approval:t.Func([it],[t.Variant({Ok:x,Err:at})],[]),update_balance:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Variant({Ok:t.Vec(ct),Err:dt})],[])})};var kt=({IDL:t})=>{let e=t.Variant({RestrictedTo:t.Vec(t.Principal),DepositsRestrictedTo:t.Vec(t.Principal),ReadOnly:t.Null,GeneralAvailability:t.Null}),r=t.Record({kyt_principal:t.Opt(t.Principal),mode:t.Opt(e),retrieve_btc_min_amount:t.Opt(t.Nat64),max_time_in_queue_nanos:t.Opt(t.Nat64),min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),n=t.Variant({Mainnet:t.Null,Regtest:t.Null,Testnet:t.Null}),o=t.Record({kyt_principal:t.Opt(t.Principal),ecdsa_key_name:t.Text,mode:e,retrieve_btc_min_amount:t.Nat64,ledger_id:t.Principal,max_time_in_queue_nanos:t.Nat64,btc_network:n,min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),a=t.Variant({Upgrade:t.Opt(r),Init:o}),i=t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),s=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),memory_allocation:t.Nat,compute_allocation:t.Nat}),u=t.Record({response_payload_bytes_total:t.Nat,num_instructions_total:t.Nat,num_calls_total:t.Nat,request_payload_bytes_total:t.Nat}),l=t.Record({status:i,memory_size:t.Nat,cycles:t.Nat,settings:s,query_stats:u,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8))}),d=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),c=t.Record({height:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),p=t.Variant({CallFailed:t.Null,TaintedDestination:t.Record({kyt_fee:t.Nat64,kyt_provider:t.Principal})}),f=t.Variant({p2wsh_v0:t.Vec(t.Nat8),p2tr_v1:t.Vec(t.Nat8),p2sh:t.Vec(t.Nat8),p2wpkh_v0:t.Vec(t.Nat8),p2pkh:t.Vec(t.Nat8)}),h=t.Variant({received_utxos:t.Record({to_account:d,mint_txid:t.Opt(t.Nat64),utxos:t.Vec(c)}),schedule_deposit_reimbursement:t.Record({burn_block_index:t.Nat64,account:d,amount:t.Nat64,reason:p}),sent_transaction:t.Record({fee:t.Opt(t.Nat64),change_output:t.Opt(t.Record({value:t.Nat64,vout:t.Nat32})),txid:t.Vec(t.Nat8),utxos:t.Vec(c),requests:t.Vec(t.Nat64),submitted_at:t.Nat64}),distributed_kyt_fee:t.Record({block_index:t.Nat64,amount:t.Nat64,kyt_provider:t.Principal}),init:o,upgrade:r,retrieve_btc_kyt_failed:t.Record({block_index:t.Nat64,owner:t.Principal,uuid:t.Text,address:t.Text,amount:t.Nat64,kyt_provider:t.Principal}),accepted_retrieve_btc_request:t.Record({received_at:t.Nat64,block_index:t.Nat64,address:f,reimbursement_account:t.Opt(d),amount:t.Nat64,kyt_provider:t.Opt(t.Principal)}),checked_utxo:t.Record({clean:t.Bool,utxo:c,uuid:t.Text,kyt_provider:t.Opt(t.Principal)}),removed_retrieve_btc_request:t.Record({block_index:t.Nat64}),confirmed_transaction:t.Record({txid:t.Vec(t.Nat8)}),replaced_transaction:t.Record({fee:t.Nat64,change_output:t.Record({value:t.Nat64,vout:t.Nat32}),old_txid:t.Vec(t.Nat8),new_txid:t.Vec(t.Nat8),submitted_at:t.Nat64}),ignored_utxo:t.Record({utxo:c}),reimbursed_failed_deposit:t.Record({burn_block_index:t.Nat64,mint_block_index:t.Nat64})}),m=t.Record({retrieve_btc_min_amount:t.Nat64,min_confirmations:t.Nat32,kyt_fee:t.Nat64}),g=t.Record({address:t.Text,amount:t.Nat64}),x=t.Record({block_index:t.Nat64}),et=t.Variant({MalformedAddress:t.Text,GenericError:t.Record({error_message:t.Text,error_code:t.Nat64}),TemporarilyUnavailable:t.Text,AlreadyProcessing:t.Null,AmountTooLow:t.Nat64,InsufficientFunds:t.Record({balance:t.Nat64})}),rt=t.Variant({Signing:t.Null,Confirmed:t.Record({txid:t.Vec(t.Nat8)}),Sending:t.Record({txid:t.Vec(t.Nat8)}),AmountTooLow:t.Null,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Pending:t.Null}),nt=t.Record({account:d,amount:t.Nat64,reason:p}),ot=t.Record({account:d,mint_block_index:t.Nat64,amount:t.Nat64,reason:p}),U=t.Variant({Signing:t.Null,Confirmed:t.Record({txid:t.Vec(t.Nat8)}),Sending:t.Record({txid:t.Vec(t.Nat8)}),AmountTooLow:t.Null,WillReimburse:nt,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Reimbursed:ot,Pending:t.Null}),it=t.Record({from_subaccount:t.Opt(t.Vec(t.Nat8)),address:t.Text,amount:t.Nat64}),at=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})}),ct=t.Variant({ValueTooSmall:c,Tainted:c,Minted:t.Record({minted_amount:t.Nat64,block_index:t.Nat64,utxo:c}),Checked:c}),st=t.Record({confirmations:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),dt=t.Variant({GenericError:t.Record({error_message:t.Text,error_code:t.Nat64}),TemporarilyUnavailable:t.Text,AlreadyProcessing:t.Null,NoNewUtxos:t.Record({required_confirmations:t.Nat32,pending_utxos:t.Opt(t.Vec(st)),current_confirmations:t.Opt(t.Nat32)})});return t.Service({estimate_withdrawal_fee:t.Func([t.Record({amount:t.Opt(t.Nat64)})],[t.Record({minter_fee:t.Nat64,bitcoin_fee:t.Nat64})],["query"]),get_btc_address:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Text],[]),get_canister_status:t.Func([],[l],[]),get_deposit_fee:t.Func([],[t.Nat64],["query"]),get_events:t.Func([t.Record({start:t.Nat64,length:t.Nat64})],[t.Vec(h)],["query"]),get_minter_info:t.Func([],[m],["query"]),get_withdrawal_account:t.Func([],[d],[]),retrieve_btc:t.Func([g],[t.Variant({Ok:x,Err:et})],[]),retrieve_btc_status:t.Func([t.Record({block_index:t.Nat64})],[rt],["query"]),retrieve_btc_status_v2:t.Func([t.Record({block_index:t.Nat64})],[U],["query"]),retrieve_btc_status_v2_by_account:t.Func([t.Opt(d)],[t.Vec(t.Record({block_index:t.Nat64,status_v2:t.Opt(U)}))],["query"]),retrieve_btc_with_approval:t.Func([it],[t.Variant({Ok:x,Err:at})],[]),update_balance:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Variant({Ok:t.Vec(ct),Err:dt})],[])})};var Y=class t extends _.Canister{constructor(){super(...arguments);this.getBtcAddress=({owner:r,subaccount:n})=>this.caller({certified:!0}).get_btc_address({owner:(0,_.toNullable)(r),subaccount:(0,_.toNullable)(n)});this.updateBalance=async({owner:r,subaccount:n})=>{let o=await this.caller({certified:!0}).update_balance({owner:(0,_.toNullable)(r),subaccount:(0,_.toNullable)(n)});if("Err"in o)throw ft(o.Err);return o.Ok};this.getWithdrawalAccount=()=>this.caller({certified:!0}).get_withdrawal_account();this.retrieveBtc=async r=>{let n=await this.caller({certified:!0}).retrieve_btc(r);if("Err"in n)throw K(n.Err);return n.Ok};this.retrieveBtcWithApproval=async({address:r,amount:n,fromSubaccount:o})=>{let a=await this.caller({certified:!0}).retrieve_btc_with_approval({address:r,amount:n,from_subaccount:(0,_.toNullable)(o)});if("Err"in a)throw _t(a.Err);return a.Ok};this.retrieveBtcStatus=async({transactionId:r,certified:n})=>this.caller({certified:n}).retrieve_btc_status({block_index:r});this.retrieveBtcStatusV2ByAccount=async({account:r,certified:n})=>{let{retrieve_btc_status_v2_by_account:o}=this.caller({certified:n});return(await o((0,_.isNullish)(r)?[]:[{owner:r.owner,subaccount:(0,_.toNullable)(r.subaccount)}])).map(({block_index:i,status_v2:s})=>({id:i,status:(0,_.fromNullable)(s)}))};this.estimateWithdrawalFee=async({certified:r,amount:n})=>this.caller({certified:r}).estimate_withdrawal_fee({amount:(0,_.toNullable)(n)});this.getMinterInfo=async({certified:r})=>this.caller({certified:r}).get_minter_info()}static create(r){let{service:n,certifiedService:o,canisterId:a}=(0,_.createServices)({options:r,idlFactory:kt,certifiedIdlFactory:vt});return new t(a,n,o)}};var yt=require("@dfinity/utils");function Zt(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function mt(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function At(t,e){Zt(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var It=t=>t instanceof Uint8Array;var I=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),b=(t,e)=>t<<32-e|t>>>e,Lt=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Lt)throw new Error("Non little-endian hardware is not supported");function Dt(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function ht(t){if(typeof t=="string"&&(t=Dt(t)),!It(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}var Z=class{clone(){return this._cloneInto()}},Ce={}.toString;function Vt(t){let e=n=>t().update(ht(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function te(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let o=BigInt(32),a=BigInt(4294967295),i=Number(r>>o&a),s=Number(r&a),u=n?4:0,l=n?0:4;t.setUint32(e+u,i,n),t.setUint32(e+l,s,n)}var L=class extends Z{constructor(e,r,n,o){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=I(this.buffer)}update(e){mt(this);let{view:r,buffer:n,blockLen:o}=this;e=ht(e);let a=e.length;for(let i=0;i<a;){let s=Math.min(o-this.pos,a-i);if(s===o){let u=I(e);for(;o<=a-i;i+=o)this.process(u,i);continue}n.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){mt(this),At(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:a}=this,{pos:i}=this;r[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let c=i;c<o;c++)r[c]=0;te(n,o-8,BigInt(this.length*8),a),this.process(n,0);let s=I(e),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=u/4,d=this.get();if(l>d.length)throw new Error("_sha2: outputLen bigger than state");for(let c=0;c<l;c++)s.setUint32(4*c,d[c],a)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:a,destroyed:i,pos:s}=this;return e.length=o,e.pos=s,e.finished=a,e.destroyed=i,o%r&&e.buffer.set(n),e}};var ee=(t,e,r)=>t&e^~t&r,re=(t,e,r)=>t&e^t&r^e&r,ne=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),R=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),v=new Uint32Array(64),xt=class extends L{constructor(){super(64,32,8,!1),this.A=R[0]|0,this.B=R[1]|0,this.C=R[2]|0,this.D=R[3]|0,this.E=R[4]|0,this.F=R[5]|0,this.G=R[6]|0,this.H=R[7]|0}get(){let{A:e,B:r,C:n,D:o,E:a,F:i,G:s,H:u}=this;return[e,r,n,o,a,i,s,u]}set(e,r,n,o,a,i,s,u){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=a|0,this.F=i|0,this.G=s|0,this.H=u|0}process(e,r){for(let c=0;c<16;c++,r+=4)v[c]=e.getUint32(r,!1);for(let c=16;c<64;c++){let p=v[c-15],f=v[c-2],h=b(p,7)^b(p,18)^p>>>3,m=b(f,17)^b(f,19)^f>>>10;v[c]=m+v[c-7]+h+v[c-16]|0}let{A:n,B:o,C:a,D:i,E:s,F:u,G:l,H:d}=this;for(let c=0;c<64;c++){let p=b(s,6)^b(s,11)^b(s,25),f=d+p+ee(s,u,l)+ne[c]+v[c]|0,m=(b(n,2)^b(n,13)^b(n,22))+re(n,o,a)|0;d=l,l=u,u=s,s=i+f|0,i=a,a=o,o=n,n=f+m|0}n=n+this.A|0,o=o+this.B|0,a=a+this.C|0,i=i+this.D|0,s=s+this.E|0,u=u+this.F|0,l=l+this.G|0,d=d+this.H|0,this.set(n,o,a,i,s,u,l,d)}roundClean(){v.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Nt=Vt(()=>new xt);var Ht=Rt(qt()),W=Rt($t());var _e=0,me=5,he=111,xe=196,Ne={[_e]:{type:1,networks:[0]},[he]:{type:1,networks:[2,1]},[me]:{type:2,networks:[0]},[xe]:{type:2,networks:[2,1]}},be=({address:t,network:e})=>{let n=(d=>{try{return(0,Ht.base58_to_binary)(d)}catch{throw new V}})(t),{length:o}=n;if(o!==25)throw new k(`Expected the address to be 25 bytes, got ${o}.`);(d=>{let c=d.slice(o-4,o),p=d.slice(0,o-4),f=Nt.create();f.update(p);let h=Nt.create();h.update(f.digest());let m=h.digest().slice(0,4);if(c.some((g,x)=>g!==m[x]))throw new k(`Checksum mismatch expected ${c}, got ${m}.`)})(n);let i=n[0],s=Ne[i];if((0,yt.isNullish)(s))throw new O;let{type:u,networks:l}=s;if(!l.includes(e))throw new q;return{address:t,network:e,type:u,parser:"base58"}},ge=({address:t,network:e})=>{let r=d=>{try{return d.startsWith("bc1p")||d.startsWith("tb1p")||d.startsWith("bcrt1p")?W.bech32m.decode(d):W.bech32.decode(d)}catch{throw new k}},{prefix:n,words:o}=r(t),i={bc:0,tb:2,bcrt:1}[n];if((0,yt.isNullish)(i))throw new V;if(i!==e)throw new S;let[s,...u]=o;if(s>1)throw new F;switch(W.bech32.fromWords(u).length){case 20:return{address:t,network:e,type:0,parser:"bip-173"};case 32:return{address:t,network:e,type:s===0?3:4,parser:"bip-173"};default:throw new C}},ye=({address:t,network:e=0})=>{switch(t.charAt(0)){case"1":case"2":case"3":case"m":case"n":return be({address:t,network:e});case"b":case"B":case"t":case"T":return ge({address:t,network:e});case"":throw new E;default:throw new O}};0&&(module.exports={BtcAddressType,BtcNetwork,CkBTCMinterCanister,MinterAlreadyProcessingError,MinterAmountTooLowError,MinterGenericError,MinterInsufficientAllowanceError,MinterInsufficientFundsError,MinterMalformedAddressError,MinterNoNewUtxosError,MinterRetrieveBtcError,MinterTemporaryUnavailableError,MinterUpdateBalanceError,ParseBtcAddressBadWitnessLengthError,ParseBtcAddressError,ParseBtcAddressInvalidError,ParseBtcAddressMalformedAddressError,ParseBtcAddressNoDataError,ParseBtcAddressUnexpectedHumanReadablePartError,ParseBtcAddressUnsupportedAddressTypeError,ParseBtcAddressUnsupportedWitnessVersionError,ParseBtcAddressWrongNetworkError,createRetrieveBtcError,createRetrieveBtcWithApprovalError,createUpdateBalanceError,parseBtcAddress});
2
2
  /*! Bundled license information:
3
3
 
4
4
  @noble/hashes/esm/utils.js: