@dfinity/ckbtc 2.1.0 → 2.1.1-next-2024-01-30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -4
- package/dist/candid/minter.certified.idl.js +7 -0
- package/dist/candid/minter.d.ts +7 -0
- package/dist/candid/minter.did +11 -3
- package/dist/candid/minter.idl.js +7 -0
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/index.cjs.js.map +3 -3
- package/dist/esm/chunk-CUU2H4L4.js +2 -0
- package/dist/esm/chunk-CUU2H4L4.js.map +7 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/minter.canister.js +1 -1
- package/dist/types/minter.canister.d.ts +2 -2
- package/package.json +6 -6
- package/dist/esm/chunk-GAS5QHUV.js +0 -2
- package/dist/esm/chunk-GAS5QHUV.js.map +0 -7
package/README.md
CHANGED
|
@@ -28,8 +28,6 @@ npm i @dfinity/agent @dfinity/candid @dfinity/principal @dfinity/utils
|
|
|
28
28
|
|
|
29
29
|
The features are available through the class `CkBTCCanister`. It has to be instantiated with a canister ID.
|
|
30
30
|
|
|
31
|
-
e.g. fetching a token metadata.
|
|
32
|
-
|
|
33
31
|
```ts
|
|
34
32
|
import { CkBTCCanister } from "@dfinity/ckbtc";
|
|
35
33
|
import { createAgent } from "@dfinity/utils";
|
|
@@ -151,11 +149,11 @@ Returns the account to which the caller should deposit ckBTC before withdrawing
|
|
|
151
149
|
|
|
152
150
|
Submits a request to convert ckBTC to BTC.
|
|
153
151
|
|
|
154
|
-
|
|
152
|
+
Note:
|
|
155
153
|
|
|
156
154
|
The BTC retrieval process is slow. Instead of synchronously waiting for a BTC transaction to settle, this method returns a request ([block_index]) that the caller can use to query the request status.
|
|
157
155
|
|
|
158
|
-
|
|
156
|
+
Preconditions:
|
|
159
157
|
|
|
160
158
|
The caller deposited the requested amount in ckBTC to the account that the [getWithdrawalAccount] endpoint returns.
|
|
161
159
|
|
|
@@ -45,11 +45,18 @@ export const idlFactory = ({ IDL }) => {
|
|
|
45
45
|
'memory_allocation' : IDL.Nat,
|
|
46
46
|
'compute_allocation' : IDL.Nat,
|
|
47
47
|
});
|
|
48
|
+
const QueryStats = IDL.Record({
|
|
49
|
+
'response_payload_bytes_total' : IDL.Nat,
|
|
50
|
+
'num_instructions_total' : IDL.Nat,
|
|
51
|
+
'num_calls_total' : IDL.Nat,
|
|
52
|
+
'request_payload_bytes_total' : IDL.Nat,
|
|
53
|
+
});
|
|
48
54
|
const CanisterStatusResponse = IDL.Record({
|
|
49
55
|
'status' : CanisterStatusType,
|
|
50
56
|
'memory_size' : IDL.Nat,
|
|
51
57
|
'cycles' : IDL.Nat,
|
|
52
58
|
'settings' : DefiniteCanisterSettings,
|
|
59
|
+
'query_stats' : QueryStats,
|
|
53
60
|
'idle_cycles_burned_per_day' : IDL.Nat,
|
|
54
61
|
'module_hash' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
55
62
|
});
|
package/dist/candid/minter.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export interface CanisterStatusResponse {
|
|
|
20
20
|
memory_size: bigint;
|
|
21
21
|
cycles: bigint;
|
|
22
22
|
settings: DefiniteCanisterSettings;
|
|
23
|
+
query_stats: QueryStats;
|
|
23
24
|
idle_cycles_burned_per_day: bigint;
|
|
24
25
|
module_hash: [] | [Uint8Array | number[]];
|
|
25
26
|
}
|
|
@@ -141,6 +142,12 @@ export interface PendingUtxo {
|
|
|
141
142
|
value: bigint;
|
|
142
143
|
outpoint: { txid: Uint8Array | number[]; vout: number };
|
|
143
144
|
}
|
|
145
|
+
export interface QueryStats {
|
|
146
|
+
response_payload_bytes_total: bigint;
|
|
147
|
+
num_instructions_total: bigint;
|
|
148
|
+
num_calls_total: bigint;
|
|
149
|
+
request_payload_bytes_total: bigint;
|
|
150
|
+
}
|
|
144
151
|
export interface ReimbursedDeposit {
|
|
145
152
|
account: Account;
|
|
146
153
|
mint_block_index: bigint;
|
package/dist/candid/minter.did
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated from IC repo commit
|
|
1
|
+
// Generated from IC repo commit 044cfd5 (2024-01-25 tags: release-2024-01-25_14-09+p2p-con) '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
|
|
|
@@ -9,6 +9,14 @@ type CanisterStatusResponse = record {
|
|
|
9
9
|
settings : DefiniteCanisterSettings;
|
|
10
10
|
idle_cycles_burned_per_day : nat;
|
|
11
11
|
module_hash : opt vec nat8;
|
|
12
|
+
query_stats : QueryStats;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type QueryStats = record {
|
|
16
|
+
response_payload_bytes_total : nat;
|
|
17
|
+
num_instructions_total : nat;
|
|
18
|
+
num_calls_total : nat;
|
|
19
|
+
request_payload_bytes_total : nat;
|
|
12
20
|
};
|
|
13
21
|
|
|
14
22
|
type CanisterStatusType = variant { stopped; stopping; running };
|
|
@@ -23,14 +31,14 @@ type DefiniteCanisterSettings = record {
|
|
|
23
31
|
type RetrieveBtcArgs = record {
|
|
24
32
|
// The address to which the ckBTC minter should deposit BTC.
|
|
25
33
|
address : text;
|
|
26
|
-
// The amount of
|
|
34
|
+
// The amount of ckBTC in Satoshis that the client wants to withdraw.
|
|
27
35
|
amount : nat64;
|
|
28
36
|
};
|
|
29
37
|
|
|
30
38
|
type RetrieveBtcWithApprovalArgs = record {
|
|
31
39
|
// The address to which the ckBTC minter should deposit BTC.
|
|
32
40
|
address : text;
|
|
33
|
-
// The amount of
|
|
41
|
+
// The amount of ckBTC in Satoshis that the client wants to withdraw.
|
|
34
42
|
amount : nat64;
|
|
35
43
|
// The subaccount to burn ckBTC from.
|
|
36
44
|
from_subaccount : opt blob;
|
|
@@ -45,11 +45,18 @@ export const idlFactory = ({ IDL }) => {
|
|
|
45
45
|
'memory_allocation' : IDL.Nat,
|
|
46
46
|
'compute_allocation' : IDL.Nat,
|
|
47
47
|
});
|
|
48
|
+
const QueryStats = IDL.Record({
|
|
49
|
+
'response_payload_bytes_total' : IDL.Nat,
|
|
50
|
+
'num_instructions_total' : IDL.Nat,
|
|
51
|
+
'num_calls_total' : IDL.Nat,
|
|
52
|
+
'request_payload_bytes_total' : IDL.Nat,
|
|
53
|
+
});
|
|
48
54
|
const CanisterStatusResponse = IDL.Record({
|
|
49
55
|
'status' : CanisterStatusType,
|
|
50
56
|
'memory_size' : IDL.Nat,
|
|
51
57
|
'cycles' : IDL.Nat,
|
|
52
58
|
'settings' : DefiniteCanisterSettings,
|
|
59
|
+
'query_stats' : QueryStats,
|
|
53
60
|
'idle_cycles_burned_per_day' : IDL.Nat,
|
|
54
61
|
'module_hash' : IDL.Opt(IDL.Vec(IDL.Nat8)),
|
|
55
62
|
});
|
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Ht=Object.create;var G=Object.defineProperty;var jt=Object.getOwnPropertyDescriptor;var zt=Object.getOwnPropertyNames;var Xt=Object.getPrototypeOf,Jt=Object.prototype.hasOwnProperty;var A=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Qt=(t,e)=>{for(var r in e)G(t,r,{get:e[r],enumerable:!0})},wt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of zt(e))!Jt.call(t,o)&&o!==r&&G(t,o,{get:()=>e[o],enumerable:!(n=jt(e,o))||n.enumerable});return t};var yt=(t,e,r)=>(r=t!=null?Ht(Xt(t)):{},wt(e||!t||!t.__esModule?G(r,"default",{value:t,enumerable:!0}):r,t)),Kt=t=>wt(G({},"__esModule",{value:!0}),t);var D=A(($e,Vt)=>{"use strict";var ne="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";Vt.exports=ne});var Bt=A((He,Ot)=>{"use strict";var oe=D(),ie=t=>{if(!t||typeof t!="string")throw new Error(`Expected base58 string but got \u201C${t}\u201D`);if(t.match(/[IOl0]/gmu))throw new Error(`Invalid base58 character \u201C${t.match(/[IOl0]/gmu)}\u201D`);let e=t.match(/^1+/gmu),r=e?e[0].length:0,n=(t.length-r)*(Math.log(58)/Math.log(256))+1>>>0;return new Uint8Array([...new Uint8Array(r),...t.match(/.{1}/gmu).map(o=>oe.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))])};Ot.exports=ie});var Ut=A((je,Tt)=>{"use strict";var Pt=D(),ce=()=>{let t=Array(256).fill(-1);for(let e=0;e<Pt.length;++e)t[Pt.charCodeAt(e)]=e;return t};Tt.exports=ce});var Ft=A((ze,Ct)=>{"use strict";var Et=D(),ae=Ut(),se=ae(),de=t=>{let e=[];for(let r of t){let n=r;for(let o=0;o<e.length;++o){let c=(se[e[o]]<<8)+n;e[o]=Et.charCodeAt(c%58),n=c/58|0}for(;n;)e.push(Et.charCodeAt(n%58)),n=n/58|0}for(let r of t){if(r)break;e.push("1".charCodeAt(0))}return e.reverse(),String.fromCharCode(...e)};Ct.exports=de});var St=A(Nt=>{"use strict";Nt.base58_to_binary=Bt();Nt.binary_to_base58=Ft()});var Gt=A(T=>{"use strict";Object.defineProperty(T,"__esModule",{value:!0});T.bech32m=T.bech32=void 0;var tt="qpzry9x8gf2tvdw0s3jn54khce6mua7l",qt={};for(let t=0;t<tt.length;t++){let e=tt.charAt(t);qt[e]=t}function P(t){let e=t>>25;return(t&33554431)<<5^-(e>>0&1)&996825010^-(e>>1&1)&642813549^-(e>>2&1)&513874426^-(e>>3&1)&1027748829^-(e>>4&1)&705979059}function Mt(t){let e=1;for(let r=0;r<t.length;++r){let n=t.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+t+")";e=P(e)^n>>5}e=P(e);for(let r=0;r<t.length;++r){let n=t.charCodeAt(r);e=P(e)^n&31}return e}function bt(t,e,r,n){let o=0,c=0,i=(1<<r)-1,a=[];for(let u=0;u<t.length;++u)for(o=o<<e|t[u],c+=e;c>=r;)c-=r,a.push(o>>c&i);if(n)c>0&&a.push(o<<r-c&i);else{if(c>=e)return"Excess padding";if(o<<r-c&i)return"Non-zero padding"}return a}function ue(t){return bt(t,8,5,!0)}function le(t){let e=bt(t,5,8,!1);if(Array.isArray(e))return e}function pe(t){let e=bt(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function Wt(t){let e;t==="bech32"?e=1:e=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=Mt(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=P(l)^p,d+=tt.charAt(p)}for(let s=0;s<6;++s)l=P(l);l^=e;for(let s=0;s<6;++s){let p=l>>(5-s)*5&31;d+=tt.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=Mt(s);if(typeof f=="string")return f;let x=[];for(let _=0;_<p.length;++_){let b=p.charAt(_),g=qt[b];if(g===void 0)return"Unknown character "+b;f=P(f)^g,!(_+6>=p.length)&&x.push(g)}return f!==e?"Invalid checksum for "+i:{prefix:s,words:x}}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:ue,fromWordsUnsafe:le,fromWords:pe}}T.bech32=Wt("bech32");T.bech32m=Wt("bech32m")});var we={};Qt(we,{BtcAddressType:()=>ut,BtcNetwork:()=>dt,CkBTCMinterCanister:()=>Y,MinterAlreadyProcessingError:()=>H,MinterAmountTooLowError:()=>X,MinterGenericError:()=>w,MinterInsufficientAllowanceError:()=>Q,MinterInsufficientFundsError:()=>J,MinterMalformedAddressError:()=>z,MinterNoNewUtxosError:()=>j,MinterRetrieveBtcError:()=>y,MinterTemporaryUnavailableError:()=>$,MinterUpdateBalanceError:()=>q,ParseBtcAddressBadWitnessLengthError:()=>C,ParseBtcAddressError:()=>h,ParseBtcAddressInvalidError:()=>V,ParseBtcAddressMalformedAddressError:()=>k,ParseBtcAddressNoDataError:()=>E,ParseBtcAddressUnexpectedHumanReadablePartError:()=>S,ParseBtcAddressUnsupportedAddressTypeError:()=>O,ParseBtcAddressUnsupportedWitnessVersionError:()=>F,ParseBtcAddressWrongNetworkError:()=>M,createRetrieveBtcError:()=>K,createRetrieveBtcWithApprovalError:()=>ft,createUpdateBalanceError:()=>pt,parseBtcAddress:()=>ge});module.exports=Kt(we);var dt=(n=>(n[n.Mainnet=0]="Mainnet",n[n.Regtest=1]="Regtest",n[n.Testnet=2]="Testnet",n))(dt||{}),ut=(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))(ut||{});var h=class extends Error{},V=class extends h{},E=class extends h{},O=class extends h{},C=class extends h{},F=class extends h{},S=class extends h{},k=class extends h{},M=class extends h{};var B=require("@dfinity/utils"),w=class extends Error{},$=class extends w{},H=class extends w{},q=class extends w{},j=class extends q{constructor({pending_utxos:r,required_confirmations:n}){super();this.pendingUtxos=(0,B.fromNullable)(r)||[],this.requiredConfirmations=n}},y=class extends w{},z=class extends y{},X=class extends y{},J=class extends y{},Q=class extends y{},lt=t=>{if("GenericError"in t){let{GenericError:{error_message:e,error_code:r}}=t;return new w(`${e} (${r})`)}if("TemporarilyUnavailable"in t)return new $(t.TemporarilyUnavailable);if("AlreadyProcessing"in t)return new H},pt=t=>{let e=lt(t);return(0,B.nonNullish)(e)?e:"NoNewUtxos"in t?new j(t.NoNewUtxos):new q(`Unsupported response type in minter.updateBalance ${JSON.stringify(t)}`)},K=t=>{let e=lt(t);return(0,B.nonNullish)(e)?e:"MalformedAddress"in t?new z(t.MalformedAddress):"AmountTooLow"in t?new X(`${t.AmountTooLow}`):"InsufficientFunds"in t?new J(`${t.InsufficientFunds.balance}`):new y(`Unsupported response type in minter.retrieveBtc ${JSON.stringify(t)}`)},ft=t=>{let e=lt(t);return(0,B.nonNullish)(e)?e:"InsufficientAllowance"in t?new Q(`${t.InsufficientAllowance.allowance}`):K(t)};var m=require("@dfinity/utils");var Rt=({IDL:t})=>{let e=t.Variant({RestrictedTo:t.Vec(t.Principal),DepositsRestrictedTo:t.Vec(t.Principal),ReadOnly:t.Null,GeneralAvailability:t.Null}),r=t.Record({kyt_principal:t.Opt(t.Principal),mode:t.Opt(e),retrieve_btc_min_amount:t.Opt(t.Nat64),max_time_in_queue_nanos:t.Opt(t.Nat64),min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),n=t.Variant({Mainnet:t.Null,Regtest:t.Null,Testnet:t.Null}),o=t.Record({kyt_principal:t.Opt(t.Principal),ecdsa_key_name:t.Text,mode:e,retrieve_btc_min_amount:t.Nat64,ledger_id:t.Principal,max_time_in_queue_nanos:t.Nat64,btc_network:n,min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),c=t.Variant({Upgrade:t.Opt(r),Init:o}),i=t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),a=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),memory_allocation:t.Nat,compute_allocation:t.Nat}),u=t.Record({status:i,memory_size:t.Nat,cycles:t.Nat,settings:a,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8))}),l=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),d=t.Record({height:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),s=t.Variant({CallFailed:t.Null,TaintedDestination:t.Record({kyt_fee:t.Nat64,kyt_provider:t.Principal})}),p=t.Variant({p2wsh_v0:t.Vec(t.Nat8),p2tr_v1:t.Vec(t.Nat8),p2sh:t.Vec(t.Nat8),p2wpkh_v0:t.Vec(t.Nat8),p2pkh:t.Vec(t.Nat8)}),f=t.Variant({received_utxos:t.Record({to_account:l,mint_txid:t.Opt(t.Nat64),utxos:t.Vec(d)}),schedule_deposit_reimbursement:t.Record({burn_block_index:t.Nat64,account:l,amount:t.Nat64,reason:s}),sent_transaction:t.Record({fee:t.Opt(t.Nat64),change_output:t.Opt(t.Record({value:t.Nat64,vout:t.Nat32})),txid:t.Vec(t.Nat8),utxos:t.Vec(d),requests:t.Vec(t.Nat64),submitted_at:t.Nat64}),distributed_kyt_fee:t.Record({block_index:t.Nat64,amount:t.Nat64,kyt_provider:t.Principal}),init:o,upgrade:r,retrieve_btc_kyt_failed:t.Record({block_index:t.Nat64,owner:t.Principal,uuid:t.Text,address:t.Text,amount:t.Nat64,kyt_provider:t.Principal}),accepted_retrieve_btc_request:t.Record({received_at:t.Nat64,block_index:t.Nat64,address:p,reimbursement_account:t.Opt(l),amount:t.Nat64,kyt_provider:t.Opt(t.Principal)}),checked_utxo:t.Record({clean:t.Bool,utxo:d,uuid:t.Text,kyt_provider:t.Opt(t.Principal)}),removed_retrieve_btc_request:t.Record({block_index:t.Nat64}),confirmed_transaction:t.Record({txid:t.Vec(t.Nat8)}),replaced_transaction:t.Record({fee:t.Nat64,change_output:t.Record({value:t.Nat64,vout:t.Nat32}),old_txid:t.Vec(t.Nat8),new_txid:t.Vec(t.Nat8),submitted_at:t.Nat64}),ignored_utxo:t.Record({utxo:d}),reimbursed_failed_deposit:t.Record({burn_block_index:t.Nat64,mint_block_index:t.Nat64})}),x=t.Record({retrieve_btc_min_amount:t.Nat64,min_confirmations:t.Nat32,kyt_fee:t.Nat64}),_=t.Record({address:t.Text,amount:t.Nat64}),b=t.Record({block_index:t.Nat64}),g=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})}),et=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}),rt=t.Record({account:l,amount:t.Nat64,reason:s}),nt=t.Record({account:l,mint_block_index:t.Nat64,amount:t.Nat64,reason:s}),U=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:rt,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Reimbursed:nt,Pending:t.Null}),ot=t.Record({from_subaccount:t.Opt(t.Vec(t.Nat8)),address:t.Text,amount:t.Nat64}),it=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})}),ct=t.Variant({ValueTooSmall:d,Tainted:d,Minted:t.Record({minted_amount:t.Nat64,block_index:t.Nat64,utxo:d}),Checked:d}),at=t.Record({confirmations:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),st=t.Variant({GenericError:t.Record({error_message:t.Text,error_code:t.Nat64}),TemporarilyUnavailable:t.Text,AlreadyProcessing:t.Null,NoNewUtxos:t.Record({required_confirmations:t.Nat32,pending_utxos:t.Opt(t.Vec(at)),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([],[u],[]),get_deposit_fee:t.Func([],[t.Nat64],[]),get_events:t.Func([t.Record({start:t.Nat64,length:t.Nat64})],[t.Vec(f)],[]),get_minter_info:t.Func([],[x],[]),get_withdrawal_account:t.Func([],[l],[]),retrieve_btc:t.Func([_],[t.Variant({Ok:b,Err:g})],[]),retrieve_btc_status:t.Func([t.Record({block_index:t.Nat64})],[et],[]),retrieve_btc_status_v2:t.Func([t.Record({block_index:t.Nat64})],[U],[]),retrieve_btc_status_v2_by_account:t.Func([t.Opt(l)],[t.Vec(t.Record({block_index:t.Nat64,status_v2:t.Opt(U)}))],[]),retrieve_btc_with_approval:t.Func([ot],[t.Variant({Ok:b,Err:it})],[]),update_balance:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Variant({Ok:t.Vec(ct),Err:st})],[])})};var vt=({IDL:t})=>{let e=t.Variant({RestrictedTo:t.Vec(t.Principal),DepositsRestrictedTo:t.Vec(t.Principal),ReadOnly:t.Null,GeneralAvailability:t.Null}),r=t.Record({kyt_principal:t.Opt(t.Principal),mode:t.Opt(e),retrieve_btc_min_amount:t.Opt(t.Nat64),max_time_in_queue_nanos:t.Opt(t.Nat64),min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),n=t.Variant({Mainnet:t.Null,Regtest:t.Null,Testnet:t.Null}),o=t.Record({kyt_principal:t.Opt(t.Principal),ecdsa_key_name:t.Text,mode:e,retrieve_btc_min_amount:t.Nat64,ledger_id:t.Principal,max_time_in_queue_nanos:t.Nat64,btc_network:n,min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),c=t.Variant({Upgrade:t.Opt(r),Init:o}),i=t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),a=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),memory_allocation:t.Nat,compute_allocation:t.Nat}),u=t.Record({status:i,memory_size:t.Nat,cycles:t.Nat,settings:a,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8))}),l=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),d=t.Record({height:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),s=t.Variant({CallFailed:t.Null,TaintedDestination:t.Record({kyt_fee:t.Nat64,kyt_provider:t.Principal})}),p=t.Variant({p2wsh_v0:t.Vec(t.Nat8),p2tr_v1:t.Vec(t.Nat8),p2sh:t.Vec(t.Nat8),p2wpkh_v0:t.Vec(t.Nat8),p2pkh:t.Vec(t.Nat8)}),f=t.Variant({received_utxos:t.Record({to_account:l,mint_txid:t.Opt(t.Nat64),utxos:t.Vec(d)}),schedule_deposit_reimbursement:t.Record({burn_block_index:t.Nat64,account:l,amount:t.Nat64,reason:s}),sent_transaction:t.Record({fee:t.Opt(t.Nat64),change_output:t.Opt(t.Record({value:t.Nat64,vout:t.Nat32})),txid:t.Vec(t.Nat8),utxos:t.Vec(d),requests:t.Vec(t.Nat64),submitted_at:t.Nat64}),distributed_kyt_fee:t.Record({block_index:t.Nat64,amount:t.Nat64,kyt_provider:t.Principal}),init:o,upgrade:r,retrieve_btc_kyt_failed:t.Record({block_index:t.Nat64,owner:t.Principal,uuid:t.Text,address:t.Text,amount:t.Nat64,kyt_provider:t.Principal}),accepted_retrieve_btc_request:t.Record({received_at:t.Nat64,block_index:t.Nat64,address:p,reimbursement_account:t.Opt(l),amount:t.Nat64,kyt_provider:t.Opt(t.Principal)}),checked_utxo:t.Record({clean:t.Bool,utxo:d,uuid:t.Text,kyt_provider:t.Opt(t.Principal)}),removed_retrieve_btc_request:t.Record({block_index:t.Nat64}),confirmed_transaction:t.Record({txid:t.Vec(t.Nat8)}),replaced_transaction:t.Record({fee:t.Nat64,change_output:t.Record({value:t.Nat64,vout:t.Nat32}),old_txid:t.Vec(t.Nat8),new_txid:t.Vec(t.Nat8),submitted_at:t.Nat64}),ignored_utxo:t.Record({utxo:d}),reimbursed_failed_deposit:t.Record({burn_block_index:t.Nat64,mint_block_index:t.Nat64})}),x=t.Record({retrieve_btc_min_amount:t.Nat64,min_confirmations:t.Nat32,kyt_fee:t.Nat64}),_=t.Record({address:t.Text,amount:t.Nat64}),b=t.Record({block_index:t.Nat64}),g=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})}),et=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}),rt=t.Record({account:l,amount:t.Nat64,reason:s}),nt=t.Record({account:l,mint_block_index:t.Nat64,amount:t.Nat64,reason:s}),U=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:rt,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Reimbursed:nt,Pending:t.Null}),ot=t.Record({from_subaccount:t.Opt(t.Vec(t.Nat8)),address:t.Text,amount:t.Nat64}),it=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})}),ct=t.Variant({ValueTooSmall:d,Tainted:d,Minted:t.Record({minted_amount:t.Nat64,block_index:t.Nat64,utxo:d}),Checked:d}),at=t.Record({confirmations:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),st=t.Variant({GenericError:t.Record({error_message:t.Text,error_code:t.Nat64}),TemporarilyUnavailable:t.Text,AlreadyProcessing:t.Null,NoNewUtxos:t.Record({required_confirmations:t.Nat32,pending_utxos:t.Opt(t.Vec(at)),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([],[u],[]),get_deposit_fee:t.Func([],[t.Nat64],["query"]),get_events:t.Func([t.Record({start:t.Nat64,length:t.Nat64})],[t.Vec(f)],["query"]),get_minter_info:t.Func([],[x],["query"]),get_withdrawal_account:t.Func([],[l],[]),retrieve_btc:t.Func([_],[t.Variant({Ok:b,Err:g})],[]),retrieve_btc_status:t.Func([t.Record({block_index:t.Nat64})],[et],["query"]),retrieve_btc_status_v2:t.Func([t.Record({block_index:t.Nat64})],[U],["query"]),retrieve_btc_status_v2_by_account:t.Func([t.Opt(l)],[t.Vec(t.Record({block_index:t.Nat64,status_v2:t.Opt(U)}))],["query"]),retrieve_btc_with_approval:t.Func([ot],[t.Variant({Ok:b,Err:it})],[]),update_balance:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Variant({Ok:t.Vec(ct),Err:st})],[])})};var Y=class t 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 pt(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 K(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 ft(c.Err);return c.Ok};this.retrieveBtcStatus=async({transactionId:r,certified:n})=>this.caller({certified:n}).retrieve_btc_status({block_index:r});this.retrieveBtcStatusV2ByAccount=async({certified:r})=>(await this.caller({certified:r}).retrieve_btc_status_v2_by_account([])).map(({block_index:o,status_v2:c})=>({id:o,status:(0,m.fromNullable)(c)}));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:vt,certifiedIdlFactory:Rt});return new t(c,n,o)}};var gt=require("@dfinity/utils");function Yt(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function _t(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 kt(t,e){Yt(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var Zt=t=>t instanceof Uint8Array;var I=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),N=(t,e)=>t<<32-e|t>>>e,It=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!It)throw new Error("Non little-endian hardware is not supported");function Lt(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function mt(t){if(typeof t=="string"&&(t=Lt(t)),!Zt(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}var Z=class{clone(){return this._cloneInto()}},Ee={}.toString;function At(t){let e=n=>t().update(mt(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Dt(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,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;t.setUint32(e+u,i,n),t.setUint32(e+l,a,n)}var L=class extends Z{constructor(e,r,n,o){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=I(this.buffer)}update(e){_t(this);let{view:r,buffer:n,blockLen:o}=this;e=mt(e);let c=e.length;for(let i=0;i<c;){let a=Math.min(o-this.pos,c-i);if(a===o){let u=I(e);for(;o<=c-i;i+=o)this.process(u,i);continue}n.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){_t(this),kt(e,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;Dt(n,o-8,BigInt(this.length*8),c),this.process(n,0);let a=I(e),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: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:i,pos:a}=this;return e.length=o,e.pos=a,e.finished=c,e.destroyed=i,o%r&&e.buffer.set(n),e}};var te=(t,e,r)=>t&e^~t&r,ee=(t,e,r)=>t&e^t&r^e&r,re=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),xt=class extends L{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:e,B:r,C:n,D:o,E:c,F:i,G:a,H:u}=this;return[e,r,n,o,c,i,a,u]}set(e,r,n,o,c,i,a,u){this.A=e|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(e,r){for(let s=0;s<16;s++,r+=4)v[s]=e.getUint32(r,!1);for(let s=16;s<64;s++){let p=v[s-15],f=v[s-2],x=N(p,7)^N(p,18)^p>>>3,_=N(f,17)^N(f,19)^f>>>10;v[s]=_+v[s-7]+x+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+te(a,u,l)+re[s]+v[s]|0,_=(N(n,2)^N(n,13)^N(n,22))+ee(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 ht=At(()=>new xt);var $t=yt(St()),W=yt(Gt());var fe=0,_e=5,me=111,xe=196,he={[fe]:{type:1,networks:[0]},[me]:{type:1,networks:[2,1]},[_e]:{type:2,networks:[0]},[xe]:{type:2,networks:[2,1]}},Ne=({address:t,network:e})=>{let n=(d=>{try{return(0,$t.base58_to_binary)(d)}catch{throw new V}})(t),{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=ht.create();f.update(p);let x=ht.create();x.update(f.digest());let _=x.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=he[i];if((0,gt.isNullish)(a))throw new O;let{type:u,networks:l}=a;if(!l.includes(e))throw new M;return{address:t,network:e,type:u,parser:"base58"}},be=({address:t,network:e})=>{let r=d=>{try{return d.startsWith("bc1p")||d.startsWith("tb1p")||d.startsWith("bcrt1p")?W.bech32m.decode(d):W.bech32.decode(d)}catch{throw new k}},{prefix:n,words:o}=r(t),i={bc:0,tb:2,bcrt:1}[n];if((0,gt.isNullish)(i))throw new V;if(i!==e)throw new S;let[a,...u]=o;if(a>1)throw new F;switch(W.bech32.fromWords(u).length){case 20:return{address:t,network:e,type:0,parser:"bip-173"};case 32:return{address:t,network:e,type:a===0?3:4,parser:"bip-173"};default:throw new C}},ge=({address:t,network:e=0})=>{switch(t.charAt(0)){case"1":case"2":case"3":case"m":case"n":return Ne({address:t,network:e});case"b":case"B":case"t":case"T":return be({address:t,network:e});case"":throw new E;default:throw new O}};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 jt=Object.create;var G=Object.defineProperty;var zt=Object.getOwnPropertyDescriptor;var Xt=Object.getOwnPropertyNames;var Qt=Object.getPrototypeOf,Jt=Object.prototype.hasOwnProperty;var A=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Kt=(t,e)=>{for(var r in e)G(t,r,{get:e[r],enumerable:!0})},wt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Xt(e))!Jt.call(t,o)&&o!==r&&G(t,o,{get:()=>e[o],enumerable:!(n=zt(e,o))||n.enumerable});return t};var Rt=(t,e,r)=>(r=t!=null?jt(Qt(t)):{},wt(e||!t||!t.__esModule?G(r,"default",{value:t,enumerable:!0}):r,t)),Yt=t=>wt(G({},"__esModule",{value:!0}),t);var D=A((He,Ot)=>{"use strict";var oe="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";Ot.exports=oe});var Pt=A((je,Bt)=>{"use strict";var ie=D(),ae=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=>ie.indexOf(o)).reduce((o,a)=>(o=o.map(i=>{let s=i*58+a;return a=s>>8,s}),o),new Uint8Array(n)).reverse().filter((o=>a=>o=o||a)(!1))])};Bt.exports=ae});var Et=A((ze,Ut)=>{"use strict";var Tt=D(),ce=()=>{let t=Array(256).fill(-1);for(let e=0;e<Tt.length;++e)t[Tt.charCodeAt(e)]=e;return t};Ut.exports=ce});var St=A((Xe,Ft)=>{"use strict";var Ct=D(),se=Et(),de=se(),ue=t=>{let e=[];for(let r of t){let n=r;for(let o=0;o<e.length;++o){let a=(de[e[o]]<<8)+n;e[o]=Ct.charCodeAt(a%58),n=a/58|0}for(;n;)e.push(Ct.charCodeAt(n%58)),n=n/58|0}for(let r of t){if(r)break;e.push("1".charCodeAt(0))}return e.reverse(),String.fromCharCode(...e)};Ft.exports=ue});var qt=A(bt=>{"use strict";bt.base58_to_binary=Pt();bt.binary_to_base58=St()});var $t=A(T=>{"use strict";Object.defineProperty(T,"__esModule",{value:!0});T.bech32m=T.bech32=void 0;var tt="qpzry9x8gf2tvdw0s3jn54khce6mua7l",Wt={};for(let t=0;t<tt.length;t++){let e=tt.charAt(t);Wt[e]=t}function P(t){let e=t>>25;return(t&33554431)<<5^-(e>>0&1)&996825010^-(e>>1&1)&642813549^-(e>>2&1)&513874426^-(e>>3&1)&1027748829^-(e>>4&1)&705979059}function Mt(t){let e=1;for(let r=0;r<t.length;++r){let n=t.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+t+")";e=P(e)^n>>5}e=P(e);for(let r=0;r<t.length;++r){let n=t.charCodeAt(r);e=P(e)^n&31}return e}function gt(t,e,r,n){let o=0,a=0,i=(1<<r)-1,s=[];for(let u=0;u<t.length;++u)for(o=o<<e|t[u],a+=e;a>=r;)a-=r,s.push(o>>a&i);if(n)a>0&&s.push(o<<r-a&i);else{if(a>=e)return"Excess padding";if(o<<r-a&i)return"Non-zero padding"}return s}function le(t){return gt(t,8,5,!0)}function pe(t){let e=gt(t,5,8,!1);if(Array.isArray(e))return e}function fe(t){let e=gt(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function Gt(t){let e;t==="bech32"?e=1:e=734539939;function r(i,s,u){if(u=u||90,i.length+7+s.length>u)throw new TypeError("Exceeds length limit");i=i.toLowerCase();let l=Mt(i);if(typeof l=="string")throw new Error(l);let d=i+"1";for(let c=0;c<s.length;++c){let p=s[c];if(p>>5)throw new Error("Non 5-bit word");l=P(l)^p,d+=tt.charAt(p)}for(let c=0;c<6;++c)l=P(l);l^=e;for(let c=0;c<6;++c){let p=l>>(5-c)*5&31;d+=tt.charAt(p)}return d}function n(i,s){if(s=s||90,i.length<8)return i+" too short";if(i.length>s)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 c=i.slice(0,d),p=i.slice(d+1);if(p.length<6)return"Data too short";let f=Mt(c);if(typeof f=="string")return f;let x=[];for(let _=0;_<p.length;++_){let g=p.charAt(_),h=Wt[g];if(h===void 0)return"Unknown character "+g;f=P(f)^h,!(_+6>=p.length)&&x.push(h)}return f!==e?"Invalid checksum for "+i:{prefix:c,words:x}}function o(i,s){let u=n(i,s);if(typeof u=="object")return u}function a(i,s){let u=n(i,s);if(typeof u=="object")return u;throw new Error(u)}return{decodeUnsafe:o,decode:a,encode:r,toWords:le,fromWordsUnsafe:pe,fromWords:fe}}T.bech32=Gt("bech32");T.bech32m=Gt("bech32m")});var we={};Kt(we,{BtcAddressType:()=>lt,BtcNetwork:()=>ut,CkBTCMinterCanister:()=>Y,MinterAlreadyProcessingError:()=>H,MinterAmountTooLowError:()=>X,MinterGenericError:()=>y,MinterInsufficientAllowanceError:()=>J,MinterInsufficientFundsError:()=>Q,MinterMalformedAddressError:()=>z,MinterNoNewUtxosError:()=>j,MinterRetrieveBtcError:()=>w,MinterTemporaryUnavailableError:()=>$,MinterUpdateBalanceError:()=>M,ParseBtcAddressBadWitnessLengthError:()=>C,ParseBtcAddressError:()=>N,ParseBtcAddressInvalidError:()=>V,ParseBtcAddressMalformedAddressError:()=>k,ParseBtcAddressNoDataError:()=>E,ParseBtcAddressUnexpectedHumanReadablePartError:()=>S,ParseBtcAddressUnsupportedAddressTypeError:()=>O,ParseBtcAddressUnsupportedWitnessVersionError:()=>F,ParseBtcAddressWrongNetworkError:()=>q,createRetrieveBtcError:()=>K,createRetrieveBtcWithApprovalError:()=>_t,createUpdateBalanceError:()=>ft,parseBtcAddress:()=>ye});module.exports=Yt(we);var ut=(n=>(n[n.Mainnet=0]="Mainnet",n[n.Regtest=1]="Regtest",n[n.Testnet=2]="Testnet",n))(ut||{}),lt=(a=>(a[a.P2wpkhV0=0]="P2wpkhV0",a[a.P2pkh=1]="P2pkh",a[a.P2sh=2]="P2sh",a[a.P2wsh=3]="P2wsh",a[a.P2tr=4]="P2tr",a))(lt||{});var N=class extends Error{},V=class extends N{},E=class extends N{},O=class extends N{},C=class extends N{},F=class extends N{},S=class extends N{},k=class extends N{},q=class extends N{};var B=require("@dfinity/utils"),y=class extends Error{},$=class extends y{},H=class extends y{},M=class extends y{},j=class extends M{constructor({pending_utxos:r,required_confirmations:n}){super();this.pendingUtxos=(0,B.fromNullable)(r)||[],this.requiredConfirmations=n}},w=class extends y{},z=class extends w{},X=class extends w{},Q=class extends w{},J=class extends w{},pt=t=>{if("GenericError"in t){let{GenericError:{error_message:e,error_code:r}}=t;return new y(`${e} (${r})`)}if("TemporarilyUnavailable"in t)return new $(t.TemporarilyUnavailable);if("AlreadyProcessing"in t)return new H},ft=t=>{let e=pt(t);return(0,B.nonNullish)(e)?e:"NoNewUtxos"in t?new j(t.NoNewUtxos):new M(`Unsupported response type in minter.updateBalance ${JSON.stringify(t)}`)},K=t=>{let e=pt(t);return(0,B.nonNullish)(e)?e:"MalformedAddress"in t?new z(t.MalformedAddress):"AmountTooLow"in t?new X(`${t.AmountTooLow}`):"InsufficientFunds"in t?new Q(`${t.InsufficientFunds.balance}`):new w(`Unsupported response type in minter.retrieveBtc ${JSON.stringify(t)}`)},_t=t=>{let e=pt(t);return(0,B.nonNullish)(e)?e:"InsufficientAllowance"in t?new J(`${t.InsufficientAllowance.allowance}`):K(t)};var m=require("@dfinity/utils");var vt=({IDL:t})=>{let e=t.Variant({RestrictedTo:t.Vec(t.Principal),DepositsRestrictedTo:t.Vec(t.Principal),ReadOnly:t.Null,GeneralAvailability:t.Null}),r=t.Record({kyt_principal:t.Opt(t.Principal),mode:t.Opt(e),retrieve_btc_min_amount:t.Opt(t.Nat64),max_time_in_queue_nanos:t.Opt(t.Nat64),min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),n=t.Variant({Mainnet:t.Null,Regtest:t.Null,Testnet:t.Null}),o=t.Record({kyt_principal:t.Opt(t.Principal),ecdsa_key_name:t.Text,mode:e,retrieve_btc_min_amount:t.Nat64,ledger_id:t.Principal,max_time_in_queue_nanos:t.Nat64,btc_network:n,min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),a=t.Variant({Upgrade:t.Opt(r),Init:o}),i=t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),s=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),memory_allocation:t.Nat,compute_allocation:t.Nat}),u=t.Record({response_payload_bytes_total:t.Nat,num_instructions_total:t.Nat,num_calls_total:t.Nat,request_payload_bytes_total:t.Nat}),l=t.Record({status:i,memory_size:t.Nat,cycles:t.Nat,settings:s,query_stats:u,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8))}),d=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),c=t.Record({height:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),p=t.Variant({CallFailed:t.Null,TaintedDestination:t.Record({kyt_fee:t.Nat64,kyt_provider:t.Principal})}),f=t.Variant({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)}),x=t.Variant({received_utxos:t.Record({to_account:d,mint_txid:t.Opt(t.Nat64),utxos:t.Vec(c)}),schedule_deposit_reimbursement:t.Record({burn_block_index:t.Nat64,account:d,amount:t.Nat64,reason:p}),sent_transaction:t.Record({fee:t.Opt(t.Nat64),change_output:t.Opt(t.Record({value:t.Nat64,vout:t.Nat32})),txid:t.Vec(t.Nat8),utxos:t.Vec(c),requests:t.Vec(t.Nat64),submitted_at:t.Nat64}),distributed_kyt_fee:t.Record({block_index:t.Nat64,amount:t.Nat64,kyt_provider:t.Principal}),init:o,upgrade:r,retrieve_btc_kyt_failed:t.Record({block_index:t.Nat64,owner:t.Principal,uuid:t.Text,address:t.Text,amount:t.Nat64,kyt_provider:t.Principal}),accepted_retrieve_btc_request:t.Record({received_at:t.Nat64,block_index:t.Nat64,address:f,reimbursement_account:t.Opt(d),amount:t.Nat64,kyt_provider:t.Opt(t.Principal)}),checked_utxo:t.Record({clean:t.Bool,utxo:c,uuid:t.Text,kyt_provider:t.Opt(t.Principal)}),removed_retrieve_btc_request:t.Record({block_index:t.Nat64}),confirmed_transaction:t.Record({txid:t.Vec(t.Nat8)}),replaced_transaction:t.Record({fee:t.Nat64,change_output:t.Record({value:t.Nat64,vout:t.Nat32}),old_txid:t.Vec(t.Nat8),new_txid:t.Vec(t.Nat8),submitted_at:t.Nat64}),ignored_utxo:t.Record({utxo:c}),reimbursed_failed_deposit:t.Record({burn_block_index:t.Nat64,mint_block_index:t.Nat64})}),_=t.Record({retrieve_btc_min_amount:t.Nat64,min_confirmations:t.Nat32,kyt_fee:t.Nat64}),g=t.Record({address:t.Text,amount:t.Nat64}),h=t.Record({block_index:t.Nat64}),et=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})}),rt=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}),nt=t.Record({account:d,amount:t.Nat64,reason:p}),ot=t.Record({account:d,mint_block_index:t.Nat64,amount:t.Nat64,reason:p}),U=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:nt,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Reimbursed:ot,Pending:t.Null}),it=t.Record({from_subaccount:t.Opt(t.Vec(t.Nat8)),address:t.Text,amount:t.Nat64}),at=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})}),ct=t.Variant({ValueTooSmall:c,Tainted:c,Minted:t.Record({minted_amount:t.Nat64,block_index:t.Nat64,utxo:c}),Checked:c}),st=t.Record({confirmations:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),dt=t.Variant({GenericError:t.Record({error_message:t.Text,error_code:t.Nat64}),TemporarilyUnavailable:t.Text,AlreadyProcessing:t.Null,NoNewUtxos:t.Record({required_confirmations:t.Nat32,pending_utxos:t.Opt(t.Vec(st)),current_confirmations:t.Opt(t.Nat32)})});return t.Service({estimate_withdrawal_fee:t.Func([t.Record({amount:t.Opt(t.Nat64)})],[t.Record({minter_fee:t.Nat64,bitcoin_fee:t.Nat64})],[]),get_btc_address:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Text],[]),get_canister_status:t.Func([],[l],[]),get_deposit_fee:t.Func([],[t.Nat64],[]),get_events:t.Func([t.Record({start:t.Nat64,length:t.Nat64})],[t.Vec(x)],[]),get_minter_info:t.Func([],[_],[]),get_withdrawal_account:t.Func([],[d],[]),retrieve_btc:t.Func([g],[t.Variant({Ok:h,Err:et})],[]),retrieve_btc_status:t.Func([t.Record({block_index:t.Nat64})],[rt],[]),retrieve_btc_status_v2:t.Func([t.Record({block_index:t.Nat64})],[U],[]),retrieve_btc_status_v2_by_account:t.Func([t.Opt(d)],[t.Vec(t.Record({block_index:t.Nat64,status_v2:t.Opt(U)}))],[]),retrieve_btc_with_approval:t.Func([it],[t.Variant({Ok:h,Err:at})],[]),update_balance:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Variant({Ok:t.Vec(ct),Err:dt})],[])})};var kt=({IDL:t})=>{let e=t.Variant({RestrictedTo:t.Vec(t.Principal),DepositsRestrictedTo:t.Vec(t.Principal),ReadOnly:t.Null,GeneralAvailability:t.Null}),r=t.Record({kyt_principal:t.Opt(t.Principal),mode:t.Opt(e),retrieve_btc_min_amount:t.Opt(t.Nat64),max_time_in_queue_nanos:t.Opt(t.Nat64),min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),n=t.Variant({Mainnet:t.Null,Regtest:t.Null,Testnet:t.Null}),o=t.Record({kyt_principal:t.Opt(t.Principal),ecdsa_key_name:t.Text,mode:e,retrieve_btc_min_amount:t.Nat64,ledger_id:t.Principal,max_time_in_queue_nanos:t.Nat64,btc_network:n,min_confirmations:t.Opt(t.Nat32),kyt_fee:t.Opt(t.Nat64)}),a=t.Variant({Upgrade:t.Opt(r),Init:o}),i=t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),s=t.Record({freezing_threshold:t.Nat,controllers:t.Vec(t.Principal),memory_allocation:t.Nat,compute_allocation:t.Nat}),u=t.Record({response_payload_bytes_total:t.Nat,num_instructions_total:t.Nat,num_calls_total:t.Nat,request_payload_bytes_total:t.Nat}),l=t.Record({status:i,memory_size:t.Nat,cycles:t.Nat,settings:s,query_stats:u,idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8))}),d=t.Record({owner:t.Principal,subaccount:t.Opt(t.Vec(t.Nat8))}),c=t.Record({height:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),p=t.Variant({CallFailed:t.Null,TaintedDestination:t.Record({kyt_fee:t.Nat64,kyt_provider:t.Principal})}),f=t.Variant({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)}),x=t.Variant({received_utxos:t.Record({to_account:d,mint_txid:t.Opt(t.Nat64),utxos:t.Vec(c)}),schedule_deposit_reimbursement:t.Record({burn_block_index:t.Nat64,account:d,amount:t.Nat64,reason:p}),sent_transaction:t.Record({fee:t.Opt(t.Nat64),change_output:t.Opt(t.Record({value:t.Nat64,vout:t.Nat32})),txid:t.Vec(t.Nat8),utxos:t.Vec(c),requests:t.Vec(t.Nat64),submitted_at:t.Nat64}),distributed_kyt_fee:t.Record({block_index:t.Nat64,amount:t.Nat64,kyt_provider:t.Principal}),init:o,upgrade:r,retrieve_btc_kyt_failed:t.Record({block_index:t.Nat64,owner:t.Principal,uuid:t.Text,address:t.Text,amount:t.Nat64,kyt_provider:t.Principal}),accepted_retrieve_btc_request:t.Record({received_at:t.Nat64,block_index:t.Nat64,address:f,reimbursement_account:t.Opt(d),amount:t.Nat64,kyt_provider:t.Opt(t.Principal)}),checked_utxo:t.Record({clean:t.Bool,utxo:c,uuid:t.Text,kyt_provider:t.Opt(t.Principal)}),removed_retrieve_btc_request:t.Record({block_index:t.Nat64}),confirmed_transaction:t.Record({txid:t.Vec(t.Nat8)}),replaced_transaction:t.Record({fee:t.Nat64,change_output:t.Record({value:t.Nat64,vout:t.Nat32}),old_txid:t.Vec(t.Nat8),new_txid:t.Vec(t.Nat8),submitted_at:t.Nat64}),ignored_utxo:t.Record({utxo:c}),reimbursed_failed_deposit:t.Record({burn_block_index:t.Nat64,mint_block_index:t.Nat64})}),_=t.Record({retrieve_btc_min_amount:t.Nat64,min_confirmations:t.Nat32,kyt_fee:t.Nat64}),g=t.Record({address:t.Text,amount:t.Nat64}),h=t.Record({block_index:t.Nat64}),et=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})}),rt=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}),nt=t.Record({account:d,amount:t.Nat64,reason:p}),ot=t.Record({account:d,mint_block_index:t.Nat64,amount:t.Nat64,reason:p}),U=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:nt,Unknown:t.Null,Submitted:t.Record({txid:t.Vec(t.Nat8)}),Reimbursed:ot,Pending:t.Null}),it=t.Record({from_subaccount:t.Opt(t.Vec(t.Nat8)),address:t.Text,amount:t.Nat64}),at=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})}),ct=t.Variant({ValueTooSmall:c,Tainted:c,Minted:t.Record({minted_amount:t.Nat64,block_index:t.Nat64,utxo:c}),Checked:c}),st=t.Record({confirmations:t.Nat32,value:t.Nat64,outpoint:t.Record({txid:t.Vec(t.Nat8),vout:t.Nat32})}),dt=t.Variant({GenericError:t.Record({error_message:t.Text,error_code:t.Nat64}),TemporarilyUnavailable:t.Text,AlreadyProcessing:t.Null,NoNewUtxos:t.Record({required_confirmations:t.Nat32,pending_utxos:t.Opt(t.Vec(st)),current_confirmations:t.Opt(t.Nat32)})});return t.Service({estimate_withdrawal_fee:t.Func([t.Record({amount:t.Opt(t.Nat64)})],[t.Record({minter_fee:t.Nat64,bitcoin_fee:t.Nat64})],["query"]),get_btc_address:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Text],[]),get_canister_status:t.Func([],[l],[]),get_deposit_fee:t.Func([],[t.Nat64],["query"]),get_events:t.Func([t.Record({start:t.Nat64,length:t.Nat64})],[t.Vec(x)],["query"]),get_minter_info:t.Func([],[_],["query"]),get_withdrawal_account:t.Func([],[d],[]),retrieve_btc:t.Func([g],[t.Variant({Ok:h,Err:et})],[]),retrieve_btc_status:t.Func([t.Record({block_index:t.Nat64})],[rt],["query"]),retrieve_btc_status_v2:t.Func([t.Record({block_index:t.Nat64})],[U],["query"]),retrieve_btc_status_v2_by_account:t.Func([t.Opt(d)],[t.Vec(t.Record({block_index:t.Nat64,status_v2:t.Opt(U)}))],["query"]),retrieve_btc_with_approval:t.Func([it],[t.Variant({Ok:h,Err:at})],[]),update_balance:t.Func([t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))})],[t.Variant({Ok:t.Vec(ct),Err:dt})],[])})};var Y=class t 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 ft(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 K(n.Err);return n.Ok};this.retrieveBtcWithApproval=async({address:r,amount:n,fromSubaccount:o})=>{let a=await this.caller({certified:!0}).retrieve_btc_with_approval({address:r,amount:n,from_subaccount:(0,m.toNullable)(o)});if("Err"in a)throw _t(a.Err);return a.Ok};this.retrieveBtcStatus=async({transactionId:r,certified:n})=>this.caller({certified:n}).retrieve_btc_status({block_index:r});this.retrieveBtcStatusV2ByAccount=async({certified:r})=>(await this.caller({certified:r}).retrieve_btc_status_v2_by_account([])).map(({block_index:o,status_v2:a})=>({id:o,status:(0,m.fromNullable)(a)}));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:a}=(0,m.createServices)({options:r,idlFactory:kt,certifiedIdlFactory:vt});return new t(a,n,o)}};var yt=require("@dfinity/utils");function Zt(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function mt(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 At(t,e){Zt(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var It=t=>t instanceof Uint8Array;var I=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),b=(t,e)=>t<<32-e|t>>>e,Lt=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Lt)throw new Error("Non little-endian hardware is not supported");function Dt(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function xt(t){if(typeof t=="string"&&(t=Dt(t)),!It(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}var Z=class{clone(){return this._cloneInto()}},Ce={}.toString;function Vt(t){let e=n=>t().update(xt(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function te(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let o=BigInt(32),a=BigInt(4294967295),i=Number(r>>o&a),s=Number(r&a),u=n?4:0,l=n?0:4;t.setUint32(e+u,i,n),t.setUint32(e+l,s,n)}var L=class extends Z{constructor(e,r,n,o){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=I(this.buffer)}update(e){mt(this);let{view:r,buffer:n,blockLen:o}=this;e=xt(e);let a=e.length;for(let i=0;i<a;){let s=Math.min(o-this.pos,a-i);if(s===o){let u=I(e);for(;o<=a-i;i+=o)this.process(u,i);continue}n.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){mt(this),At(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:a}=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 c=i;c<o;c++)r[c]=0;te(n,o-8,BigInt(this.length*8),a),this.process(n,0);let s=I(e),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 c=0;c<l;c++)s.setUint32(4*c,d[c],a)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:a,destroyed:i,pos:s}=this;return e.length=o,e.pos=s,e.finished=a,e.destroyed=i,o%r&&e.buffer.set(n),e}};var ee=(t,e,r)=>t&e^~t&r,re=(t,e,r)=>t&e^t&r^e&r,ne=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),ht=class extends L{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:e,B:r,C:n,D:o,E:a,F:i,G:s,H:u}=this;return[e,r,n,o,a,i,s,u]}set(e,r,n,o,a,i,s,u){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=a|0,this.F=i|0,this.G=s|0,this.H=u|0}process(e,r){for(let c=0;c<16;c++,r+=4)v[c]=e.getUint32(r,!1);for(let c=16;c<64;c++){let p=v[c-15],f=v[c-2],x=b(p,7)^b(p,18)^p>>>3,_=b(f,17)^b(f,19)^f>>>10;v[c]=_+v[c-7]+x+v[c-16]|0}let{A:n,B:o,C:a,D:i,E:s,F:u,G:l,H:d}=this;for(let c=0;c<64;c++){let p=b(s,6)^b(s,11)^b(s,25),f=d+p+ee(s,u,l)+ne[c]+v[c]|0,_=(b(n,2)^b(n,13)^b(n,22))+re(n,o,a)|0;d=l,l=u,u=s,s=i+f|0,i=a,a=o,o=n,n=f+_|0}n=n+this.A|0,o=o+this.B|0,a=a+this.C|0,i=i+this.D|0,s=s+this.E|0,u=u+this.F|0,l=l+this.G|0,d=d+this.H|0,this.set(n,o,a,i,s,u,l,d)}roundClean(){v.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Nt=Vt(()=>new ht);var Ht=Rt(qt()),W=Rt($t());var _e=0,me=5,xe=111,he=196,Ne={[_e]:{type:1,networks:[0]},[xe]:{type:1,networks:[2,1]},[me]:{type:2,networks:[0]},[he]:{type:2,networks:[2,1]}},be=({address:t,network:e})=>{let n=(d=>{try{return(0,Ht.base58_to_binary)(d)}catch{throw new V}})(t),{length:o}=n;if(o!==25)throw new k(`Expected the address to be 25 bytes, got ${o}.`);(d=>{let c=d.slice(o-4,o),p=d.slice(0,o-4),f=Nt.create();f.update(p);let x=Nt.create();x.update(f.digest());let _=x.digest().slice(0,4);if(c.some((g,h)=>g!==_[h]))throw new k(`Checksum mismatch expected ${c}, got ${_}.`)})(n);let i=n[0],s=Ne[i];if((0,yt.isNullish)(s))throw new O;let{type:u,networks:l}=s;if(!l.includes(e))throw new q;return{address:t,network:e,type:u,parser:"base58"}},ge=({address:t,network:e})=>{let r=d=>{try{return d.startsWith("bc1p")||d.startsWith("tb1p")||d.startsWith("bcrt1p")?W.bech32m.decode(d):W.bech32.decode(d)}catch{throw new k}},{prefix:n,words:o}=r(t),i={bc:0,tb:2,bcrt:1}[n];if((0,yt.isNullish)(i))throw new V;if(i!==e)throw new S;let[s,...u]=o;if(s>1)throw new F;switch(W.bech32.fromWords(u).length){case 20:return{address:t,network:e,type:0,parser:"bip-173"};case 32:return{address:t,network:e,type:s===0?3:4,parser:"bip-173"};default:throw new C}},ye=({address:t,network:e=0})=>{switch(t.charAt(0)){case"1":case"2":case"3":case"m":case"n":return be({address:t,network:e});case"b":case"B":case"t":case"T":return ge({address:t,network:e});case"":throw new E;default:throw new O}};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:
|