@dfinity/ckbtc 3.1.14 → 3.2.0-next-2025-08-13
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 +3 -3
- package/dist/candid/minter.did +1 -1
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/index.cjs.js.map +4 -4
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +4 -4
- package/dist/types/types/minter.responses.d.ts +4 -4
- package/package.json +8 -8
- package/dist/esm/base58.d.js +0 -1
- package/dist/esm/base58.d.js.map +0 -7
package/README.md
CHANGED
|
@@ -202,9 +202,9 @@ The BTC retrieval process is slow. Instead of synchronously waiting for a BTC tr
|
|
|
202
202
|
The caller allowed the minter's principal to spend its funds using
|
|
203
203
|
[icrc2_approve] on the ckBTC ledger.
|
|
204
204
|
|
|
205
|
-
| Method | Type
|
|
206
|
-
| ------------------------- |
|
|
207
|
-
| `retrieveBtcWithApproval` | `({ address, amount, fromSubaccount, }: { address: string; amount: bigint; fromSubaccount?: Uint8Array or undefined; }) => Promise<RetrieveBtcOk>` |
|
|
205
|
+
| Method | Type |
|
|
206
|
+
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
207
|
+
| `retrieveBtcWithApproval` | `({ address, amount, fromSubaccount, }: { address: string; amount: bigint; fromSubaccount?: Uint8Array<ArrayBufferLike> or undefined; }) => Promise<RetrieveBtcOk>` |
|
|
208
208
|
|
|
209
209
|
Parameters:
|
|
210
210
|
|
package/dist/candid/minter.did
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated from IC repo commit
|
|
1
|
+
// Generated from IC repo commit 047925d (2025-08-06 tags: release-2025-08-07_03-33-base) 'rs/bitcoin/ckbtc/minter/ckbtc_minter.did' by import-candid
|
|
2
2
|
// Represents an account on the ckBTC ledger.
|
|
3
3
|
type Account = record { owner : principal; subaccount : opt blob };
|
|
4
4
|
|
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var oe=Object.create;var Q=Object.defineProperty;var ce=Object.getOwnPropertyDescriptor;var ae=Object.getOwnPropertyNames;var ie=Object.getPrototypeOf,se=Object.prototype.hasOwnProperty;var B=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),le=(t,e)=>{for(var r in e)Q(t,r,{get:e[r],enumerable:!0})},Ct=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ae(e))!se.call(t,o)&&o!==r&&Q(t,o,{get:()=>e[o],enumerable:!(n=ce(e,o))||n.enumerable});return t};var Ft=(t,e,r)=>(r=t!=null?oe(ie(t)):{},Ct(e||!t||!t.__esModule?Q(r,"default",{value:t,enumerable:!0}):r,t)),ue=t=>Ct(Q({},"__esModule",{value:!0}),t);var at=B((lr,$t)=>{"use strict";var xe="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";$t.exports=xe});var Qt=B((ur,jt)=>{"use strict";var he=at(),Ne=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=>he.indexOf(o)).reduce((o,i)=>(o=o.map(c=>{let s=c*58+i;return i=s>>8,s}),o),new Uint8Array(n)).reverse().filter((o=>i=>o=o||i)(!1))])};jt.exports=Ne});var Jt=B((_r,Kt)=>{"use strict";var Xt=at(),be=()=>{let t=Array(256).fill(-1);for(let e=0;e<Xt.length;++e)t[Xt.charCodeAt(e)]=e;return t};Kt.exports=be});var It=B((dr,Zt)=>{"use strict";var Yt=at(),ge=Jt(),ye=ge(),we=t=>{let e=[];for(let r of t){let n=r;for(let o=0;o<e.length;++o){let i=(ye[e[o]]<<8)+n;e[o]=Yt.charCodeAt(i%58),n=i/58|0}for(;n;)e.push(Yt.charCodeAt(n%58)),n=n/58|0}for(let r of t){if(r)break;e.push(49)}return e.reverse(),String.fromCharCode(...e)};Zt.exports=we});var Lt=B(Bt=>{"use strict";Bt.base58_to_binary=Qt();Bt.binary_to_base58=It()});var re=B(S=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0});S.bech32m=S.bech32=void 0;var it="qpzry9x8gf2tvdw0s3jn54khce6mua7l",te={};for(let t=0;t<it.length;t++){let e=it.charAt(t);te[e]=t}function E(t){let e=t>>25;return(t&33554431)<<5^-(e>>0&1)&996825010^-(e>>1&1)&642813549^-(e>>2&1)&513874426^-(e>>3&1)&1027748829^-(e>>4&1)&705979059}function Dt(t){let e=1;for(let r=0;r<t.length;++r){let n=t.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+t+")";e=E(e)^n>>5}e=E(e);for(let r=0;r<t.length;++r){let n=t.charCodeAt(r);e=E(e)^n&31}return e}function Tt(t,e,r,n){let o=0,i=0,c=(1<<r)-1,s=[];for(let l=0;l<t.length;++l)for(o=o<<e|t[l],i+=e;i>=r;)i-=r,s.push(o>>i&c);if(n)i>0&&s.push(o<<r-i&c);else{if(i>=e)return"Excess padding";if(o<<r-i&c)return"Non-zero padding"}return s}function Re(t){return Tt(t,8,5,!0)}function ke(t){let e=Tt(t,5,8,!1);if(Array.isArray(e))return e}function Oe(t){let e=Tt(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function ee(t){let e;t==="bech32"?e=1:e=734539939;function r(c,s,l){if(l=l||90,c.length+7+s.length>l)throw new TypeError("Exceeds length limit");c=c.toLowerCase();let d=Dt(c);if(typeof d=="string")throw new Error(d);let _=c+"1";for(let a=0;a<s.length;++a){let u=s[a];if(u>>5!==0)throw new Error("Non 5-bit word");d=E(d)^u,_+=it.charAt(u)}for(let a=0;a<6;++a)d=E(d);d^=e;for(let a=0;a<6;++a){let u=d>>(5-a)*5&31;_+=it.charAt(u)}return _}function n(c,s){if(s=s||90,c.length<8)return c+" too short";if(c.length>s)return"Exceeds length limit";let l=c.toLowerCase(),d=c.toUpperCase();if(c!==l&&c!==d)return"Mixed-case string "+c;c=l;let _=c.lastIndexOf("1");if(_===-1)return"No separator character for "+c;if(_===0)return"Missing prefix for "+c;let a=c.slice(0,_),u=c.slice(_+1);if(u.length<6)return"Data too short";let p=Dt(a);if(typeof p=="string")return p;let f=[];for(let m=0;m<u.length;++m){let N=u.charAt(m),h=te[N];if(h===void 0)return"Unknown character "+N;p=E(p)^h,!(m+6>=u.length)&&f.push(h)}return p!==e?"Invalid checksum for "+c:{prefix:a,words:f}}function o(c,s){let l=n(c,s);if(typeof l=="object")return l}function i(c,s){let l=n(c,s);if(typeof l=="object")return l;throw new Error(l)}return{decodeUnsafe:o,decode:i,encode:r,toWords:Re,fromWordsUnsafe:ke,fromWords:Oe}}S.bech32=ee("bech32");S.bech32m=ee("bech32m")});var Fe={};le(Fe,{BitcoinCanister:()=>X,BtcAddressType:()=>yt,BtcNetwork:()=>gt,CkBTCMinterCanister:()=>rt,MinterAlreadyProcessingError:()=>Y,MinterAmountTooLowError:()=>L,MinterGenericError:()=>R,MinterInsufficientAllowanceError:()=>tt,MinterInsufficientFundsError:()=>D,MinterMalformedAddressError:()=>I,MinterNoNewUtxosError:()=>Z,MinterRetrieveBtcError:()=>k,MinterTemporaryUnavailableError:()=>J,MinterUpdateBalanceError:()=>$,ParseBtcAddressBadWitnessLengthError:()=>G,ParseBtcAddressError:()=>b,ParseBtcAddressInvalidError:()=>U,ParseBtcAddressMalformedAddressError:()=>A,ParseBtcAddressNoDataError:()=>M,ParseBtcAddressUnexpectedHumanReadablePartError:()=>z,ParseBtcAddressUnsupportedAddressTypeError:()=>C,ParseBtcAddressUnsupportedWitnessVersionError:()=>W,ParseBtcAddressWrongNetworkError:()=>H,createRetrieveBtcError:()=>et,createRetrieveBtcWithApprovalError:()=>kt,createUpdateBalanceError:()=>Rt,parseBtcAddress:()=>Ce,toGetBalanceParams:()=>bt,toGetUtxosParams:()=>Nt});module.exports=ue(Fe);var K=require("@dfinity/utils");var Et=({IDL:t})=>{let e=t.Variant({disabled:t.Null,enabled:t.Null}),r=t.Record({get_current_fee_percentiles:t.Nat,get_utxos_maximum:t.Nat,get_block_headers_cycles_per_ten_instructions:t.Nat,get_current_fee_percentiles_maximum:t.Nat,send_transaction_per_byte:t.Nat,get_balance:t.Nat,get_utxos_cycles_per_ten_instructions:t.Nat,get_block_headers_base:t.Nat,get_utxos_base:t.Nat,get_balance_maximum:t.Nat,send_transaction_base:t.Nat,get_block_headers_maximum:t.Nat}),n=t.Variant({mainnet:t.Null,regtest:t.Null,testnet:t.Null}),o=t.Record({api_access:t.Opt(e),lazily_evaluate_fee_percentiles:t.Opt(e),blocks_source:t.Opt(t.Principal),fees:t.Opt(r),watchdog_canister:t.Opt(t.Opt(t.Principal)),network:t.Opt(n),stability_threshold:t.Opt(t.Nat),syncing:t.Opt(e),burn_cycles:t.Opt(e),disable_api_if_not_fully_synced:t.Opt(e)}),i=t.Text,c=t.Record({network:n,address:i,min_confirmations:t.Opt(t.Nat32)}),s=t.Nat64,l=t.Nat32,d=t.Record({start_height:l,end_height:t.Opt(l),network:n}),_=t.Vec(t.Nat8),a=t.Record({tip_height:l,block_headers:t.Vec(_)}),u=t.Record({network:n}),p=t.Nat64,f=t.Record({network:n,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:i}),m=t.Vec(t.Nat8),N=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),h=t.Record({height:l,value:s,outpoint:N}),y=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:l,tip_block_hash:m,utxos:t.Vec(h)}),V=t.Record({transaction:t.Vec(t.Nat8),network:n}),w=t.Record({api_access:e,lazily_evaluate_fee_percentiles:e,blocks_source:t.Principal,fees:r,watchdog_canister:t.Opt(t.Principal),network:n,stability_threshold:t.Nat,syncing:e,burn_cycles:e,disable_api_if_not_fully_synced:e}),P=t.Record({api_access:t.Opt(e),lazily_evaluate_fee_percentiles:t.Opt(e),fees:t.Opt(r),watchdog_canister:t.Opt(t.Opt(t.Principal)),stability_threshold:t.Opt(t.Nat),syncing:t.Opt(e),burn_cycles:t.Opt(e),disable_api_if_not_fully_synced:t.Opt(e)});return t.Service({bitcoin_get_balance:t.Func([c],[s],[]),bitcoin_get_balance_query:t.Func([c],[s],[]),bitcoin_get_block_headers:t.Func([d],[a],[]),bitcoin_get_current_fee_percentiles:t.Func([u],[t.Vec(p)],[]),bitcoin_get_utxos:t.Func([f],[y],[]),bitcoin_get_utxos_query:t.Func([f],[y],[]),bitcoin_send_transaction:t.Func([V],[],[]),get_config:t.Func([],[w],[]),set_config:t.Func([P],[],[])})};var St=({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)}),i=t.Text,c=t.Record({network:n,address:i,min_confirmations:t.Opt(t.Nat32)}),s=t.Nat64,l=t.Nat32,d=t.Record({start_height:l,end_height:t.Opt(l),network:n}),_=t.Vec(t.Nat8),a=t.Record({tip_height:l,block_headers:t.Vec(_)}),u=t.Record({network:n}),p=t.Nat64,f=t.Record({network:n,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:i}),m=t.Vec(t.Nat8),N=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),h=t.Record({height:l,value:s,outpoint:N}),y=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:l,tip_block_hash:m,utxos:t.Vec(h)}),V=t.Record({transaction:t.Vec(t.Nat8),network:n}),w=t.Record({api_access:e,lazily_evaluate_fee_percentiles:e,blocks_source:t.Principal,fees:r,watchdog_canister:t.Opt(t.Principal),network:n,stability_threshold:t.Nat,syncing:e,burn_cycles:e,disable_api_if_not_fully_synced:e}),P=t.Record({api_access:t.Opt(e),lazily_evaluate_fee_percentiles:t.Opt(e),fees:t.Opt(r),watchdog_canister:t.Opt(t.Opt(t.Principal)),stability_threshold:t.Opt(t.Nat),syncing:t.Opt(e),burn_cycles:t.Opt(e),disable_api_if_not_fully_synced:t.Opt(e)});return t.Service({bitcoin_get_balance:t.Func([c],[s],[]),bitcoin_get_balance_query:t.Func([c],[s],["query"]),bitcoin_get_block_headers:t.Func([d],[a],[]),bitcoin_get_current_fee_percentiles:t.Func([u],[t.Vec(p)],[]),bitcoin_get_utxos:t.Func([f],[y],[]),bitcoin_get_utxos_query:t.Func([f],[y],["query"]),bitcoin_send_transaction:t.Func([V],[],[]),get_config:t.Func([],[w],["query"]),set_config:t.Func([P],[],[])})};var T=require("@dfinity/utils"),_e={mainnet:{mainnet:null},testnet:{testnet:null},regtest:{regtest:null}},Nt=({network:t,filter:e,...r})=>({filter:(0,T.nonNullish)(e)?(0,T.toNullable)("minConfirmations"in e?{min_confirmations:e.minConfirmations}:{page:e.page}):(0,T.toNullable)(),network:t==="testnet"?{testnet:null}:{mainnet:null},...r}),bt=({network:t,minConfirmations:e,...r})=>({min_confirmations:(0,T.toNullable)(e),network:_e[t],...r});var X=class t extends K.Canister{static create(e){let{service:r,certifiedService:n,canisterId:o}=(0,K.createServices)({options:e,idlFactory:St,certifiedIdlFactory:Et});return new t(o,r,n)}getUtxosQuery=({...e})=>{let{bitcoin_get_utxos_query:r}=this.caller({certified:!1});return r(Nt(e))};getBalanceQuery=({...e})=>{let{bitcoin_get_balance_query:r}=this.caller({certified:!1});return r(bt(e))}};var gt=(n=>(n[n.Mainnet=0]="Mainnet",n[n.Regtest=1]="Regtest",n[n.Testnet=2]="Testnet",n))(gt||{}),yt=(i=>(i[i.P2wpkhV0=0]="P2wpkhV0",i[i.P2pkh=1]="P2pkh",i[i.P2sh=2]="P2sh",i[i.P2wsh=3]="P2wsh",i[i.P2tr=4]="P2tr",i))(yt||{});var b=class extends Error{},U=class extends b{},M=class extends b{},C=class extends b{},G=class extends b{},W=class extends b{},z=class extends b{},A=class extends b{},H=class extends b{};var F=require("@dfinity/utils"),R=class extends Error{},J=class extends R{},Y=class extends R{},$=class extends R{},Z=class extends ${pendingUtxos;requiredConfirmations;constructor({pending_utxos:e,required_confirmations:r}){super(),this.pendingUtxos=(0,F.fromNullable)(e)??[],this.requiredConfirmations=r}},k=class extends R{},I=class extends k{},L=class extends k{},D=class extends k{},tt=class extends k{},wt=t=>{if("GenericError"in t){let{GenericError:{error_message:e,error_code:r}}=t;return new R(`${e} (${r})`)}if("TemporarilyUnavailable"in t)return new J(t.TemporarilyUnavailable);if("AlreadyProcessing"in t)return new Y},Rt=t=>{let e=wt(t);return(0,F.nonNullish)(e)?e:"NoNewUtxos"in t?new Z(t.NoNewUtxos):new $(`Unsupported response type in minter.updateBalance ${JSON.stringify(t)}`)},et=t=>{let e=wt(t);return(0,F.nonNullish)(e)?e:"MalformedAddress"in t?new I(t.MalformedAddress):"AmountTooLow"in t?new L(`${t.AmountTooLow}`):"InsufficientFunds"in t?new D(`${t.InsufficientFunds.balance}`):new k(`Unsupported response type in minter.retrieveBtc ${JSON.stringify(t)}`)},kt=t=>{let e=wt(t);return(0,F.nonNullish)(e)?e:"InsufficientAllowance"in t?new tt(`${t.InsufficientAllowance.allowance}`):et(t)};var x=require("@dfinity/utils");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)}),i=t.Variant({Upgrade:t.Opt(r),Init:o}),c=t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),s=t.Variant({controllers:t.Null,public:t.Null,allowed_viewers:t.Vec(t.Principal)}),l=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,log_visibility:s,wasm_memory_limit:t.Nat,memory_allocation:t.Nat,compute_allocation:t.Nat}),d=t.Record({response_payload_bytes_total:t.Nat,num_instructions_total:t.Nat,num_calls_total:t.Nat,request_payload_bytes_total:t.Nat}),_=t.Record({status:c,memory_size:t.Nat,cycles:t.Nat,settings:l,query_stats:d,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8)),reserved_cycles:t.Nat}),a=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),u=t.Record({height:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),p=t.Variant({CallFailed:t.Null,TaintedDestination:t.Record({kyt_fee:t.Nat64,kyt_provider:t.Principal})}),f=t.Variant({ValueTooSmall:t.Null,Quarantined:t.Null}),m=t.Variant({p2wsh_v0:t.Vec(t.Nat8),p2tr_v1:t.Vec(t.Nat8),p2sh:t.Vec(t.Nat8),p2wpkh_v0:t.Vec(t.Nat8),p2pkh:t.Vec(t.Nat8)}),N=t.Variant({received_utxos:t.Record({to_account:a,mint_txid:t.Opt(t.Nat64),utxos:t.Vec(u)}),schedule_deposit_reimbursement:t.Record({burn_block_index:t.Nat64,account:a,amount:t.Nat64,reason:p}),sent_transaction:t.Record({fee:t.Opt(t.Nat64),change_output:t.Opt(t.Record({value:t.Nat64,vout:t.Nat32})),txid:t.Vec(t.Nat8),utxos:t.Vec(u),requests:t.Vec(t.Nat64),submitted_at:t.Nat64}),distributed_kyt_fee:t.Record({block_index:t.Nat64,amount:t.Nat64,kyt_provider:t.Principal}),init:o,upgrade:r,retrieve_btc_kyt_failed:t.Record({block_index:t.Nat64,owner:t.Principal,uuid:t.Text,address:t.Text,amount:t.Nat64,kyt_provider:t.Principal}),suspended_utxo:t.Record({utxo:u,account:a,reason:f}),accepted_retrieve_btc_request:t.Record({received_at:t.Nat64,block_index:t.Nat64,address:m,reimbursement_account:t.Opt(a),amount:t.Nat64,kyt_provider:t.Opt(t.Principal)}),checked_utxo:t.Record({clean:t.Bool,utxo:u,uuid:t.Text,kyt_provider:t.Opt(t.Principal)}),removed_retrieve_btc_request:t.Record({block_index:t.Nat64}),confirmed_transaction:t.Record({txid:t.Vec(t.Nat8)}),replaced_transaction:t.Record({fee:t.Nat64,change_output:t.Record({value:t.Nat64,vout:t.Nat32}),old_txid:t.Vec(t.Nat8),new_txid:t.Vec(t.Nat8),submitted_at:t.Nat64}),checked_utxo_v2:t.Record({utxo:u,account:a}),ignored_utxo:t.Record({utxo:u}),checked_utxo_mint_unknown:t.Record({utxo:u,account:a}),reimbursed_failed_deposit:t.Record({burn_block_index:t.Nat64,mint_block_index:t.Nat64})}),h=t.Record({timestamp:t.Opt(t.Nat64),payload:N}),y=t.Record({retrieve_btc_min_amount:t.Nat64,min_confirmations:t.Nat32,kyt_fee:t.Nat64}),V=t.Record({address:t.Text,amount:t.Nat64}),w=t.Record({block_index:t.Nat64}),P=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})}),st=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}),lt=t.Record({account:a,amount:t.Nat64,reason:p}),ut=t.Record({account:a,mint_block_index:t.Nat64,amount:t.Nat64,reason:p}),q=t.Variant({Signing:t.Null,Confirmed:t.Record({txid:t.Vec(t.Nat8)}),Sending:t.Record({txid:t.Vec(t.Nat8)}),AmountTooLow:t.Null,WillReimburse:lt,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Reimbursed:ut,Pending:t.Null}),_t=t.Record({from_subaccount:t.Opt(t.Vec(t.Nat8)),address:t.Text,amount:t.Nat64}),dt=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})}),pt=t.Variant({ValueTooSmall:u,Tainted:u,Minted:t.Record({minted_amount:t.Nat64,block_index:t.Nat64,utxo:u}),Checked:u}),ft=t.Nat64,mt=t.Record({utxo:u,earliest_retry:ft,reason:f}),xt=t.Record({confirmations:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),ht=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(mt)),required_confirmations:t.Nat32,pending_utxos:t.Opt(t.Vec(xt)),current_confirmations:t.Opt(t.Nat32)})});return t.Service({estimate_withdrawal_fee:t.Func([t.Record({amount:t.Opt(t.Nat64)})],[t.Record({minter_fee:t.Nat64,bitcoin_fee:t.Nat64})],[]),get_btc_address:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Text],[]),get_canister_status:t.Func([],[_],[]),get_deposit_fee:t.Func([],[t.Nat64],[]),get_events:t.Func([t.Record({start:t.Nat64,length:t.Nat64})],[t.Vec(h)],[]),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([],[y],[]),get_withdrawal_account:t.Func([],[a],[]),retrieve_btc:t.Func([V],[t.Variant({Ok:w,Err:P})],[]),retrieve_btc_status:t.Func([t.Record({block_index:t.Nat64})],[st],[]),retrieve_btc_status_v2:t.Func([t.Record({block_index:t.Nat64})],[q],[]),retrieve_btc_status_v2_by_account:t.Func([t.Opt(a)],[t.Vec(t.Record({block_index:t.Nat64,status_v2:t.Opt(q)}))],[]),retrieve_btc_with_approval:t.Func([_t],[t.Variant({Ok:w,Err:dt})],[]),update_balance:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Variant({Ok:t.Vec(pt),Err:ht})],[])})};var Mt=({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)}),i=t.Variant({Upgrade:t.Opt(r),Init:o}),c=t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),s=t.Variant({controllers:t.Null,public:t.Null,allowed_viewers:t.Vec(t.Principal)}),l=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,log_visibility:s,wasm_memory_limit:t.Nat,memory_allocation:t.Nat,compute_allocation:t.Nat}),d=t.Record({response_payload_bytes_total:t.Nat,num_instructions_total:t.Nat,num_calls_total:t.Nat,request_payload_bytes_total:t.Nat}),_=t.Record({status:c,memory_size:t.Nat,cycles:t.Nat,settings:l,query_stats:d,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8)),reserved_cycles:t.Nat}),a=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),u=t.Record({height:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),p=t.Variant({CallFailed:t.Null,TaintedDestination:t.Record({kyt_fee:t.Nat64,kyt_provider:t.Principal})}),f=t.Variant({ValueTooSmall:t.Null,Quarantined:t.Null}),m=t.Variant({p2wsh_v0:t.Vec(t.Nat8),p2tr_v1:t.Vec(t.Nat8),p2sh:t.Vec(t.Nat8),p2wpkh_v0:t.Vec(t.Nat8),p2pkh:t.Vec(t.Nat8)}),N=t.Variant({received_utxos:t.Record({to_account:a,mint_txid:t.Opt(t.Nat64),utxos:t.Vec(u)}),schedule_deposit_reimbursement:t.Record({burn_block_index:t.Nat64,account:a,amount:t.Nat64,reason:p}),sent_transaction:t.Record({fee:t.Opt(t.Nat64),change_output:t.Opt(t.Record({value:t.Nat64,vout:t.Nat32})),txid:t.Vec(t.Nat8),utxos:t.Vec(u),requests:t.Vec(t.Nat64),submitted_at:t.Nat64}),distributed_kyt_fee:t.Record({block_index:t.Nat64,amount:t.Nat64,kyt_provider:t.Principal}),init:o,upgrade:r,retrieve_btc_kyt_failed:t.Record({block_index:t.Nat64,owner:t.Principal,uuid:t.Text,address:t.Text,amount:t.Nat64,kyt_provider:t.Principal}),suspended_utxo:t.Record({utxo:u,account:a,reason:f}),accepted_retrieve_btc_request:t.Record({received_at:t.Nat64,block_index:t.Nat64,address:m,reimbursement_account:t.Opt(a),amount:t.Nat64,kyt_provider:t.Opt(t.Principal)}),checked_utxo:t.Record({clean:t.Bool,utxo:u,uuid:t.Text,kyt_provider:t.Opt(t.Principal)}),removed_retrieve_btc_request:t.Record({block_index:t.Nat64}),confirmed_transaction:t.Record({txid:t.Vec(t.Nat8)}),replaced_transaction:t.Record({fee:t.Nat64,change_output:t.Record({value:t.Nat64,vout:t.Nat32}),old_txid:t.Vec(t.Nat8),new_txid:t.Vec(t.Nat8),submitted_at:t.Nat64}),checked_utxo_v2:t.Record({utxo:u,account:a}),ignored_utxo:t.Record({utxo:u}),checked_utxo_mint_unknown:t.Record({utxo:u,account:a}),reimbursed_failed_deposit:t.Record({burn_block_index:t.Nat64,mint_block_index:t.Nat64})}),h=t.Record({timestamp:t.Opt(t.Nat64),payload:N}),y=t.Record({retrieve_btc_min_amount:t.Nat64,min_confirmations:t.Nat32,kyt_fee:t.Nat64}),V=t.Record({address:t.Text,amount:t.Nat64}),w=t.Record({block_index:t.Nat64}),P=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})}),st=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}),lt=t.Record({account:a,amount:t.Nat64,reason:p}),ut=t.Record({account:a,mint_block_index:t.Nat64,amount:t.Nat64,reason:p}),q=t.Variant({Signing:t.Null,Confirmed:t.Record({txid:t.Vec(t.Nat8)}),Sending:t.Record({txid:t.Vec(t.Nat8)}),AmountTooLow:t.Null,WillReimburse:lt,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Reimbursed:ut,Pending:t.Null}),_t=t.Record({from_subaccount:t.Opt(t.Vec(t.Nat8)),address:t.Text,amount:t.Nat64}),dt=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})}),pt=t.Variant({ValueTooSmall:u,Tainted:u,Minted:t.Record({minted_amount:t.Nat64,block_index:t.Nat64,utxo:u}),Checked:u}),ft=t.Nat64,mt=t.Record({utxo:u,earliest_retry:ft,reason:f}),xt=t.Record({confirmations:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),ht=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(mt)),required_confirmations:t.Nat32,pending_utxos:t.Opt(t.Vec(xt)),current_confirmations:t.Opt(t.Nat32)})});return t.Service({estimate_withdrawal_fee:t.Func([t.Record({amount:t.Opt(t.Nat64)})],[t.Record({minter_fee:t.Nat64,bitcoin_fee:t.Nat64})],["query"]),get_btc_address:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Text],[]),get_canister_status:t.Func([],[_],[]),get_deposit_fee:t.Func([],[t.Nat64],["query"]),get_events:t.Func([t.Record({start:t.Nat64,length:t.Nat64})],[t.Vec(h)],["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([],[y],["query"]),get_withdrawal_account:t.Func([],[a],[]),retrieve_btc:t.Func([V],[t.Variant({Ok:w,Err:P})],[]),retrieve_btc_status:t.Func([t.Record({block_index:t.Nat64})],[st],["query"]),retrieve_btc_status_v2:t.Func([t.Record({block_index:t.Nat64})],[q],["query"]),retrieve_btc_status_v2_by_account:t.Func([t.Opt(a)],[t.Vec(t.Record({block_index:t.Nat64,status_v2:t.Opt(q)}))],["query"]),retrieve_btc_with_approval:t.Func([_t],[t.Variant({Ok:w,Err:dt})],[]),update_balance:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Variant({Ok:t.Vec(pt),Err:ht})],[])})};var rt=class t extends x.Canister{static create(e){let{service:r,certifiedService:n,canisterId:o}=(0,x.createServices)({options:e,idlFactory:Mt,certifiedIdlFactory:qt});return new t(o,r,n)}getBtcAddress=({owner:e,subaccount:r})=>this.caller({certified:!0}).get_btc_address({owner:(0,x.toNullable)(e),subaccount:(0,x.toNullable)(r)});updateBalance=async({owner:e,subaccount:r})=>{let n=await this.caller({certified:!0}).update_balance({owner:(0,x.toNullable)(e),subaccount:(0,x.toNullable)(r)});if("Err"in n)throw Rt(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 et(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:(0,x.toNullable)(n)});if("Err"in o)throw kt(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((0,x.isNullish)(e)?[]:[{owner:e.owner,subaccount:(0,x.toNullable)(e.subaccount)}])).map(({block_index:i,status_v2:c})=>({id:i,status:(0,x.fromNullable)(c)}))};estimateWithdrawalFee=({certified:e,amount:r})=>this.caller({certified:e}).estimate_withdrawal_fee({amount:(0,x.toNullable)(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:(0,x.toNullable)(e),subaccount:(0,x.toNullable)(r)})}};var Ut=require("@dfinity/utils");function de(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Ot(t,...e){if(!de(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function vt(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){Ot(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var ot=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),g=(t,e)=>t<<32-e|t>>>e;var tr=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function pe(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Vt(t){return typeof t=="string"&&(t=pe(t)),Ot(t),t}var nt=class{clone(){return this._cloneInto()}},er={}.toString;function Wt(t){let e=n=>t().update(Vt(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function fe(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let o=BigInt(32),i=BigInt(4294967295),c=Number(r>>o&i),s=Number(r&i),l=n?4:0,d=n?0:4;t.setUint32(e+l,c,n),t.setUint32(e+d,s,n)}var zt=(t,e,r)=>t&e^~t&r,Ht=(t,e,r)=>t&e^t&r^e&r,ct=class extends nt{constructor(e,r,n,o){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=ot(this.buffer)}update(e){vt(this);let{view:r,buffer:n,blockLen:o}=this;e=Vt(e);let i=e.length;for(let c=0;c<i;){let s=Math.min(o-this.pos,i-c);if(s===o){let l=ot(e);for(;o<=i-c;c+=o)this.process(l,c);continue}n.set(e.subarray(c,c+s),this.pos),this.pos+=s,c+=s,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){vt(this),Gt(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:c}=this;r[c++]=128,this.buffer.subarray(c).fill(0),this.padOffset>o-c&&(this.process(n,0),c=0);for(let a=c;a<o;a++)r[a]=0;fe(n,o-8,BigInt(this.length*8),i),this.process(n,0);let s=ot(e),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let d=l/4,_=this.get();if(d>_.length)throw new Error("_sha2: outputLen bigger than state");for(let a=0;a<d;a++)s.setUint32(4*a,_[a],i)}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:i,destroyed:c,pos:s}=this;return e.length=o,e.pos=s,e.finished=i,e.destroyed=c,o%r&&e.buffer.set(n),e}};var me=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),O=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),v=new Uint32Array(64),Pt=class extends ct{constructor(){super(64,32,8,!1),this.A=O[0]|0,this.B=O[1]|0,this.C=O[2]|0,this.D=O[3]|0,this.E=O[4]|0,this.F=O[5]|0,this.G=O[6]|0,this.H=O[7]|0}get(){let{A:e,B:r,C:n,D:o,E:i,F:c,G:s,H:l}=this;return[e,r,n,o,i,c,s,l]}set(e,r,n,o,i,c,s,l){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=c|0,this.G=s|0,this.H=l|0}process(e,r){for(let a=0;a<16;a++,r+=4)v[a]=e.getUint32(r,!1);for(let a=16;a<64;a++){let u=v[a-15],p=v[a-2],f=g(u,7)^g(u,18)^u>>>3,m=g(p,17)^g(p,19)^p>>>10;v[a]=m+v[a-7]+f+v[a-16]|0}let{A:n,B:o,C:i,D:c,E:s,F:l,G:d,H:_}=this;for(let a=0;a<64;a++){let u=g(s,6)^g(s,11)^g(s,25),p=_+u+zt(s,l,d)+me[a]+v[a]|0,m=(g(n,2)^g(n,13)^g(n,22))+Ht(n,o,i)|0;_=d,d=l,l=s,s=c+p|0,c=i,i=o,o=n,n=p+m|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,c=c+this.D|0,s=s+this.E|0,l=l+this.F|0,d=d+this.G|0,_=_+this.H|0,this.set(n,o,i,c,s,l,d,_)}roundClean(){v.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var At=Wt(()=>new Pt);var ne=Ft(Lt()),j=Ft(re());var ve=0,Ve=5,Pe=111,Ae=196,Be={[ve]:{type:1,networks:[0]},[Pe]:{type:1,networks:[2,1]},[Ve]:{type:2,networks:[0]},[Ae]:{type:2,networks:[2,1]}},Te=({address:t,network:e})=>{let n=(_=>{try{return(0,ne.base58_to_binary)(_)}catch{throw new U}})(t),{length:o}=n;if(o!==25)throw new A(`Expected the address to be 25 bytes, got ${o}.`);(_=>{let a=_.slice(o-4,o),u=_.slice(0,o-4),p=At.create();p.update(u);let f=At.create();f.update(p.digest());let m=f.digest().slice(0,4);if(a.some((N,h)=>N!==m[h]))throw new A(`Checksum mismatch expected ${a}, got ${m}.`)})(n);let[c]=n,s=Be[c];if((0,Ut.isNullish)(s))throw new C;let{type:l,networks:d}=s;if(!d.includes(e))throw new H;return{address:t,network:e,type:l,parser:"base58"}},Ue=({address:t,network:e})=>{let r=_=>{try{return _.startsWith("bc1p")||_.startsWith("tb1p")||_.startsWith("bcrt1p")?j.bech32m.decode(_):j.bech32.decode(_)}catch{throw new A}},{prefix:n,words:o}=r(t),c={bc:0,tb:2,bcrt:1}[n];if((0,Ut.isNullish)(c))throw new U;if(c!==e)throw new z;let[s,...l]=o;if(s>1)throw new W;switch(j.bech32.fromWords(l).length){case 20:return{address:t,network:e,type:0,parser:"bip-173"};case 32:return{address:t,network:e,type:s===0?3:4,parser:"bip-173"};default:throw new G}},Ce=({address:t,network:e=0})=>{switch(t.charAt(0)){case"1":case"2":case"3":case"m":case"n":return Te({address:t,network:e});case"b":case"B":case"t":case"T":return Ue({address:t,network:e});case"":throw new M;default:throw new C}};0&&(module.exports={BitcoinCanister,BtcAddressType,BtcNetwork,CkBTCMinterCanister,MinterAlreadyProcessingError,MinterAmountTooLowError,MinterGenericError,MinterInsufficientAllowanceError,MinterInsufficientFundsError,MinterMalformedAddressError,MinterNoNewUtxosError,MinterRetrieveBtcError,MinterTemporaryUnavailableError,MinterUpdateBalanceError,ParseBtcAddressBadWitnessLengthError,ParseBtcAddressError,ParseBtcAddressInvalidError,ParseBtcAddressMalformedAddressError,ParseBtcAddressNoDataError,ParseBtcAddressUnexpectedHumanReadablePartError,ParseBtcAddressUnsupportedAddressTypeError,ParseBtcAddressUnsupportedWitnessVersionError,ParseBtcAddressWrongNetworkError,createRetrieveBtcError,createRetrieveBtcWithApprovalError,createUpdateBalanceError,parseBtcAddress,toGetBalanceParams,toGetUtxosParams});
|
|
1
|
+
"use strict";var Kt=Object.create;var j=Object.defineProperty;var Xt=Object.getOwnPropertyDescriptor;var Jt=Object.getOwnPropertyNames;var Yt=Object.getPrototypeOf,Zt=Object.prototype.hasOwnProperty;var It=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Lt=(t,e)=>{for(var r in e)j(t,r,{get:e[r],enumerable:!0})},Tt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Jt(e))!Zt.call(t,o)&&o!==r&&j(t,o,{get:()=>e[o],enumerable:!(n=Xt(e,o))||n.enumerable});return t};var Dt=(t,e,r)=>(r=t!=null?Kt(Yt(t)):{},Tt(e||!t||!t.__esModule?j(r,"default",{value:t,enumerable:!0}):r,t)),te=t=>Tt(j({},"__esModule",{value:!0}),t);var jt=It(S=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0});S.bech32m=S.bech32=void 0;var it="qpzry9x8gf2tvdw0s3jn54khce6mua7l",Qt={};for(let t=0;t<it.length;t++){let e=it.charAt(t);Qt[e]=t}function E(t){let e=t>>25;return(t&33554431)<<5^-(e>>0&1)&996825010^-(e>>1&1)&642813549^-(e>>2&1)&513874426^-(e>>3&1)&1027748829^-(e>>4&1)&705979059}function zt(t){let e=1;for(let r=0;r<t.length;++r){let n=t.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+t+")";e=E(e)^n>>5}e=E(e);for(let r=0;r<t.length;++r){let n=t.charCodeAt(r);e=E(e)^n&31}return e}function Pt(t,e,r,n){let o=0,i=0,c=(1<<r)-1,s=[];for(let l=0;l<t.length;++l)for(o=o<<e|t[l],i+=e;i>=r;)i-=r,s.push(o>>i&c);if(n)i>0&&s.push(o<<r-i&c);else{if(i>=e)return"Excess padding";if(o<<r-i&c)return"Non-zero padding"}return s}function se(t){return Pt(t,8,5,!0)}function le(t){let e=Pt(t,5,8,!1);if(Array.isArray(e))return e}function ue(t){let e=Pt(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function $t(t){let e;t==="bech32"?e=1:e=734539939;function r(c,s,l){if(l=l||90,c.length+7+s.length>l)throw new TypeError("Exceeds length limit");c=c.toLowerCase();let _=zt(c);if(typeof _=="string")throw new Error(_);let d=c+"1";for(let a=0;a<s.length;++a){let u=s[a];if(u>>5!==0)throw new Error("Non 5-bit word");_=E(_)^u,d+=it.charAt(u)}for(let a=0;a<6;++a)_=E(_);_^=e;for(let a=0;a<6;++a){let u=_>>(5-a)*5&31;d+=it.charAt(u)}return d}function n(c,s){if(s=s||90,c.length<8)return c+" too short";if(c.length>s)return"Exceeds length limit";let l=c.toLowerCase(),_=c.toUpperCase();if(c!==l&&c!==_)return"Mixed-case string "+c;c=l;let d=c.lastIndexOf("1");if(d===-1)return"No separator character for "+c;if(d===0)return"Missing prefix for "+c;let a=c.slice(0,d),u=c.slice(d+1);if(u.length<6)return"Data too short";let p=zt(a);if(typeof p=="string")return p;let f=[];for(let x=0;x<u.length;++x){let m=u.charAt(x),b=Qt[m];if(b===void 0)return"Unknown character "+m;p=E(p)^b,!(x+6>=u.length)&&f.push(b)}return p!==e?"Invalid checksum for "+c:{prefix:a,words:f}}function o(c,s){let l=n(c,s);if(typeof l=="object")return l}function i(c,s){let l=n(c,s);if(typeof l=="object")return l;throw new Error(l)}return{decodeUnsafe:o,decode:i,encode:r,toWords:se,fromWordsUnsafe:le,fromWords:ue}}S.bech32=$t("bech32");S.bech32m=$t("bech32m")});var Ne={};Lt(Ne,{BitcoinCanister:()=>K,BtcAddressType:()=>yt,BtcNetwork:()=>gt,CkBTCMinterCanister:()=>rt,MinterAlreadyProcessingError:()=>Y,MinterAmountTooLowError:()=>L,MinterGenericError:()=>k,MinterInsufficientAllowanceError:()=>tt,MinterInsufficientFundsError:()=>D,MinterMalformedAddressError:()=>I,MinterNoNewUtxosError:()=>Z,MinterRetrieveBtcError:()=>O,MinterTemporaryUnavailableError:()=>J,MinterUpdateBalanceError:()=>z,ParseBtcAddressBadWitnessLengthError:()=>q,ParseBtcAddressError:()=>N,ParseBtcAddressInvalidError:()=>U,ParseBtcAddressMalformedAddressError:()=>B,ParseBtcAddressNoDataError:()=>H,ParseBtcAddressUnexpectedHumanReadablePartError:()=>W,ParseBtcAddressUnsupportedAddressTypeError:()=>T,ParseBtcAddressUnsupportedWitnessVersionError:()=>G,ParseBtcAddressWrongNetworkError:()=>M,createRetrieveBtcError:()=>et,createRetrieveBtcWithApprovalError:()=>kt,createUpdateBalanceError:()=>Rt,parseBtcAddress:()=>me,toGetBalanceParams:()=>Nt,toGetUtxosParams:()=>mt});module.exports=te(Ne);var X=require("@dfinity/utils");var Ft=({IDL:t})=>{let e=t.Variant({disabled:t.Null,enabled:t.Null}),r=t.Record({get_current_fee_percentiles:t.Nat,get_utxos_maximum:t.Nat,get_block_headers_cycles_per_ten_instructions:t.Nat,get_current_fee_percentiles_maximum:t.Nat,send_transaction_per_byte:t.Nat,get_balance:t.Nat,get_utxos_cycles_per_ten_instructions:t.Nat,get_block_headers_base:t.Nat,get_utxos_base:t.Nat,get_balance_maximum:t.Nat,send_transaction_base:t.Nat,get_block_headers_maximum:t.Nat}),n=t.Variant({mainnet:t.Null,regtest:t.Null,testnet:t.Null}),o=t.Record({api_access:t.Opt(e),lazily_evaluate_fee_percentiles:t.Opt(e),blocks_source:t.Opt(t.Principal),fees:t.Opt(r),watchdog_canister:t.Opt(t.Opt(t.Principal)),network:t.Opt(n),stability_threshold:t.Opt(t.Nat),syncing:t.Opt(e),burn_cycles:t.Opt(e),disable_api_if_not_fully_synced:t.Opt(e)}),i=t.Text,c=t.Record({network:n,address:i,min_confirmations:t.Opt(t.Nat32)}),s=t.Nat64,l=t.Nat32,_=t.Record({start_height:l,end_height:t.Opt(l),network:n}),d=t.Vec(t.Nat8),a=t.Record({tip_height:l,block_headers:t.Vec(d)}),u=t.Record({network:n}),p=t.Nat64,f=t.Record({network:n,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:i}),x=t.Vec(t.Nat8),m=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),b=t.Record({height:l,value:s,outpoint:m}),y=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:l,tip_block_hash:x,utxos:t.Vec(b)}),V=t.Record({transaction:t.Vec(t.Nat8),network:n}),w=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}),A=t.Record({api_access:t.Opt(e),lazily_evaluate_fee_percentiles:t.Opt(e),fees:t.Opt(r),watchdog_canister:t.Opt(t.Opt(t.Principal)),stability_threshold:t.Opt(t.Nat),syncing:t.Opt(e),burn_cycles:t.Opt(e),disable_api_if_not_fully_synced:t.Opt(e)});return t.Service({bitcoin_get_balance:t.Func([c],[s],[]),bitcoin_get_balance_query:t.Func([c],[s],[]),bitcoin_get_block_headers:t.Func([_],[a],[]),bitcoin_get_current_fee_percentiles:t.Func([u],[t.Vec(p)],[]),bitcoin_get_utxos:t.Func([f],[y],[]),bitcoin_get_utxos_query:t.Func([f],[y],[]),bitcoin_send_transaction:t.Func([V],[],[]),get_config:t.Func([],[w],[]),set_config:t.Func([A],[],[])})};var Et=({IDL:t})=>{let e=t.Variant({disabled:t.Null,enabled:t.Null}),r=t.Record({get_current_fee_percentiles:t.Nat,get_utxos_maximum:t.Nat,get_block_headers_cycles_per_ten_instructions:t.Nat,get_current_fee_percentiles_maximum:t.Nat,send_transaction_per_byte:t.Nat,get_balance:t.Nat,get_utxos_cycles_per_ten_instructions:t.Nat,get_block_headers_base:t.Nat,get_utxos_base:t.Nat,get_balance_maximum:t.Nat,send_transaction_base:t.Nat,get_block_headers_maximum:t.Nat}),n=t.Variant({mainnet:t.Null,regtest:t.Null,testnet:t.Null}),o=t.Record({api_access:t.Opt(e),lazily_evaluate_fee_percentiles:t.Opt(e),blocks_source:t.Opt(t.Principal),fees:t.Opt(r),watchdog_canister:t.Opt(t.Opt(t.Principal)),network:t.Opt(n),stability_threshold:t.Opt(t.Nat),syncing:t.Opt(e),burn_cycles:t.Opt(e),disable_api_if_not_fully_synced:t.Opt(e)}),i=t.Text,c=t.Record({network:n,address:i,min_confirmations:t.Opt(t.Nat32)}),s=t.Nat64,l=t.Nat32,_=t.Record({start_height:l,end_height:t.Opt(l),network:n}),d=t.Vec(t.Nat8),a=t.Record({tip_height:l,block_headers:t.Vec(d)}),u=t.Record({network:n}),p=t.Nat64,f=t.Record({network:n,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:i}),x=t.Vec(t.Nat8),m=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),b=t.Record({height:l,value:s,outpoint:m}),y=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:l,tip_block_hash:x,utxos:t.Vec(b)}),V=t.Record({transaction:t.Vec(t.Nat8),network:n}),w=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}),A=t.Record({api_access:t.Opt(e),lazily_evaluate_fee_percentiles:t.Opt(e),fees:t.Opt(r),watchdog_canister:t.Opt(t.Opt(t.Principal)),stability_threshold:t.Opt(t.Nat),syncing:t.Opt(e),burn_cycles:t.Opt(e),disable_api_if_not_fully_synced:t.Opt(e)});return t.Service({bitcoin_get_balance:t.Func([c],[s],[]),bitcoin_get_balance_query:t.Func([c],[s],["query"]),bitcoin_get_block_headers:t.Func([_],[a],[]),bitcoin_get_current_fee_percentiles:t.Func([u],[t.Vec(p)],[]),bitcoin_get_utxos:t.Func([f],[y],[]),bitcoin_get_utxos_query:t.Func([f],[y],["query"]),bitcoin_send_transaction:t.Func([V],[],[]),get_config:t.Func([],[w],["query"]),set_config:t.Func([A],[],[])})};var P=require("@dfinity/utils"),ee={mainnet:{mainnet:null},testnet:{testnet:null},regtest:{regtest:null}},mt=({network:t,filter:e,...r})=>({filter:(0,P.nonNullish)(e)?(0,P.toNullable)("minConfirmations"in e?{min_confirmations:e.minConfirmations}:{page:e.page}):(0,P.toNullable)(),network:t==="testnet"?{testnet:null}:{mainnet:null},...r}),Nt=({network:t,minConfirmations:e,...r})=>({min_confirmations:(0,P.toNullable)(e),network:ee[t],...r});var K=class t extends X.Canister{static create(e){let{service:r,certifiedService:n,canisterId:o}=(0,X.createServices)({options:e,idlFactory:Et,certifiedIdlFactory:Ft});return new t(o,r,n)}getUtxosQuery=({...e})=>{let{bitcoin_get_utxos_query:r}=this.caller({certified:!1});return r(mt(e))};getBalanceQuery=({...e})=>{let{bitcoin_get_balance_query:r}=this.caller({certified:!1});return r(Nt(e))}};var gt=(n=>(n[n.Mainnet=0]="Mainnet",n[n.Regtest=1]="Regtest",n[n.Testnet=2]="Testnet",n))(gt||{}),yt=(i=>(i[i.P2wpkhV0=0]="P2wpkhV0",i[i.P2pkh=1]="P2pkh",i[i.P2sh=2]="P2sh",i[i.P2wsh=3]="P2wsh",i[i.P2tr=4]="P2tr",i))(yt||{});var N=class extends Error{},U=class extends N{},H=class extends N{},T=class extends N{},q=class extends N{},G=class extends N{},W=class extends N{},B=class extends N{},M=class extends N{};var F=require("@dfinity/utils"),k=class extends Error{},J=class extends k{},Y=class extends k{},z=class extends k{},Z=class extends z{pendingUtxos;requiredConfirmations;constructor({pending_utxos:e,required_confirmations:r}){super(),this.pendingUtxos=(0,F.fromNullable)(e)??[],this.requiredConfirmations=r}},O=class extends k{},I=class extends O{},L=class extends O{},D=class extends O{},tt=class extends O{},wt=t=>{if("GenericError"in t){let{GenericError:{error_message:e,error_code:r}}=t;return new k(`${e} (${r})`)}if("TemporarilyUnavailable"in t)return new J(t.TemporarilyUnavailable);if("AlreadyProcessing"in t)return new Y},Rt=t=>{let e=wt(t);return(0,F.nonNullish)(e)?e:"NoNewUtxos"in t?new Z(t.NoNewUtxos):new z(`Unsupported response type in minter.updateBalance ${JSON.stringify(t)}`)},et=t=>{let e=wt(t);return(0,F.nonNullish)(e)?e:"MalformedAddress"in t?new I(t.MalformedAddress):"AmountTooLow"in t?new L(`${t.AmountTooLow}`):"InsufficientFunds"in t?new D(`${t.InsufficientFunds.balance}`):new O(`Unsupported response type in minter.retrieveBtc ${JSON.stringify(t)}`)},kt=t=>{let e=wt(t);return(0,F.nonNullish)(e)?e:"InsufficientAllowance"in t?new tt(`${t.InsufficientAllowance.allowance}`):et(t)};var h=require("@dfinity/utils");var St=({IDL:t})=>{let e=t.Variant({RestrictedTo:t.Vec(t.Principal),DepositsRestrictedTo:t.Vec(t.Principal),ReadOnly:t.Null,GeneralAvailability:t.Null}),r=t.Record({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)}),i=t.Variant({Upgrade:t.Opt(r),Init:o}),c=t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),s=t.Variant({controllers:t.Null,public:t.Null,allowed_viewers:t.Vec(t.Principal)}),l=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,log_visibility:s,wasm_memory_limit:t.Nat,memory_allocation:t.Nat,compute_allocation:t.Nat}),_=t.Record({response_payload_bytes_total:t.Nat,num_instructions_total:t.Nat,num_calls_total:t.Nat,request_payload_bytes_total:t.Nat}),d=t.Record({status:c,memory_size:t.Nat,cycles:t.Nat,settings:l,query_stats:_,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8)),reserved_cycles:t.Nat}),a=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),u=t.Record({height:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),p=t.Variant({CallFailed:t.Null,TaintedDestination:t.Record({kyt_fee:t.Nat64,kyt_provider:t.Principal})}),f=t.Variant({ValueTooSmall:t.Null,Quarantined:t.Null}),x=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)}),m=t.Variant({received_utxos:t.Record({to_account:a,mint_txid:t.Opt(t.Nat64),utxos:t.Vec(u)}),schedule_deposit_reimbursement:t.Record({burn_block_index:t.Nat64,account:a,amount:t.Nat64,reason:p}),sent_transaction:t.Record({fee:t.Opt(t.Nat64),change_output:t.Opt(t.Record({value:t.Nat64,vout:t.Nat32})),txid:t.Vec(t.Nat8),utxos:t.Vec(u),requests:t.Vec(t.Nat64),submitted_at:t.Nat64}),distributed_kyt_fee:t.Record({block_index:t.Nat64,amount:t.Nat64,kyt_provider:t.Principal}),init:o,upgrade:r,retrieve_btc_kyt_failed:t.Record({block_index:t.Nat64,owner:t.Principal,uuid:t.Text,address:t.Text,amount:t.Nat64,kyt_provider:t.Principal}),suspended_utxo:t.Record({utxo:u,account:a,reason:f}),accepted_retrieve_btc_request:t.Record({received_at:t.Nat64,block_index:t.Nat64,address:x,reimbursement_account:t.Opt(a),amount:t.Nat64,kyt_provider:t.Opt(t.Principal)}),checked_utxo:t.Record({clean:t.Bool,utxo:u,uuid:t.Text,kyt_provider:t.Opt(t.Principal)}),removed_retrieve_btc_request:t.Record({block_index:t.Nat64}),confirmed_transaction:t.Record({txid:t.Vec(t.Nat8)}),replaced_transaction:t.Record({fee:t.Nat64,change_output:t.Record({value:t.Nat64,vout:t.Nat32}),old_txid:t.Vec(t.Nat8),new_txid:t.Vec(t.Nat8),submitted_at:t.Nat64}),checked_utxo_v2:t.Record({utxo:u,account:a}),ignored_utxo:t.Record({utxo:u}),checked_utxo_mint_unknown:t.Record({utxo:u,account:a}),reimbursed_failed_deposit:t.Record({burn_block_index:t.Nat64,mint_block_index:t.Nat64})}),b=t.Record({timestamp:t.Opt(t.Nat64),payload:m}),y=t.Record({retrieve_btc_min_amount:t.Nat64,min_confirmations:t.Nat32,kyt_fee:t.Nat64}),V=t.Record({address:t.Text,amount:t.Nat64}),w=t.Record({block_index:t.Nat64}),A=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})}),st=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}),lt=t.Record({account:a,amount:t.Nat64,reason:p}),ut=t.Record({account:a,mint_block_index:t.Nat64,amount:t.Nat64,reason:p}),C=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:lt,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Reimbursed:ut,Pending:t.Null}),dt=t.Record({from_subaccount:t.Opt(t.Vec(t.Nat8)),address:t.Text,amount:t.Nat64}),_t=t.Variant({MalformedAddress:t.Text,GenericError:t.Record({error_message:t.Text,error_code:t.Nat64}),TemporarilyUnavailable:t.Text,InsufficientAllowance:t.Record({allowance:t.Nat64}),AlreadyProcessing:t.Null,AmountTooLow:t.Nat64,InsufficientFunds:t.Record({balance:t.Nat64})}),pt=t.Variant({ValueTooSmall:u,Tainted:u,Minted:t.Record({minted_amount:t.Nat64,block_index:t.Nat64,utxo:u}),Checked:u}),ft=t.Nat64,xt=t.Record({utxo:u,earliest_retry:ft,reason:f}),ht=t.Record({confirmations:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),bt=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(xt)),required_confirmations:t.Nat32,pending_utxos:t.Opt(t.Vec(ht)),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([],[d],[]),get_deposit_fee:t.Func([],[t.Nat64],[]),get_events:t.Func([t.Record({start:t.Nat64,length:t.Nat64})],[t.Vec(b)],[]),get_known_utxos:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Vec(u)],[]),get_minter_info:t.Func([],[y],[]),get_withdrawal_account:t.Func([],[a],[]),retrieve_btc:t.Func([V],[t.Variant({Ok:w,Err:A})],[]),retrieve_btc_status:t.Func([t.Record({block_index:t.Nat64})],[st],[]),retrieve_btc_status_v2:t.Func([t.Record({block_index:t.Nat64})],[C],[]),retrieve_btc_status_v2_by_account:t.Func([t.Opt(a)],[t.Vec(t.Record({block_index:t.Nat64,status_v2:t.Opt(C)}))],[]),retrieve_btc_with_approval:t.Func([dt],[t.Variant({Ok:w,Err:_t})],[]),update_balance:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Variant({Ok:t.Vec(pt),Err:bt})],[])})};var Ct=({IDL:t})=>{let e=t.Variant({RestrictedTo:t.Vec(t.Principal),DepositsRestrictedTo:t.Vec(t.Principal),ReadOnly:t.Null,GeneralAvailability:t.Null}),r=t.Record({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)}),i=t.Variant({Upgrade:t.Opt(r),Init:o}),c=t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),s=t.Variant({controllers:t.Null,public:t.Null,allowed_viewers:t.Vec(t.Principal)}),l=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,log_visibility:s,wasm_memory_limit:t.Nat,memory_allocation:t.Nat,compute_allocation:t.Nat}),_=t.Record({response_payload_bytes_total:t.Nat,num_instructions_total:t.Nat,num_calls_total:t.Nat,request_payload_bytes_total:t.Nat}),d=t.Record({status:c,memory_size:t.Nat,cycles:t.Nat,settings:l,query_stats:_,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8)),reserved_cycles:t.Nat}),a=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),u=t.Record({height:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),p=t.Variant({CallFailed:t.Null,TaintedDestination:t.Record({kyt_fee:t.Nat64,kyt_provider:t.Principal})}),f=t.Variant({ValueTooSmall:t.Null,Quarantined:t.Null}),x=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)}),m=t.Variant({received_utxos:t.Record({to_account:a,mint_txid:t.Opt(t.Nat64),utxos:t.Vec(u)}),schedule_deposit_reimbursement:t.Record({burn_block_index:t.Nat64,account:a,amount:t.Nat64,reason:p}),sent_transaction:t.Record({fee:t.Opt(t.Nat64),change_output:t.Opt(t.Record({value:t.Nat64,vout:t.Nat32})),txid:t.Vec(t.Nat8),utxos:t.Vec(u),requests:t.Vec(t.Nat64),submitted_at:t.Nat64}),distributed_kyt_fee:t.Record({block_index:t.Nat64,amount:t.Nat64,kyt_provider:t.Principal}),init:o,upgrade:r,retrieve_btc_kyt_failed:t.Record({block_index:t.Nat64,owner:t.Principal,uuid:t.Text,address:t.Text,amount:t.Nat64,kyt_provider:t.Principal}),suspended_utxo:t.Record({utxo:u,account:a,reason:f}),accepted_retrieve_btc_request:t.Record({received_at:t.Nat64,block_index:t.Nat64,address:x,reimbursement_account:t.Opt(a),amount:t.Nat64,kyt_provider:t.Opt(t.Principal)}),checked_utxo:t.Record({clean:t.Bool,utxo:u,uuid:t.Text,kyt_provider:t.Opt(t.Principal)}),removed_retrieve_btc_request:t.Record({block_index:t.Nat64}),confirmed_transaction:t.Record({txid:t.Vec(t.Nat8)}),replaced_transaction:t.Record({fee:t.Nat64,change_output:t.Record({value:t.Nat64,vout:t.Nat32}),old_txid:t.Vec(t.Nat8),new_txid:t.Vec(t.Nat8),submitted_at:t.Nat64}),checked_utxo_v2:t.Record({utxo:u,account:a}),ignored_utxo:t.Record({utxo:u}),checked_utxo_mint_unknown:t.Record({utxo:u,account:a}),reimbursed_failed_deposit:t.Record({burn_block_index:t.Nat64,mint_block_index:t.Nat64})}),b=t.Record({timestamp:t.Opt(t.Nat64),payload:m}),y=t.Record({retrieve_btc_min_amount:t.Nat64,min_confirmations:t.Nat32,kyt_fee:t.Nat64}),V=t.Record({address:t.Text,amount:t.Nat64}),w=t.Record({block_index:t.Nat64}),A=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})}),st=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}),lt=t.Record({account:a,amount:t.Nat64,reason:p}),ut=t.Record({account:a,mint_block_index:t.Nat64,amount:t.Nat64,reason:p}),C=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:lt,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Reimbursed:ut,Pending:t.Null}),dt=t.Record({from_subaccount:t.Opt(t.Vec(t.Nat8)),address:t.Text,amount:t.Nat64}),_t=t.Variant({MalformedAddress:t.Text,GenericError:t.Record({error_message:t.Text,error_code:t.Nat64}),TemporarilyUnavailable:t.Text,InsufficientAllowance:t.Record({allowance:t.Nat64}),AlreadyProcessing:t.Null,AmountTooLow:t.Nat64,InsufficientFunds:t.Record({balance:t.Nat64})}),pt=t.Variant({ValueTooSmall:u,Tainted:u,Minted:t.Record({minted_amount:t.Nat64,block_index:t.Nat64,utxo:u}),Checked:u}),ft=t.Nat64,xt=t.Record({utxo:u,earliest_retry:ft,reason:f}),ht=t.Record({confirmations:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),bt=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(xt)),required_confirmations:t.Nat32,pending_utxos:t.Opt(t.Vec(ht)),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([],[d],[]),get_deposit_fee:t.Func([],[t.Nat64],["query"]),get_events:t.Func([t.Record({start:t.Nat64,length:t.Nat64})],[t.Vec(b)],["query"]),get_known_utxos:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Vec(u)],["query"]),get_minter_info:t.Func([],[y],["query"]),get_withdrawal_account:t.Func([],[a],[]),retrieve_btc:t.Func([V],[t.Variant({Ok:w,Err:A})],[]),retrieve_btc_status:t.Func([t.Record({block_index:t.Nat64})],[st],["query"]),retrieve_btc_status_v2:t.Func([t.Record({block_index:t.Nat64})],[C],["query"]),retrieve_btc_status_v2_by_account:t.Func([t.Opt(a)],[t.Vec(t.Record({block_index:t.Nat64,status_v2:t.Opt(C)}))],["query"]),retrieve_btc_with_approval:t.Func([dt],[t.Variant({Ok:w,Err:_t})],[]),update_balance:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Variant({Ok:t.Vec(pt),Err:bt})],[])})};var rt=class t extends h.Canister{static create(e){let{service:r,certifiedService:n,canisterId:o}=(0,h.createServices)({options:e,idlFactory:Ct,certifiedIdlFactory:St});return new t(o,r,n)}getBtcAddress=({owner:e,subaccount:r})=>this.caller({certified:!0}).get_btc_address({owner:(0,h.toNullable)(e),subaccount:(0,h.toNullable)(r)});updateBalance=async({owner:e,subaccount:r})=>{let n=await this.caller({certified:!0}).update_balance({owner:(0,h.toNullable)(e),subaccount:(0,h.toNullable)(r)});if("Err"in n)throw Rt(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 et(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:(0,h.toNullable)(n)});if("Err"in o)throw kt(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((0,h.isNullish)(e)?[]:[{owner:e.owner,subaccount:(0,h.toNullable)(e.subaccount)}])).map(({block_index:i,status_v2:c})=>({id:i,status:(0,h.fromNullable)(c)}))};estimateWithdrawalFee=({certified:e,amount:r})=>this.caller({certified:e}).estimate_withdrawal_fee({amount:(0,h.toNullable)(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:(0,h.toNullable)(e),subaccount:(0,h.toNullable)(r)})}};var Ut=require("@dfinity/utils");function re(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ot(t,...e){if(!re(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 Ot(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Ht(t,e){ot(t);let r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Q(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function ct(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function g(t,e){return t<<32-e|t>>>e}function ne(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function vt(t){return typeof t=="string"&&(t=ne(t)),ot(t),t}var nt=class{};function qt(t){let e=n=>t().update(vt(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function oe(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let o=BigInt(32),i=BigInt(4294967295),c=Number(r>>o&i),s=Number(r&i),l=n?4:0,_=n?0:4;t.setUint32(e+l,c,n),t.setUint32(e+_,s,n)}function Gt(t,e,r){return t&e^~t&r}function Wt(t,e,r){return t&e^t&r^e&r}var at=class extends nt{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=ct(this.buffer)}update(e){Ot(this),e=vt(e),ot(e);let{view:r,buffer:n,blockLen:o}=this,i=e.length;for(let c=0;c<i;){let s=Math.min(o-this.pos,i-c);if(s===o){let l=ct(e);for(;o<=i-c;c+=o)this.process(l,c);continue}n.set(e.subarray(c,c+s),this.pos),this.pos+=s,c+=s,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ot(this),Ht(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:c}=this;r[c++]=128,Q(this.buffer.subarray(c)),this.padOffset>o-c&&(this.process(n,0),c=0);for(let a=c;a<o;a++)r[a]=0;oe(n,o-8,BigInt(this.length*8),i),this.process(n,0);let s=ct(e),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let _=l/4,d=this.get();if(_>d.length)throw new Error("_sha2: outputLen bigger than state");for(let a=0;a<_;a++)s.setUint32(4*a,d[a],i)}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:i,destroyed:c,pos:s}=this;return e.destroyed=c,e.finished=i,e.length=o,e.pos=s,o%r&&e.buffer.set(n),e}clone(){return this._cloneInto()}},R=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var ce=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]),v=new Uint32Array(64),Vt=class extends at{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:i,F:c,G:s,H:l}=this;return[e,r,n,o,i,c,s,l]}set(e,r,n,o,i,c,s,l){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=c|0,this.G=s|0,this.H=l|0}process(e,r){for(let a=0;a<16;a++,r+=4)v[a]=e.getUint32(r,!1);for(let a=16;a<64;a++){let u=v[a-15],p=v[a-2],f=g(u,7)^g(u,18)^u>>>3,x=g(p,17)^g(p,19)^p>>>10;v[a]=x+v[a-7]+f+v[a-16]|0}let{A:n,B:o,C:i,D:c,E:s,F:l,G:_,H:d}=this;for(let a=0;a<64;a++){let u=g(s,6)^g(s,11)^g(s,25),p=d+u+Gt(s,l,_)+ce[a]+v[a]|0,x=(g(n,2)^g(n,13)^g(n,22))+Wt(n,o,i)|0;d=_,_=l,l=s,s=c+p|0,c=i,i=o,o=n,n=p+x|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,c=c+this.D|0,s=s+this.E|0,l=l+this.F|0,_=_+this.G|0,d=d+this.H|0,this.set(n,o,i,c,s,l,_,d)}roundClean(){Q(v)}destroy(){this.set(0,0,0,0,0,0,0,0),Q(this.buffer)}};var At=qt(()=>new Vt);var ae="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Mt=ae;function ie(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=>Mt.indexOf(o)).reduce((o,i)=>(o=o.map(c=>{let s=c*58+i;return i=s>>8,s}),o),new Uint8Array(n)).reverse().filter((o=>i=>o=o||i)(!1))])}var Bt=ie;var $=Dt(jt());var de=0,_e=5,pe=111,fe=196,xe={[de]:{type:1,networks:[0]},[pe]:{type:1,networks:[2,1]},[_e]:{type:2,networks:[0]},[fe]:{type:2,networks:[2,1]}},he=({address:t,network:e})=>{let n=(d=>{try{return Bt(d)}catch{throw new U}})(t),{length:o}=n;if(o!==25)throw new B(`Expected the address to be 25 bytes, got ${o}.`);(d=>{let a=d.slice(o-4,o),u=d.slice(0,o-4),p=At.create();p.update(u);let f=At.create();f.update(p.digest());let x=f.digest().slice(0,4);if(a.some((m,b)=>m!==x[b]))throw new B(`Checksum mismatch expected ${a}, got ${x}.`)})(n);let[c]=n,s=xe[c];if((0,Ut.isNullish)(s))throw new T;let{type:l,networks:_}=s;if(!_.includes(e))throw new M;return{address:t,network:e,type:l,parser:"base58"}},be=({address:t,network:e})=>{let r=d=>{try{return d.startsWith("bc1p")||d.startsWith("tb1p")||d.startsWith("bcrt1p")?$.bech32m.decode(d):$.bech32.decode(d)}catch{throw new B}},{prefix:n,words:o}=r(t),c={bc:0,tb:2,bcrt:1}[n];if((0,Ut.isNullish)(c))throw new U;if(c!==e)throw new W;let[s,...l]=o;if(s>1)throw new G;switch($.bech32.fromWords(l).length){case 20:return{address:t,network:e,type:0,parser:"bip-173"};case 32:return{address:t,network:e,type:s===0?3:4,parser:"bip-173"};default:throw new q}},me=({address:t,network:e=0})=>{switch(t.charAt(0)){case"1":case"2":case"3":case"m":case"n":return he({address:t,network:e});case"b":case"B":case"t":case"T":return be({address:t,network:e});case"":throw new H;default:throw new T}};0&&(module.exports={BitcoinCanister,BtcAddressType,BtcNetwork,CkBTCMinterCanister,MinterAlreadyProcessingError,MinterAmountTooLowError,MinterGenericError,MinterInsufficientAllowanceError,MinterInsufficientFundsError,MinterMalformedAddressError,MinterNoNewUtxosError,MinterRetrieveBtcError,MinterTemporaryUnavailableError,MinterUpdateBalanceError,ParseBtcAddressBadWitnessLengthError,ParseBtcAddressError,ParseBtcAddressInvalidError,ParseBtcAddressMalformedAddressError,ParseBtcAddressNoDataError,ParseBtcAddressUnexpectedHumanReadablePartError,ParseBtcAddressUnsupportedAddressTypeError,ParseBtcAddressUnsupportedWitnessVersionError,ParseBtcAddressWrongNetworkError,createRetrieveBtcError,createRetrieveBtcWithApprovalError,createUpdateBalanceError,parseBtcAddress,toGetBalanceParams,toGetUtxosParams});
|
|
2
2
|
/*! Bundled license information:
|
|
3
3
|
|
|
4
4
|
@noble/hashes/esm/utils.js:
|