@dfinity/ckbtc 1.1.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/candid/minter.certified.idl.js +6 -0
- package/dist/candid/minter.d.ts +35 -19
- package/dist/candid/minter.did +10 -2
- package/dist/candid/minter.idl.js +6 -0
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/index.cjs.js.map +3 -3
- package/dist/esm/chunk-VQD66NVJ.js +2 -0
- package/dist/esm/chunk-VQD66NVJ.js.map +7 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/minter.canister.js +1 -1
- package/dist/types/errors/minter.errors.d.ts +7 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
- package/dist/esm/chunk-XGTBIGYK.js +0 -2
- package/dist/esm/chunk-XGTBIGYK.js.map +0 -7
|
@@ -198,6 +198,11 @@ export const idlFactory = ({ IDL }) => {
|
|
|
198
198
|
}),
|
|
199
199
|
'Checked' : Utxo,
|
|
200
200
|
});
|
|
201
|
+
const PendingUtxo = IDL.Record({
|
|
202
|
+
'confirmations' : IDL.Nat32,
|
|
203
|
+
'value' : IDL.Nat64,
|
|
204
|
+
'outpoint' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8), 'vout' : IDL.Nat32 }),
|
|
205
|
+
});
|
|
201
206
|
const UpdateBalanceError = IDL.Variant({
|
|
202
207
|
'GenericError' : IDL.Record({
|
|
203
208
|
'error_message' : IDL.Text,
|
|
@@ -207,6 +212,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
207
212
|
'AlreadyProcessing' : IDL.Null,
|
|
208
213
|
'NoNewUtxos' : IDL.Record({
|
|
209
214
|
'required_confirmations' : IDL.Nat32,
|
|
215
|
+
'pending_utxos' : IDL.Opt(IDL.Vec(PendingUtxo)),
|
|
210
216
|
'current_confirmations' : IDL.Opt(IDL.Nat32),
|
|
211
217
|
}),
|
|
212
218
|
});
|
package/dist/candid/minter.d.ts
CHANGED
|
@@ -3,14 +3,14 @@ import type { Principal } from "@dfinity/principal";
|
|
|
3
3
|
|
|
4
4
|
export interface Account {
|
|
5
5
|
owner: Principal;
|
|
6
|
-
subaccount: [] | [Uint8Array];
|
|
6
|
+
subaccount: [] | [Uint8Array | number[]];
|
|
7
7
|
}
|
|
8
8
|
export type BitcoinAddress =
|
|
9
|
-
| { p2wsh_v0: Uint8Array }
|
|
10
|
-
| { p2tr_v1: Uint8Array }
|
|
11
|
-
| { p2sh: Uint8Array }
|
|
12
|
-
| { p2wpkh_v0: Uint8Array }
|
|
13
|
-
| { p2pkh: Uint8Array };
|
|
9
|
+
| { p2wsh_v0: Uint8Array | number[] }
|
|
10
|
+
| { p2tr_v1: Uint8Array | number[] }
|
|
11
|
+
| { p2sh: Uint8Array | number[] }
|
|
12
|
+
| { p2wpkh_v0: Uint8Array | number[] }
|
|
13
|
+
| { p2pkh: Uint8Array | number[] };
|
|
14
14
|
export type BtcNetwork =
|
|
15
15
|
| { Mainnet: null }
|
|
16
16
|
| { Regtest: null }
|
|
@@ -21,7 +21,7 @@ export interface CanisterStatusResponse {
|
|
|
21
21
|
cycles: bigint;
|
|
22
22
|
settings: DefiniteCanisterSettings;
|
|
23
23
|
idle_cycles_burned_per_day: bigint;
|
|
24
|
-
module_hash: [] | [Uint8Array];
|
|
24
|
+
module_hash: [] | [Uint8Array | number[]];
|
|
25
25
|
}
|
|
26
26
|
export type CanisterStatusType =
|
|
27
27
|
| { stopped: null }
|
|
@@ -53,9 +53,9 @@ export type Event =
|
|
|
53
53
|
sent_transaction: {
|
|
54
54
|
fee: [] | [bigint];
|
|
55
55
|
change_output: [] | [{ value: bigint; vout: number }];
|
|
56
|
-
txid: Uint8Array;
|
|
56
|
+
txid: Uint8Array | number[];
|
|
57
57
|
utxos: Array<Utxo>;
|
|
58
|
-
requests: BigUint64Array;
|
|
58
|
+
requests: BigUint64Array | bigint[];
|
|
59
59
|
submitted_at: bigint;
|
|
60
60
|
};
|
|
61
61
|
}
|
|
@@ -96,13 +96,13 @@ export type Event =
|
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
98
|
| { removed_retrieve_btc_request: { block_index: bigint } }
|
|
99
|
-
| { confirmed_transaction: { txid: Uint8Array } }
|
|
99
|
+
| { confirmed_transaction: { txid: Uint8Array | number[] } }
|
|
100
100
|
| {
|
|
101
101
|
replaced_transaction: {
|
|
102
102
|
fee: bigint;
|
|
103
103
|
change_output: { value: bigint; vout: number };
|
|
104
|
-
old_txid: Uint8Array;
|
|
105
|
-
new_txid: Uint8Array;
|
|
104
|
+
old_txid: Uint8Array | number[];
|
|
105
|
+
new_txid: Uint8Array | number[];
|
|
106
106
|
submitted_at: bigint;
|
|
107
107
|
};
|
|
108
108
|
}
|
|
@@ -135,6 +135,11 @@ export type Mode =
|
|
|
135
135
|
| { DepositsRestrictedTo: Array<Principal> }
|
|
136
136
|
| { ReadOnly: null }
|
|
137
137
|
| { GeneralAvailability: null };
|
|
138
|
+
export interface PendingUtxo {
|
|
139
|
+
confirmations: number;
|
|
140
|
+
value: bigint;
|
|
141
|
+
outpoint: { txid: Uint8Array | number[]; vout: number };
|
|
142
|
+
}
|
|
138
143
|
export type ReimbursementReason =
|
|
139
144
|
| { CallFailed: null }
|
|
140
145
|
| { TaintedDestination: { kyt_fee: bigint; kyt_provider: Principal } };
|
|
@@ -154,14 +159,14 @@ export interface RetrieveBtcOk {
|
|
|
154
159
|
}
|
|
155
160
|
export type RetrieveBtcStatus =
|
|
156
161
|
| { Signing: null }
|
|
157
|
-
| { Confirmed: { txid: Uint8Array } }
|
|
158
|
-
| { Sending: { txid: Uint8Array } }
|
|
162
|
+
| { Confirmed: { txid: Uint8Array | number[] } }
|
|
163
|
+
| { Sending: { txid: Uint8Array | number[] } }
|
|
159
164
|
| { AmountTooLow: null }
|
|
160
165
|
| { Unknown: null }
|
|
161
|
-
| { Submitted: { txid: Uint8Array } }
|
|
166
|
+
| { Submitted: { txid: Uint8Array | number[] } }
|
|
162
167
|
| { Pending: null };
|
|
163
168
|
export interface RetrieveBtcWithApprovalArgs {
|
|
164
|
-
from_subaccount: [] | [Uint8Array];
|
|
169
|
+
from_subaccount: [] | [Uint8Array | number[]];
|
|
165
170
|
address: string;
|
|
166
171
|
amount: bigint;
|
|
167
172
|
}
|
|
@@ -182,6 +187,7 @@ export type UpdateBalanceError =
|
|
|
182
187
|
| {
|
|
183
188
|
NoNewUtxos: {
|
|
184
189
|
required_confirmations: number;
|
|
190
|
+
pending_utxos: [] | [Array<PendingUtxo>];
|
|
185
191
|
current_confirmations: [] | [number];
|
|
186
192
|
};
|
|
187
193
|
};
|
|
@@ -196,7 +202,7 @@ export interface UpgradeArgs {
|
|
|
196
202
|
export interface Utxo {
|
|
197
203
|
height: number;
|
|
198
204
|
value: bigint;
|
|
199
|
-
outpoint: { txid: Uint8Array; vout: number };
|
|
205
|
+
outpoint: { txid: Uint8Array | number[]; vout: number };
|
|
200
206
|
}
|
|
201
207
|
export type UtxoStatus =
|
|
202
208
|
| { ValueTooSmall: Utxo }
|
|
@@ -215,7 +221,12 @@ export interface _SERVICE {
|
|
|
215
221
|
{ minter_fee: bigint; bitcoin_fee: bigint }
|
|
216
222
|
>;
|
|
217
223
|
get_btc_address: ActorMethod<
|
|
218
|
-
[
|
|
224
|
+
[
|
|
225
|
+
{
|
|
226
|
+
owner: [] | [Principal];
|
|
227
|
+
subaccount: [] | [Uint8Array | number[]];
|
|
228
|
+
},
|
|
229
|
+
],
|
|
219
230
|
string
|
|
220
231
|
>;
|
|
221
232
|
get_canister_status: ActorMethod<[], CanisterStatusResponse>;
|
|
@@ -236,7 +247,12 @@ export interface _SERVICE {
|
|
|
236
247
|
{ Ok: RetrieveBtcOk } | { Err: RetrieveBtcWithApprovalError }
|
|
237
248
|
>;
|
|
238
249
|
update_balance: ActorMethod<
|
|
239
|
-
[
|
|
250
|
+
[
|
|
251
|
+
{
|
|
252
|
+
owner: [] | [Principal];
|
|
253
|
+
subaccount: [] | [Uint8Array | number[]];
|
|
254
|
+
},
|
|
255
|
+
],
|
|
240
256
|
{ Ok: Array<UtxoStatus> } | { Err: UpdateBalanceError }
|
|
241
257
|
>;
|
|
242
258
|
}
|
package/dist/candid/minter.did
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated from IC repo commit
|
|
1
|
+
// Generated from IC repo commit 4de99bc27b (2023-11-20) '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
|
|
|
@@ -101,11 +101,19 @@ type UtxoStatus = variant {
|
|
|
101
101
|
};
|
|
102
102
|
};
|
|
103
103
|
|
|
104
|
+
// Utxos that don't have enough confirmations to be processed.
|
|
105
|
+
type PendingUtxo = record {
|
|
106
|
+
outpoint : record { txid : vec nat8; vout : nat32 };
|
|
107
|
+
value : nat64;
|
|
108
|
+
confirmations: nat32;
|
|
109
|
+
};
|
|
110
|
+
|
|
104
111
|
type UpdateBalanceError = variant {
|
|
105
112
|
// There are no new UTXOs to process.
|
|
106
113
|
NoNewUtxos : record {
|
|
107
114
|
current_confirmations: opt nat32;
|
|
108
|
-
required_confirmations: nat32
|
|
115
|
+
required_confirmations: nat32;
|
|
116
|
+
pending_utxos: opt vec PendingUtxo;
|
|
109
117
|
};
|
|
110
118
|
// The minter is already processing another update balance request for the caller.
|
|
111
119
|
AlreadyProcessing;
|
|
@@ -198,6 +198,11 @@ export const idlFactory = ({ IDL }) => {
|
|
|
198
198
|
}),
|
|
199
199
|
'Checked' : Utxo,
|
|
200
200
|
});
|
|
201
|
+
const PendingUtxo = IDL.Record({
|
|
202
|
+
'confirmations' : IDL.Nat32,
|
|
203
|
+
'value' : IDL.Nat64,
|
|
204
|
+
'outpoint' : IDL.Record({ 'txid' : IDL.Vec(IDL.Nat8), 'vout' : IDL.Nat32 }),
|
|
205
|
+
});
|
|
201
206
|
const UpdateBalanceError = IDL.Variant({
|
|
202
207
|
'GenericError' : IDL.Record({
|
|
203
208
|
'error_message' : IDL.Text,
|
|
@@ -207,6 +212,7 @@ export const idlFactory = ({ IDL }) => {
|
|
|
207
212
|
'AlreadyProcessing' : IDL.Null,
|
|
208
213
|
'NoNewUtxos' : IDL.Record({
|
|
209
214
|
'required_confirmations' : IDL.Nat32,
|
|
215
|
+
'pending_utxos' : IDL.Opt(IDL.Vec(PendingUtxo)),
|
|
210
216
|
'current_confirmations' : IDL.Opt(IDL.Nat32),
|
|
211
217
|
}),
|
|
212
218
|
});
|
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var We=Object.create;var W=Object.defineProperty;var qe=Object.getOwnPropertyDescriptor;var Ge=Object.getOwnPropertyNames;var $e=Object.getPrototypeOf,He=Object.prototype.hasOwnProperty;var A=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),je=(e,t)=>{for(var r in t)W(e,r,{get:t[r],enumerable:!0})},xe=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ge(t))!He.call(e,o)&&o!==r&&W(e,o,{get:()=>t[o],enumerable:!(n=qe(t,o))||n.enumerable});return e};var Ne=(e,t,r)=>(r=e!=null?We($e(e)):{},xe(t||!e||!e.__esModule?W(r,"default",{value:e,enumerable:!0}):r,e)),ze=e=>xe(W({},"__esModule",{value:!0}),e);var L=A((St,Re)=>{"use strict";var De="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";Re.exports=De});var ke=A((Wt,ve)=>{"use strict";var et=L(),tt=e=>{if(!e||typeof e!="string")throw new Error(`Expected base58 string but got \u201C${e}\u201D`);if(e.match(/[IOl0]/gmu))throw new Error(`Invalid base58 character \u201C${e.match(/[IOl0]/gmu)}\u201D`);let t=e.match(/^1+/gmu),r=t?t[0].length:0,n=(e.length-r)*(Math.log(58)/Math.log(256))+1>>>0;return new Uint8Array([...new Uint8Array(r),...e.match(/.{1}/gmu).map(o=>et.indexOf(o)).reduce((o,c)=>(o=o.map(i=>{let a=i*58+c;return c=a>>8,a}),o),new Uint8Array(n)).reverse().filter((o=>c=>o=o||c)(!1))])};ve.exports=tt});var Ve=A((qt,Oe)=>{"use strict";var Ae=L(),rt=()=>{let e=Array(256).fill(-1);for(let t=0;t<Ae.length;++t)e[Ae.charCodeAt(t)]=t;return e};Oe.exports=rt});var Pe=A((Gt,Be)=>{"use strict";var Te=L(),nt=Ve(),ot=nt(),it=e=>{let t=[];for(let r of e){let n=r;for(let o=0;o<t.length;++o){let c=(ot[t[o]]<<8)+n;t[o]=Te.charCodeAt(c%58),n=c/58|0}for(;n;)t.push(Te.charCodeAt(n%58)),n=n/58|0}for(let r of e){if(r)break;t.push("1".charCodeAt(0))}return t.reverse(),String.fromCharCode(...t)};Be.exports=it});var Ee=A(_e=>{"use strict";_e.base58_to_binary=ke();_e.binary_to_base58=Pe()});var Me=A(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});B.bech32m=B.bech32=void 0;var D="qpzry9x8gf2tvdw0s3jn54khce6mua7l",Ce={};for(let e=0;e<D.length;e++){let t=D.charAt(e);Ce[t]=e}function T(e){let t=e>>25;return(e&33554431)<<5^-(t>>0&1)&996825010^-(t>>1&1)&642813549^-(t>>2&1)&513874426^-(t>>3&1)&1027748829^-(t>>4&1)&705979059}function Ue(e){let t=1;for(let r=0;r<e.length;++r){let n=e.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+e+")";t=T(t)^n>>5}t=T(t);for(let r=0;r<e.length;++r){let n=e.charCodeAt(r);t=T(t)^n&31}return t}function he(e,t,r,n){let o=0,c=0,i=(1<<r)-1,a=[];for(let u=0;u<e.length;++u)for(o=o<<t|e[u],c+=t;c>=r;)c-=r,a.push(o>>c&i);if(n)c>0&&a.push(o<<r-c&i);else{if(c>=t)return"Excess padding";if(o<<r-c&i)return"Non-zero padding"}return a}function ct(e){return he(e,8,5,!0)}function at(e){let t=he(e,5,8,!1);if(Array.isArray(t))return t}function st(e){let t=he(e,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}function Fe(e){let t;e==="bech32"?t=1:t=734539939;function r(i,a,u){if(u=u||90,i.length+7+a.length>u)throw new TypeError("Exceeds length limit");i=i.toLowerCase();let l=Ue(i);if(typeof l=="string")throw new Error(l);let d=i+"1";for(let s=0;s<a.length;++s){let p=a[s];if(p>>5)throw new Error("Non 5-bit word");l=T(l)^p,d+=D.charAt(p)}for(let s=0;s<6;++s)l=T(l);l^=t;for(let s=0;s<6;++s){let p=l>>(5-s)*5&31;d+=D.charAt(p)}return d}function n(i,a){if(a=a||90,i.length<8)return i+" too short";if(i.length>a)return"Exceeds length limit";let u=i.toLowerCase(),l=i.toUpperCase();if(i!==u&&i!==l)return"Mixed-case string "+i;i=u;let d=i.lastIndexOf("1");if(d===-1)return"No separator character for "+i;if(d===0)return"Missing prefix for "+i;let s=i.slice(0,d),p=i.slice(d+1);if(p.length<6)return"Data too short";let f=Ue(s);if(typeof f=="string")return f;let h=[];for(let _=0;_<p.length;++_){let b=p.charAt(_),w=Ce[b];if(w===void 0)return"Unknown character "+b;f=T(f)^w,!(_+6>=p.length)&&h.push(w)}return f!==t?"Invalid checksum for "+i:{prefix:s,words:h}}function o(i,a){let u=n(i,a);if(typeof u=="object")return u}function c(i,a){let u=n(i,a);if(typeof u=="object")return u;throw new Error(u)}return{decodeUnsafe:o,decode:c,encode:r,toWords:ct,fromWordsUnsafe:at,fromWords:st}}B.bech32=Fe("bech32");B.bech32m=Fe("bech32m")});var xt={};je(xt,{BtcAddressType:()=>ce,BtcNetwork:()=>ie,CkBTCMinterCanister:()=>K,MinterAlreadyProcessingError:()=>G,MinterAmountTooLowError:()=>j,MinterGenericError:()=>g,MinterInsufficientAllowanceError:()=>X,MinterInsufficientFundsError:()=>z,MinterMalformedAddressError:()=>H,MinterNoNewUtxosError:()=>$,MinterRetrieveBtcError:()=>y,MinterTemporaryUnavailableError:()=>q,MinterUpdateBalanceError:()=>M,ParseBtcAddressBadWitnessLengthError:()=>E,ParseBtcAddressError:()=>m,ParseBtcAddressInvalidError:()=>O,ParseBtcAddressMalformedAddressError:()=>k,ParseBtcAddressNoDataError:()=>P,ParseBtcAddressUnexpectedHumanReadablePartError:()=>C,ParseBtcAddressUnsupportedAddressTypeError:()=>V,ParseBtcAddressUnsupportedWitnessVersionError:()=>U,ParseBtcAddressWrongNetworkError:()=>F,createRetrieveBtcError:()=>Q,createRetrieveBtcWithApprovalError:()=>de,createUpdateBalanceError:()=>se,parseBtcAddress:()=>mt});module.exports=ze(xt);var ie=(n=>(n[n.Mainnet=0]="Mainnet",n[n.Regtest=1]="Regtest",n[n.Testnet=2]="Testnet",n))(ie||{}),ce=(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))(ce||{});var m=class extends Error{},O=class extends m{},P=class extends m{},V=class extends m{},E=class extends m{},U=class extends m{},C=class extends m{},k=class extends m{},F=class extends m{};var J=require("@dfinity/utils"),g=class extends Error{},q=class extends g{},G=class extends g{},M=class extends g{},$=class extends M{},y=class extends g{},H=class extends y{},j=class extends y{},z=class extends y{},X=class extends y{},ae=e=>{if("GenericError"in e){let{GenericError:{error_message:t,error_code:r}}=e;return new g(`${t} (${r})`)}if("TemporarilyUnavailable"in e)return new q(e.TemporarilyUnavailable);if("AlreadyProcessing"in e)return new G},se=e=>{let t=ae(e);return(0,J.nonNullish)(t)?t:"NoNewUtxos"in e?new $:new M(`Unsupported response type in minter.updateBalance ${JSON.stringify(e)}`)},Q=e=>{let t=ae(e);return(0,J.nonNullish)(t)?t:"MalformedAddress"in e?new H(e.MalformedAddress):"AmountTooLow"in e?new j(`${e.AmountTooLow}`):"InsufficientFunds"in e?new z(`${e.InsufficientFunds.balance}`):new y(`Unsupported response type in minter.retrieveBtc ${JSON.stringify(e)}`)},de=e=>{let t=ae(e);return(0,J.nonNullish)(t)?t:"InsufficientAllowance"in e?new X(`${e.InsufficientAllowance.allowance}`):Q(e)};var x=require("@dfinity/utils");var be=({IDL:e})=>{let t=e.Variant({RestrictedTo:e.Vec(e.Principal),DepositsRestrictedTo:e.Vec(e.Principal),ReadOnly:e.Null,GeneralAvailability:e.Null}),r=e.Record({kyt_principal:e.Opt(e.Principal),mode:e.Opt(t),retrieve_btc_min_amount:e.Opt(e.Nat64),max_time_in_queue_nanos:e.Opt(e.Nat64),min_confirmations:e.Opt(e.Nat32),kyt_fee:e.Opt(e.Nat64)}),n=e.Variant({Mainnet:e.Null,Regtest:e.Null,Testnet:e.Null}),o=e.Record({kyt_principal:e.Opt(e.Principal),ecdsa_key_name:e.Text,mode:t,retrieve_btc_min_amount:e.Nat64,ledger_id:e.Principal,max_time_in_queue_nanos:e.Nat64,btc_network:n,min_confirmations:e.Opt(e.Nat32),kyt_fee:e.Opt(e.Nat64)}),c=e.Variant({Upgrade:e.Opt(r),Init:o}),i=e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),a=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),memory_allocation:e.Nat,compute_allocation:e.Nat}),u=e.Record({status:i,memory_size:e.Nat,cycles:e.Nat,settings:a,idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8))}),l=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),d=e.Record({height:e.Nat32,value:e.Nat64,outpoint:e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32})}),s=e.Variant({CallFailed:e.Null,TaintedDestination:e.Record({kyt_fee:e.Nat64,kyt_provider:e.Principal})}),p=e.Variant({p2wsh_v0:e.Vec(e.Nat8),p2tr_v1:e.Vec(e.Nat8),p2sh:e.Vec(e.Nat8),p2wpkh_v0:e.Vec(e.Nat8),p2pkh:e.Vec(e.Nat8)}),f=e.Variant({received_utxos:e.Record({to_account:l,mint_txid:e.Opt(e.Nat64),utxos:e.Vec(d)}),schedule_deposit_reimbursement:e.Record({burn_block_index:e.Nat64,account:l,amount:e.Nat64,reason:s}),sent_transaction:e.Record({fee:e.Opt(e.Nat64),change_output:e.Opt(e.Record({value:e.Nat64,vout:e.Nat32})),txid:e.Vec(e.Nat8),utxos:e.Vec(d),requests:e.Vec(e.Nat64),submitted_at:e.Nat64}),distributed_kyt_fee:e.Record({block_index:e.Nat64,amount:e.Nat64,kyt_provider:e.Principal}),init:o,upgrade:r,retrieve_btc_kyt_failed:e.Record({block_index:e.Nat64,owner:e.Principal,uuid:e.Text,address:e.Text,amount:e.Nat64,kyt_provider:e.Principal}),accepted_retrieve_btc_request:e.Record({received_at:e.Nat64,block_index:e.Nat64,address:p,amount:e.Nat64,kyt_provider:e.Opt(e.Principal)}),checked_utxo:e.Record({clean:e.Bool,utxo:d,uuid:e.Text,kyt_provider:e.Opt(e.Principal)}),removed_retrieve_btc_request:e.Record({block_index:e.Nat64}),confirmed_transaction:e.Record({txid:e.Vec(e.Nat8)}),replaced_transaction:e.Record({fee:e.Nat64,change_output:e.Record({value:e.Nat64,vout:e.Nat32}),old_txid:e.Vec(e.Nat8),new_txid:e.Vec(e.Nat8),submitted_at:e.Nat64}),ignored_utxo:e.Record({utxo:d}),reimbursed_failed_deposit:e.Record({burn_block_index:e.Nat64,mint_block_index:e.Nat64})}),h=e.Record({retrieve_btc_min_amount:e.Nat64,min_confirmations:e.Nat32,kyt_fee:e.Nat64}),_=e.Record({address:e.Text,amount:e.Nat64}),b=e.Record({block_index:e.Nat64}),w=e.Variant({MalformedAddress:e.Text,GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,AlreadyProcessing:e.Null,AmountTooLow:e.Nat64,InsufficientFunds:e.Record({balance:e.Nat64})}),ee=e.Variant({Signing:e.Null,Confirmed:e.Record({txid:e.Vec(e.Nat8)}),Sending:e.Record({txid:e.Vec(e.Nat8)}),AmountTooLow:e.Null,Unknown:e.Null,Submitted:e.Record({txid:e.Vec(e.Nat8)}),Pending:e.Null}),te=e.Record({from_subaccount:e.Opt(e.Vec(e.Nat8)),address:e.Text,amount:e.Nat64}),re=e.Variant({MalformedAddress:e.Text,GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,InsufficientAllowance:e.Record({allowance:e.Nat64}),AlreadyProcessing:e.Null,AmountTooLow:e.Nat64,InsufficientFunds:e.Record({balance:e.Nat64})}),ne=e.Variant({ValueTooSmall:d,Tainted:d,Minted:e.Record({minted_amount:e.Nat64,block_index:e.Nat64,utxo:d}),Checked:d}),oe=e.Variant({GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,AlreadyProcessing:e.Null,NoNewUtxos:e.Record({required_confirmations:e.Nat32,current_confirmations:e.Opt(e.Nat32)})});return e.Service({estimate_withdrawal_fee:e.Func([e.Record({amount:e.Opt(e.Nat64)})],[e.Record({minter_fee:e.Nat64,bitcoin_fee:e.Nat64})],[]),get_btc_address:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Text],[]),get_canister_status:e.Func([],[u],[]),get_deposit_fee:e.Func([],[e.Nat64],[]),get_events:e.Func([e.Record({start:e.Nat64,length:e.Nat64})],[e.Vec(f)],[]),get_minter_info:e.Func([],[h],[]),get_withdrawal_account:e.Func([],[l],[]),retrieve_btc:e.Func([_],[e.Variant({Ok:b,Err:w})],[]),retrieve_btc_status:e.Func([e.Record({block_index:e.Nat64})],[ee],[]),retrieve_btc_with_approval:e.Func([te],[e.Variant({Ok:b,Err:re})],[]),update_balance:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Variant({Ok:e.Vec(ne),Err:oe})],[])})};var we=({IDL:e})=>{let t=e.Variant({RestrictedTo:e.Vec(e.Principal),DepositsRestrictedTo:e.Vec(e.Principal),ReadOnly:e.Null,GeneralAvailability:e.Null}),r=e.Record({kyt_principal:e.Opt(e.Principal),mode:e.Opt(t),retrieve_btc_min_amount:e.Opt(e.Nat64),max_time_in_queue_nanos:e.Opt(e.Nat64),min_confirmations:e.Opt(e.Nat32),kyt_fee:e.Opt(e.Nat64)}),n=e.Variant({Mainnet:e.Null,Regtest:e.Null,Testnet:e.Null}),o=e.Record({kyt_principal:e.Opt(e.Principal),ecdsa_key_name:e.Text,mode:t,retrieve_btc_min_amount:e.Nat64,ledger_id:e.Principal,max_time_in_queue_nanos:e.Nat64,btc_network:n,min_confirmations:e.Opt(e.Nat32),kyt_fee:e.Opt(e.Nat64)}),c=e.Variant({Upgrade:e.Opt(r),Init:o}),i=e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),a=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),memory_allocation:e.Nat,compute_allocation:e.Nat}),u=e.Record({status:i,memory_size:e.Nat,cycles:e.Nat,settings:a,idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8))}),l=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),d=e.Record({height:e.Nat32,value:e.Nat64,outpoint:e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32})}),s=e.Variant({CallFailed:e.Null,TaintedDestination:e.Record({kyt_fee:e.Nat64,kyt_provider:e.Principal})}),p=e.Variant({p2wsh_v0:e.Vec(e.Nat8),p2tr_v1:e.Vec(e.Nat8),p2sh:e.Vec(e.Nat8),p2wpkh_v0:e.Vec(e.Nat8),p2pkh:e.Vec(e.Nat8)}),f=e.Variant({received_utxos:e.Record({to_account:l,mint_txid:e.Opt(e.Nat64),utxos:e.Vec(d)}),schedule_deposit_reimbursement:e.Record({burn_block_index:e.Nat64,account:l,amount:e.Nat64,reason:s}),sent_transaction:e.Record({fee:e.Opt(e.Nat64),change_output:e.Opt(e.Record({value:e.Nat64,vout:e.Nat32})),txid:e.Vec(e.Nat8),utxos:e.Vec(d),requests:e.Vec(e.Nat64),submitted_at:e.Nat64}),distributed_kyt_fee:e.Record({block_index:e.Nat64,amount:e.Nat64,kyt_provider:e.Principal}),init:o,upgrade:r,retrieve_btc_kyt_failed:e.Record({block_index:e.Nat64,owner:e.Principal,uuid:e.Text,address:e.Text,amount:e.Nat64,kyt_provider:e.Principal}),accepted_retrieve_btc_request:e.Record({received_at:e.Nat64,block_index:e.Nat64,address:p,amount:e.Nat64,kyt_provider:e.Opt(e.Principal)}),checked_utxo:e.Record({clean:e.Bool,utxo:d,uuid:e.Text,kyt_provider:e.Opt(e.Principal)}),removed_retrieve_btc_request:e.Record({block_index:e.Nat64}),confirmed_transaction:e.Record({txid:e.Vec(e.Nat8)}),replaced_transaction:e.Record({fee:e.Nat64,change_output:e.Record({value:e.Nat64,vout:e.Nat32}),old_txid:e.Vec(e.Nat8),new_txid:e.Vec(e.Nat8),submitted_at:e.Nat64}),ignored_utxo:e.Record({utxo:d}),reimbursed_failed_deposit:e.Record({burn_block_index:e.Nat64,mint_block_index:e.Nat64})}),h=e.Record({retrieve_btc_min_amount:e.Nat64,min_confirmations:e.Nat32,kyt_fee:e.Nat64}),_=e.Record({address:e.Text,amount:e.Nat64}),b=e.Record({block_index:e.Nat64}),w=e.Variant({MalformedAddress:e.Text,GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,AlreadyProcessing:e.Null,AmountTooLow:e.Nat64,InsufficientFunds:e.Record({balance:e.Nat64})}),ee=e.Variant({Signing:e.Null,Confirmed:e.Record({txid:e.Vec(e.Nat8)}),Sending:e.Record({txid:e.Vec(e.Nat8)}),AmountTooLow:e.Null,Unknown:e.Null,Submitted:e.Record({txid:e.Vec(e.Nat8)}),Pending:e.Null}),te=e.Record({from_subaccount:e.Opt(e.Vec(e.Nat8)),address:e.Text,amount:e.Nat64}),re=e.Variant({MalformedAddress:e.Text,GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,InsufficientAllowance:e.Record({allowance:e.Nat64}),AlreadyProcessing:e.Null,AmountTooLow:e.Nat64,InsufficientFunds:e.Record({balance:e.Nat64})}),ne=e.Variant({ValueTooSmall:d,Tainted:d,Minted:e.Record({minted_amount:e.Nat64,block_index:e.Nat64,utxo:d}),Checked:d}),oe=e.Variant({GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,AlreadyProcessing:e.Null,NoNewUtxos:e.Record({required_confirmations:e.Nat32,current_confirmations:e.Opt(e.Nat32)})});return e.Service({estimate_withdrawal_fee:e.Func([e.Record({amount:e.Opt(e.Nat64)})],[e.Record({minter_fee:e.Nat64,bitcoin_fee:e.Nat64})],["query"]),get_btc_address:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Text],[]),get_canister_status:e.Func([],[u],[]),get_deposit_fee:e.Func([],[e.Nat64],["query"]),get_events:e.Func([e.Record({start:e.Nat64,length:e.Nat64})],[e.Vec(f)],["query"]),get_minter_info:e.Func([],[h],["query"]),get_withdrawal_account:e.Func([],[l],[]),retrieve_btc:e.Func([_],[e.Variant({Ok:b,Err:w})],[]),retrieve_btc_status:e.Func([e.Record({block_index:e.Nat64})],[ee],["query"]),retrieve_btc_with_approval:e.Func([te],[e.Variant({Ok:b,Err:re})],[]),update_balance:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Variant({Ok:e.Vec(ne),Err:oe})],[])})};var K=class e extends x.Canister{constructor(){super(...arguments);this.getBtcAddress=({owner:r,subaccount:n})=>this.caller({certified:!0}).get_btc_address({owner:(0,x.toNullable)(r),subaccount:(0,x.toNullable)(n)});this.updateBalance=async({owner:r,subaccount:n})=>{let o=await this.caller({certified:!0}).update_balance({owner:(0,x.toNullable)(r),subaccount:(0,x.toNullable)(n)});if("Err"in o)throw se(o.Err);return o.Ok};this.getWithdrawalAccount=()=>this.caller({certified:!0}).get_withdrawal_account();this.retrieveBtc=async r=>{let n=await this.caller({certified:!0}).retrieve_btc(r);if("Err"in n)throw Q(n.Err);return n.Ok};this.retrieveBtcWithApproval=async({address:r,amount:n,fromSubaccount:o})=>{let c=await this.caller({certified:!0}).retrieve_btc_with_approval({address:r,amount:n,from_subaccount:(0,x.toNullable)(o)});if("Err"in c)throw de(c.Err);return c.Ok};this.estimateWithdrawalFee=async({certified:r,amount:n})=>this.caller({certified:r}).estimate_withdrawal_fee({amount:(0,x.toNullable)(n)});this.getMinterInfo=async({certified:r})=>this.caller({certified:r}).get_minter_info()}static create(r){let{service:n,certifiedService:o,canisterId:c}=(0,x.createServices)({options:r,idlFactory:we,certifiedIdlFactory:be});return new e(c,n,o)}};var me=require("@dfinity/utils");function Xe(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function ue(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function ge(e,t){Xe(e);let r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var Je=e=>e instanceof Uint8Array;var Z=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),N=(e,t)=>e<<32-t|e>>>t,Qe=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Qe)throw new Error("Non little-endian hardware is not supported");function Ke(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function le(e){if(typeof e=="string"&&(e=Ke(e)),!Je(e))throw new Error(`expected Uint8Array, got ${typeof e}`);return e}var Y=class{clone(){return this._cloneInto()}},Tt={}.toString;function ye(e){let t=n=>e().update(le(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Ye(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let o=BigInt(32),c=BigInt(4294967295),i=Number(r>>o&c),a=Number(r&c),u=n?4:0,l=n?0:4;e.setUint32(t+u,i,n),e.setUint32(t+l,a,n)}var I=class extends Y{constructor(t,r,n,o){super(),this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Z(this.buffer)}update(t){ue(this);let{view:r,buffer:n,blockLen:o}=this;t=le(t);let c=t.length;for(let i=0;i<c;){let a=Math.min(o-this.pos,c-i);if(a===o){let u=Z(t);for(;o<=c-i;i+=o)this.process(u,i);continue}n.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){ue(this),ge(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:c}=this,{pos:i}=this;r[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let s=i;s<o;s++)r[s]=0;Ye(n,o-8,BigInt(this.length*8),c),this.process(n,0);let a=Z(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=u/4,d=this.get();if(l>d.length)throw new Error("_sha2: outputLen bigger than state");for(let s=0;s<l;s++)a.setUint32(4*s,d[s],c)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:c,destroyed:i,pos:a}=this;return t.length=o,t.pos=a,t.finished=c,t.destroyed=i,o%r&&t.buffer.set(n),t}};var Ze=(e,t,r)=>e&t^~e&r,Ie=(e,t,r)=>e&t^e&r^t&r,Le=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),R=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),v=new Uint32Array(64),pe=class extends I{constructor(){super(64,32,8,!1),this.A=R[0]|0,this.B=R[1]|0,this.C=R[2]|0,this.D=R[3]|0,this.E=R[4]|0,this.F=R[5]|0,this.G=R[6]|0,this.H=R[7]|0}get(){let{A:t,B:r,C:n,D:o,E:c,F:i,G:a,H:u}=this;return[t,r,n,o,c,i,a,u]}set(t,r,n,o,c,i,a,u){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=c|0,this.F=i|0,this.G=a|0,this.H=u|0}process(t,r){for(let s=0;s<16;s++,r+=4)v[s]=t.getUint32(r,!1);for(let s=16;s<64;s++){let p=v[s-15],f=v[s-2],h=N(p,7)^N(p,18)^p>>>3,_=N(f,17)^N(f,19)^f>>>10;v[s]=_+v[s-7]+h+v[s-16]|0}let{A:n,B:o,C:c,D:i,E:a,F:u,G:l,H:d}=this;for(let s=0;s<64;s++){let p=N(a,6)^N(a,11)^N(a,25),f=d+p+Ze(a,u,l)+Le[s]+v[s]|0,_=(N(n,2)^N(n,13)^N(n,22))+Ie(n,o,c)|0;d=l,l=u,u=a,a=i+f|0,i=c,c=o,o=n,n=f+_|0}n=n+this.A|0,o=o+this.B|0,c=c+this.C|0,i=i+this.D|0,a=a+this.E|0,u=u+this.F|0,l=l+this.G|0,d=d+this.H|0,this.set(n,o,c,i,a,u,l,d)}roundClean(){v.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var fe=ye(()=>new pe);var Se=Ne(Ee()),S=Ne(Me());var dt=0,ut=5,lt=111,pt=196,ft={[dt]:{type:1,networks:[0]},[lt]:{type:1,networks:[2,1]},[ut]:{type:2,networks:[0]},[pt]:{type:2,networks:[2,1]}},_t=({address:e,network:t})=>{let n=(d=>{try{return(0,Se.base58_to_binary)(d)}catch{throw new O}})(e),{length:o}=n;if(o!==25)throw new k(`Expected the address to be 25 bytes, got ${o}.`);(d=>{let s=d.slice(o-4,o),p=d.slice(0,o-4),f=fe.create();f.update(p);let h=fe.create();h.update(f.digest());let _=h.digest().slice(0,4);if(s.some((b,w)=>b!==_[w]))throw new k(`Checksum mismatch expected ${s}, got ${_}.`)})(n);let i=n[0],a=ft[i];if((0,me.isNullish)(a))throw new V;let{type:u,networks:l}=a;if(!l.includes(t))throw new F;return{address:e,network:t,type:u,parser:"base58"}},ht=({address:e,network:t})=>{let r=d=>{try{return d.startsWith("bc1p")||d.startsWith("tb1p")||d.startsWith("bcrt1p")?S.bech32m.decode(d):S.bech32.decode(d)}catch{throw new k}},{prefix:n,words:o}=r(e),i={bc:0,tb:2,bcrt:1}[n];if((0,me.isNullish)(i))throw new O;if(i!==t)throw new C;let[a,...u]=o;if(a>1)throw new U;switch(S.bech32.fromWords(u).length){case 20:return{address:e,network:t,type:0,parser:"bip-173"};case 32:return{address:e,network:t,type:a===0?3:4,parser:"bip-173"};default:throw new E}},mt=({address:e,network:t=0})=>{switch(e.charAt(0)){case"1":case"2":case"3":case"m":case"n":return _t({address:e,network:t});case"b":case"B":case"t":case"T":return ht({address:e,network:t});case"":throw new P;default:throw new V}};0&&(module.exports={BtcAddressType,BtcNetwork,CkBTCMinterCanister,MinterAlreadyProcessingError,MinterAmountTooLowError,MinterGenericError,MinterInsufficientAllowanceError,MinterInsufficientFundsError,MinterMalformedAddressError,MinterNoNewUtxosError,MinterRetrieveBtcError,MinterTemporaryUnavailableError,MinterUpdateBalanceError,ParseBtcAddressBadWitnessLengthError,ParseBtcAddressError,ParseBtcAddressInvalidError,ParseBtcAddressMalformedAddressError,ParseBtcAddressNoDataError,ParseBtcAddressUnexpectedHumanReadablePartError,ParseBtcAddressUnsupportedAddressTypeError,ParseBtcAddressUnsupportedWitnessVersionError,ParseBtcAddressWrongNetworkError,createRetrieveBtcError,createRetrieveBtcWithApprovalError,createUpdateBalanceError,parseBtcAddress});
|
|
1
|
+
"use strict";var We=Object.create;var W=Object.defineProperty;var Ge=Object.getOwnPropertyDescriptor;var $e=Object.getOwnPropertyNames;var He=Object.getPrototypeOf,je=Object.prototype.hasOwnProperty;var A=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ze=(e,t)=>{for(var r in t)W(e,r,{get:t[r],enumerable:!0})},Ne=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of $e(t))!je.call(e,o)&&o!==r&&W(e,o,{get:()=>t[o],enumerable:!(n=Ge(t,o))||n.enumerable});return e};var be=(e,t,r)=>(r=e!=null?We(He(e)):{},Ne(t||!e||!e.__esModule?W(r,"default",{value:e,enumerable:!0}):r,e)),Xe=e=>Ne(W({},"__esModule",{value:!0}),e);var L=A((qt,ve)=>{"use strict";var et="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";ve.exports=et});var Ae=A((Wt,ke)=>{"use strict";var tt=L(),rt=e=>{if(!e||typeof e!="string")throw new Error(`Expected base58 string but got \u201C${e}\u201D`);if(e.match(/[IOl0]/gmu))throw new Error(`Invalid base58 character \u201C${e.match(/[IOl0]/gmu)}\u201D`);let t=e.match(/^1+/gmu),r=t?t[0].length:0,n=(e.length-r)*(Math.log(58)/Math.log(256))+1>>>0;return new Uint8Array([...new Uint8Array(r),...e.match(/.{1}/gmu).map(o=>tt.indexOf(o)).reduce((o,c)=>(o=o.map(i=>{let a=i*58+c;return c=a>>8,a}),o),new Uint8Array(n)).reverse().filter((o=>c=>o=o||c)(!1))])};ke.exports=rt});var Pe=A((Gt,Ve)=>{"use strict";var Oe=L(),nt=()=>{let e=Array(256).fill(-1);for(let t=0;t<Oe.length;++t)e[Oe.charCodeAt(t)]=t;return e};Ve.exports=nt});var Ee=A(($t,Be)=>{"use strict";var Te=L(),ot=Pe(),it=ot(),ct=e=>{let t=[];for(let r of e){let n=r;for(let o=0;o<t.length;++o){let c=(it[t[o]]<<8)+n;t[o]=Te.charCodeAt(c%58),n=c/58|0}for(;n;)t.push(Te.charCodeAt(n%58)),n=n/58|0}for(let r of e){if(r)break;t.push("1".charCodeAt(0))}return t.reverse(),String.fromCharCode(...t)};Be.exports=ct});var Ue=A(he=>{"use strict";he.base58_to_binary=Ae();he.binary_to_base58=Ee()});var Se=A(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});B.bech32m=B.bech32=void 0;var D="qpzry9x8gf2tvdw0s3jn54khce6mua7l",Fe={};for(let e=0;e<D.length;e++){let t=D.charAt(e);Fe[t]=e}function T(e){let t=e>>25;return(e&33554431)<<5^-(t>>0&1)&996825010^-(t>>1&1)&642813549^-(t>>2&1)&513874426^-(t>>3&1)&1027748829^-(t>>4&1)&705979059}function Ce(e){let t=1;for(let r=0;r<e.length;++r){let n=e.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+e+")";t=T(t)^n>>5}t=T(t);for(let r=0;r<e.length;++r){let n=e.charCodeAt(r);t=T(t)^n&31}return t}function xe(e,t,r,n){let o=0,c=0,i=(1<<r)-1,a=[];for(let u=0;u<e.length;++u)for(o=o<<t|e[u],c+=t;c>=r;)c-=r,a.push(o>>c&i);if(n)c>0&&a.push(o<<r-c&i);else{if(c>=t)return"Excess padding";if(o<<r-c&i)return"Non-zero padding"}return a}function at(e){return xe(e,8,5,!0)}function st(e){let t=xe(e,5,8,!1);if(Array.isArray(t))return t}function dt(e){let t=xe(e,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}function Me(e){let t;e==="bech32"?t=1:t=734539939;function r(i,a,u){if(u=u||90,i.length+7+a.length>u)throw new TypeError("Exceeds length limit");i=i.toLowerCase();let l=Ce(i);if(typeof l=="string")throw new Error(l);let d=i+"1";for(let s=0;s<a.length;++s){let p=a[s];if(p>>5)throw new Error("Non 5-bit word");l=T(l)^p,d+=D.charAt(p)}for(let s=0;s<6;++s)l=T(l);l^=t;for(let s=0;s<6;++s){let p=l>>(5-s)*5&31;d+=D.charAt(p)}return d}function n(i,a){if(a=a||90,i.length<8)return i+" too short";if(i.length>a)return"Exceeds length limit";let u=i.toLowerCase(),l=i.toUpperCase();if(i!==u&&i!==l)return"Mixed-case string "+i;i=u;let d=i.lastIndexOf("1");if(d===-1)return"No separator character for "+i;if(d===0)return"Missing prefix for "+i;let s=i.slice(0,d),p=i.slice(d+1);if(p.length<6)return"Data too short";let f=Ce(s);if(typeof f=="string")return f;let h=[];for(let _=0;_<p.length;++_){let b=p.charAt(_),g=Fe[b];if(g===void 0)return"Unknown character "+b;f=T(f)^g,!(_+6>=p.length)&&h.push(g)}return f!==t?"Invalid checksum for "+i:{prefix:s,words:h}}function o(i,a){let u=n(i,a);if(typeof u=="object")return u}function c(i,a){let u=n(i,a);if(typeof u=="object")return u;throw new Error(u)}return{decodeUnsafe:o,decode:c,encode:r,toWords:at,fromWordsUnsafe:st,fromWords:dt}}B.bech32=Me("bech32");B.bech32m=Me("bech32m")});var Nt={};ze(Nt,{BtcAddressType:()=>ae,BtcNetwork:()=>ce,CkBTCMinterCanister:()=>K,MinterAlreadyProcessingError:()=>$,MinterAmountTooLowError:()=>z,MinterGenericError:()=>w,MinterInsufficientAllowanceError:()=>J,MinterInsufficientFundsError:()=>X,MinterMalformedAddressError:()=>j,MinterNoNewUtxosError:()=>H,MinterRetrieveBtcError:()=>y,MinterTemporaryUnavailableError:()=>G,MinterUpdateBalanceError:()=>S,ParseBtcAddressBadWitnessLengthError:()=>U,ParseBtcAddressError:()=>x,ParseBtcAddressInvalidError:()=>O,ParseBtcAddressMalformedAddressError:()=>k,ParseBtcAddressNoDataError:()=>E,ParseBtcAddressUnexpectedHumanReadablePartError:()=>F,ParseBtcAddressUnsupportedAddressTypeError:()=>V,ParseBtcAddressUnsupportedWitnessVersionError:()=>C,ParseBtcAddressWrongNetworkError:()=>M,createRetrieveBtcError:()=>Q,createRetrieveBtcWithApprovalError:()=>ue,createUpdateBalanceError:()=>de,parseBtcAddress:()=>mt});module.exports=Xe(Nt);var ce=(n=>(n[n.Mainnet=0]="Mainnet",n[n.Regtest=1]="Regtest",n[n.Testnet=2]="Testnet",n))(ce||{}),ae=(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))(ae||{});var x=class extends Error{},O=class extends x{},E=class extends x{},V=class extends x{},U=class extends x{},C=class extends x{},F=class extends x{},k=class extends x{},M=class extends x{};var P=require("@dfinity/utils"),w=class extends Error{},G=class extends w{},$=class extends w{},S=class extends w{},H=class extends S{constructor({pending_utxos:r,required_confirmations:n}){super();this.pendingUtxos=(0,P.fromNullable)(r)||[],this.requiredConfirmations=n}},y=class extends w{},j=class extends y{},z=class extends y{},X=class extends y{},J=class extends y{},se=e=>{if("GenericError"in e){let{GenericError:{error_message:t,error_code:r}}=e;return new w(`${t} (${r})`)}if("TemporarilyUnavailable"in e)return new G(e.TemporarilyUnavailable);if("AlreadyProcessing"in e)return new $},de=e=>{let t=se(e);return(0,P.nonNullish)(t)?t:"NoNewUtxos"in e?new H(e.NoNewUtxos):new S(`Unsupported response type in minter.updateBalance ${JSON.stringify(e)}`)},Q=e=>{let t=se(e);return(0,P.nonNullish)(t)?t:"MalformedAddress"in e?new j(e.MalformedAddress):"AmountTooLow"in e?new z(`${e.AmountTooLow}`):"InsufficientFunds"in e?new X(`${e.InsufficientFunds.balance}`):new y(`Unsupported response type in minter.retrieveBtc ${JSON.stringify(e)}`)},ue=e=>{let t=se(e);return(0,P.nonNullish)(t)?t:"InsufficientAllowance"in e?new J(`${e.InsufficientAllowance.allowance}`):Q(e)};var m=require("@dfinity/utils");var ge=({IDL:e})=>{let t=e.Variant({RestrictedTo:e.Vec(e.Principal),DepositsRestrictedTo:e.Vec(e.Principal),ReadOnly:e.Null,GeneralAvailability:e.Null}),r=e.Record({kyt_principal:e.Opt(e.Principal),mode:e.Opt(t),retrieve_btc_min_amount:e.Opt(e.Nat64),max_time_in_queue_nanos:e.Opt(e.Nat64),min_confirmations:e.Opt(e.Nat32),kyt_fee:e.Opt(e.Nat64)}),n=e.Variant({Mainnet:e.Null,Regtest:e.Null,Testnet:e.Null}),o=e.Record({kyt_principal:e.Opt(e.Principal),ecdsa_key_name:e.Text,mode:t,retrieve_btc_min_amount:e.Nat64,ledger_id:e.Principal,max_time_in_queue_nanos:e.Nat64,btc_network:n,min_confirmations:e.Opt(e.Nat32),kyt_fee:e.Opt(e.Nat64)}),c=e.Variant({Upgrade:e.Opt(r),Init:o}),i=e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),a=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),memory_allocation:e.Nat,compute_allocation:e.Nat}),u=e.Record({status:i,memory_size:e.Nat,cycles:e.Nat,settings:a,idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8))}),l=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),d=e.Record({height:e.Nat32,value:e.Nat64,outpoint:e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32})}),s=e.Variant({CallFailed:e.Null,TaintedDestination:e.Record({kyt_fee:e.Nat64,kyt_provider:e.Principal})}),p=e.Variant({p2wsh_v0:e.Vec(e.Nat8),p2tr_v1:e.Vec(e.Nat8),p2sh:e.Vec(e.Nat8),p2wpkh_v0:e.Vec(e.Nat8),p2pkh:e.Vec(e.Nat8)}),f=e.Variant({received_utxos:e.Record({to_account:l,mint_txid:e.Opt(e.Nat64),utxos:e.Vec(d)}),schedule_deposit_reimbursement:e.Record({burn_block_index:e.Nat64,account:l,amount:e.Nat64,reason:s}),sent_transaction:e.Record({fee:e.Opt(e.Nat64),change_output:e.Opt(e.Record({value:e.Nat64,vout:e.Nat32})),txid:e.Vec(e.Nat8),utxos:e.Vec(d),requests:e.Vec(e.Nat64),submitted_at:e.Nat64}),distributed_kyt_fee:e.Record({block_index:e.Nat64,amount:e.Nat64,kyt_provider:e.Principal}),init:o,upgrade:r,retrieve_btc_kyt_failed:e.Record({block_index:e.Nat64,owner:e.Principal,uuid:e.Text,address:e.Text,amount:e.Nat64,kyt_provider:e.Principal}),accepted_retrieve_btc_request:e.Record({received_at:e.Nat64,block_index:e.Nat64,address:p,amount:e.Nat64,kyt_provider:e.Opt(e.Principal)}),checked_utxo:e.Record({clean:e.Bool,utxo:d,uuid:e.Text,kyt_provider:e.Opt(e.Principal)}),removed_retrieve_btc_request:e.Record({block_index:e.Nat64}),confirmed_transaction:e.Record({txid:e.Vec(e.Nat8)}),replaced_transaction:e.Record({fee:e.Nat64,change_output:e.Record({value:e.Nat64,vout:e.Nat32}),old_txid:e.Vec(e.Nat8),new_txid:e.Vec(e.Nat8),submitted_at:e.Nat64}),ignored_utxo:e.Record({utxo:d}),reimbursed_failed_deposit:e.Record({burn_block_index:e.Nat64,mint_block_index:e.Nat64})}),h=e.Record({retrieve_btc_min_amount:e.Nat64,min_confirmations:e.Nat32,kyt_fee:e.Nat64}),_=e.Record({address:e.Text,amount:e.Nat64}),b=e.Record({block_index:e.Nat64}),g=e.Variant({MalformedAddress:e.Text,GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,AlreadyProcessing:e.Null,AmountTooLow:e.Nat64,InsufficientFunds:e.Record({balance:e.Nat64})}),ee=e.Variant({Signing:e.Null,Confirmed:e.Record({txid:e.Vec(e.Nat8)}),Sending:e.Record({txid:e.Vec(e.Nat8)}),AmountTooLow:e.Null,Unknown:e.Null,Submitted:e.Record({txid:e.Vec(e.Nat8)}),Pending:e.Null}),te=e.Record({from_subaccount:e.Opt(e.Vec(e.Nat8)),address:e.Text,amount:e.Nat64}),re=e.Variant({MalformedAddress:e.Text,GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,InsufficientAllowance:e.Record({allowance:e.Nat64}),AlreadyProcessing:e.Null,AmountTooLow:e.Nat64,InsufficientFunds:e.Record({balance:e.Nat64})}),ne=e.Variant({ValueTooSmall:d,Tainted:d,Minted:e.Record({minted_amount:e.Nat64,block_index:e.Nat64,utxo:d}),Checked:d}),oe=e.Record({confirmations:e.Nat32,value:e.Nat64,outpoint:e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32})}),ie=e.Variant({GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,AlreadyProcessing:e.Null,NoNewUtxos:e.Record({required_confirmations:e.Nat32,pending_utxos:e.Opt(e.Vec(oe)),current_confirmations:e.Opt(e.Nat32)})});return e.Service({estimate_withdrawal_fee:e.Func([e.Record({amount:e.Opt(e.Nat64)})],[e.Record({minter_fee:e.Nat64,bitcoin_fee:e.Nat64})],[]),get_btc_address:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Text],[]),get_canister_status:e.Func([],[u],[]),get_deposit_fee:e.Func([],[e.Nat64],[]),get_events:e.Func([e.Record({start:e.Nat64,length:e.Nat64})],[e.Vec(f)],[]),get_minter_info:e.Func([],[h],[]),get_withdrawal_account:e.Func([],[l],[]),retrieve_btc:e.Func([_],[e.Variant({Ok:b,Err:g})],[]),retrieve_btc_status:e.Func([e.Record({block_index:e.Nat64})],[ee],[]),retrieve_btc_with_approval:e.Func([te],[e.Variant({Ok:b,Err:re})],[]),update_balance:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Variant({Ok:e.Vec(ne),Err:ie})],[])})};var we=({IDL:e})=>{let t=e.Variant({RestrictedTo:e.Vec(e.Principal),DepositsRestrictedTo:e.Vec(e.Principal),ReadOnly:e.Null,GeneralAvailability:e.Null}),r=e.Record({kyt_principal:e.Opt(e.Principal),mode:e.Opt(t),retrieve_btc_min_amount:e.Opt(e.Nat64),max_time_in_queue_nanos:e.Opt(e.Nat64),min_confirmations:e.Opt(e.Nat32),kyt_fee:e.Opt(e.Nat64)}),n=e.Variant({Mainnet:e.Null,Regtest:e.Null,Testnet:e.Null}),o=e.Record({kyt_principal:e.Opt(e.Principal),ecdsa_key_name:e.Text,mode:t,retrieve_btc_min_amount:e.Nat64,ledger_id:e.Principal,max_time_in_queue_nanos:e.Nat64,btc_network:n,min_confirmations:e.Opt(e.Nat32),kyt_fee:e.Opt(e.Nat64)}),c=e.Variant({Upgrade:e.Opt(r),Init:o}),i=e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),a=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),memory_allocation:e.Nat,compute_allocation:e.Nat}),u=e.Record({status:i,memory_size:e.Nat,cycles:e.Nat,settings:a,idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8))}),l=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),d=e.Record({height:e.Nat32,value:e.Nat64,outpoint:e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32})}),s=e.Variant({CallFailed:e.Null,TaintedDestination:e.Record({kyt_fee:e.Nat64,kyt_provider:e.Principal})}),p=e.Variant({p2wsh_v0:e.Vec(e.Nat8),p2tr_v1:e.Vec(e.Nat8),p2sh:e.Vec(e.Nat8),p2wpkh_v0:e.Vec(e.Nat8),p2pkh:e.Vec(e.Nat8)}),f=e.Variant({received_utxos:e.Record({to_account:l,mint_txid:e.Opt(e.Nat64),utxos:e.Vec(d)}),schedule_deposit_reimbursement:e.Record({burn_block_index:e.Nat64,account:l,amount:e.Nat64,reason:s}),sent_transaction:e.Record({fee:e.Opt(e.Nat64),change_output:e.Opt(e.Record({value:e.Nat64,vout:e.Nat32})),txid:e.Vec(e.Nat8),utxos:e.Vec(d),requests:e.Vec(e.Nat64),submitted_at:e.Nat64}),distributed_kyt_fee:e.Record({block_index:e.Nat64,amount:e.Nat64,kyt_provider:e.Principal}),init:o,upgrade:r,retrieve_btc_kyt_failed:e.Record({block_index:e.Nat64,owner:e.Principal,uuid:e.Text,address:e.Text,amount:e.Nat64,kyt_provider:e.Principal}),accepted_retrieve_btc_request:e.Record({received_at:e.Nat64,block_index:e.Nat64,address:p,amount:e.Nat64,kyt_provider:e.Opt(e.Principal)}),checked_utxo:e.Record({clean:e.Bool,utxo:d,uuid:e.Text,kyt_provider:e.Opt(e.Principal)}),removed_retrieve_btc_request:e.Record({block_index:e.Nat64}),confirmed_transaction:e.Record({txid:e.Vec(e.Nat8)}),replaced_transaction:e.Record({fee:e.Nat64,change_output:e.Record({value:e.Nat64,vout:e.Nat32}),old_txid:e.Vec(e.Nat8),new_txid:e.Vec(e.Nat8),submitted_at:e.Nat64}),ignored_utxo:e.Record({utxo:d}),reimbursed_failed_deposit:e.Record({burn_block_index:e.Nat64,mint_block_index:e.Nat64})}),h=e.Record({retrieve_btc_min_amount:e.Nat64,min_confirmations:e.Nat32,kyt_fee:e.Nat64}),_=e.Record({address:e.Text,amount:e.Nat64}),b=e.Record({block_index:e.Nat64}),g=e.Variant({MalformedAddress:e.Text,GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,AlreadyProcessing:e.Null,AmountTooLow:e.Nat64,InsufficientFunds:e.Record({balance:e.Nat64})}),ee=e.Variant({Signing:e.Null,Confirmed:e.Record({txid:e.Vec(e.Nat8)}),Sending:e.Record({txid:e.Vec(e.Nat8)}),AmountTooLow:e.Null,Unknown:e.Null,Submitted:e.Record({txid:e.Vec(e.Nat8)}),Pending:e.Null}),te=e.Record({from_subaccount:e.Opt(e.Vec(e.Nat8)),address:e.Text,amount:e.Nat64}),re=e.Variant({MalformedAddress:e.Text,GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,InsufficientAllowance:e.Record({allowance:e.Nat64}),AlreadyProcessing:e.Null,AmountTooLow:e.Nat64,InsufficientFunds:e.Record({balance:e.Nat64})}),ne=e.Variant({ValueTooSmall:d,Tainted:d,Minted:e.Record({minted_amount:e.Nat64,block_index:e.Nat64,utxo:d}),Checked:d}),oe=e.Record({confirmations:e.Nat32,value:e.Nat64,outpoint:e.Record({txid:e.Vec(e.Nat8),vout:e.Nat32})}),ie=e.Variant({GenericError:e.Record({error_message:e.Text,error_code:e.Nat64}),TemporarilyUnavailable:e.Text,AlreadyProcessing:e.Null,NoNewUtxos:e.Record({required_confirmations:e.Nat32,pending_utxos:e.Opt(e.Vec(oe)),current_confirmations:e.Opt(e.Nat32)})});return e.Service({estimate_withdrawal_fee:e.Func([e.Record({amount:e.Opt(e.Nat64)})],[e.Record({minter_fee:e.Nat64,bitcoin_fee:e.Nat64})],["query"]),get_btc_address:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Text],[]),get_canister_status:e.Func([],[u],[]),get_deposit_fee:e.Func([],[e.Nat64],["query"]),get_events:e.Func([e.Record({start:e.Nat64,length:e.Nat64})],[e.Vec(f)],["query"]),get_minter_info:e.Func([],[h],["query"]),get_withdrawal_account:e.Func([],[l],[]),retrieve_btc:e.Func([_],[e.Variant({Ok:b,Err:g})],[]),retrieve_btc_status:e.Func([e.Record({block_index:e.Nat64})],[ee],["query"]),retrieve_btc_with_approval:e.Func([te],[e.Variant({Ok:b,Err:re})],[]),update_balance:e.Func([e.Record({owner:e.Opt(e.Principal),subaccount:e.Opt(e.Vec(e.Nat8))})],[e.Variant({Ok:e.Vec(ne),Err:ie})],[])})};var K=class e extends m.Canister{constructor(){super(...arguments);this.getBtcAddress=({owner:r,subaccount:n})=>this.caller({certified:!0}).get_btc_address({owner:(0,m.toNullable)(r),subaccount:(0,m.toNullable)(n)});this.updateBalance=async({owner:r,subaccount:n})=>{let o=await this.caller({certified:!0}).update_balance({owner:(0,m.toNullable)(r),subaccount:(0,m.toNullable)(n)});if("Err"in o)throw de(o.Err);return o.Ok};this.getWithdrawalAccount=()=>this.caller({certified:!0}).get_withdrawal_account();this.retrieveBtc=async r=>{let n=await this.caller({certified:!0}).retrieve_btc(r);if("Err"in n)throw Q(n.Err);return n.Ok};this.retrieveBtcWithApproval=async({address:r,amount:n,fromSubaccount:o})=>{let c=await this.caller({certified:!0}).retrieve_btc_with_approval({address:r,amount:n,from_subaccount:(0,m.toNullable)(o)});if("Err"in c)throw ue(c.Err);return c.Ok};this.estimateWithdrawalFee=async({certified:r,amount:n})=>this.caller({certified:r}).estimate_withdrawal_fee({amount:(0,m.toNullable)(n)});this.getMinterInfo=async({certified:r})=>this.caller({certified:r}).get_minter_info()}static create(r){let{service:n,certifiedService:o,canisterId:c}=(0,m.createServices)({options:r,idlFactory:we,certifiedIdlFactory:ge});return new e(c,n,o)}};var me=require("@dfinity/utils");function Je(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function le(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function ye(e,t){Je(e);let r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var Qe=e=>e instanceof Uint8Array;var Z=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),N=(e,t)=>e<<32-t|e>>>t,Ke=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Ke)throw new Error("Non little-endian hardware is not supported");function Ye(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function pe(e){if(typeof e=="string"&&(e=Ye(e)),!Qe(e))throw new Error(`expected Uint8Array, got ${typeof e}`);return e}var Y=class{clone(){return this._cloneInto()}},Tt={}.toString;function Re(e){let t=n=>e().update(pe(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Ze(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let o=BigInt(32),c=BigInt(4294967295),i=Number(r>>o&c),a=Number(r&c),u=n?4:0,l=n?0:4;e.setUint32(t+u,i,n),e.setUint32(t+l,a,n)}var I=class extends Y{constructor(t,r,n,o){super(),this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Z(this.buffer)}update(t){le(this);let{view:r,buffer:n,blockLen:o}=this;t=pe(t);let c=t.length;for(let i=0;i<c;){let a=Math.min(o-this.pos,c-i);if(a===o){let u=Z(t);for(;o<=c-i;i+=o)this.process(u,i);continue}n.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){le(this),ye(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:c}=this,{pos:i}=this;r[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let s=i;s<o;s++)r[s]=0;Ze(n,o-8,BigInt(this.length*8),c),this.process(n,0);let a=Z(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=u/4,d=this.get();if(l>d.length)throw new Error("_sha2: outputLen bigger than state");for(let s=0;s<l;s++)a.setUint32(4*s,d[s],c)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:c,destroyed:i,pos:a}=this;return t.length=o,t.pos=a,t.finished=c,t.destroyed=i,o%r&&t.buffer.set(n),t}};var Ie=(e,t,r)=>e&t^~e&r,Le=(e,t,r)=>e&t^e&r^t&r,De=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),R=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),v=new Uint32Array(64),fe=class extends I{constructor(){super(64,32,8,!1),this.A=R[0]|0,this.B=R[1]|0,this.C=R[2]|0,this.D=R[3]|0,this.E=R[4]|0,this.F=R[5]|0,this.G=R[6]|0,this.H=R[7]|0}get(){let{A:t,B:r,C:n,D:o,E:c,F:i,G:a,H:u}=this;return[t,r,n,o,c,i,a,u]}set(t,r,n,o,c,i,a,u){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=c|0,this.F=i|0,this.G=a|0,this.H=u|0}process(t,r){for(let s=0;s<16;s++,r+=4)v[s]=t.getUint32(r,!1);for(let s=16;s<64;s++){let p=v[s-15],f=v[s-2],h=N(p,7)^N(p,18)^p>>>3,_=N(f,17)^N(f,19)^f>>>10;v[s]=_+v[s-7]+h+v[s-16]|0}let{A:n,B:o,C:c,D:i,E:a,F:u,G:l,H:d}=this;for(let s=0;s<64;s++){let p=N(a,6)^N(a,11)^N(a,25),f=d+p+Ie(a,u,l)+De[s]+v[s]|0,_=(N(n,2)^N(n,13)^N(n,22))+Le(n,o,c)|0;d=l,l=u,u=a,a=i+f|0,i=c,c=o,o=n,n=f+_|0}n=n+this.A|0,o=o+this.B|0,c=c+this.C|0,i=i+this.D|0,a=a+this.E|0,u=u+this.F|0,l=l+this.G|0,d=d+this.H|0,this.set(n,o,c,i,a,u,l,d)}roundClean(){v.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var _e=Re(()=>new fe);var qe=be(Ue()),q=be(Se());var ut=0,lt=5,pt=111,ft=196,_t={[ut]:{type:1,networks:[0]},[pt]:{type:1,networks:[2,1]},[lt]:{type:2,networks:[0]},[ft]:{type:2,networks:[2,1]}},ht=({address:e,network:t})=>{let n=(d=>{try{return(0,qe.base58_to_binary)(d)}catch{throw new O}})(e),{length:o}=n;if(o!==25)throw new k(`Expected the address to be 25 bytes, got ${o}.`);(d=>{let s=d.slice(o-4,o),p=d.slice(0,o-4),f=_e.create();f.update(p);let h=_e.create();h.update(f.digest());let _=h.digest().slice(0,4);if(s.some((b,g)=>b!==_[g]))throw new k(`Checksum mismatch expected ${s}, got ${_}.`)})(n);let i=n[0],a=_t[i];if((0,me.isNullish)(a))throw new V;let{type:u,networks:l}=a;if(!l.includes(t))throw new M;return{address:e,network:t,type:u,parser:"base58"}},xt=({address:e,network:t})=>{let r=d=>{try{return d.startsWith("bc1p")||d.startsWith("tb1p")||d.startsWith("bcrt1p")?q.bech32m.decode(d):q.bech32.decode(d)}catch{throw new k}},{prefix:n,words:o}=r(e),i={bc:0,tb:2,bcrt:1}[n];if((0,me.isNullish)(i))throw new O;if(i!==t)throw new F;let[a,...u]=o;if(a>1)throw new C;switch(q.bech32.fromWords(u).length){case 20:return{address:e,network:t,type:0,parser:"bip-173"};case 32:return{address:e,network:t,type:a===0?3:4,parser:"bip-173"};default:throw new U}},mt=({address:e,network:t=0})=>{switch(e.charAt(0)){case"1":case"2":case"3":case"m":case"n":return ht({address:e,network:t});case"b":case"B":case"t":case"T":return xt({address:e,network:t});case"":throw new E;default:throw new V}};0&&(module.exports={BtcAddressType,BtcNetwork,CkBTCMinterCanister,MinterAlreadyProcessingError,MinterAmountTooLowError,MinterGenericError,MinterInsufficientAllowanceError,MinterInsufficientFundsError,MinterMalformedAddressError,MinterNoNewUtxosError,MinterRetrieveBtcError,MinterTemporaryUnavailableError,MinterUpdateBalanceError,ParseBtcAddressBadWitnessLengthError,ParseBtcAddressError,ParseBtcAddressInvalidError,ParseBtcAddressMalformedAddressError,ParseBtcAddressNoDataError,ParseBtcAddressUnexpectedHumanReadablePartError,ParseBtcAddressUnsupportedAddressTypeError,ParseBtcAddressUnsupportedWitnessVersionError,ParseBtcAddressWrongNetworkError,createRetrieveBtcError,createRetrieveBtcWithApprovalError,createUpdateBalanceError,parseBtcAddress});
|
|
2
2
|
/*! Bundled license information:
|
|
3
3
|
|
|
4
4
|
@noble/hashes/esm/utils.js:
|