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