@dfinity/ckbtc 4.0.1 → 4.0.2
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/dist/candid/minter.certified.idl.js +12 -0
- package/dist/candid/minter.d.ts +12 -0
- package/dist/candid/minter.did +14 -1
- package/dist/candid/minter.idl.js +12 -0
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/index.cjs.js.map +3 -3
- package/dist/esm/chunk-7W3XZWUY.js +2 -0
- package/dist/esm/chunk-7W3XZWUY.js.map +7 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/minter.canister.js +1 -1
- package/package.json +1 -1
- package/dist/esm/chunk-E4ZZJDK5.js +0 -2
- package/dist/esm/chunk-E4ZZJDK5.js.map +0 -7
|
@@ -40,6 +40,16 @@ export const idlFactory = ({ IDL }) => {
|
|
|
40
40
|
'Upgrade' : IDL.Opt(UpgradeArgs),
|
|
41
41
|
'Init' : InitArgs,
|
|
42
42
|
});
|
|
43
|
+
const MemoryMetrics = IDL.Record({
|
|
44
|
+
'wasm_binary_size' : IDL.Nat,
|
|
45
|
+
'wasm_chunk_store_size' : IDL.Nat,
|
|
46
|
+
'canister_history_size' : IDL.Nat,
|
|
47
|
+
'stable_memory_size' : IDL.Nat,
|
|
48
|
+
'snapshots_size' : IDL.Nat,
|
|
49
|
+
'wasm_memory_size' : IDL.Nat,
|
|
50
|
+
'global_memory_size' : IDL.Nat,
|
|
51
|
+
'custom_sections_size' : IDL.Nat,
|
|
52
|
+
});
|
|
43
53
|
const CanisterStatusType = IDL.Variant({
|
|
44
54
|
'stopped' : IDL.Null,
|
|
45
55
|
'stopping' : IDL.Null,
|
|
@@ -52,6 +62,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
52
62
|
});
|
|
53
63
|
const DefiniteCanisterSettings = IDL.Record({
|
|
54
64
|
'freezing_threshold' : IDL.Nat,
|
|
65
|
+
'wasm_memory_threshold' : IDL.Nat,
|
|
55
66
|
'controllers' : IDL.Vec(IDL.Principal),
|
|
56
67
|
'reserved_cycles_limit' : IDL.Nat,
|
|
57
68
|
'log_visibility' : LogVisibility,
|
|
@@ -66,6 +77,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
66
77
|
'request_payload_bytes_total' : IDL.Nat,
|
|
67
78
|
});
|
|
68
79
|
const CanisterStatusResponse = IDL.Record({
|
|
80
|
+
'memory_metrics' : MemoryMetrics,
|
|
69
81
|
'status' : CanisterStatusType,
|
|
70
82
|
'memory_size' : IDL.Nat,
|
|
71
83
|
'cycles' : IDL.Nat,
|
package/dist/candid/minter.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export type BtcNetwork =
|
|
|
17
17
|
| { Regtest: null }
|
|
18
18
|
| { Testnet: null };
|
|
19
19
|
export interface CanisterStatusResponse {
|
|
20
|
+
memory_metrics: MemoryMetrics;
|
|
20
21
|
status: CanisterStatusType;
|
|
21
22
|
memory_size: bigint;
|
|
22
23
|
cycles: bigint;
|
|
@@ -32,6 +33,7 @@ export type CanisterStatusType =
|
|
|
32
33
|
| { running: null };
|
|
33
34
|
export interface DefiniteCanisterSettings {
|
|
34
35
|
freezing_threshold: bigint;
|
|
36
|
+
wasm_memory_threshold: bigint;
|
|
35
37
|
controllers: Array<Principal>;
|
|
36
38
|
reserved_cycles_limit: bigint;
|
|
37
39
|
log_visibility: LogVisibility;
|
|
@@ -173,6 +175,16 @@ export type LogVisibility =
|
|
|
173
175
|
| { controllers: null }
|
|
174
176
|
| { public: null }
|
|
175
177
|
| { allowed_viewers: Array<Principal> };
|
|
178
|
+
export interface MemoryMetrics {
|
|
179
|
+
wasm_binary_size: bigint;
|
|
180
|
+
wasm_chunk_store_size: bigint;
|
|
181
|
+
canister_history_size: bigint;
|
|
182
|
+
stable_memory_size: bigint;
|
|
183
|
+
snapshots_size: bigint;
|
|
184
|
+
wasm_memory_size: bigint;
|
|
185
|
+
global_memory_size: bigint;
|
|
186
|
+
custom_sections_size: bigint;
|
|
187
|
+
}
|
|
176
188
|
export type MinterArg = { Upgrade: [] | [UpgradeArgs] } | { Init: InitArgs };
|
|
177
189
|
export interface MinterInfo {
|
|
178
190
|
retrieve_btc_min_amount: bigint;
|
package/dist/candid/minter.did
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated from IC repo commit
|
|
1
|
+
// Generated from IC repo commit 206b61a (2025-09-25 tags: release-2025-09-25_09-52-base) 'rs/bitcoin/ckbtc/minter/ckbtc_minter.did' by import-candid
|
|
2
2
|
// Represents an account on the ckBTC ledger.
|
|
3
3
|
type Account = record { owner : principal; subaccount : opt blob };
|
|
4
4
|
|
|
@@ -11,6 +11,7 @@ type CanisterStatusResponse = record {
|
|
|
11
11
|
module_hash : opt vec nat8;
|
|
12
12
|
query_stats : QueryStats;
|
|
13
13
|
reserved_cycles : nat;
|
|
14
|
+
memory_metrics : MemoryMetrics;
|
|
14
15
|
};
|
|
15
16
|
|
|
16
17
|
type QueryStats = record {
|
|
@@ -20,6 +21,17 @@ type QueryStats = record {
|
|
|
20
21
|
request_payload_bytes_total : nat;
|
|
21
22
|
};
|
|
22
23
|
|
|
24
|
+
type MemoryMetrics = record {
|
|
25
|
+
wasm_memory_size : nat;
|
|
26
|
+
stable_memory_size : nat;
|
|
27
|
+
global_memory_size : nat;
|
|
28
|
+
wasm_binary_size : nat;
|
|
29
|
+
custom_sections_size : nat;
|
|
30
|
+
canister_history_size : nat;
|
|
31
|
+
wasm_chunk_store_size : nat;
|
|
32
|
+
snapshots_size : nat;
|
|
33
|
+
};
|
|
34
|
+
|
|
23
35
|
type CanisterStatusType = variant { stopped; stopping; running };
|
|
24
36
|
|
|
25
37
|
type DefiniteCanisterSettings = record {
|
|
@@ -30,6 +42,7 @@ type DefiniteCanisterSettings = record {
|
|
|
30
42
|
reserved_cycles_limit : nat;
|
|
31
43
|
log_visibility: LogVisibility;
|
|
32
44
|
wasm_memory_limit : nat;
|
|
45
|
+
wasm_memory_threshold : nat;
|
|
33
46
|
};
|
|
34
47
|
|
|
35
48
|
type LogVisibility = variant {
|
|
@@ -40,6 +40,16 @@ export const idlFactory = ({ IDL }) => {
|
|
|
40
40
|
'Upgrade' : IDL.Opt(UpgradeArgs),
|
|
41
41
|
'Init' : InitArgs,
|
|
42
42
|
});
|
|
43
|
+
const MemoryMetrics = IDL.Record({
|
|
44
|
+
'wasm_binary_size' : IDL.Nat,
|
|
45
|
+
'wasm_chunk_store_size' : IDL.Nat,
|
|
46
|
+
'canister_history_size' : IDL.Nat,
|
|
47
|
+
'stable_memory_size' : IDL.Nat,
|
|
48
|
+
'snapshots_size' : IDL.Nat,
|
|
49
|
+
'wasm_memory_size' : IDL.Nat,
|
|
50
|
+
'global_memory_size' : IDL.Nat,
|
|
51
|
+
'custom_sections_size' : IDL.Nat,
|
|
52
|
+
});
|
|
43
53
|
const CanisterStatusType = IDL.Variant({
|
|
44
54
|
'stopped' : IDL.Null,
|
|
45
55
|
'stopping' : IDL.Null,
|
|
@@ -52,6 +62,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
52
62
|
});
|
|
53
63
|
const DefiniteCanisterSettings = IDL.Record({
|
|
54
64
|
'freezing_threshold' : IDL.Nat,
|
|
65
|
+
'wasm_memory_threshold' : IDL.Nat,
|
|
55
66
|
'controllers' : IDL.Vec(IDL.Principal),
|
|
56
67
|
'reserved_cycles_limit' : IDL.Nat,
|
|
57
68
|
'log_visibility' : LogVisibility,
|
|
@@ -66,6 +77,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
66
77
|
'request_payload_bytes_total' : IDL.Nat,
|
|
67
78
|
});
|
|
68
79
|
const CanisterStatusResponse = IDL.Record({
|
|
80
|
+
'memory_metrics' : MemoryMetrics,
|
|
69
81
|
'status' : CanisterStatusType,
|
|
70
82
|
'memory_size' : IDL.Nat,
|
|
71
83
|
'cycles' : IDL.Nat,
|
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Zt=Object.create;var K=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),re=(t,e)=>{for(var r in e)K(t,r,{get:e[r],enumerable:!0})},Ct=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Lt(e))!te.call(t,o)&&o!==r&&K(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)):{},Ct(e||!t||!t.__esModule?K(r,"default",{value:t,enumerable:!0}):r,t)),oe=t=>Ct(K({},"__esModule",{value:!0}),t);var Yt=ee(S=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0});S.bech32m=S.bech32=void 0;var st="qpzry9x8gf2tvdw0s3jn54khce6mua7l",Xt={};for(let t=0;t<st.length;t++){let e=st.charAt(t);Xt[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 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=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 Et(t,e,r,n){let o=0,i=0,a=(1<<r)-1,s=[];for(let l=0;l<t.length;++l)for(o=o<<e|t[l],i+=e;i>=r;)i-=r,s.push(o>>i&a);if(n)i>0&&s.push(o<<r-i&a);else{if(i>=e)return"Excess padding";if(o<<r-i&a)return"Non-zero padding"}return s}function _e(t){return Et(t,8,5,!0)}function pe(t){let e=Et(t,5,8,!1);if(Array.isArray(e))return e}function fe(t){let e=Et(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function Jt(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 _=Kt(a);if(typeof _=="string")throw new Error(_);let d=a+"1";for(let c=0;c<s.length;++c){let u=s[c];if(u>>5!==0)throw new Error("Non 5-bit word");_=E(_)^u,d+=st.charAt(u)}for(let c=0;c<6;++c)_=E(_);_^=e;for(let c=0;c<6;++c){let u=_>>(5-c)*5&31;d+=st.charAt(u)}return d}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 d=a.lastIndexOf("1");if(d===-1)return"No separator character for "+a;if(d===0)return"Missing prefix for "+a;let c=a.slice(0,d),u=a.slice(d+1);if(u.length<6)return"Data too short";let p=Kt(c);if(typeof p=="string")return p;let x=[];for(let f=0;f<u.length;++f){let m=u.charAt(f),b=Xt[m];if(b===void 0)return"Unknown character "+m;p=E(p)^b,!(f+6>=u.length)&&x.push(b)}return p!==e?"Invalid checksum for "+a:{prefix:c,words:x}}function o(a,s){let l=n(a,s);if(typeof l=="object")return l}function i(a,s){let l=n(a,s);if(typeof l=="object")return l;throw new Error(l)}return{decodeUnsafe:o,decode:i,encode:r,toWords:_e,fromWordsUnsafe:pe,fromWords:fe}}S.bech32=Jt("bech32");S.bech32m=Jt("bech32m")});var Re={};re(Re,{BitcoinCanister:()=>X,BtcAddressType:()=>Ot,BtcNetwork:()=>kt,CkBTCMinterCanister:()=>nt,MinterAlreadyProcessingError:()=>Z,MinterAmountTooLowError:()=>D,MinterGenericError:()=>R,MinterInsufficientAllowanceError:()=>et,MinterInsufficientFundsError:()=>tt,MinterMalformedAddressError:()=>L,MinterNoNewUtxosError:()=>I,MinterRetrieveBtcError:()=>k,MinterTemporaryUnavailableError:()=>Y,MinterUpdateBalanceError:()=>Q,ParseBtcAddressBadWitnessLengthError:()=>G,ParseBtcAddressError:()=>g,ParseBtcAddressInvalidError:()=>T,ParseBtcAddressMalformedAddressError:()=>B,ParseBtcAddressNoDataError:()=>q,ParseBtcAddressUnexpectedHumanReadablePartError:()=>M,ParseBtcAddressUnsupportedAddressTypeError:()=>U,ParseBtcAddressUnsupportedWitnessVersionError:()=>W,ParseBtcAddressWrongNetworkError:()=>z,createRetrieveBtcError:()=>rt,createRetrieveBtcWithApprovalError:()=>At,createUpdateBalanceError:()=>Vt,parseBtcAddress:()=>we,toGetBalanceParams:()=>Rt,toGetUtxosParams:()=>wt});module.exports=oe(Re);var J=require("@dfinity/utils");var Ht=({IDL:t})=>{let e=t.Variant({disabled:t.Null,enabled:t.Null}),r=t.Record({get_current_fee_percentiles:t.Nat,get_utxos_maximum:t.Nat,get_block_headers_cycles_per_ten_instructions:t.Nat,get_current_fee_percentiles_maximum:t.Nat,send_transaction_per_byte:t.Nat,get_balance:t.Nat,get_utxos_cycles_per_ten_instructions:t.Nat,get_block_headers_base:t.Nat,get_utxos_base:t.Nat,get_balance_maximum:t.Nat,send_transaction_base:t.Nat,get_block_headers_maximum:t.Nat}),n=t.Variant({mainnet:t.Null,regtest:t.Null,testnet:t.Null}),o=t.Record({api_access:t.Opt(e),lazily_evaluate_fee_percentiles:t.Opt(e),blocks_source:t.Opt(t.Principal),fees:t.Opt(r),watchdog_canister:t.Opt(t.Opt(t.Principal)),network:t.Opt(n),stability_threshold:t.Opt(t.Nat),syncing:t.Opt(e),burn_cycles:t.Opt(e),disable_api_if_not_fully_synced:t.Opt(e)}),i=t.Text,a=t.Record({network:n,address:i,min_confirmations:t.Opt(t.Nat32)}),s=t.Nat64,l=t.Nat32,_=t.Record({start_height:l,end_height:t.Opt(l),network:n}),d=t.Vec(t.Nat8),c=t.Record({tip_height:l,block_headers:t.Vec(d)}),u=t.Record({network:n}),p=t.Nat64,x=t.Record({network:n,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:i}),f=t.Vec(t.Nat8),m=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),b=t.Record({height:l,value:s,outpoint:m}),N=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:l,tip_block_hash:f,utxos:t.Vec(b)}),v=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([_],[c],[]),bitcoin_get_current_fee_percentiles:t.Func([u],[t.Vec(p)],[]),bitcoin_get_utxos:t.Func([x],[N],[]),bitcoin_get_utxos_query:t.Func([x],[N],[]),bitcoin_send_transaction:t.Func([v],[],[]),get_config:t.Func([],[V],[]),set_config:t.Func([A],[],[])})};var qt=({IDL:t})=>{let e=t.Variant({disabled:t.Null,enabled:t.Null}),r=t.Record({get_current_fee_percentiles:t.Nat,get_utxos_maximum:t.Nat,get_block_headers_cycles_per_ten_instructions:t.Nat,get_current_fee_percentiles_maximum:t.Nat,send_transaction_per_byte:t.Nat,get_balance:t.Nat,get_utxos_cycles_per_ten_instructions:t.Nat,get_block_headers_base:t.Nat,get_utxos_base:t.Nat,get_balance_maximum:t.Nat,send_transaction_base:t.Nat,get_block_headers_maximum:t.Nat}),n=t.Variant({mainnet:t.Null,regtest:t.Null,testnet:t.Null}),o=t.Record({api_access:t.Opt(e),lazily_evaluate_fee_percentiles:t.Opt(e),blocks_source:t.Opt(t.Principal),fees:t.Opt(r),watchdog_canister:t.Opt(t.Opt(t.Principal)),network:t.Opt(n),stability_threshold:t.Opt(t.Nat),syncing:t.Opt(e),burn_cycles:t.Opt(e),disable_api_if_not_fully_synced:t.Opt(e)}),i=t.Text,a=t.Record({network:n,address:i,min_confirmations:t.Opt(t.Nat32)}),s=t.Nat64,l=t.Nat32,_=t.Record({start_height:l,end_height:t.Opt(l),network:n}),d=t.Vec(t.Nat8),c=t.Record({tip_height:l,block_headers:t.Vec(d)}),u=t.Record({network:n}),p=t.Nat64,x=t.Record({network:n,filter:t.Opt(t.Variant({page:t.Vec(t.Nat8),min_confirmations:t.Nat32})),address:i}),f=t.Vec(t.Nat8),m=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),b=t.Record({height:l,value:s,outpoint:m}),N=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:l,tip_block_hash:f,utxos:t.Vec(b)}),v=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([_],[c],[]),bitcoin_get_current_fee_percentiles:t.Func([u],[t.Vec(p)],[]),bitcoin_get_utxos:t.Func([x],[N],[]),bitcoin_get_utxos_query:t.Func([x],[N],["query"]),bitcoin_send_transaction:t.Func([v],[],[]),get_config:t.Func([],[V],["query"]),set_config:t.Func([A],[],[])})};var P=require("@dfinity/utils"),ae={mainnet:{mainnet:null},testnet:{testnet:null},regtest:{regtest:null}},wt=({network:t,filter:e,...r})=>({filter:(0,P.nonNullish)(e)?(0,P.toNullable)("minConfirmations"in e?{min_confirmations:e.minConfirmations}:{page:e.page}):(0,P.toNullable)(),network:t==="testnet"?{testnet:null}:{mainnet:null},...r}),Rt=({network:t,minConfirmations:e,...r})=>({min_confirmations:(0,P.toNullable)(e),network:ae[t],...r});var X=class t extends J.Canister{static create(e){let{service:r,certifiedService:n,canisterId:o}=(0,J.createServices)({options:e,idlFactory:qt,certifiedIdlFactory:Ht});return new t(o,r,n)}getUtxosQuery=({...e})=>{let{bitcoin_get_utxos_query:r}=this.caller({certified:!1});return r(wt(e))};getBalanceQuery=({...e})=>{let{bitcoin_get_balance_query:r}=this.caller({certified:!1});return r(Rt(e))}};var kt=(n=>(n[n.Mainnet=0]="Mainnet",n[n.Regtest=1]="Regtest",n[n.Testnet=2]="Testnet",n))(kt||{}),Ot=(i=>(i[i.P2wpkhV0=0]="P2wpkhV0",i[i.P2pkh=1]="P2pkh",i[i.P2sh=2]="P2sh",i[i.P2wsh=3]="P2wsh",i[i.P2tr=4]="P2tr",i))(Ot||{});var g=class extends Error{},T=class extends g{},q=class extends g{},U=class extends g{},G=class extends g{},W=class extends g{},M=class extends g{},B=class extends g{},z=class extends g{};var F=require("@dfinity/utils"),R=class extends Error{},Y=class extends R{},Z=class extends R{},Q=class extends R{},I=class extends Q{pendingUtxos;requiredConfirmations;constructor({pending_utxos:e,required_confirmations:r}){super(),this.pendingUtxos=(0,F.fromNullable)(e)??[],this.requiredConfirmations=r}},k=class extends R{},L=class extends k{},D=class extends k{},tt=class extends k{},et=class extends k{},vt=t=>{if("GenericError"in t){let{GenericError:{error_message:e,error_code:r}}=t;return new R(`${e} (${r})`)}if("TemporarilyUnavailable"in t)return new Y(t.TemporarilyUnavailable);if("AlreadyProcessing"in t)return new Z},Vt=t=>{let e=vt(t);return(0,F.nonNullish)(e)?e:"NoNewUtxos"in t?new I(t.NoNewUtxos):new Q(`Unsupported response type in minter.updateBalance ${JSON.stringify(t)}`)},rt=t=>{let e=vt(t);return(0,F.nonNullish)(e)?e:"MalformedAddress"in t?new L(t.MalformedAddress):"AmountTooLow"in t?new D(`${t.AmountTooLow}`):"InsufficientFunds"in t?new tt(`${t.InsufficientFunds.balance}`):new k(`Unsupported response type in minter.retrieveBtc ${JSON.stringify(t)}`)},At=t=>{let e=vt(t);return(0,F.nonNullish)(e)?e:"InsufficientAllowance"in t?new et(`${t.InsufficientAllowance.allowance}`):rt(t)};var h=require("@dfinity/utils");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)}),i=t.Variant({Upgrade:t.Opt(r),Init:o}),a=t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),s=t.Variant({controllers:t.Null,public:t.Null,allowed_viewers:t.Vec(t.Principal)}),l=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,log_visibility:s,wasm_memory_limit:t.Nat,memory_allocation:t.Nat,compute_allocation:t.Nat}),_=t.Record({response_payload_bytes_total:t.Nat,num_instructions_total:t.Nat,num_calls_total:t.Nat,request_payload_bytes_total:t.Nat}),d=t.Record({status:a,memory_size:t.Nat,cycles:t.Nat,settings:l,query_stats:_,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8)),reserved_cycles:t.Nat}),c=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),u=t.Record({height:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),p=t.Variant({CallFailed:t.Null,TaintedDestination:t.Record({kyt_fee:t.Nat64,kyt_provider:t.Principal})}),x=t.Record({minter_fee:t.Nat64,bitcoin_fee:t.Nat64}),f=t.Variant({ValueTooSmall:t.Null,Quarantined:t.Null}),m=t.Variant({p2wsh_v0:t.Vec(t.Nat8),p2tr_v1:t.Vec(t.Nat8),p2sh:t.Vec(t.Nat8),p2wpkh_v0:t.Vec(t.Nat8),p2pkh:t.Vec(t.Nat8)}),b=t.Variant({too_many_inputs:t.Record({max_num_inputs:t.Nat64,num_inputs:t.Nat64})}),N=t.Variant({invalid_transaction:b}),v=t.Variant({to_cancel:t.Record({reason:N}),to_retry:t.Null}),V=t.Variant({received_utxos:t.Record({to_account:c,mint_txid:t.Opt(t.Nat64),utxos:t.Vec(u)}),schedule_deposit_reimbursement:t.Record({burn_block_index:t.Nat64,account:c,amount:t.Nat64,reason:p}),sent_transaction:t.Record({fee:t.Opt(t.Nat64),change_output:t.Opt(t.Record({value:t.Nat64,vout:t.Nat32})),txid:t.Vec(t.Nat8),withdrawal_fee:t.Opt(x),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:c,reason:f}),accepted_retrieve_btc_request:t.Record({received_at:t.Nat64,block_index:t.Nat64,address:m,reimbursement_account:t.Opt(c),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:c,amount:t.Nat64,reason:N}),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(x),new_txid:t.Vec(t.Nat8),submitted_at:t.Nat64,reason:t.Opt(v)}),checked_utxo_v2:t.Record({utxo:u,account:c}),ignored_utxo:t.Record({utxo:u}),checked_utxo_mint_unknown:t.Record({utxo:u,account:c}),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})}),A=t.Record({timestamp:t.Opt(t.Nat64),payload:V}),lt=t.Record({retrieve_btc_min_amount:t.Nat64,min_confirmations:t.Nat32,kyt_fee:t.Nat64}),ut=t.Record({address:t.Text,amount:t.Nat64}),C=t.Record({block_index:t.Nat64}),dt=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})}),_t=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}),pt=t.Record({account:c,amount:t.Nat64,reason:p}),ft=t.Record({account:c,mint_block_index:t.Nat64,amount:t.Nat64,reason:p}),H=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:pt,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Reimbursed:ft,Pending:t.Null}),xt=t.Record({from_subaccount:t.Opt(t.Vec(t.Nat8)),address:t.Text,amount:t.Nat64}),ht=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})}),bt=t.Variant({ValueTooSmall:u,Tainted:u,Minted:t.Record({minted_amount:t.Nat64,block_index:t.Nat64,utxo:u}),Checked:u}),mt=t.Nat64,Nt=t.Record({utxo:u,earliest_retry:mt,reason:f}),gt=t.Record({confirmations:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),yt=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(Nt)),required_confirmations:t.Nat32,pending_utxos:t.Opt(t.Vec(gt)),current_confirmations:t.Opt(t.Nat32)})});return t.Service({estimate_withdrawal_fee:t.Func([t.Record({amount:t.Opt(t.Nat64)})],[t.Record({minter_fee:t.Nat64,bitcoin_fee:t.Nat64})],[]),get_btc_address:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Text],[]),get_canister_status:t.Func([],[d],[]),get_deposit_fee:t.Func([],[t.Nat64],[]),get_events:t.Func([t.Record({start:t.Nat64,length:t.Nat64})],[t.Vec(A)],[]),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([],[lt],[]),get_withdrawal_account:t.Func([],[c],[]),retrieve_btc:t.Func([ut],[t.Variant({Ok:C,Err:dt})],[]),retrieve_btc_status:t.Func([t.Record({block_index:t.Nat64})],[_t],[]),retrieve_btc_status_v2:t.Func([t.Record({block_index:t.Nat64})],[H],[]),retrieve_btc_status_v2_by_account:t.Func([t.Opt(c)],[t.Vec(t.Record({block_index:t.Nat64,status_v2:t.Opt(H)}))],[]),retrieve_btc_with_approval:t.Func([xt],[t.Variant({Ok:C,Err:ht})],[]),update_balance:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Variant({Ok:t.Vec(bt),Err:yt})],[])})};var Wt=({IDL:t})=>{let e=t.Variant({RestrictedTo:t.Vec(t.Principal),DepositsRestrictedTo:t.Vec(t.Principal),ReadOnly:t.Null,GeneralAvailability:t.Null}),r=t.Record({get_utxos_cache_expiration_seconds:t.Opt(t.Nat64),kyt_principal:t.Opt(t.Principal),mode:t.Opt(e),retrieve_btc_min_amount:t.Opt(t.Nat64),max_time_in_queue_nanos:t.Opt(t.Nat64),check_fee:t.Opt(t.Nat64),btc_checker_principal:t.Opt(t.Principal),min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),n=t.Variant({Mainnet:t.Null,Regtest:t.Null,Testnet:t.Null}),o=t.Record({get_utxos_cache_expiration_seconds:t.Opt(t.Nat64),kyt_principal:t.Opt(t.Principal),ecdsa_key_name:t.Text,mode:e,retrieve_btc_min_amount:t.Nat64,ledger_id:t.Principal,max_time_in_queue_nanos:t.Nat64,btc_network:n,check_fee:t.Opt(t.Nat64),btc_checker_principal:t.Opt(t.Principal),min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),i=t.Variant({Upgrade:t.Opt(r),Init:o}),a=t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),s=t.Variant({controllers:t.Null,public:t.Null,allowed_viewers:t.Vec(t.Principal)}),l=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),reserved_cycles_limit:t.Nat,log_visibility:s,wasm_memory_limit:t.Nat,memory_allocation:t.Nat,compute_allocation:t.Nat}),_=t.Record({response_payload_bytes_total:t.Nat,num_instructions_total:t.Nat,num_calls_total:t.Nat,request_payload_bytes_total:t.Nat}),d=t.Record({status:a,memory_size:t.Nat,cycles:t.Nat,settings:l,query_stats:_,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8)),reserved_cycles:t.Nat}),c=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),u=t.Record({height:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),p=t.Variant({CallFailed:t.Null,TaintedDestination:t.Record({kyt_fee:t.Nat64,kyt_provider:t.Principal})}),x=t.Record({minter_fee:t.Nat64,bitcoin_fee:t.Nat64}),f=t.Variant({ValueTooSmall:t.Null,Quarantined:t.Null}),m=t.Variant({p2wsh_v0:t.Vec(t.Nat8),p2tr_v1:t.Vec(t.Nat8),p2sh:t.Vec(t.Nat8),p2wpkh_v0:t.Vec(t.Nat8),p2pkh:t.Vec(t.Nat8)}),b=t.Variant({too_many_inputs:t.Record({max_num_inputs:t.Nat64,num_inputs:t.Nat64})}),N=t.Variant({invalid_transaction:b}),v=t.Variant({to_cancel:t.Record({reason:N}),to_retry:t.Null}),V=t.Variant({received_utxos:t.Record({to_account:c,mint_txid:t.Opt(t.Nat64),utxos:t.Vec(u)}),schedule_deposit_reimbursement:t.Record({burn_block_index:t.Nat64,account:c,amount:t.Nat64,reason:p}),sent_transaction:t.Record({fee:t.Opt(t.Nat64),change_output:t.Opt(t.Record({value:t.Nat64,vout:t.Nat32})),txid:t.Vec(t.Nat8),withdrawal_fee:t.Opt(x),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:c,reason:f}),accepted_retrieve_btc_request:t.Record({received_at:t.Nat64,block_index:t.Nat64,address:m,reimbursement_account:t.Opt(c),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:c,amount:t.Nat64,reason:N}),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(x),new_txid:t.Vec(t.Nat8),submitted_at:t.Nat64,reason:t.Opt(v)}),checked_utxo_v2:t.Record({utxo:u,account:c}),ignored_utxo:t.Record({utxo:u}),checked_utxo_mint_unknown:t.Record({utxo:u,account:c}),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})}),A=t.Record({timestamp:t.Opt(t.Nat64),payload:V}),lt=t.Record({retrieve_btc_min_amount:t.Nat64,min_confirmations:t.Nat32,kyt_fee:t.Nat64}),ut=t.Record({address:t.Text,amount:t.Nat64}),C=t.Record({block_index:t.Nat64}),dt=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})}),_t=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}),pt=t.Record({account:c,amount:t.Nat64,reason:p}),ft=t.Record({account:c,mint_block_index:t.Nat64,amount:t.Nat64,reason:p}),H=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:pt,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Reimbursed:ft,Pending:t.Null}),xt=t.Record({from_subaccount:t.Opt(t.Vec(t.Nat8)),address:t.Text,amount:t.Nat64}),ht=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})}),bt=t.Variant({ValueTooSmall:u,Tainted:u,Minted:t.Record({minted_amount:t.Nat64,block_index:t.Nat64,utxo:u}),Checked:u}),mt=t.Nat64,Nt=t.Record({utxo:u,earliest_retry:mt,reason:f}),gt=t.Record({confirmations:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),yt=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(Nt)),required_confirmations:t.Nat32,pending_utxos:t.Opt(t.Vec(gt)),current_confirmations:t.Opt(t.Nat32)})});return t.Service({estimate_withdrawal_fee:t.Func([t.Record({amount:t.Opt(t.Nat64)})],[t.Record({minter_fee:t.Nat64,bitcoin_fee:t.Nat64})],["query"]),get_btc_address:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Text],[]),get_canister_status:t.Func([],[d],[]),get_deposit_fee:t.Func([],[t.Nat64],["query"]),get_events:t.Func([t.Record({start:t.Nat64,length:t.Nat64})],[t.Vec(A)],["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([],[lt],["query"]),get_withdrawal_account:t.Func([],[c],[]),retrieve_btc:t.Func([ut],[t.Variant({Ok:C,Err:dt})],[]),retrieve_btc_status:t.Func([t.Record({block_index:t.Nat64})],[_t],["query"]),retrieve_btc_status_v2:t.Func([t.Record({block_index:t.Nat64})],[H],["query"]),retrieve_btc_status_v2_by_account:t.Func([t.Opt(c)],[t.Vec(t.Record({block_index:t.Nat64,status_v2:t.Opt(H)}))],["query"]),retrieve_btc_with_approval:t.Func([xt],[t.Variant({Ok:C,Err:ht})],[]),update_balance:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Variant({Ok:t.Vec(bt),Err:yt})],[])})};var nt=class t extends h.Canister{static create(e){let{service:r,certifiedService:n,canisterId:o}=(0,h.createServices)({options:e,idlFactory:Wt,certifiedIdlFactory:Gt});return new t(o,r,n)}getBtcAddress=({owner:e,subaccount:r})=>this.caller({certified:!0}).get_btc_address({owner:(0,h.toNullable)(e),subaccount:(0,h.toNullable)(r)});updateBalance=async({owner:e,subaccount:r})=>{let n=await this.caller({certified:!0}).update_balance({owner:(0,h.toNullable)(e),subaccount:(0,h.toNullable)(r)});if("Err"in n)throw Vt(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 rt(r.Err);return r.Ok};retrieveBtcWithApproval=async({address:e,amount:r,fromSubaccount:n})=>{let o=await this.caller({certified:!0}).retrieve_btc_with_approval({address:e,amount:r,from_subaccount:(0,h.toNullable)(n)});if("Err"in o)throw At(o.Err);return o.Ok};retrieveBtcStatus=({transactionId:e,certified:r})=>this.caller({certified:r}).retrieve_btc_status({block_index:e});retrieveBtcStatusV2ByAccount=async({account:e,certified:r})=>{let{retrieve_btc_status_v2_by_account:n}=this.caller({certified:r});return(await n((0,h.isNullish)(e)?[]:[{owner:e.owner,subaccount:(0,h.toNullable)(e.subaccount)}])).map(({block_index:i,status_v2:a})=>({id:i,status:(0,h.fromNullable)(a)}))};estimateWithdrawalFee=({certified:e,amount:r})=>this.caller({certified:e}).estimate_withdrawal_fee({amount:(0,h.toNullable)(r)});getMinterInfo=({certified:e})=>this.caller({certified:e}).get_minter_info();getKnownUtxos=({owner:e,subaccount:r,certified:n})=>{let{get_known_utxos:o}=this.caller({certified:n});return o({owner:(0,h.toNullable)(e),subaccount:(0,h.toNullable)(r)})}};var St=require("@dfinity/utils");function ce(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function at(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+", got length="+t.length)}function Bt(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 Mt(t,e){at(t);let r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function $(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function ct(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function y(t,e){return t<<32-e|t>>>e}function ie(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function Pt(t){return typeof t=="string"&&(t=ie(t)),at(t),t}var ot=class{};function zt(t){let e=n=>t().update(Pt(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function se(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let o=BigInt(32),i=BigInt(4294967295),a=Number(r>>o&i),s=Number(r&i),l=n?4:0,_=n?0:4;t.setUint32(e+l,a,n),t.setUint32(e+_,s,n)}function Qt(t,e,r){return t&e^~t&r}function $t(t,e,r){return t&e^t&r^e&r}var it=class extends ot{constructor(e,r,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(e),this.view=ct(this.buffer)}update(e){Bt(this),e=Pt(e),at(e);let{view:r,buffer:n,blockLen:o}=this,i=e.length;for(let a=0;a<i;){let s=Math.min(o-this.pos,i-a);if(s===o){let l=ct(e);for(;o<=i-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){Bt(this),Mt(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:a}=this;r[a++]=128,$(this.buffer.subarray(a)),this.padOffset>o-a&&(this.process(n,0),a=0);for(let c=a;c<o;c++)r[c]=0;se(n,o-8,BigInt(this.length*8),i),this.process(n,0);let s=ct(e),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let _=l/4,d=this.get();if(_>d.length)throw new Error("_sha2: outputLen bigger than state");for(let c=0;c<_;c++)s.setUint32(4*c,d[c],i)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:a,pos:s}=this;return e.destroyed=a,e.finished=i,e.length=o,e.pos=s,o%r&&e.buffer.set(n),e}clone(){return this._cloneInto()}},w=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var le=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]),O=new Uint32Array(64),Tt=class extends it{constructor(e=32){super(64,e,8,!1),this.A=w[0]|0,this.B=w[1]|0,this.C=w[2]|0,this.D=w[3]|0,this.E=w[4]|0,this.F=w[5]|0,this.G=w[6]|0,this.H=w[7]|0}get(){let{A:e,B:r,C:n,D:o,E:i,F:a,G:s,H:l}=this;return[e,r,n,o,i,a,s,l]}set(e,r,n,o,i,a,s,l){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=a|0,this.G=s|0,this.H=l|0}process(e,r){for(let c=0;c<16;c++,r+=4)O[c]=e.getUint32(r,!1);for(let c=16;c<64;c++){let u=O[c-15],p=O[c-2],x=y(u,7)^y(u,18)^u>>>3,f=y(p,17)^y(p,19)^p>>>10;O[c]=f+O[c-7]+x+O[c-16]|0}let{A:n,B:o,C:i,D:a,E:s,F:l,G:_,H:d}=this;for(let c=0;c<64;c++){let u=y(s,6)^y(s,11)^y(s,25),p=d+u+Qt(s,l,_)+le[c]+O[c]|0,f=(y(n,2)^y(n,13)^y(n,22))+$t(n,o,i)|0;d=_,_=l,l=s,s=a+p|0,a=i,i=o,o=n,n=p+f|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,a=a+this.D|0,s=s+this.E|0,l=l+this.F|0,_=_+this.G|0,d=d+this.H|0,this.set(n,o,i,a,s,l,_,d)}roundClean(){$(O)}destroy(){this.set(0,0,0,0,0,0,0,0),$(this.buffer)}};var Ut=zt(()=>new Tt);var ue="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",jt=ue;function de(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=>jt.indexOf(o)).reduce((o,i)=>(o=o.map(a=>{let s=a*58+i;return i=s>>8,s}),o),new Uint8Array(n)).reverse().filter((o=>i=>o=o||i)(!1))])}var Ft=de;var j=ne(Yt());var xe=0,he=5,be=111,me=196,Ne={[xe]:{type:1,networks:[0]},[be]:{type:1,networks:[2,1]},[he]:{type:2,networks:[0]},[me]:{type:2,networks:[2,1]}},ge=({address:t,network:e})=>{let n=(d=>{try{return Ft(d)}catch{throw new T}})(t),{length:o}=n;if(o!==25)throw new B(`Expected the address to be 25 bytes, got ${o}.`);(d=>{let c=d.slice(o-4,o),u=d.slice(0,o-4),p=Ut.create();p.update(u);let x=Ut.create();x.update(p.digest());let f=x.digest().slice(0,4);if(c.some((m,b)=>m!==f[b]))throw new B(`Checksum mismatch expected ${c}, got ${f}.`)})(n);let[a]=n,s=Ne[a];if((0,St.isNullish)(s))throw new U;let{type:l,networks:_}=s;if(!_.includes(e))throw new z;return{address:t,network:e,type:l,parser:"base58"}},ye=({address:t,network:e})=>{let r=d=>{try{return d.startsWith("bc1p")||d.startsWith("tb1p")||d.startsWith("bcrt1p")?j.bech32m.decode(d):j.bech32.decode(d)}catch{throw new B}},{prefix:n,words:o}=r(t),a={bc:0,tb:2,bcrt:1}[n];if((0,St.isNullish)(a))throw new T;if(a!==e)throw new M;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}},we=({address:t,network:e=0})=>{switch(t.charAt(0)){case"1":case"2":case"3":case"m":case"n":return ge({address:t,network:e});case"b":case"B":case"t":case"T":return ye({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,toGetBalanceParams,toGetUtxosParams});
|
|
1
|
+
"use strict";var It=Object.create;var K=Object.defineProperty;var Lt=Object.getOwnPropertyDescriptor;var Dt=Object.getOwnPropertyNames;var te=Object.getPrototypeOf,ee=Object.prototype.hasOwnProperty;var re=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ne=(t,e)=>{for(var r in e)K(t,r,{get:e[r],enumerable:!0})},Ht=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Dt(e))!ee.call(t,o)&&o!==r&&K(t,o,{get:()=>e[o],enumerable:!(n=Lt(e,o))||n.enumerable});return t};var oe=(t,e,r)=>(r=t!=null?It(te(t)):{},Ht(e||!t||!t.__esModule?K(r,"default",{value:t,enumerable:!0}):r,t)),ae=t=>Ht(K({},"__esModule",{value:!0}),t);var Zt=re(S=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0});S.bech32m=S.bech32=void 0;var st="qpzry9x8gf2tvdw0s3jn54khce6mua7l",Jt={};for(let t=0;t<st.length;t++){let e=st.charAt(t);Jt[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 Xt(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 St(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 pe(t){return St(t,8,5,!0)}function fe(t){let e=St(t,5,8,!1);if(Array.isArray(e))return e}function he(t){let e=St(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(a,i,s){if(s=s||90,a.length+7+i.length>s)throw new TypeError("Exceeds length limit");a=a.toLowerCase();let p=Xt(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=E(p)^d,_+=st.charAt(d)}for(let l=0;l<6;++l)p=E(p);p^=e;for(let l=0;l<6;++l){let d=p>>(5-l)*5&31;_+=st.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=Xt(l);if(typeof u=="string")return u;let f=[];for(let h=0;h<d.length;++h){let m=d.charAt(h),b=Jt[m];if(b===void 0)return"Unknown character "+m;u=E(u)^b,!(h+6>=d.length)&&f.push(b)}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:pe,fromWordsUnsafe:fe,fromWords:he}}S.bech32=Yt("bech32");S.bech32m=Yt("bech32m")});var ke={};ne(ke,{BitcoinCanister:()=>X,BtcAddressType:()=>vt,BtcNetwork:()=>Ot,CkBTCMinterCanister:()=>nt,MinterAlreadyProcessingError:()=>Z,MinterAmountTooLowError:()=>D,MinterGenericError:()=>k,MinterInsufficientAllowanceError:()=>et,MinterInsufficientFundsError:()=>tt,MinterMalformedAddressError:()=>L,MinterNoNewUtxosError:()=>I,MinterRetrieveBtcError:()=>O,MinterTemporaryUnavailableError:()=>Y,MinterUpdateBalanceError:()=>Q,ParseBtcAddressBadWitnessLengthError:()=>G,ParseBtcAddressError:()=>N,ParseBtcAddressInvalidError:()=>T,ParseBtcAddressMalformedAddressError:()=>B,ParseBtcAddressNoDataError:()=>q,ParseBtcAddressUnexpectedHumanReadablePartError:()=>M,ParseBtcAddressUnsupportedAddressTypeError:()=>U,ParseBtcAddressUnsupportedWitnessVersionError:()=>W,ParseBtcAddressWrongNetworkError:()=>z,createRetrieveBtcError:()=>rt,createRetrieveBtcWithApprovalError:()=>Bt,createUpdateBalanceError:()=>At,parseBtcAddress:()=>Re,toGetBalanceParams:()=>kt,toGetUtxosParams:()=>Rt});module.exports=ae(ke);var J=require("@dfinity/utils");var qt=({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),m=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),b=t.Record({height:s,value:i,outpoint:m}),y=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:s,tip_block_hash:h,utxos:t.Vec(b)}),w=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],[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],[y],[]),bitcoin_get_utxos_query:t.Func([f],[y],[]),bitcoin_send_transaction:t.Func([w],[],[]),get_config:t.Func([],[V],[]),set_config:t.Func([A],[],[])})};var Gt=({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),m=t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32}),b=t.Record({height:s,value:i,outpoint:m}),y=t.Record({next_page:t.Opt(t.Vec(t.Nat8)),tip_height:s,tip_block_hash:h,utxos:t.Vec(b)}),w=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],[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],[y],[]),bitcoin_get_utxos_query:t.Func([f],[y],["query"]),bitcoin_send_transaction:t.Func([w],[],[]),get_config:t.Func([],[V],["query"]),set_config:t.Func([A],[],[])})};var P=require("@dfinity/utils"),ce={mainnet:{mainnet:null},testnet:{testnet:null},regtest:{regtest:null}},Rt=({network:t,filter:e,...r})=>({filter:(0,P.nonNullish)(e)?(0,P.toNullable)("minConfirmations"in e?{min_confirmations:e.minConfirmations}:{page:e.page}):(0,P.toNullable)(),network:t==="testnet"?{testnet:null}:{mainnet:null},...r}),kt=({network:t,minConfirmations:e,...r})=>({min_confirmations:(0,P.toNullable)(e),network:ce[t],...r});var X=class t extends J.Canister{static create(e){let{service:r,certifiedService:n,canisterId:o}=(0,J.createServices)({options:e,idlFactory:Gt,certifiedIdlFactory:qt});return new t(o,r,n)}getUtxosQuery=({...e})=>{let{bitcoin_get_utxos_query:r}=this.caller({certified:!1});return r(Rt(e))};getBalanceQuery=({...e})=>{let{bitcoin_get_balance_query:r}=this.caller({certified:!1});return r(kt(e))}};var Ot=(n=>(n[n.Mainnet=0]="Mainnet",n[n.Regtest=1]="Regtest",n[n.Testnet=2]="Testnet",n))(Ot||{}),vt=(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))(vt||{});var N=class extends Error{},T=class extends N{},q=class extends N{},U=class extends N{},G=class extends N{},W=class extends N{},M=class extends N{},B=class extends N{},z=class extends N{};var F=require("@dfinity/utils"),k=class extends Error{},Y=class extends k{},Z=class extends k{},Q=class extends k{},I=class extends Q{pendingUtxos;requiredConfirmations;constructor({pending_utxos:e,required_confirmations:r}){super(),this.pendingUtxos=(0,F.fromNullable)(e)??[],this.requiredConfirmations=r}},O=class extends k{},L=class extends O{},D=class extends O{},tt=class extends O{},et=class extends O{},Vt=t=>{if("GenericError"in t){let{GenericError:{error_message:e,error_code:r}}=t;return new k(`${e} (${r})`)}if("TemporarilyUnavailable"in t)return new Y(t.TemporarilyUnavailable);if("AlreadyProcessing"in t)return new Z},At=t=>{let e=Vt(t);return(0,F.nonNullish)(e)?e:"NoNewUtxos"in t?new I(t.NoNewUtxos):new Q(`Unsupported response type in minter.updateBalance ${JSON.stringify(t)}`)},rt=t=>{let e=Vt(t);return(0,F.nonNullish)(e)?e:"MalformedAddress"in t?new L(t.MalformedAddress):"AmountTooLow"in t?new D(`${t.AmountTooLow}`):"InsufficientFunds"in t?new tt(`${t.InsufficientFunds.balance}`):new O(`Unsupported response type in minter.retrieveBtc ${JSON.stringify(t)}`)},Bt=t=>{let e=Vt(t);return(0,F.nonNullish)(e)?e:"InsufficientAllowance"in t?new et(`${t.InsufficientAllowance.allowance}`):rt(t)};var x=require("@dfinity/utils");var Wt=({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}),m=t.Variant({ValueTooSmall:t.Null,Quarantined:t.Null}),b=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)}),y=t.Variant({too_many_inputs:t.Record({max_num_inputs:t.Nat64,num_inputs:t.Nat64})}),w=t.Variant({invalid_transaction:y}),V=t.Variant({to_cancel:t.Record({reason:w}),to_retry:t.Null}),A=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:m}),accepted_retrieve_btc_request:t.Record({received_at:t.Nat64,block_index:t.Nat64,address:b,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:w}),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(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})}),lt=t.Record({timestamp:t.Opt(t.Nat64),payload:A}),ut=t.Record({retrieve_btc_min_amount:t.Nat64,min_confirmations:t.Nat32,kyt_fee:t.Nat64}),dt=t.Record({address:t.Text,amount:t.Nat64}),C=t.Record({block_index:t.Nat64}),_t=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})}),pt=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}),ft=t.Record({account:d,amount:t.Nat64,reason:f}),ht=t.Record({account:d,mint_block_index:t.Nat64,amount:t.Nat64,reason:f}),H=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:ft,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Reimbursed:ht,Pending:t.Null}),xt=t.Record({from_subaccount:t.Opt(t.Vec(t.Nat8)),address:t.Text,amount:t.Nat64}),mt=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})}),bt=t.Variant({ValueTooSmall:u,Tainted:u,Minted:t.Record({minted_amount:t.Nat64,block_index:t.Nat64,utxo:u}),Checked:u}),Nt=t.Nat64,gt=t.Record({utxo:u,earliest_retry:Nt,reason:m}),yt=t.Record({confirmations:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),wt=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(gt)),required_confirmations:t.Nat32,pending_utxos:t.Opt(t.Vec(yt)),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(lt)],[]),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([],[ut],[]),get_withdrawal_account:t.Func([],[d],[]),retrieve_btc:t.Func([dt],[t.Variant({Ok:C,Err:_t})],[]),retrieve_btc_status:t.Func([t.Record({block_index:t.Nat64})],[pt],[]),retrieve_btc_status_v2:t.Func([t.Record({block_index:t.Nat64})],[H],[]),retrieve_btc_status_v2_by_account:t.Func([t.Opt(d)],[t.Vec(t.Record({block_index:t.Nat64,status_v2:t.Opt(H)}))],[]),retrieve_btc_with_approval:t.Func([xt],[t.Variant({Ok:C,Err:mt})],[]),update_balance:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Variant({Ok:t.Vec(bt),Err:wt})],[])})};var Mt=({IDL:t})=>{let e=t.Variant({RestrictedTo:t.Vec(t.Principal),DepositsRestrictedTo:t.Vec(t.Principal),ReadOnly:t.Null,GeneralAvailability:t.Null}),r=t.Record({get_utxos_cache_expiration_seconds:t.Opt(t.Nat64),kyt_principal:t.Opt(t.Principal),mode:t.Opt(e),retrieve_btc_min_amount:t.Opt(t.Nat64),max_time_in_queue_nanos:t.Opt(t.Nat64),check_fee:t.Opt(t.Nat64),btc_checker_principal:t.Opt(t.Principal),min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),n=t.Variant({Mainnet:t.Null,Regtest:t.Null,Testnet:t.Null}),o=t.Record({get_utxos_cache_expiration_seconds:t.Opt(t.Nat64),kyt_principal:t.Opt(t.Principal),ecdsa_key_name:t.Text,mode:e,retrieve_btc_min_amount:t.Nat64,ledger_id:t.Principal,max_time_in_queue_nanos:t.Nat64,btc_network:n,check_fee:t.Opt(t.Nat64),btc_checker_principal:t.Opt(t.Principal),min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),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}),m=t.Variant({ValueTooSmall:t.Null,Quarantined:t.Null}),b=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)}),y=t.Variant({too_many_inputs:t.Record({max_num_inputs:t.Nat64,num_inputs:t.Nat64})}),w=t.Variant({invalid_transaction:y}),V=t.Variant({to_cancel:t.Record({reason:w}),to_retry:t.Null}),A=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:m}),accepted_retrieve_btc_request:t.Record({received_at:t.Nat64,block_index:t.Nat64,address:b,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:w}),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(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})}),lt=t.Record({timestamp:t.Opt(t.Nat64),payload:A}),ut=t.Record({retrieve_btc_min_amount:t.Nat64,min_confirmations:t.Nat32,kyt_fee:t.Nat64}),dt=t.Record({address:t.Text,amount:t.Nat64}),C=t.Record({block_index:t.Nat64}),_t=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})}),pt=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}),ft=t.Record({account:d,amount:t.Nat64,reason:f}),ht=t.Record({account:d,mint_block_index:t.Nat64,amount:t.Nat64,reason:f}),H=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:ft,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Reimbursed:ht,Pending:t.Null}),xt=t.Record({from_subaccount:t.Opt(t.Vec(t.Nat8)),address:t.Text,amount:t.Nat64}),mt=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})}),bt=t.Variant({ValueTooSmall:u,Tainted:u,Minted:t.Record({minted_amount:t.Nat64,block_index:t.Nat64,utxo:u}),Checked:u}),Nt=t.Nat64,gt=t.Record({utxo:u,earliest_retry:Nt,reason:m}),yt=t.Record({confirmations:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),wt=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(gt)),required_confirmations:t.Nat32,pending_utxos:t.Opt(t.Vec(yt)),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(lt)],["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([],[ut],["query"]),get_withdrawal_account:t.Func([],[d],[]),retrieve_btc:t.Func([dt],[t.Variant({Ok:C,Err:_t})],[]),retrieve_btc_status:t.Func([t.Record({block_index:t.Nat64})],[pt],["query"]),retrieve_btc_status_v2:t.Func([t.Record({block_index:t.Nat64})],[H],["query"]),retrieve_btc_status_v2_by_account:t.Func([t.Opt(d)],[t.Vec(t.Record({block_index:t.Nat64,status_v2:t.Opt(H)}))],["query"]),retrieve_btc_with_approval:t.Func([xt],[t.Variant({Ok:C,Err:mt})],[]),update_balance:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Variant({Ok:t.Vec(bt),Err:wt})],[])})};var nt=class t extends x.Canister{static create(e){let{service:r,certifiedService:n,canisterId:o}=(0,x.createServices)({options:e,idlFactory:Mt,certifiedIdlFactory:Wt});return new t(o,r,n)}getBtcAddress=({owner:e,subaccount:r})=>this.caller({certified:!0}).get_btc_address({owner:(0,x.toNullable)(e),subaccount:(0,x.toNullable)(r)});updateBalance=async({owner:e,subaccount:r})=>{let n=await this.caller({certified:!0}).update_balance({owner:(0,x.toNullable)(e),subaccount:(0,x.toNullable)(r)});if("Err"in n)throw At(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 rt(r.Err);return r.Ok};retrieveBtcWithApproval=async({address:e,amount:r,fromSubaccount:n})=>{let o=await this.caller({certified:!0}).retrieve_btc_with_approval({address:e,amount:r,from_subaccount:(0,x.toNullable)(n)});if("Err"in o)throw Bt(o.Err);return o.Ok};retrieveBtcStatus=({transactionId:e,certified:r})=>this.caller({certified:r}).retrieve_btc_status({block_index:e});retrieveBtcStatusV2ByAccount=async({account:e,certified:r})=>{let{retrieve_btc_status_v2_by_account:n}=this.caller({certified:r});return(await n((0,x.isNullish)(e)?[]:[{owner:e.owner,subaccount:(0,x.toNullable)(e.subaccount)}])).map(({block_index:c,status_v2:a})=>({id:c,status:(0,x.fromNullable)(a)}))};estimateWithdrawalFee=({certified:e,amount:r})=>this.caller({certified:e}).estimate_withdrawal_fee({amount:(0,x.toNullable)(r)});getMinterInfo=({certified:e})=>this.caller({certified:e}).get_minter_info();getKnownUtxos=({owner:e,subaccount:r,certified:n})=>{let{get_known_utxos:o}=this.caller({certified:n});return o({owner:(0,x.toNullable)(e),subaccount:(0,x.toNullable)(r)})}};var Ct=require("@dfinity/utils");function ie(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function at(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+", got length="+t.length)}function Pt(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 zt(t,e){at(t);let r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function $(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function ct(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function g(t,e){return t<<32-e|t>>>e}function se(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function Tt(t){return typeof t=="string"&&(t=se(t)),at(t),t}var ot=class{};function Qt(t){let e=n=>t().update(Tt(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),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 $t(t,e,r){return t&e^~t&r}function jt(t,e,r){return t&e^t&r^e&r}var it=class extends ot{constructor(e,r,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(e),this.view=ct(this.buffer)}update(e){Pt(this),e=Tt(e),at(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=ct(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){Pt(this),zt(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)),this.padOffset>o-a&&(this.process(n,0),a=0);for(let l=a;l<o;l++)r[l]=0;le(n,o-8,BigInt(this.length*8),c),this.process(n,0);let i=ct(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 ue=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),v=new Uint32Array(64),Ut=class extends it{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)v[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){let d=v[l-15],u=v[l-2],f=g(d,7)^g(d,18)^d>>>3,h=g(u,17)^g(u,19)^u>>>10;v[l]=h+v[l-7]+f+v[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=g(i,6)^g(i,11)^g(i,25),u=_+d+$t(i,s,p)+ue[l]+v[l]|0,h=(g(n,2)^g(n,13)^g(n,22))+jt(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(){$(v)}destroy(){this.set(0,0,0,0,0,0,0,0),$(this.buffer)}};var Ft=Qt(()=>new Ut);var de="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Kt=de;function _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=>Kt.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 Et=_e;var j=oe(Zt());var xe=0,me=5,be=111,Ne=196,ge={[xe]:{type:1,networks:[0]},[be]:{type:1,networks:[2,1]},[me]:{type:2,networks:[0]},[Ne]:{type:2,networks:[2,1]}},ye=({address:t,network:e})=>{let n=(_=>{try{return Et(_)}catch{throw new T}})(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=Ft.create();u.update(d);let f=Ft.create();f.update(u.digest());let h=f.digest().slice(0,4);if(l.some((m,b)=>m!==h[b]))throw new B(`Checksum mismatch expected ${l}, got ${h}.`)})(n);let[a]=n,i=ge[a];if((0,Ct.isNullish)(i))throw new U;let{type:s,networks:p}=i;if(!p.includes(e))throw new z;return{address:t,network:e,type:s,parser:"base58"}},we=({address:t,network:e})=>{let r=_=>{try{return _.startsWith("bc1p")||_.startsWith("tb1p")||_.startsWith("bcrt1p")?j.bech32m.decode(_):j.bech32.decode(_)}catch{throw new B}},{prefix:n,words:o}=r(t),a={bc:0,tb:2,bcrt:1}[n];if((0,Ct.isNullish)(a))throw new T;if(a!==e)throw new M;let[i,...s]=o;if(i>1)throw new W;switch(j.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}},Re=({address:t,network:e=0})=>{switch(t.charAt(0)){case"1":case"2":case"3":case"m":case"n":return ye({address:t,network:e});case"b":case"B":case"t":case"T":return we({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,toGetBalanceParams,toGetUtxosParams});
|
|
2
2
|
/*! Bundled license information:
|
|
3
3
|
|
|
4
4
|
@noble/hashes/esm/utils.js:
|