Socket
Socket
Sign inDemoInstall

@dfinity/ckbtc

Package Overview
Dependencies
Maintainers
0
Versions
626
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dfinity/ckbtc - npm Package Compare versions

Comparing version 2.5.0 to 3.0.0

dist/esm/chunk-WUAXPVZB.js

2

dist/cjs/index.cjs.js

@@ -1,2 +0,2 @@

"use strict";var Lt=Object.create;var j=Object.defineProperty;var Dt=Object.getOwnPropertyDescriptor;var te=Object.getOwnPropertyNames;var ee=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var B=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ne=(t,e)=>{for(var r in e)j(t,r,{get:e[r],enumerable:!0})},Ot=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of te(e))!re.call(t,o)&&o!==r&&j(t,o,{get:()=>e[o],enumerable:!(n=Dt(e,o))||n.enumerable});return t};var Vt=(t,e,r)=>(r=t!=null?Lt(ee(t)):{},Ot(e||!t||!t.__esModule?j(r,"default",{value:t,enumerable:!0}):r,t)),oe=t=>Ot(j({},"__esModule",{value:!0}),t);var ct=B((rr,qt)=>{"use strict";var ue="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";qt.exports=ue});var Wt=B((nr,Mt)=>{"use strict";var le=ct(),_e=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=>le.indexOf(o)).reduce((o,a)=>(o=o.map(c=>{let s=c*58+a;return a=s>>8,s}),o),new Uint8Array(n)).reverse().filter((o=>a=>o=o||a)(!1))])};Mt.exports=_e});var Ht=B((or,zt)=>{"use strict";var Gt=ct(),de=()=>{let t=Array(256).fill(-1);for(let e=0;e<Gt.length;++e)t[Gt.charCodeAt(e)]=e;return t};zt.exports=de});var Qt=B((cr,jt)=>{"use strict";var $t=ct(),pe=Ht(),fe=pe(),me=t=>{let e=[];for(let r of t){let n=r;for(let o=0;o<e.length;++o){let a=(fe[e[o]]<<8)+n;e[o]=$t.charCodeAt(a%58),n=a/58|0}for(;n;)e.push($t.charCodeAt(n%58)),n=n/58|0}for(let r of t){if(r)break;e.push(49)}return e.reverse(),String.fromCharCode(...e)};jt.exports=me});var Xt=B(Rt=>{"use strict";Rt.base58_to_binary=Wt();Rt.binary_to_base58=Qt()});var Zt=B(E=>{"use strict";Object.defineProperty(E,"__esModule",{value:!0});E.bech32m=E.bech32=void 0;var at="qpzry9x8gf2tvdw0s3jn54khce6mua7l",Jt={};for(let t=0;t<at.length;t++){let e=at.charAt(t);Jt[e]=t}function C(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 Kt(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=C(e)^n>>5}e=C(e);for(let r=0;r<t.length;++r){let n=t.charCodeAt(r);e=C(e)^n&31}return e}function kt(t,e,r,n){let o=0,a=0,c=(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&c);if(n)a>0&&s.push(o<<r-a&c);else{if(a>=e)return"Excess padding";if(o<<r-a&c)return"Non-zero padding"}return s}function xe(t){return kt(t,8,5,!0)}function he(t){let e=kt(t,5,8,!1);if(Array.isArray(e))return e}function be(t){let e=kt(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function Yt(t){let e;t==="bech32"?e=1:e=734539939;function r(c,s,u){if(u=u||90,c.length+7+s.length>u)throw new TypeError("Exceeds length limit");c=c.toLowerCase();let _=Kt(c);if(typeof _=="string")throw new Error(_);let l=c+"1";for(let i=0;i<s.length;++i){let d=s[i];if(d>>5)throw new Error("Non 5-bit word");_=C(_)^d,l+=at.charAt(d)}for(let i=0;i<6;++i)_=C(_);_^=e;for(let i=0;i<6;++i){let d=_>>(5-i)*5&31;l+=at.charAt(d)}return l}function n(c,s){if(s=s||90,c.length<8)return c+" too short";if(c.length>s)return"Exceeds length limit";let u=c.toLowerCase(),_=c.toUpperCase();if(c!==u&&c!==_)return"Mixed-case string "+c;c=u;let l=c.lastIndexOf("1");if(l===-1)return"No separator character for "+c;if(l===0)return"Missing prefix for "+c;let i=c.slice(0,l),d=c.slice(l+1);if(d.length<6)return"Data too short";let p=Kt(i);if(typeof p=="string")return p;let m=[];for(let f=0;f<d.length;++f){let b=d.charAt(f),h=Jt[b];if(h===void 0)return"Unknown character "+b;p=C(p)^h,!(f+6>=d.length)&&m.push(h)}return p!==e?"Invalid checksum for "+c:{prefix:i,words:m}}function o(c,s){let u=n(c,s);if(typeof u=="object")return u}function a(c,s){let u=n(c,s);if(typeof u=="object")return u;throw new Error(u)}return{decodeUnsafe:o,decode:a,encode:r,toWords:xe,fromWordsUnsafe:he,fromWords:be}}E.bech32=Yt("bech32");E.bech32m=Yt("bech32m")});var Ve={};ne(Ve,{BitcoinCanister:()=>Q,BtcAddressType:()=>ft,BtcNetwork:()=>pt,CkBTCMinterCanister:()=>et,MinterAlreadyProcessingError:()=>J,MinterAmountTooLowError:()=>I,MinterGenericError:()=>w,MinterInsufficientAllowanceError:()=>D,MinterInsufficientFundsError:()=>L,MinterMalformedAddressError:()=>Z,MinterNoNewUtxosError:()=>Y,MinterRetrieveBtcError:()=>R,MinterTemporaryUnavailableError:()=>K,MinterUpdateBalanceError:()=>H,ParseBtcAddressBadWitnessLengthError:()=>M,ParseBtcAddressError:()=>N,ParseBtcAddressInvalidError:()=>T,ParseBtcAddressMalformedAddressError:()=>P,ParseBtcAddressNoDataError:()=>q,ParseBtcAddressUnexpectedHumanReadablePartError:()=>G,ParseBtcAddressUnsupportedAddressTypeError:()=>U,ParseBtcAddressUnsupportedWitnessVersionError:()=>W,ParseBtcAddressWrongNetworkError:()=>z,createRetrieveBtcError:()=>tt,createRetrieveBtcWithApprovalError:()=>ht,createUpdateBalanceError:()=>xt,parseBtcAddress:()=>Oe,toGetUtxosParams:()=>dt});module.exports=oe(Ve);var X=require("@dfinity/utils");var At=({IDL:t})=>{let e=t.Variant({disabled:t.Null,enabled:t.Null}),r=t.Record({get_current_fee_percentiles:t.Nat,get_utxos_maximum:t.Nat,get_block_headers_cycles_per_ten_instructions:t.Nat,get_current_fee_percentiles_maximum:t.Nat,send_transaction_per_byte:t.Nat,get_balance:t.Nat,get_utxos_cycles_per_ten_instructions:t.Nat,get_block_headers_base:t.Nat,get_utxos_base:t.Nat,get_balance_maximum:t.Nat,send_transaction_base:t.Nat,get_block_headers_maximum:t.Nat}),n=t.Variant({mainnet:t.Null,regtest:t.Null,testnet:t.Null}),o=t.Record({api_access:t.Opt(e),lazily_evaluate_fee_percentiles:t.Opt(e),blocks_source:t.Opt(t.Principal),fees:t.Opt(r),watchdog_canister:t.Opt(t.Opt(t.Principal)),network:t.Opt(n),stability_threshold:t.Opt(t.Nat),syncing:t.Opt(e),burn_cycles:t.Opt(e),disable_api_if_not_fully_synced:t.Opt(e)}),a=t.Text,c=t.Record({network:n,address:a,min_confirmations:t.Opt(t.Nat32)}),s=t.Nat64,u=t.Nat32,_=t.Record({start_height:u,end_height:t.Opt(u),network:n}),l=t.Vec(t.Nat8),i=t.Record({tip_height:u,block_headers:t.Vec(l)}),d=t.Record({network:n}),p=t.Nat64,m=t.Record({network:n,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:a}),f=t.Vec(t.Nat8),b=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),h=t.Record({height:u,value:s,outpoint:b}),y=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:u,tip_block_hash:f,utxos:t.Vec(h)}),O=t.Record({transaction:t.Vec(t.Nat8),network:n}),V=t.Record({api_access:e,lazily_evaluate_fee_percentiles:e,blocks_source:t.Principal,fees:r,watchdog_canister:t.Opt(t.Principal),network:n,stability_threshold:t.Nat,syncing:e,burn_cycles:e,disable_api_if_not_fully_synced:e}),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([_],[i],[]),bitcoin_get_current_fee_percentiles:t.Func([d],[t.Vec(p)],[]),bitcoin_get_utxos:t.Func([m],[y],[]),bitcoin_get_utxos_query:t.Func([m],[y],[]),bitcoin_send_transaction:t.Func([O],[],[]),get_config:t.Func([],[V],[]),set_config:t.Func([A],[],[])})};var Pt=({IDL:t})=>{let e=t.Variant({disabled:t.Null,enabled:t.Null}),r=t.Record({get_current_fee_percentiles:t.Nat,get_utxos_maximum:t.Nat,get_block_headers_cycles_per_ten_instructions:t.Nat,get_current_fee_percentiles_maximum:t.Nat,send_transaction_per_byte:t.Nat,get_balance:t.Nat,get_utxos_cycles_per_ten_instructions:t.Nat,get_block_headers_base:t.Nat,get_utxos_base:t.Nat,get_balance_maximum:t.Nat,send_transaction_base:t.Nat,get_block_headers_maximum:t.Nat}),n=t.Variant({mainnet:t.Null,regtest:t.Null,testnet:t.Null}),o=t.Record({api_access:t.Opt(e),lazily_evaluate_fee_percentiles:t.Opt(e),blocks_source:t.Opt(t.Principal),fees:t.Opt(r),watchdog_canister:t.Opt(t.Opt(t.Principal)),network:t.Opt(n),stability_threshold:t.Opt(t.Nat),syncing:t.Opt(e),burn_cycles:t.Opt(e),disable_api_if_not_fully_synced:t.Opt(e)}),a=t.Text,c=t.Record({network:n,address:a,min_confirmations:t.Opt(t.Nat32)}),s=t.Nat64,u=t.Nat32,_=t.Record({start_height:u,end_height:t.Opt(u),network:n}),l=t.Vec(t.Nat8),i=t.Record({tip_height:u,block_headers:t.Vec(l)}),d=t.Record({network:n}),p=t.Nat64,m=t.Record({network:n,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:a}),f=t.Vec(t.Nat8),b=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),h=t.Record({height:u,value:s,outpoint:b}),y=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:u,tip_block_hash:f,utxos:t.Vec(h)}),O=t.Record({transaction:t.Vec(t.Nat8),network:n}),V=t.Record({api_access:e,lazily_evaluate_fee_percentiles:e,blocks_source:t.Principal,fees:r,watchdog_canister:t.Opt(t.Principal),network:n,stability_threshold:t.Nat,syncing:e,burn_cycles:e,disable_api_if_not_fully_synced:e}),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([_],[i],[]),bitcoin_get_current_fee_percentiles:t.Func([d],[t.Vec(p)],[]),bitcoin_get_utxos:t.Func([m],[y],[]),bitcoin_get_utxos_query:t.Func([m],[y],["query"]),bitcoin_send_transaction:t.Func([O],[],[]),get_config:t.Func([],[V],["query"]),set_config:t.Func([A],[],[])})};var Bt=require("@dfinity/utils"),dt=({network:t,filter:e,...r})=>({filter:(0,Bt.toNullable)(e),network:t==="testnet"?{testnet:null}:{mainnet:null},...r});var Q=class t extends X.Canister{constructor(){super(...arguments);this.getUtxos=({certified:r=!0,...n})=>{let{bitcoin_get_utxos:o,bitcoin_get_utxos_query:a}=this.caller({certified:r});return(r?o:a)(dt(n))}}static create(r){let{service:n,certifiedService:o,canisterId:a}=(0,X.createServices)({options:r,idlFactory:Pt,certifiedIdlFactory:At});return new t(a,n,o)}};var pt=(n=>(n[n.Mainnet=0]="Mainnet",n[n.Regtest=1]="Regtest",n[n.Testnet=2]="Testnet",n))(pt||{}),ft=(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))(ft||{});var N=class extends Error{},T=class extends N{},q=class extends N{},U=class extends N{},M=class extends N{},W=class extends N{},G=class extends N{},P=class extends N{},z=class extends N{};var F=require("@dfinity/utils"),w=class extends Error{},K=class extends w{},J=class extends w{},H=class extends w{},Y=class extends H{constructor({pending_utxos:e,required_confirmations:r}){super(),this.pendingUtxos=(0,F.fromNullable)(e)||[],this.requiredConfirmations=r}},R=class extends w{},Z=class extends R{},I=class extends R{},L=class extends R{},D=class extends R{},mt=t=>{if("GenericError"in t){let{GenericError:{error_message:e,error_code:r}}=t;return new w(`${e} (${r})`)}if("TemporarilyUnavailable"in t)return new K(t.TemporarilyUnavailable);if("AlreadyProcessing"in t)return new J},xt=t=>{let e=mt(t);return(0,F.nonNullish)(e)?e:"NoNewUtxos"in t?new Y(t.NoNewUtxos):new H(`Unsupported response type in minter.updateBalance ${JSON.stringify(t)}`)},tt=t=>{let e=mt(t);return(0,F.nonNullish)(e)?e:"MalformedAddress"in t?new Z(t.MalformedAddress):"AmountTooLow"in t?new I(`${t.AmountTooLow}`):"InsufficientFunds"in t?new L(`${t.InsufficientFunds.balance}`):new R(`Unsupported response type in minter.retrieveBtc ${JSON.stringify(t)}`)},ht=t=>{let e=mt(t);return(0,F.nonNullish)(e)?e:"InsufficientAllowance"in t?new D(`${t.InsufficientAllowance.allowance}`):tt(t)};var x=require("@dfinity/utils");var Tt=({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}),c=t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),s=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,memory_allocation:t.Nat,compute_allocation:t.Nat}),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}),_=t.Record({status:c,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)),reserved_cycles:t.Nat}),l=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),i=t.Record({height:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),d=t.Variant({CallFailed:t.Null,TaintedDestination:t.Record({kyt_fee:t.Nat64,kyt_provider:t.Principal})}),p=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:l,mint_txid:t.Opt(t.Nat64),utxos:t.Vec(i)}),schedule_deposit_reimbursement:t.Record({burn_block_index:t.Nat64,account:l,amount:t.Nat64,reason:d}),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(i),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:p,reimbursement_account:t.Opt(l),amount:t.Nat64,kyt_provider:t.Opt(t.Principal)}),checked_utxo:t.Record({clean:t.Bool,utxo:i,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:i}),reimbursed_failed_deposit:t.Record({burn_block_index:t.Nat64,mint_block_index:t.Nat64})}),f=t.Record({retrieve_btc_min_amount:t.Nat64,min_confirmations:t.Nat32,kyt_fee:t.Nat64}),b=t.Record({address:t.Text,amount:t.Nat64}),h=t.Record({block_index:t.Nat64}),y=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})}),O=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}),V=t.Record({account:l,amount:t.Nat64,reason:d}),A=t.Record({account:l,mint_block_index:t.Nat64,amount:t.Nat64,reason:d}),S=t.Variant({Signing:t.Null,Confirmed:t.Record({txid:t.Vec(t.Nat8)}),Sending:t.Record({txid:t.Vec(t.Nat8)}),AmountTooLow:t.Null,WillReimburse:V,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Reimbursed:A,Pending:t.Null}),it=t.Record({from_subaccount:t.Opt(t.Vec(t.Nat8)),address:t.Text,amount:t.Nat64}),st=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})}),ut=t.Variant({ValueTooSmall:i,Tainted:i,Minted:t.Record({minted_amount:t.Nat64,block_index:t.Nat64,utxo:i}),Checked:i}),lt=t.Record({confirmations:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),_t=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(lt)),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(m)],[]),get_known_utxos:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Vec(i)],[]),get_minter_info:t.Func([],[f],[]),get_withdrawal_account:t.Func([],[l],[]),retrieve_btc:t.Func([b],[t.Variant({Ok:h,Err:y})],[]),retrieve_btc_status:t.Func([t.Record({block_index:t.Nat64})],[O],[]),retrieve_btc_status_v2:t.Func([t.Record({block_index:t.Nat64})],[S],[]),retrieve_btc_status_v2_by_account:t.Func([t.Opt(l)],[t.Vec(t.Record({block_index:t.Nat64,status_v2:t.Opt(S)}))],[]),retrieve_btc_with_approval:t.Func([it],[t.Variant({Ok:h,Err:st})],[]),update_balance:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Variant({Ok:t.Vec(ut),Err:_t})],[])})};var Ut=({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}),c=t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),s=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,memory_allocation:t.Nat,compute_allocation:t.Nat}),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}),_=t.Record({status:c,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)),reserved_cycles:t.Nat}),l=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),i=t.Record({height:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),d=t.Variant({CallFailed:t.Null,TaintedDestination:t.Record({kyt_fee:t.Nat64,kyt_provider:t.Principal})}),p=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:l,mint_txid:t.Opt(t.Nat64),utxos:t.Vec(i)}),schedule_deposit_reimbursement:t.Record({burn_block_index:t.Nat64,account:l,amount:t.Nat64,reason:d}),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(i),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:p,reimbursement_account:t.Opt(l),amount:t.Nat64,kyt_provider:t.Opt(t.Principal)}),checked_utxo:t.Record({clean:t.Bool,utxo:i,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:i}),reimbursed_failed_deposit:t.Record({burn_block_index:t.Nat64,mint_block_index:t.Nat64})}),f=t.Record({retrieve_btc_min_amount:t.Nat64,min_confirmations:t.Nat32,kyt_fee:t.Nat64}),b=t.Record({address:t.Text,amount:t.Nat64}),h=t.Record({block_index:t.Nat64}),y=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})}),O=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}),V=t.Record({account:l,amount:t.Nat64,reason:d}),A=t.Record({account:l,mint_block_index:t.Nat64,amount:t.Nat64,reason:d}),S=t.Variant({Signing:t.Null,Confirmed:t.Record({txid:t.Vec(t.Nat8)}),Sending:t.Record({txid:t.Vec(t.Nat8)}),AmountTooLow:t.Null,WillReimburse:V,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Reimbursed:A,Pending:t.Null}),it=t.Record({from_subaccount:t.Opt(t.Vec(t.Nat8)),address:t.Text,amount:t.Nat64}),st=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})}),ut=t.Variant({ValueTooSmall:i,Tainted:i,Minted:t.Record({minted_amount:t.Nat64,block_index:t.Nat64,utxo:i}),Checked:i}),lt=t.Record({confirmations:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),_t=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(lt)),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(m)],["query"]),get_known_utxos:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Vec(i)],["query"]),get_minter_info:t.Func([],[f],["query"]),get_withdrawal_account:t.Func([],[l],[]),retrieve_btc:t.Func([b],[t.Variant({Ok:h,Err:y})],[]),retrieve_btc_status:t.Func([t.Record({block_index:t.Nat64})],[O],["query"]),retrieve_btc_status_v2:t.Func([t.Record({block_index:t.Nat64})],[S],["query"]),retrieve_btc_status_v2_by_account:t.Func([t.Opt(l)],[t.Vec(t.Record({block_index:t.Nat64,status_v2:t.Opt(S)}))],["query"]),retrieve_btc_with_approval:t.Func([it],[t.Variant({Ok:h,Err:st})],[]),update_balance:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Variant({Ok:t.Vec(ut),Err:_t})],[])})};var et=class t extends x.Canister{constructor(){super(...arguments);this.getBtcAddress=({owner:r,subaccount:n})=>this.caller({certified:!0}).get_btc_address({owner:(0,x.toNullable)(r),subaccount:(0,x.toNullable)(n)});this.updateBalance=async({owner:r,subaccount:n})=>{let o=await this.caller({certified:!0}).update_balance({owner:(0,x.toNullable)(r),subaccount:(0,x.toNullable)(n)});if("Err"in o)throw xt(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 tt(n.Err);return n.Ok};this.retrieveBtcWithApproval=async({address:r,amount:n,fromSubaccount:o})=>{let a=await this.caller({certified:!0}).retrieve_btc_with_approval({address:r,amount:n,from_subaccount:(0,x.toNullable)(o)});if("Err"in a)throw ht(a.Err);return a.Ok};this.retrieveBtcStatus=async({transactionId:r,certified:n})=>this.caller({certified:n}).retrieve_btc_status({block_index:r});this.retrieveBtcStatusV2ByAccount=async({account:r,certified:n})=>{let{retrieve_btc_status_v2_by_account:o}=this.caller({certified:n});return(await o((0,x.isNullish)(r)?[]:[{owner:r.owner,subaccount:(0,x.toNullable)(r.subaccount)}])).map(({block_index:c,status_v2:s})=>({id:c,status:(0,x.fromNullable)(s)}))};this.estimateWithdrawalFee=async({certified:r,amount:n})=>this.caller({certified:r}).estimate_withdrawal_fee({amount:(0,x.toNullable)(n)});this.getMinterInfo=async({certified:r})=>this.caller({certified:r}).get_minter_info();this.getKnownUtxos=({owner:r,subaccount:n,certified:o})=>{let{get_known_utxos:a}=this.caller({certified:o});return a({owner:(0,x.toNullable)(r),subaccount:(0,x.toNullable)(n)})}}static create(r){let{service:n,certifiedService:o,canisterId:a}=(0,x.createServices)({options:r,idlFactory:Ut,certifiedIdlFactory:Tt});return new t(a,n,o)}};var vt=require("@dfinity/utils");function ce(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function bt(t,...e){if(!ce(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 Nt(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 Ft(t,e){bt(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var nt=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),g=(t,e)=>t<<32-e|t>>>e;var Ke=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function ae(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function gt(t){return typeof t=="string"&&(t=ae(t)),bt(t),t}var rt=class{clone(){return this._cloneInto()}},Je={}.toString;function Ct(t){let e=n=>t().update(gt(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function ie(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let o=BigInt(32),a=BigInt(4294967295),c=Number(r>>o&a),s=Number(r&a),u=n?4:0,_=n?0:4;t.setUint32(e+u,c,n),t.setUint32(e+_,s,n)}var Et=(t,e,r)=>t&e^~t&r,St=(t,e,r)=>t&e^t&r^e&r,ot=class extends rt{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=nt(this.buffer)}update(e){Nt(this);let{view:r,buffer:n,blockLen:o}=this;e=gt(e);let a=e.length;for(let c=0;c<a;){let s=Math.min(o-this.pos,a-c);if(s===o){let u=nt(e);for(;o<=a-c;c+=o)this.process(u,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){Nt(this),Ft(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:a}=this,{pos:c}=this;r[c++]=128,this.buffer.subarray(c).fill(0),this.padOffset>o-c&&(this.process(n,0),c=0);for(let i=c;i<o;i++)r[i]=0;ie(n,o-8,BigInt(this.length*8),a),this.process(n,0);let s=nt(e),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let _=u/4,l=this.get();if(_>l.length)throw new Error("_sha2: outputLen bigger than state");for(let i=0;i<_;i++)s.setUint32(4*i,l[i],a)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:a,destroyed:c,pos:s}=this;return e.length=o,e.pos=s,e.finished=a,e.destroyed=c,o%r&&e.buffer.set(n),e}};var se=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),k=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),v=new Uint32Array(64),yt=class extends ot{constructor(){super(64,32,8,!1),this.A=k[0]|0,this.B=k[1]|0,this.C=k[2]|0,this.D=k[3]|0,this.E=k[4]|0,this.F=k[5]|0,this.G=k[6]|0,this.H=k[7]|0}get(){let{A:e,B:r,C:n,D:o,E:a,F:c,G:s,H:u}=this;return[e,r,n,o,a,c,s,u]}set(e,r,n,o,a,c,s,u){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=a|0,this.F=c|0,this.G=s|0,this.H=u|0}process(e,r){for(let i=0;i<16;i++,r+=4)v[i]=e.getUint32(r,!1);for(let i=16;i<64;i++){let d=v[i-15],p=v[i-2],m=g(d,7)^g(d,18)^d>>>3,f=g(p,17)^g(p,19)^p>>>10;v[i]=f+v[i-7]+m+v[i-16]|0}let{A:n,B:o,C:a,D:c,E:s,F:u,G:_,H:l}=this;for(let i=0;i<64;i++){let d=g(s,6)^g(s,11)^g(s,25),p=l+d+Et(s,u,_)+se[i]+v[i]|0,f=(g(n,2)^g(n,13)^g(n,22))+St(n,o,a)|0;l=_,_=u,u=s,s=c+p|0,c=a,a=o,o=n,n=p+f|0}n=n+this.A|0,o=o+this.B|0,a=a+this.C|0,c=c+this.D|0,s=s+this.E|0,u=u+this.F|0,_=_+this.G|0,l=l+this.H|0,this.set(n,o,a,c,s,u,_,l)}roundClean(){v.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var wt=Ct(()=>new yt);var It=Vt(Xt()),$=Vt(Zt());var Ne=0,ge=5,ye=111,we=196,Re={[Ne]:{type:1,networks:[0]},[ye]:{type:1,networks:[2,1]},[ge]:{type:2,networks:[0]},[we]:{type:2,networks:[2,1]}},ke=({address:t,network:e})=>{let n=(l=>{try{return(0,It.base58_to_binary)(l)}catch{throw new T}})(t),{length:o}=n;if(o!==25)throw new P(`Expected the address to be 25 bytes, got ${o}.`);(l=>{let i=l.slice(o-4,o),d=l.slice(0,o-4),p=wt.create();p.update(d);let m=wt.create();m.update(p.digest());let f=m.digest().slice(0,4);if(i.some((b,h)=>b!==f[h]))throw new P(`Checksum mismatch expected ${i}, got ${f}.`)})(n);let c=n[0],s=Re[c];if((0,vt.isNullish)(s))throw new U;let{type:u,networks:_}=s;if(!_.includes(e))throw new z;return{address:t,network:e,type:u,parser:"base58"}},ve=({address:t,network:e})=>{let r=l=>{try{return l.startsWith("bc1p")||l.startsWith("tb1p")||l.startsWith("bcrt1p")?$.bech32m.decode(l):$.bech32.decode(l)}catch{throw new P}},{prefix:n,words:o}=r(t),c={bc:0,tb:2,bcrt:1}[n];if((0,vt.isNullish)(c))throw new T;if(c!==e)throw new G;let[s,...u]=o;if(s>1)throw new W;switch($.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 M}},Oe=({address:t,network:e=0})=>{switch(t.charAt(0)){case"1":case"2":case"3":case"m":case"n":return ke({address:t,network:e});case"b":case"B":case"t":case"T":return ve({address:t,network:e});case"":throw new q;default:throw new U}};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,toGetUtxosParams});
"use strict";var Dt=Object.create;var Q=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var re=Object.getPrototypeOf,ne=Object.prototype.hasOwnProperty;var B=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),oe=(t,e)=>{for(var r in e)Q(t,r,{get:e[r],enumerable:!0})},At=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ee(e))!ne.call(t,o)&&o!==r&&Q(t,o,{get:()=>e[o],enumerable:!(n=te(e,o))||n.enumerable});return t};var Pt=(t,e,r)=>(r=t!=null?Dt(re(t)):{},At(e||!t||!t.__esModule?Q(r,"default",{value:t,enumerable:!0}):r,t)),ae=t=>At(Q({},"__esModule",{value:!0}),t);var ct=B((or,Mt)=>{"use strict";var _e="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";Mt.exports=_e});var Wt=B((ar,Gt)=>{"use strict";var de=ct(),pe=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=>de.indexOf(o)).reduce((o,c)=>(o=o.map(a=>{let s=a*58+c;return c=s>>8,s}),o),new Uint8Array(n)).reverse().filter((o=>c=>o=o||c)(!1))])};Gt.exports=pe});var $t=B((cr,Ht)=>{"use strict";var zt=ct(),fe=()=>{let t=Array(256).fill(-1);for(let e=0;e<zt.length;++e)t[zt.charCodeAt(e)]=e;return t};Ht.exports=fe});var Xt=B((ir,Qt)=>{"use strict";var jt=ct(),me=$t(),xe=me(),he=t=>{let e=[];for(let r of t){let n=r;for(let o=0;o<e.length;++o){let c=(xe[e[o]]<<8)+n;e[o]=jt.charCodeAt(c%58),n=c/58|0}for(;n;)e.push(jt.charCodeAt(n%58)),n=n/58|0}for(let r of t){if(r)break;e.push(49)}return e.reverse(),String.fromCharCode(...e)};Qt.exports=he});var Kt=B(vt=>{"use strict";vt.base58_to_binary=Wt();vt.binary_to_base58=Xt()});var It=B(q=>{"use strict";Object.defineProperty(q,"__esModule",{value:!0});q.bech32m=q.bech32=void 0;var it="qpzry9x8gf2tvdw0s3jn54khce6mua7l",Yt={};for(let t=0;t<it.length;t++){let e=it.charAt(t);Yt[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 Jt(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 Ot(t,e,r,n){let o=0,c=0,a=(1<<r)-1,s=[];for(let l=0;l<t.length;++l)for(o=o<<e|t[l],c+=e;c>=r;)c-=r,s.push(o>>c&a);if(n)c>0&&s.push(o<<r-c&a);else{if(c>=e)return"Excess padding";if(o<<r-c&a)return"Non-zero padding"}return s}function be(t){return Ot(t,8,5,!0)}function Ne(t){let e=Ot(t,5,8,!1);if(Array.isArray(e))return e}function ge(t){let e=Ot(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function Zt(t){let e;t==="bech32"?e=1:e=734539939;function r(a,s,l){if(l=l||90,a.length+7+s.length>l)throw new TypeError("Exceeds length limit");a=a.toLowerCase();let _=Jt(a);if(typeof _=="string")throw new Error(_);let u=a+"1";for(let i=0;i<s.length;++i){let d=s[i];if(d>>5)throw new Error("Non 5-bit word");_=E(_)^d,u+=it.charAt(d)}for(let i=0;i<6;++i)_=E(_);_^=e;for(let i=0;i<6;++i){let d=_>>(5-i)*5&31;u+=it.charAt(d)}return u}function n(a,s){if(s=s||90,a.length<8)return a+" too short";if(a.length>s)return"Exceeds length limit";let l=a.toLowerCase(),_=a.toUpperCase();if(a!==l&&a!==_)return"Mixed-case string "+a;a=l;let u=a.lastIndexOf("1");if(u===-1)return"No separator character for "+a;if(u===0)return"Missing prefix for "+a;let i=a.slice(0,u),d=a.slice(u+1);if(d.length<6)return"Data too short";let p=Jt(i);if(typeof p=="string")return p;let m=[];for(let f=0;f<d.length;++f){let b=d.charAt(f),h=Yt[b];if(h===void 0)return"Unknown character "+b;p=E(p)^h,!(f+6>=d.length)&&m.push(h)}return p!==e?"Invalid checksum for "+a:{prefix:i,words:m}}function o(a,s){let l=n(a,s);if(typeof l=="object")return l}function c(a,s){let l=n(a,s);if(typeof l=="object")return l;throw new Error(l)}return{decodeUnsafe:o,decode:c,encode:r,toWords:be,fromWordsUnsafe:Ne,fromWords:ge}}q.bech32=Zt("bech32");q.bech32m=Zt("bech32m")});var Pe={};oe(Pe,{BitcoinCanister:()=>X,BtcAddressType:()=>xt,BtcNetwork:()=>mt,CkBTCMinterCanister:()=>rt,MinterAlreadyProcessingError:()=>Y,MinterAmountTooLowError:()=>L,MinterGenericError:()=>w,MinterInsufficientAllowanceError:()=>tt,MinterInsufficientFundsError:()=>D,MinterMalformedAddressError:()=>I,MinterNoNewUtxosError:()=>Z,MinterRetrieveBtcError:()=>R,MinterTemporaryUnavailableError:()=>J,MinterUpdateBalanceError:()=>$,ParseBtcAddressBadWitnessLengthError:()=>G,ParseBtcAddressError:()=>N,ParseBtcAddressInvalidError:()=>U,ParseBtcAddressMalformedAddressError:()=>P,ParseBtcAddressNoDataError:()=>M,ParseBtcAddressUnexpectedHumanReadablePartError:()=>z,ParseBtcAddressUnsupportedAddressTypeError:()=>C,ParseBtcAddressUnsupportedWitnessVersionError:()=>W,ParseBtcAddressWrongNetworkError:()=>H,createRetrieveBtcError:()=>et,createRetrieveBtcWithApprovalError:()=>Nt,createUpdateBalanceError:()=>bt,parseBtcAddress:()=>Ae,toGetBalanceParams:()=>ft,toGetUtxosParams:()=>pt});module.exports=ae(Pe);var K=require("@dfinity/utils");var Bt=({IDL:t})=>{let e=t.Variant({disabled:t.Null,enabled:t.Null}),r=t.Record({get_current_fee_percentiles:t.Nat,get_utxos_maximum:t.Nat,get_block_headers_cycles_per_ten_instructions:t.Nat,get_current_fee_percentiles_maximum:t.Nat,send_transaction_per_byte:t.Nat,get_balance:t.Nat,get_utxos_cycles_per_ten_instructions:t.Nat,get_block_headers_base:t.Nat,get_utxos_base:t.Nat,get_balance_maximum:t.Nat,send_transaction_base:t.Nat,get_block_headers_maximum:t.Nat}),n=t.Variant({mainnet:t.Null,regtest:t.Null,testnet:t.Null}),o=t.Record({api_access:t.Opt(e),lazily_evaluate_fee_percentiles:t.Opt(e),blocks_source:t.Opt(t.Principal),fees:t.Opt(r),watchdog_canister:t.Opt(t.Opt(t.Principal)),network:t.Opt(n),stability_threshold:t.Opt(t.Nat),syncing:t.Opt(e),burn_cycles:t.Opt(e),disable_api_if_not_fully_synced:t.Opt(e)}),c=t.Text,a=t.Record({network:n,address:c,min_confirmations:t.Opt(t.Nat32)}),s=t.Nat64,l=t.Nat32,_=t.Record({start_height:l,end_height:t.Opt(l),network:n}),u=t.Vec(t.Nat8),i=t.Record({tip_height:l,block_headers:t.Vec(u)}),d=t.Record({network:n}),p=t.Nat64,m=t.Record({network:n,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:c}),f=t.Vec(t.Nat8),b=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),h=t.Record({height:l,value:s,outpoint:b}),y=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:l,tip_block_hash:f,utxos:t.Vec(h)}),O=t.Record({transaction:t.Vec(t.Nat8),network:n}),V=t.Record({api_access:e,lazily_evaluate_fee_percentiles:e,blocks_source:t.Principal,fees:r,watchdog_canister:t.Opt(t.Principal),network:n,stability_threshold:t.Nat,syncing:e,burn_cycles:e,disable_api_if_not_fully_synced:e}),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([a],[s],[]),bitcoin_get_balance_query:t.Func([a],[s],[]),bitcoin_get_block_headers:t.Func([_],[i],[]),bitcoin_get_current_fee_percentiles:t.Func([d],[t.Vec(p)],[]),bitcoin_get_utxos:t.Func([m],[y],[]),bitcoin_get_utxos_query:t.Func([m],[y],[]),bitcoin_send_transaction:t.Func([O],[],[]),get_config:t.Func([],[V],[]),set_config:t.Func([A],[],[])})};var Tt=({IDL:t})=>{let e=t.Variant({disabled:t.Null,enabled:t.Null}),r=t.Record({get_current_fee_percentiles:t.Nat,get_utxos_maximum:t.Nat,get_block_headers_cycles_per_ten_instructions:t.Nat,get_current_fee_percentiles_maximum:t.Nat,send_transaction_per_byte:t.Nat,get_balance:t.Nat,get_utxos_cycles_per_ten_instructions:t.Nat,get_block_headers_base:t.Nat,get_utxos_base:t.Nat,get_balance_maximum:t.Nat,send_transaction_base:t.Nat,get_block_headers_maximum:t.Nat}),n=t.Variant({mainnet:t.Null,regtest:t.Null,testnet:t.Null}),o=t.Record({api_access:t.Opt(e),lazily_evaluate_fee_percentiles:t.Opt(e),blocks_source:t.Opt(t.Principal),fees:t.Opt(r),watchdog_canister:t.Opt(t.Opt(t.Principal)),network:t.Opt(n),stability_threshold:t.Opt(t.Nat),syncing:t.Opt(e),burn_cycles:t.Opt(e),disable_api_if_not_fully_synced:t.Opt(e)}),c=t.Text,a=t.Record({network:n,address:c,min_confirmations:t.Opt(t.Nat32)}),s=t.Nat64,l=t.Nat32,_=t.Record({start_height:l,end_height:t.Opt(l),network:n}),u=t.Vec(t.Nat8),i=t.Record({tip_height:l,block_headers:t.Vec(u)}),d=t.Record({network:n}),p=t.Nat64,m=t.Record({network:n,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:c}),f=t.Vec(t.Nat8),b=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),h=t.Record({height:l,value:s,outpoint:b}),y=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:l,tip_block_hash:f,utxos:t.Vec(h)}),O=t.Record({transaction:t.Vec(t.Nat8),network:n}),V=t.Record({api_access:e,lazily_evaluate_fee_percentiles:e,blocks_source:t.Principal,fees:r,watchdog_canister:t.Opt(t.Principal),network:n,stability_threshold:t.Nat,syncing:e,burn_cycles:e,disable_api_if_not_fully_synced:e}),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([a],[s],[]),bitcoin_get_balance_query:t.Func([a],[s],["query"]),bitcoin_get_block_headers:t.Func([_],[i],[]),bitcoin_get_current_fee_percentiles:t.Func([d],[t.Vec(p)],[]),bitcoin_get_utxos:t.Func([m],[y],[]),bitcoin_get_utxos_query:t.Func([m],[y],["query"]),bitcoin_send_transaction:t.Func([O],[],[]),get_config:t.Func([],[V],["query"]),set_config:t.Func([A],[],[])})};var T=require("@dfinity/utils"),ce=t=>t==="testnet"?{testnet:null}:{mainnet:null},pt=({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}),ft=({network:t,minConfirmations:e,...r})=>({min_confirmations:(0,T.toNullable)(e),network:ce(t),...r});var X=class t extends K.Canister{constructor(){super(...arguments);this.getUtxosQuery=({...r})=>{let{bitcoin_get_utxos_query:n}=this.caller({certified:!1});return n(pt(r))};this.getBalanceQuery=({...r})=>{let{bitcoin_get_balance_query:n}=this.caller({certified:!1});return n(ft(r))}}static create(r){let{service:n,certifiedService:o,canisterId:c}=(0,K.createServices)({options:r,idlFactory:Tt,certifiedIdlFactory:Bt});return new t(c,n,o)}};var mt=(n=>(n[n.Mainnet=0]="Mainnet",n[n.Regtest=1]="Regtest",n[n.Testnet=2]="Testnet",n))(mt||{}),xt=(c=>(c[c.P2wpkhV0=0]="P2wpkhV0",c[c.P2pkh=1]="P2pkh",c[c.P2sh=2]="P2sh",c[c.P2wsh=3]="P2wsh",c[c.P2tr=4]="P2tr",c))(xt||{});var N=class extends Error{},U=class extends N{},M=class extends N{},C=class extends N{},G=class extends N{},W=class extends N{},z=class extends N{},P=class extends N{},H=class extends N{};var F=require("@dfinity/utils"),w=class extends Error{},J=class extends w{},Y=class extends w{},$=class extends w{},Z=class extends ${constructor({pending_utxos:e,required_confirmations:r}){super(),this.pendingUtxos=(0,F.fromNullable)(e)||[],this.requiredConfirmations=r}},R=class extends w{},I=class extends R{},L=class extends R{},D=class extends R{},tt=class extends R{},ht=t=>{if("GenericError"in t){let{GenericError:{error_message:e,error_code:r}}=t;return new w(`${e} (${r})`)}if("TemporarilyUnavailable"in t)return new J(t.TemporarilyUnavailable);if("AlreadyProcessing"in t)return new Y},bt=t=>{let e=ht(t);return(0,F.nonNullish)(e)?e:"NoNewUtxos"in t?new Z(t.NoNewUtxos):new $(`Unsupported response type in minter.updateBalance ${JSON.stringify(t)}`)},et=t=>{let e=ht(t);return(0,F.nonNullish)(e)?e:"MalformedAddress"in t?new I(t.MalformedAddress):"AmountTooLow"in t?new L(`${t.AmountTooLow}`):"InsufficientFunds"in t?new D(`${t.InsufficientFunds.balance}`):new R(`Unsupported response type in minter.retrieveBtc ${JSON.stringify(t)}`)},Nt=t=>{let e=ht(t);return(0,F.nonNullish)(e)?e:"InsufficientAllowance"in t?new tt(`${t.InsufficientAllowance.allowance}`):et(t)};var x=require("@dfinity/utils");var Ut=({IDL:t})=>{let e=t.Variant({RestrictedTo:t.Vec(t.Principal),DepositsRestrictedTo:t.Vec(t.Principal),ReadOnly:t.Null,GeneralAvailability:t.Null}),r=t.Record({kyt_principal:t.Opt(t.Principal),mode:t.Opt(e),retrieve_btc_min_amount:t.Opt(t.Nat64),max_time_in_queue_nanos:t.Opt(t.Nat64),min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),n=t.Variant({Mainnet:t.Null,Regtest:t.Null,Testnet:t.Null}),o=t.Record({kyt_principal:t.Opt(t.Principal),ecdsa_key_name:t.Text,mode:e,retrieve_btc_min_amount:t.Nat64,ledger_id:t.Principal,max_time_in_queue_nanos:t.Nat64,btc_network:n,min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),c=t.Variant({Upgrade:t.Opt(r),Init:o}),a=t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),s=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,memory_allocation:t.Nat,compute_allocation:t.Nat}),l=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:a,memory_size:t.Nat,cycles:t.Nat,settings:s,query_stats:l,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8)),reserved_cycles:t.Nat}),u=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),i=t.Record({height:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),d=t.Variant({CallFailed:t.Null,TaintedDestination:t.Record({kyt_fee:t.Nat64,kyt_provider:t.Principal})}),p=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:u,mint_txid:t.Opt(t.Nat64),utxos:t.Vec(i)}),schedule_deposit_reimbursement:t.Record({burn_block_index:t.Nat64,account:u,amount:t.Nat64,reason:d}),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(i),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:p,reimbursement_account:t.Opt(u),amount:t.Nat64,kyt_provider:t.Opt(t.Principal)}),checked_utxo:t.Record({clean:t.Bool,utxo:i,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:i}),reimbursed_failed_deposit:t.Record({burn_block_index:t.Nat64,mint_block_index:t.Nat64})}),f=t.Record({retrieve_btc_min_amount:t.Nat64,min_confirmations:t.Nat32,kyt_fee:t.Nat64}),b=t.Record({address:t.Text,amount:t.Nat64}),h=t.Record({block_index:t.Nat64}),y=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})}),O=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}),V=t.Record({account:u,amount:t.Nat64,reason:d}),A=t.Record({account:u,mint_block_index:t.Nat64,amount:t.Nat64,reason:d}),S=t.Variant({Signing:t.Null,Confirmed:t.Record({txid:t.Vec(t.Nat8)}),Sending:t.Record({txid:t.Vec(t.Nat8)}),AmountTooLow:t.Null,WillReimburse:V,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Reimbursed:A,Pending:t.Null}),st=t.Record({from_subaccount:t.Opt(t.Vec(t.Nat8)),address:t.Text,amount:t.Nat64}),lt=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})}),ut=t.Variant({ValueTooSmall:i,Tainted:i,Minted:t.Record({minted_amount:t.Nat64,block_index:t.Nat64,utxo:i}),Checked:i}),_t=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(_t)),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(m)],[]),get_known_utxos:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Vec(i)],[]),get_minter_info:t.Func([],[f],[]),get_withdrawal_account:t.Func([],[u],[]),retrieve_btc:t.Func([b],[t.Variant({Ok:h,Err:y})],[]),retrieve_btc_status:t.Func([t.Record({block_index:t.Nat64})],[O],[]),retrieve_btc_status_v2:t.Func([t.Record({block_index:t.Nat64})],[S],[]),retrieve_btc_status_v2_by_account:t.Func([t.Opt(u)],[t.Vec(t.Record({block_index:t.Nat64,status_v2:t.Opt(S)}))],[]),retrieve_btc_with_approval:t.Func([st],[t.Variant({Ok:h,Err:lt})],[]),update_balance:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Variant({Ok:t.Vec(ut),Err:dt})],[])})};var Ct=({IDL:t})=>{let e=t.Variant({RestrictedTo:t.Vec(t.Principal),DepositsRestrictedTo:t.Vec(t.Principal),ReadOnly:t.Null,GeneralAvailability:t.Null}),r=t.Record({kyt_principal:t.Opt(t.Principal),mode:t.Opt(e),retrieve_btc_min_amount:t.Opt(t.Nat64),max_time_in_queue_nanos:t.Opt(t.Nat64),min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),n=t.Variant({Mainnet:t.Null,Regtest:t.Null,Testnet:t.Null}),o=t.Record({kyt_principal:t.Opt(t.Principal),ecdsa_key_name:t.Text,mode:e,retrieve_btc_min_amount:t.Nat64,ledger_id:t.Principal,max_time_in_queue_nanos:t.Nat64,btc_network:n,min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),c=t.Variant({Upgrade:t.Opt(r),Init:o}),a=t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),s=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,memory_allocation:t.Nat,compute_allocation:t.Nat}),l=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:a,memory_size:t.Nat,cycles:t.Nat,settings:s,query_stats:l,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8)),reserved_cycles:t.Nat}),u=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),i=t.Record({height:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),d=t.Variant({CallFailed:t.Null,TaintedDestination:t.Record({kyt_fee:t.Nat64,kyt_provider:t.Principal})}),p=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:u,mint_txid:t.Opt(t.Nat64),utxos:t.Vec(i)}),schedule_deposit_reimbursement:t.Record({burn_block_index:t.Nat64,account:u,amount:t.Nat64,reason:d}),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(i),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:p,reimbursement_account:t.Opt(u),amount:t.Nat64,kyt_provider:t.Opt(t.Principal)}),checked_utxo:t.Record({clean:t.Bool,utxo:i,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:i}),reimbursed_failed_deposit:t.Record({burn_block_index:t.Nat64,mint_block_index:t.Nat64})}),f=t.Record({retrieve_btc_min_amount:t.Nat64,min_confirmations:t.Nat32,kyt_fee:t.Nat64}),b=t.Record({address:t.Text,amount:t.Nat64}),h=t.Record({block_index:t.Nat64}),y=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})}),O=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}),V=t.Record({account:u,amount:t.Nat64,reason:d}),A=t.Record({account:u,mint_block_index:t.Nat64,amount:t.Nat64,reason:d}),S=t.Variant({Signing:t.Null,Confirmed:t.Record({txid:t.Vec(t.Nat8)}),Sending:t.Record({txid:t.Vec(t.Nat8)}),AmountTooLow:t.Null,WillReimburse:V,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Reimbursed:A,Pending:t.Null}),st=t.Record({from_subaccount:t.Opt(t.Vec(t.Nat8)),address:t.Text,amount:t.Nat64}),lt=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})}),ut=t.Variant({ValueTooSmall:i,Tainted:i,Minted:t.Record({minted_amount:t.Nat64,block_index:t.Nat64,utxo:i}),Checked:i}),_t=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(_t)),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(m)],["query"]),get_known_utxos:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Vec(i)],["query"]),get_minter_info:t.Func([],[f],["query"]),get_withdrawal_account:t.Func([],[u],[]),retrieve_btc:t.Func([b],[t.Variant({Ok:h,Err:y})],[]),retrieve_btc_status:t.Func([t.Record({block_index:t.Nat64})],[O],["query"]),retrieve_btc_status_v2:t.Func([t.Record({block_index:t.Nat64})],[S],["query"]),retrieve_btc_status_v2_by_account:t.Func([t.Opt(u)],[t.Vec(t.Record({block_index:t.Nat64,status_v2:t.Opt(S)}))],["query"]),retrieve_btc_with_approval:t.Func([st],[t.Variant({Ok:h,Err:lt})],[]),update_balance:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Variant({Ok:t.Vec(ut),Err:dt})],[])})};var rt=class t extends x.Canister{constructor(){super(...arguments);this.getBtcAddress=({owner:r,subaccount:n})=>this.caller({certified:!0}).get_btc_address({owner:(0,x.toNullable)(r),subaccount:(0,x.toNullable)(n)});this.updateBalance=async({owner:r,subaccount:n})=>{let o=await this.caller({certified:!0}).update_balance({owner:(0,x.toNullable)(r),subaccount:(0,x.toNullable)(n)});if("Err"in o)throw bt(o.Err);return o.Ok};this.getWithdrawalAccount=()=>this.caller({certified:!0}).get_withdrawal_account();this.retrieveBtc=async r=>{let n=await this.caller({certified:!0}).retrieve_btc(r);if("Err"in n)throw et(n.Err);return n.Ok};this.retrieveBtcWithApproval=async({address:r,amount:n,fromSubaccount:o})=>{let c=await this.caller({certified:!0}).retrieve_btc_with_approval({address:r,amount:n,from_subaccount:(0,x.toNullable)(o)});if("Err"in c)throw Nt(c.Err);return c.Ok};this.retrieveBtcStatus=async({transactionId:r,certified:n})=>this.caller({certified:n}).retrieve_btc_status({block_index:r});this.retrieveBtcStatusV2ByAccount=async({account:r,certified:n})=>{let{retrieve_btc_status_v2_by_account:o}=this.caller({certified:n});return(await o((0,x.isNullish)(r)?[]:[{owner:r.owner,subaccount:(0,x.toNullable)(r.subaccount)}])).map(({block_index:a,status_v2:s})=>({id:a,status:(0,x.fromNullable)(s)}))};this.estimateWithdrawalFee=async({certified:r,amount:n})=>this.caller({certified:r}).estimate_withdrawal_fee({amount:(0,x.toNullable)(n)});this.getMinterInfo=async({certified:r})=>this.caller({certified:r}).get_minter_info();this.getKnownUtxos=({owner:r,subaccount:n,certified:o})=>{let{get_known_utxos:c}=this.caller({certified:o});return c({owner:(0,x.toNullable)(r),subaccount:(0,x.toNullable)(n)})}}static create(r){let{service:n,certifiedService:o,canisterId:c}=(0,x.createServices)({options:r,idlFactory:Ct,certifiedIdlFactory:Ut});return new t(c,n,o)}};var Vt=require("@dfinity/utils");function ie(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function gt(t,...e){if(!ie(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 yt(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 Ft(t,e){gt(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 Ye=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function se(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function wt(t){return typeof t=="string"&&(t=se(t)),gt(t),t}var nt=class{clone(){return this._cloneInto()}},Ze={}.toString;function Et(t){let e=n=>t().update(wt(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function le(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let o=BigInt(32),c=BigInt(4294967295),a=Number(r>>o&c),s=Number(r&c),l=n?4:0,_=n?0:4;t.setUint32(e+l,a,n),t.setUint32(e+_,s,n)}var qt=(t,e,r)=>t&e^~t&r,St=(t,e,r)=>t&e^t&r^e&r,at=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){yt(this);let{view:r,buffer:n,blockLen:o}=this;e=wt(e);let c=e.length;for(let a=0;a<c;){let s=Math.min(o-this.pos,c-a);if(s===o){let l=ot(e);for(;o<=c-a;a+=o)this.process(l,a);continue}n.set(e.subarray(a,a+s),this.pos),this.pos+=s,a+=s,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){yt(this),Ft(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:c}=this,{pos:a}=this;r[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>o-a&&(this.process(n,0),a=0);for(let i=a;i<o;i++)r[i]=0;le(n,o-8,BigInt(this.length*8),c),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 _=l/4,u=this.get();if(_>u.length)throw new Error("_sha2: outputLen bigger than state");for(let i=0;i<_;i++)s.setUint32(4*i,u[i],c)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:c,destroyed:a,pos:s}=this;return e.length=o,e.pos=s,e.finished=c,e.destroyed=a,o%r&&e.buffer.set(n),e}};var ue=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),k=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),v=new Uint32Array(64),Rt=class extends at{constructor(){super(64,32,8,!1),this.A=k[0]|0,this.B=k[1]|0,this.C=k[2]|0,this.D=k[3]|0,this.E=k[4]|0,this.F=k[5]|0,this.G=k[6]|0,this.H=k[7]|0}get(){let{A:e,B:r,C:n,D:o,E:c,F:a,G:s,H:l}=this;return[e,r,n,o,c,a,s,l]}set(e,r,n,o,c,a,s,l){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=c|0,this.F=a|0,this.G=s|0,this.H=l|0}process(e,r){for(let i=0;i<16;i++,r+=4)v[i]=e.getUint32(r,!1);for(let i=16;i<64;i++){let d=v[i-15],p=v[i-2],m=g(d,7)^g(d,18)^d>>>3,f=g(p,17)^g(p,19)^p>>>10;v[i]=f+v[i-7]+m+v[i-16]|0}let{A:n,B:o,C:c,D:a,E:s,F:l,G:_,H:u}=this;for(let i=0;i<64;i++){let d=g(s,6)^g(s,11)^g(s,25),p=u+d+qt(s,l,_)+ue[i]+v[i]|0,f=(g(n,2)^g(n,13)^g(n,22))+St(n,o,c)|0;u=_,_=l,l=s,s=a+p|0,a=c,c=o,o=n,n=p+f|0}n=n+this.A|0,o=o+this.B|0,c=c+this.C|0,a=a+this.D|0,s=s+this.E|0,l=l+this.F|0,_=_+this.G|0,u=u+this.H|0,this.set(n,o,c,a,s,l,_,u)}roundClean(){v.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var kt=Et(()=>new Rt);var Lt=Pt(Kt()),j=Pt(It());var ye=0,we=5,Re=111,ke=196,ve={[ye]:{type:1,networks:[0]},[Re]:{type:1,networks:[2,1]},[we]:{type:2,networks:[0]},[ke]:{type:2,networks:[2,1]}},Oe=({address:t,network:e})=>{let n=(u=>{try{return(0,Lt.base58_to_binary)(u)}catch{throw new U}})(t),{length:o}=n;if(o!==25)throw new P(`Expected the address to be 25 bytes, got ${o}.`);(u=>{let i=u.slice(o-4,o),d=u.slice(0,o-4),p=kt.create();p.update(d);let m=kt.create();m.update(p.digest());let f=m.digest().slice(0,4);if(i.some((b,h)=>b!==f[h]))throw new P(`Checksum mismatch expected ${i}, got ${f}.`)})(n);let a=n[0],s=ve[a];if((0,Vt.isNullish)(s))throw new C;let{type:l,networks:_}=s;if(!_.includes(e))throw new H;return{address:t,network:e,type:l,parser:"base58"}},Ve=({address:t,network:e})=>{let r=u=>{try{return u.startsWith("bc1p")||u.startsWith("tb1p")||u.startsWith("bcrt1p")?j.bech32m.decode(u):j.bech32.decode(u)}catch{throw new P}},{prefix:n,words:o}=r(t),a={bc:0,tb:2,bcrt:1}[n];if((0,Vt.isNullish)(a))throw new U;if(a!==e)throw new z;let[s,...l]=o;if(s>1)throw new W;switch(j.bech32.fromWords(l).length){case 20:return{address:t,network:e,type:0,parser:"bip-173"};case 32:return{address:t,network:e,type:s===0?3:4,parser:"bip-173"};default:throw new G}},Ae=({address:t,network:e=0})=>{switch(t.charAt(0)){case"1":case"2":case"3":case"m":case"n":return Oe({address:t,network:e});case"b":case"B":case"t":case"T":return Ve({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});
/*! Bundled license information:

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

import{b as a}from"./chunk-NEYHWXBO.js";import"./chunk-IS3C7V4B.js";export{a as BitcoinCanister};
import{c as a}from"./chunk-WUAXPVZB.js";import"./chunk-IS3C7V4B.js";export{a as BitcoinCanister};
//# sourceMappingURL=bitcoin.canister.js.map

@@ -1,2 +0,2 @@

import{a as Ft,b as dt}from"./chunk-NEYHWXBO.js";import{a as jt,b as Dt,c as Wt,d as St,e as Vt,f as $t,g as qt,h as Gt,i as zt,j as Xt,k as Kt,l as Jt,m as Qt,n as bt}from"./chunk-D2A54F3A.js";import{a as y,b as G}from"./chunk-IS3C7V4B.js";var O=y((ue,Z)=>{"use strict";var At="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";Z.exports=At});var et=y((pe,tt)=>{"use strict";var _t=O(),Et=e=>{if(!e||typeof e!="string")throw new Error(`Expected base58 string but got \u201C${e}\u201D`);if(e.match(/[IOl0]/gmu))throw new Error(`Invalid base58 character \u201C${e.match(/[IOl0]/gmu)}\u201D`);let t=e.match(/^1+/gmu),o=t?t[0].length:0,r=(e.length-o)*(Math.log(58)/Math.log(256))+1>>>0;return new Uint8Array([...new Uint8Array(o),...e.match(/.{1}/gmu).map(s=>_t.indexOf(s)).reduce((s,c)=>(s=s.map(n=>{let i=n*58+c;return c=i>>8,i}),s),new Uint8Array(r)).reverse().filter((s=>c=>s=s||c)(!1))])};tt.exports=Et});var ot=y((xe,nt)=>{"use strict";var rt=O(),Ct=()=>{let e=Array(256).fill(-1);for(let t=0;t<rt.length;++t)e[rt.charCodeAt(t)]=t;return e};nt.exports=Ct});var it=y((le,ct)=>{"use strict";var st=O(),kt=ot(),Ut=kt(),Bt=e=>{let t=[];for(let o of e){let r=o;for(let s=0;s<t.length;++s){let c=(Ut[t[s]]<<8)+r;t[s]=st.charCodeAt(c%58),r=c/58|0}for(;r;)t.push(st.charCodeAt(r%58)),r=r/58|0}for(let o of e){if(o)break;t.push(49)}return t.reverse(),String.fromCharCode(...t)};ct.exports=Bt});var ft=y($=>{"use strict";$.base58_to_binary=et();$.binary_to_base58=it()});var pt=y(E=>{"use strict";Object.defineProperty(E,"__esModule",{value:!0});E.bech32m=E.bech32=void 0;var F="qpzry9x8gf2tvdw0s3jn54khce6mua7l",ht={};for(let e=0;e<F.length;e++){let t=F.charAt(e);ht[t]=e}function _(e){let t=e>>25;return(e&33554431)<<5^-(t>>0&1)&996825010^-(t>>1&1)&642813549^-(t>>2&1)&513874426^-(t>>3&1)&1027748829^-(t>>4&1)&705979059}function at(e){let t=1;for(let o=0;o<e.length;++o){let r=e.charCodeAt(o);if(r<33||r>126)return"Invalid prefix ("+e+")";t=_(t)^r>>5}t=_(t);for(let o=0;o<e.length;++o){let r=e.charCodeAt(o);t=_(t)^r&31}return t}function q(e,t,o,r){let s=0,c=0,n=(1<<o)-1,i=[];for(let a=0;a<e.length;++a)for(s=s<<t|e[a],c+=t;c>=o;)c-=o,i.push(s>>c&n);if(r)c>0&&i.push(s<<o-c&n);else{if(c>=t)return"Excess padding";if(s<<o-c&n)return"Non-zero padding"}return i}function Lt(e){return q(e,8,5,!0)}function Pt(e){let t=q(e,5,8,!1);if(Array.isArray(t))return t}function Tt(e){let t=q(e,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}function ut(e){let t;e==="bech32"?t=1:t=734539939;function o(n,i,a){if(a=a||90,n.length+7+i.length>a)throw new TypeError("Exceeds length limit");n=n.toLowerCase();let u=at(n);if(typeof u=="string")throw new Error(u);let h=n+"1";for(let f=0;f<i.length;++f){let p=i[f];if(p>>5)throw new Error("Non 5-bit word");u=_(u)^p,h+=F.charAt(p)}for(let f=0;f<6;++f)u=_(u);u^=t;for(let f=0;f<6;++f){let p=u>>(5-f)*5&31;h+=F.charAt(p)}return h}function r(n,i){if(i=i||90,n.length<8)return n+" too short";if(n.length>i)return"Exceeds length limit";let a=n.toLowerCase(),u=n.toUpperCase();if(n!==a&&n!==u)return"Mixed-case string "+n;n=a;let h=n.lastIndexOf("1");if(h===-1)return"No separator character for "+n;if(h===0)return"Missing prefix for "+n;let f=n.slice(0,h),p=n.slice(h+1);if(p.length<6)return"Data too short";let x=at(f);if(typeof x=="string")return x;let w=[];for(let l=0;l<p.length;++l){let L=p.charAt(l),C=ht[L];if(C===void 0)return"Unknown character "+L;x=_(x)^C,!(l+6>=p.length)&&w.push(C)}return x!==t?"Invalid checksum for "+n:{prefix:f,words:w}}function s(n,i){let a=r(n,i);if(typeof a=="object")return a}function c(n,i){let a=r(n,i);if(typeof a=="object")return a;throw new Error(a)}return{decodeUnsafe:s,decode:c,encode:o,toWords:Lt,fromWordsUnsafe:Pt,fromWords:Tt}}E.bech32=ut("bech32");E.bech32m=ut("bech32m")});var z=(r=>(r[r.Mainnet=0]="Mainnet",r[r.Regtest=1]="Regtest",r[r.Testnet=2]="Testnet",r))(z||{}),X=(c=>(c[c.P2wpkhV0=0]="P2wpkhV0",c[c.P2pkh=1]="P2pkh",c[c.P2sh=2]="P2sh",c[c.P2wsh=3]="P2wsh",c[c.P2tr=4]="P2tr",c))(X||{});var b=class extends Error{},k=class extends b{},P=class extends b{},U=class extends b{},T=class extends b{},v=class extends b{},I=class extends b{},A=class extends b{},N=class extends b{};import{isNullish as xt}from"@dfinity/utils";function wt(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function j(e,...t){if(!wt(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function D(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function K(e,t){j(e);let o=t.outputLen;if(e.length<o)throw new Error(`digestInto() expects output buffer of length at least ${o}`)}var H=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),d=(e,t)=>e<<32-t|e>>>t;var re=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function gt(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function W(e){return typeof e=="string"&&(e=gt(e)),j(e),e}var R=class{clone(){return this._cloneInto()}},ne={}.toString;function J(e){let t=r=>e().update(W(r)).digest(),o=e();return t.outputLen=o.outputLen,t.blockLen=o.blockLen,t.create=()=>e(),t}function mt(e,t,o,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,o,r);let s=BigInt(32),c=BigInt(4294967295),n=Number(o>>s&c),i=Number(o&c),a=r?4:0,u=r?0:4;e.setUint32(t+a,n,r),e.setUint32(t+u,i,r)}var Q=(e,t,o)=>e&t^~e&o,Y=(e,t,o)=>e&t^e&o^t&o,M=class extends R{constructor(t,o,r,s){super(),this.blockLen=t,this.outputLen=o,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=H(this.buffer)}update(t){D(this);let{view:o,buffer:r,blockLen:s}=this;t=W(t);let c=t.length;for(let n=0;n<c;){let i=Math.min(s-this.pos,c-n);if(i===s){let a=H(t);for(;s<=c-n;n+=s)this.process(a,n);continue}r.set(t.subarray(n,n+i),this.pos),this.pos+=i,n+=i,this.pos===s&&(this.process(o,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){D(this),K(t,this),this.finished=!0;let{buffer:o,view:r,blockLen:s,isLE:c}=this,{pos:n}=this;o[n++]=128,this.buffer.subarray(n).fill(0),this.padOffset>s-n&&(this.process(r,0),n=0);for(let f=n;f<s;f++)o[f]=0;mt(r,s-8,BigInt(this.length*8),c),this.process(r,0);let i=H(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=a/4,h=this.get();if(u>h.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<u;f++)i.setUint32(4*f,h[f],c)}digest(){let{buffer:t,outputLen:o}=this;this.digestInto(t);let r=t.slice(0,o);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:o,buffer:r,length:s,finished:c,destroyed:n,pos:i}=this;return t.length=s,t.pos=i,t.finished=c,t.destroyed=n,s%o&&t.buffer.set(r),t}};var yt=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]),g=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),m=new Uint32Array(64),S=class extends M{constructor(){super(64,32,8,!1),this.A=g[0]|0,this.B=g[1]|0,this.C=g[2]|0,this.D=g[3]|0,this.E=g[4]|0,this.F=g[5]|0,this.G=g[6]|0,this.H=g[7]|0}get(){let{A:t,B:o,C:r,D:s,E:c,F:n,G:i,H:a}=this;return[t,o,r,s,c,n,i,a]}set(t,o,r,s,c,n,i,a){this.A=t|0,this.B=o|0,this.C=r|0,this.D=s|0,this.E=c|0,this.F=n|0,this.G=i|0,this.H=a|0}process(t,o){for(let f=0;f<16;f++,o+=4)m[f]=t.getUint32(o,!1);for(let f=16;f<64;f++){let p=m[f-15],x=m[f-2],w=d(p,7)^d(p,18)^p>>>3,l=d(x,17)^d(x,19)^x>>>10;m[f]=l+m[f-7]+w+m[f-16]|0}let{A:r,B:s,C:c,D:n,E:i,F:a,G:u,H:h}=this;for(let f=0;f<64;f++){let p=d(i,6)^d(i,11)^d(i,25),x=h+p+Q(i,a,u)+yt[f]+m[f]|0,l=(d(r,2)^d(r,13)^d(r,22))+Y(r,s,c)|0;h=u,u=a,a=i,i=n+x|0,n=c,c=s,s=r,r=x+l|0}r=r+this.A|0,s=s+this.B|0,c=c+this.C|0,n=n+this.D|0,i=i+this.E|0,a=a+this.F|0,u=u+this.G|0,h=h+this.H|0,this.set(r,s,c,n,i,a,u,h)}roundClean(){m.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var V=J(()=>new S);var lt=G(ft()),B=G(pt());var vt=0,It=5,Nt=111,Rt=196,Ht={[vt]:{type:1,networks:[0]},[Nt]:{type:1,networks:[2,1]},[It]:{type:2,networks:[0]},[Rt]:{type:2,networks:[2,1]}},Mt=({address:e,network:t})=>{let r=(h=>{try{return(0,lt.base58_to_binary)(h)}catch{throw new k}})(e),{length:s}=r;if(s!==25)throw new A(`Expected the address to be 25 bytes, got ${s}.`);(h=>{let f=h.slice(s-4,s),p=h.slice(0,s-4),x=V.create();x.update(p);let w=V.create();w.update(x.digest());let l=w.digest().slice(0,4);if(f.some((L,C)=>L!==l[C]))throw new A(`Checksum mismatch expected ${f}, got ${l}.`)})(r);let n=r[0],i=Ht[n];if(xt(i))throw new U;let{type:a,networks:u}=i;if(!u.includes(t))throw new N;return{address:e,network:t,type:a,parser:"base58"}},Ot=({address:e,network:t})=>{let o=h=>{try{return h.startsWith("bc1p")||h.startsWith("tb1p")||h.startsWith("bcrt1p")?B.bech32m.decode(h):B.bech32.decode(h)}catch{throw new A}},{prefix:r,words:s}=o(e),n={bc:0,tb:2,bcrt:1}[r];if(xt(n))throw new k;if(n!==t)throw new I;let[i,...a]=s;if(i>1)throw new v;switch(B.bech32.fromWords(a).length){case 20:return{address:e,network:t,type:0,parser:"bip-173"};case 32:return{address:e,network:t,type:i===0?3:4,parser:"bip-173"};default:throw new T}},Ae=({address:e,network:t=0})=>{switch(e.charAt(0)){case"1":case"2":case"3":case"m":case"n":return Mt({address:e,network:t});case"b":case"B":case"t":case"T":return Ot({address:e,network:t});case"":throw new P;default:throw new U}};export{dt as BitcoinCanister,X as BtcAddressType,z as BtcNetwork,bt as CkBTCMinterCanister,Wt as MinterAlreadyProcessingError,Gt as MinterAmountTooLowError,jt as MinterGenericError,Xt as MinterInsufficientAllowanceError,zt as MinterInsufficientFundsError,qt as MinterMalformedAddressError,Vt as MinterNoNewUtxosError,$t as MinterRetrieveBtcError,Dt as MinterTemporaryUnavailableError,St as MinterUpdateBalanceError,T as ParseBtcAddressBadWitnessLengthError,b as ParseBtcAddressError,k as ParseBtcAddressInvalidError,A as ParseBtcAddressMalformedAddressError,P as ParseBtcAddressNoDataError,I as ParseBtcAddressUnexpectedHumanReadablePartError,U as ParseBtcAddressUnsupportedAddressTypeError,v as ParseBtcAddressUnsupportedWitnessVersionError,N as ParseBtcAddressWrongNetworkError,Jt as createRetrieveBtcError,Qt as createRetrieveBtcWithApprovalError,Kt as createUpdateBalanceError,Ae as parseBtcAddress,Ft as toGetUtxosParams};
import{a as Ft,b as jt,c as dt}from"./chunk-WUAXPVZB.js";import{a as Dt,b as Wt,c as St,d as Vt,e as $t,f as qt,g as Gt,h as zt,i as Xt,j as Kt,k as Jt,l as Qt,m as Yt,n as bt}from"./chunk-D2A54F3A.js";import{a as y,b as G}from"./chunk-IS3C7V4B.js";var O=y((pe,Z)=>{"use strict";var At="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";Z.exports=At});var et=y((xe,tt)=>{"use strict";var _t=O(),Et=e=>{if(!e||typeof e!="string")throw new Error(`Expected base58 string but got \u201C${e}\u201D`);if(e.match(/[IOl0]/gmu))throw new Error(`Invalid base58 character \u201C${e.match(/[IOl0]/gmu)}\u201D`);let t=e.match(/^1+/gmu),o=t?t[0].length:0,r=(e.length-o)*(Math.log(58)/Math.log(256))+1>>>0;return new Uint8Array([...new Uint8Array(o),...e.match(/.{1}/gmu).map(s=>_t.indexOf(s)).reduce((s,c)=>(s=s.map(n=>{let i=n*58+c;return c=i>>8,i}),s),new Uint8Array(r)).reverse().filter((s=>c=>s=s||c)(!1))])};tt.exports=Et});var ot=y((le,nt)=>{"use strict";var rt=O(),Ct=()=>{let e=Array(256).fill(-1);for(let t=0;t<rt.length;++t)e[rt.charCodeAt(t)]=t;return e};nt.exports=Ct});var it=y((de,ct)=>{"use strict";var st=O(),kt=ot(),Ut=kt(),Bt=e=>{let t=[];for(let o of e){let r=o;for(let s=0;s<t.length;++s){let c=(Ut[t[s]]<<8)+r;t[s]=st.charCodeAt(c%58),r=c/58|0}for(;r;)t.push(st.charCodeAt(r%58)),r=r/58|0}for(let o of e){if(o)break;t.push(49)}return t.reverse(),String.fromCharCode(...t)};ct.exports=Bt});var ft=y($=>{"use strict";$.base58_to_binary=et();$.binary_to_base58=it()});var pt=y(E=>{"use strict";Object.defineProperty(E,"__esModule",{value:!0});E.bech32m=E.bech32=void 0;var F="qpzry9x8gf2tvdw0s3jn54khce6mua7l",ht={};for(let e=0;e<F.length;e++){let t=F.charAt(e);ht[t]=e}function _(e){let t=e>>25;return(e&33554431)<<5^-(t>>0&1)&996825010^-(t>>1&1)&642813549^-(t>>2&1)&513874426^-(t>>3&1)&1027748829^-(t>>4&1)&705979059}function at(e){let t=1;for(let o=0;o<e.length;++o){let r=e.charCodeAt(o);if(r<33||r>126)return"Invalid prefix ("+e+")";t=_(t)^r>>5}t=_(t);for(let o=0;o<e.length;++o){let r=e.charCodeAt(o);t=_(t)^r&31}return t}function q(e,t,o,r){let s=0,c=0,n=(1<<o)-1,i=[];for(let a=0;a<e.length;++a)for(s=s<<t|e[a],c+=t;c>=o;)c-=o,i.push(s>>c&n);if(r)c>0&&i.push(s<<o-c&n);else{if(c>=t)return"Excess padding";if(s<<o-c&n)return"Non-zero padding"}return i}function Lt(e){return q(e,8,5,!0)}function Pt(e){let t=q(e,5,8,!1);if(Array.isArray(t))return t}function Tt(e){let t=q(e,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}function ut(e){let t;e==="bech32"?t=1:t=734539939;function o(n,i,a){if(a=a||90,n.length+7+i.length>a)throw new TypeError("Exceeds length limit");n=n.toLowerCase();let u=at(n);if(typeof u=="string")throw new Error(u);let h=n+"1";for(let f=0;f<i.length;++f){let p=i[f];if(p>>5)throw new Error("Non 5-bit word");u=_(u)^p,h+=F.charAt(p)}for(let f=0;f<6;++f)u=_(u);u^=t;for(let f=0;f<6;++f){let p=u>>(5-f)*5&31;h+=F.charAt(p)}return h}function r(n,i){if(i=i||90,n.length<8)return n+" too short";if(n.length>i)return"Exceeds length limit";let a=n.toLowerCase(),u=n.toUpperCase();if(n!==a&&n!==u)return"Mixed-case string "+n;n=a;let h=n.lastIndexOf("1");if(h===-1)return"No separator character for "+n;if(h===0)return"Missing prefix for "+n;let f=n.slice(0,h),p=n.slice(h+1);if(p.length<6)return"Data too short";let x=at(f);if(typeof x=="string")return x;let w=[];for(let l=0;l<p.length;++l){let L=p.charAt(l),C=ht[L];if(C===void 0)return"Unknown character "+L;x=_(x)^C,!(l+6>=p.length)&&w.push(C)}return x!==t?"Invalid checksum for "+n:{prefix:f,words:w}}function s(n,i){let a=r(n,i);if(typeof a=="object")return a}function c(n,i){let a=r(n,i);if(typeof a=="object")return a;throw new Error(a)}return{decodeUnsafe:s,decode:c,encode:o,toWords:Lt,fromWordsUnsafe:Pt,fromWords:Tt}}E.bech32=ut("bech32");E.bech32m=ut("bech32m")});var z=(r=>(r[r.Mainnet=0]="Mainnet",r[r.Regtest=1]="Regtest",r[r.Testnet=2]="Testnet",r))(z||{}),X=(c=>(c[c.P2wpkhV0=0]="P2wpkhV0",c[c.P2pkh=1]="P2pkh",c[c.P2sh=2]="P2sh",c[c.P2wsh=3]="P2wsh",c[c.P2tr=4]="P2tr",c))(X||{});var b=class extends Error{},k=class extends b{},P=class extends b{},U=class extends b{},T=class extends b{},v=class extends b{},I=class extends b{},A=class extends b{},N=class extends b{};import{isNullish as xt}from"@dfinity/utils";function wt(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function j(e,...t){if(!wt(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function D(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function K(e,t){j(e);let o=t.outputLen;if(e.length<o)throw new Error(`digestInto() expects output buffer of length at least ${o}`)}var H=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),d=(e,t)=>e<<32-t|e>>>t;var ne=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function gt(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function W(e){return typeof e=="string"&&(e=gt(e)),j(e),e}var R=class{clone(){return this._cloneInto()}},oe={}.toString;function J(e){let t=r=>e().update(W(r)).digest(),o=e();return t.outputLen=o.outputLen,t.blockLen=o.blockLen,t.create=()=>e(),t}function mt(e,t,o,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,o,r);let s=BigInt(32),c=BigInt(4294967295),n=Number(o>>s&c),i=Number(o&c),a=r?4:0,u=r?0:4;e.setUint32(t+a,n,r),e.setUint32(t+u,i,r)}var Q=(e,t,o)=>e&t^~e&o,Y=(e,t,o)=>e&t^e&o^t&o,M=class extends R{constructor(t,o,r,s){super(),this.blockLen=t,this.outputLen=o,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=H(this.buffer)}update(t){D(this);let{view:o,buffer:r,blockLen:s}=this;t=W(t);let c=t.length;for(let n=0;n<c;){let i=Math.min(s-this.pos,c-n);if(i===s){let a=H(t);for(;s<=c-n;n+=s)this.process(a,n);continue}r.set(t.subarray(n,n+i),this.pos),this.pos+=i,n+=i,this.pos===s&&(this.process(o,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){D(this),K(t,this),this.finished=!0;let{buffer:o,view:r,blockLen:s,isLE:c}=this,{pos:n}=this;o[n++]=128,this.buffer.subarray(n).fill(0),this.padOffset>s-n&&(this.process(r,0),n=0);for(let f=n;f<s;f++)o[f]=0;mt(r,s-8,BigInt(this.length*8),c),this.process(r,0);let i=H(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=a/4,h=this.get();if(u>h.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<u;f++)i.setUint32(4*f,h[f],c)}digest(){let{buffer:t,outputLen:o}=this;this.digestInto(t);let r=t.slice(0,o);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:o,buffer:r,length:s,finished:c,destroyed:n,pos:i}=this;return t.length=s,t.pos=i,t.finished=c,t.destroyed=n,s%o&&t.buffer.set(r),t}};var yt=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]),g=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),m=new Uint32Array(64),S=class extends M{constructor(){super(64,32,8,!1),this.A=g[0]|0,this.B=g[1]|0,this.C=g[2]|0,this.D=g[3]|0,this.E=g[4]|0,this.F=g[5]|0,this.G=g[6]|0,this.H=g[7]|0}get(){let{A:t,B:o,C:r,D:s,E:c,F:n,G:i,H:a}=this;return[t,o,r,s,c,n,i,a]}set(t,o,r,s,c,n,i,a){this.A=t|0,this.B=o|0,this.C=r|0,this.D=s|0,this.E=c|0,this.F=n|0,this.G=i|0,this.H=a|0}process(t,o){for(let f=0;f<16;f++,o+=4)m[f]=t.getUint32(o,!1);for(let f=16;f<64;f++){let p=m[f-15],x=m[f-2],w=d(p,7)^d(p,18)^p>>>3,l=d(x,17)^d(x,19)^x>>>10;m[f]=l+m[f-7]+w+m[f-16]|0}let{A:r,B:s,C:c,D:n,E:i,F:a,G:u,H:h}=this;for(let f=0;f<64;f++){let p=d(i,6)^d(i,11)^d(i,25),x=h+p+Q(i,a,u)+yt[f]+m[f]|0,l=(d(r,2)^d(r,13)^d(r,22))+Y(r,s,c)|0;h=u,u=a,a=i,i=n+x|0,n=c,c=s,s=r,r=x+l|0}r=r+this.A|0,s=s+this.B|0,c=c+this.C|0,n=n+this.D|0,i=i+this.E|0,a=a+this.F|0,u=u+this.G|0,h=h+this.H|0,this.set(r,s,c,n,i,a,u,h)}roundClean(){m.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var V=J(()=>new S);var lt=G(ft()),B=G(pt());var vt=0,It=5,Nt=111,Rt=196,Ht={[vt]:{type:1,networks:[0]},[Nt]:{type:1,networks:[2,1]},[It]:{type:2,networks:[0]},[Rt]:{type:2,networks:[2,1]}},Mt=({address:e,network:t})=>{let r=(h=>{try{return(0,lt.base58_to_binary)(h)}catch{throw new k}})(e),{length:s}=r;if(s!==25)throw new A(`Expected the address to be 25 bytes, got ${s}.`);(h=>{let f=h.slice(s-4,s),p=h.slice(0,s-4),x=V.create();x.update(p);let w=V.create();w.update(x.digest());let l=w.digest().slice(0,4);if(f.some((L,C)=>L!==l[C]))throw new A(`Checksum mismatch expected ${f}, got ${l}.`)})(r);let n=r[0],i=Ht[n];if(xt(i))throw new U;let{type:a,networks:u}=i;if(!u.includes(t))throw new N;return{address:e,network:t,type:a,parser:"base58"}},Ot=({address:e,network:t})=>{let o=h=>{try{return h.startsWith("bc1p")||h.startsWith("tb1p")||h.startsWith("bcrt1p")?B.bech32m.decode(h):B.bech32.decode(h)}catch{throw new A}},{prefix:r,words:s}=o(e),n={bc:0,tb:2,bcrt:1}[r];if(xt(n))throw new k;if(n!==t)throw new I;let[i,...a]=s;if(i>1)throw new v;switch(B.bech32.fromWords(a).length){case 20:return{address:e,network:t,type:0,parser:"bip-173"};case 32:return{address:e,network:t,type:i===0?3:4,parser:"bip-173"};default:throw new T}},_e=({address:e,network:t=0})=>{switch(e.charAt(0)){case"1":case"2":case"3":case"m":case"n":return Mt({address:e,network:t});case"b":case"B":case"t":case"T":return Ot({address:e,network:t});case"":throw new P;default:throw new U}};export{dt as BitcoinCanister,X as BtcAddressType,z as BtcNetwork,bt as CkBTCMinterCanister,St as MinterAlreadyProcessingError,zt as MinterAmountTooLowError,Dt as MinterGenericError,Kt as MinterInsufficientAllowanceError,Xt as MinterInsufficientFundsError,Gt as MinterMalformedAddressError,$t as MinterNoNewUtxosError,qt as MinterRetrieveBtcError,Wt as MinterTemporaryUnavailableError,Vt as MinterUpdateBalanceError,T as ParseBtcAddressBadWitnessLengthError,b as ParseBtcAddressError,k as ParseBtcAddressInvalidError,A as ParseBtcAddressMalformedAddressError,P as ParseBtcAddressNoDataError,I as ParseBtcAddressUnexpectedHumanReadablePartError,U as ParseBtcAddressUnsupportedAddressTypeError,v as ParseBtcAddressUnsupportedWitnessVersionError,N as ParseBtcAddressWrongNetworkError,Qt as createRetrieveBtcError,Yt as createRetrieveBtcWithApprovalError,Jt as createUpdateBalanceError,_e as parseBtcAddress,jt as toGetBalanceParams,Ft as toGetUtxosParams};
/*! Bundled license information:

@@ -3,0 +3,0 @@

import { Canister } from "@dfinity/utils";
import type { _SERVICE as BitcoinService, get_utxos_response } from "../candid/bitcoin";
import { type GetUtxosParams } from "./types/bitcoin.params";
import type { _SERVICE as BitcoinService, get_utxos_response, satoshi } from "../candid/bitcoin";
import { type GetBalanceParams, type GetUtxosParams } from "./types/bitcoin.params";
import type { CkBTCCanisterOptions } from "./types/canister.options";

@@ -10,2 +10,4 @@ export declare class BitcoinCanister extends Canister<BitcoinService> {

*
* ⚠️ Note that this method does not support certified calls because only canisters are allowed to get UTXOs via update calls.
*
* @link https://internetcomputer.org/docs/current/references/ic-interface-spec#ic-bitcoin_get_utxos

@@ -17,6 +19,19 @@ *

* @param {string} params.address A Bitcoin address.
* @param {boolean} params.certified query or update call
* @returns {Promise<bitcoin_get_utxos_result>} The UTXOs are returned sorted by block height in descending order.
*/
getUtxos: ({ certified, ...params }: GetUtxosParams) => Promise<get_utxos_response>;
getUtxosQuery: ({ ...params }: GetUtxosParams) => Promise<get_utxos_response>;
/**
* Given a `get_balance_request`, which must specify a Bitcoin address and a Bitcoin network (`mainnet` or `testnet`), the function returns the current balance of this address in `Satoshi` (10^8 Satoshi = 1 Bitcoin) in the specified Bitcoin network.
*
* ⚠️ Note that this method does not support certified calls because only canisters are allowed to get Bitcoin balance via update calls.
*
* @link https://internetcomputer.org/docs/current/references/ic-interface-spec#ic-bitcoin_get_balance
*
* @param {Object} params
* @param {BitcoinNetwork} params.network Tesnet or mainnet.
* @param {Object} params.min_confirmations The optional filter parameter can be used to limit the set of considered UTXOs for the calculation of the balance to those with at least the provided number of confirmations in the same manner as for the `bitcoin_get_utxos` call.
* @param {string} params.address A Bitcoin address.
* @returns {Promise<satoshi>} The balance is returned in `Satoshi` (10^8 Satoshi = 1 Bitcoin).
*/
getBalanceQuery: ({ ...params }: GetBalanceParams) => Promise<satoshi>;
}
import { type QueryParams } from "@dfinity/utils";
import type { get_utxos_request } from "../../candid/bitcoin";
import type { get_balance_request, get_utxos_request } from "../../candid/bitcoin";
export type BitcoinNetwork = "testnet" | "mainnet";

@@ -9,5 +9,10 @@ export type GetUtxosParams = Omit<get_utxos_request, "network" | "filter"> & {

} | {
min_confirmations: number;
minConfirmations: number;
};
} & QueryParams;
} & Omit<QueryParams, "certified">;
export declare const toGetUtxosParams: ({ network, filter, ...rest }: GetUtxosParams) => get_utxos_request;
export type GetBalanceParams = Omit<get_balance_request, "network" | "min_confirmations"> & {
network: BitcoinNetwork;
minConfirmations?: number;
} & Omit<QueryParams, "certified">;
export declare const toGetBalanceParams: ({ network, minConfirmations, ...rest }: GetBalanceParams) => get_balance_request;
{
"name": "@dfinity/ckbtc",
"version": "2.5.0",
"version": "3.0.0",
"description": "A library for interfacing with ckBTC.",

@@ -41,6 +41,6 @@ "license": "Apache-2.0",

"peerDependencies": {
"@dfinity/agent": "^1.4.0",
"@dfinity/candid": "^1.4.0",
"@dfinity/principal": "^1.4.0",
"@dfinity/utils": "^2.4.0"
"@dfinity/agent": "^2.0.0",
"@dfinity/candid": "^2.0.0",
"@dfinity/principal": "^2.0.0",
"@dfinity/utils": "^2.5.0"
},

@@ -47,0 +47,0 @@ "dependencies": {

@@ -279,3 +279,3 @@ # ckbtc-js

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/bitcoin.canister.ts#L11)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/bitcoin.canister.ts#L17)

@@ -285,3 +285,4 @@ #### Methods

- [create](#gear-create)
- [getUtxos](#gear-getutxos)
- [getUtxosQuery](#gear-getutxosquery)
- [getBalanceQuery](#gear-getbalancequery)

@@ -294,12 +295,14 @@ ##### :gear: create

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/bitcoin.canister.ts#L12)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/bitcoin.canister.ts#L18)
##### :gear: getUtxos
##### :gear: getUtxosQuery
Given a `get_utxos_request`, which must specify a Bitcoin address and a Bitcoin network (`mainnet` or `testnet`), the function returns all unspent transaction outputs (UTXOs) associated with the provided address in the specified Bitcoin network based on the current view of the Bitcoin blockchain available to the Bitcoin component.
| Method | Type |
| ---------- | --------------------------------------------------------------------------- |
| `getUtxos` | `({ certified, ...params }: GetUtxosParams) => Promise<get_utxos_response>` |
⚠️ Note that this method does not support certified calls because only canisters are allowed to get UTXOs via update calls.
| Method | Type |
| --------------- | ---------------------------------------------------------------- |
| `getUtxosQuery` | `({ ...params }: GetUtxosParams) => Promise<get_utxos_response>` |
Parameters:

@@ -310,6 +313,23 @@

- `params.address`: A Bitcoin address.
- `params.certified`: query or update call
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/bitcoin.canister.ts#L35)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/bitcoin.canister.ts#L42)
##### :gear: getBalanceQuery
Given a `get_balance_request`, which must specify a Bitcoin address and a Bitcoin network (`mainnet` or `testnet`), the function returns the current balance of this address in `Satoshi` (10^8 Satoshi = 1 Bitcoin) in the specified Bitcoin network.
⚠️ Note that this method does not support certified calls because only canisters are allowed to get Bitcoin balance via update calls.
| Method | Type |
| ----------------- | ------------------------------------------------------ |
| `getBalanceQuery` | `({ ...params }: GetBalanceParams) => Promise<bigint>` |
Parameters:
- `params.network`: Tesnet or mainnet.
- `params.min_confirmations`: The optional filter parameter can be used to limit the set of considered UTXOs for the calculation of the balance to those with at least the provided number of confirmations in the same manner as for the `bitcoin_get_utxos` call.
- `params.address`: A Bitcoin address.
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/ckbtc/src/bitcoin.canister.ts#L64)
<!-- TSDOC_END -->

@@ -316,0 +336,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc