aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-02-24 13:18:42 -0800
committerAdam Soltys <[email protected]>2026-02-24 13:18:42 -0800
commitad7b09b43323d0ffc0a8ddabb43e4838a184c697 (patch)
treefbf2a59f81771b2938f474c8e7b35a497d2960e4
parent9e97e040617bfa0b40150c0eba298bf186bbeeaf (diff)
downloadcoinos-server-ad7b09b43323d0ffc0a8ddabb43e4838a184c697.tar.gz
coinos-server-ad7b09b43323d0ffc0a8ddabb43e4838a184c697.zip
formatting
-rw-r--r--.github/workflows/lint.yml15
-rw-r--r--.husky/pre-commit1
-rw-r--r--.oxlintrc.json11
-rw-r--r--LICENSE.md310
-rw-r--r--README.md18
-rw-r--r--biome.json10
-rw-r--r--bun.lock165
-rw-r--r--index.ts8
-rw-r--r--inspect-ark.ts2
-rw-r--r--lib/app.ts4
-rw-r--r--lib/ark.ts29
-rw-r--r--lib/auth.ts3
-rw-r--r--lib/ecash.ts1
-rw-r--r--lib/esplora.ts9
-rw-r--r--lib/health.ts29
-rw-r--r--lib/lightning.ts16
-rw-r--r--lib/ln.ts4
-rw-r--r--lib/locales/index.ts8
-rw-r--r--lib/locations.ts5
-rw-r--r--lib/migrate.ts5
-rw-r--r--lib/nostr.ts27
-rw-r--r--lib/notes.ts47
-rw-r--r--lib/notifications.ts16
-rw-r--r--lib/nwc.ts126
-rw-r--r--lib/passkey.ts8
-rw-r--r--lib/payments.ts171
-rw-r--r--lib/rates.ts4
-rw-r--r--lib/register.ts7
-rw-r--r--lib/sockets.ts13
-rw-r--r--lib/tb.ts40
-rw-r--r--lib/upload.ts9
-rw-r--r--lib/utils.ts17
-rw-r--r--lib/zmq.ts39
-rw-r--r--mint.ts7
-rw-r--r--package.json14
-rw-r--r--routes/ecash.ts12
-rw-r--r--routes/email.ts4
-rw-r--r--routes/info.ts9
-rw-r--r--routes/invoices.ts14
-rw-r--r--routes/lnurl.ts19
-rw-r--r--routes/nostr.ts19
-rw-r--r--routes/payments.ts86
-rw-r--r--routes/shopify.ts21
-rw-r--r--routes/users.ts101
-rw-r--r--templates/payments/received.html32
-rw-r--r--templates/payments/reset.html3
-rw-r--r--test/forward.test.ts211
-rw-r--r--test/integration/ark-reconcile.test.ts20
-rw-r--r--test/integration/bolt12.test.ts35
-rw-r--r--test/onchain.test.ts128
-rw-r--r--test/preload.ts639
51 files changed, 1259 insertions, 1292 deletions
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
new file mode 100644
index 00000000..c7c9dd41
--- /dev/null
+++ b/.github/workflows/lint.yml
@@ -0,0 +1,15 @@
+name: Lint & Format
+
+on:
+ push:
+ branches: [master]
+ pull_request:
+
+jobs:
+ lint:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: oven-sh/setup-bun@v2
+ - run: bun install --frozen-lockfile
+ - run: bun run lint
diff --git a/.husky/pre-commit b/.husky/pre-commit
new file mode 100644
index 00000000..ea5a55b6
--- /dev/null
+++ b/.husky/pre-commit
@@ -0,0 +1 @@
+bunx lint-staged
diff --git a/.oxlintrc.json b/.oxlintrc.json
new file mode 100644
index 00000000..3fa80a59
--- /dev/null
+++ b/.oxlintrc.json
@@ -0,0 +1,11 @@
+{
+ "$schema": "./node_modules/oxlint/configuration_schema.json",
+ "plugins": ["typescript", "unicorn", "oxc"],
+ "categories": {
+ "correctness": "warn"
+ },
+ "rules": {
+ "no-unused-expressions": "off"
+ },
+ "ignorePatterns": ["node_modules", "data"]
+}
diff --git a/LICENSE.md b/LICENSE.md
index 0ad25db4..162676cb 100644
--- a/LICENSE.md
+++ b/LICENSE.md
@@ -1,178 +1,178 @@
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
- Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
+Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
+Everyone is permitted to copy and distribute verbatim copies
+of this license document, but changing it is not allowed.
Preamble
- The GNU Affero General Public License is a free, copyleft license for
+The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
+The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
+When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
- Developers that use our General Public Licenses protect your rights
+Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
- A secondary benefit of defending all users' freedom is that
+A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
-incorporate. Many developers of free software are heartened and
-encouraged by the resulting cooperation. However, in the case of
+incorporate. Many developers of free software are heartened and
+encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
- The GNU Affero General Public License is designed specifically to
+The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
-to the community. It requires the operator of a network server to
+to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
-users of that server. Therefore, public use of a modified version, on
+users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
- An older license, called the Affero General Public License and
-published by Affero, was designed to accomplish similar goals. This is
+An older license, called the Affero General Public License and
+published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
- The precise terms and conditions for copying, distribution and
+The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
- 0. Definitions.
+0. Definitions.
- "This License" refers to version 3 of the GNU Affero General Public License.
+"This License" refers to version 3 of the GNU Affero General Public License.
- "Copyright" also means copyright-like laws that apply to other kinds of
+"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
+"The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
- To "modify" a work means to copy from or adapt all or part of the work
+To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
+exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
- A "covered work" means either the unmodified Program or a work based
+A "covered work" means either the unmodified Program or a work based
on the Program.
- To "propagate" a work means to do anything with it that, without
+To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
+computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
+To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
- An interactive user interface displays "Appropriate Legal Notices"
+An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
+work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
- 1. Source Code.
+1. Source Code.
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
+The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
form of a work.
- A "Standard Interface" means an interface that either is an official
+A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
- The "System Libraries" of an executable work include anything, other
+The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
+implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
- The "Corresponding Source" for a work in object code form means all
+The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
+control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
+which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
- The Corresponding Source need not include anything that users
+The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
- The Corresponding Source for a work in source code form is that
+The Corresponding Source for a work in source code form is that
same work.
- 2. Basic Permissions.
+2. Basic Permissions.
- All rights granted under this License are granted for the term of
+All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
+content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
- You may make, run and propagate covered works that you do not
+You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
+in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
+not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
+Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+3. Protecting Users' Legal Rights From Anti-Circumvention Law.
- No covered work shall be deemed part of an effective technological
+No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
- When you convey a covered work, you waive any legal power to forbid
+When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
@@ -180,9 +180,9 @@ modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
- 4. Conveying Verbatim Copies.
+4. Conveying Verbatim Copies.
- You may convey verbatim copies of the Program's source code as you
+You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
@@ -190,12 +190,12 @@ non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
- You may charge any price or no price for each copy that you convey,
+You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
- 5. Conveying Modified Source Versions.
+5. Conveying Modified Source Versions.
- You may convey a work based on the Program, or the modifications to
+You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
@@ -220,19 +220,19 @@ terms of section 4, provided that you also meet all of these conditions:
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
- A compilation of a covered work with other separate and independent
+A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
+beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
- 6. Conveying Non-Source Forms.
+6. Conveying Non-Source Forms.
- You may convey a covered work in object code form under the terms
+You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
@@ -278,75 +278,75 @@ in one of these ways:
Source of the work are being offered to the general public at no
charge under subsection 6d.
- A separable portion of the object code, whose source code is excluded
+A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
- A "User Product" is either (1) a "consumer product", which means any
+A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
+actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
- "Installation Information" for a User Product means any methods,
+"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
+a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
- If you convey an object code work under this section in, or with, or
+If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
+by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
- The requirement to provide Installation Information does not include a
+The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
+the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
- Corresponding Source conveyed, and Installation Information provided,
+Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
- 7. Additional Terms.
+7. Additional Terms.
- "Additional permissions" are terms that supplement the terms of this
+"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
+that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
- When you convey a copy of a covered work, you may at your option
+When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
- Notwithstanding any other provision of this License, for material you
+Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
@@ -373,74 +373,74 @@ that material) supplement the terms of this License with terms:
any liability that these contractual assumptions directly impose on
those licensors and authors.
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
+All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
+restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
- If you add terms to a covered work in accord with this section, you
+If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
- Additional terms, permissive or non-permissive, may be stated in the
+Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
- 8. Termination.
+8. Termination.
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
+You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
- However, if you cease all violation of this License, then your
+However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
- Moreover, your license from a particular copyright holder is
+Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
- Termination of your rights under this section does not terminate the
+Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
+this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
- 9. Acceptance Not Required for Having Copies.
+9. Acceptance Not Required for Having Copies.
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
+You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
+to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
- 10. Automatic Licensing of Downstream Recipients.
+10. Automatic Licensing of Downstream Recipients.
- Each time you convey a covered work, the recipient automatically
+Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
+propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
- An "entity transaction" is a transaction transferring control of an
+An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
+organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
@@ -448,43 +448,43 @@ give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
+You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
- 11. Patents.
+11. Patents.
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
+A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
- A contributor's "essential patent claims" are all patent claims
+A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
+consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
- Each contributor grants you a non-exclusive, worldwide, royalty-free
+Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
- In the following three paragraphs, a "patent license" is any express
+In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
+sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
- If you convey a covered work, knowingly relying on a patent license,
+If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
@@ -492,13 +492,13 @@ then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
+license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
- If, pursuant to or in connection with a single transaction or
+If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
@@ -506,10 +506,10 @@ or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
- A patent license is "discriminatory" if it does not include within
+A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
+specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
@@ -521,83 +521,83 @@ for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
- Nothing in this License shall be construed as excluding or limiting
+Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
- 12. No Surrender of Others' Freedom.
+12. No Surrender of Others' Freedom.
- If conditions are imposed on you (whether by court order, agreement or
+If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
+excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
+not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
- 13. Remote Network Interaction; Use with the GNU General Public License.
+13. Remote Network Interaction; Use with the GNU General Public License.
- Notwithstanding any other provision of this License, if you modify the
+Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
-means of facilitating copying of software. This Corresponding Source
+means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
- Notwithstanding any other provision of this License, you have
+Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU General Public License into a single
-combined work, and to convey the resulting work. The terms of this
+combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
- 14. Revised Versions of this License.
+14. Revised Versions of this License.
- The Free Software Foundation may publish revised and/or new versions of
-the GNU Affero General Public License from time to time. Such new versions
+The Free Software Foundation may publish revised and/or new versions of
+the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
- Each version is given a distinguishing version number. If the
+Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
+Foundation. If the Program does not specify a version number of the
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
- If the Program specifies that a proxy can decide which future
+If the Program specifies that a proxy can decide which future
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
+Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
- 15. Disclaimer of Warranty.
+15. Disclaimer of Warranty.
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
- 16. Limitation of Liability.
+16. Limitation of Liability.
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
@@ -607,9 +607,9 @@ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
- 17. Interpretation of Sections 15 and 16.
+17. Interpretation of Sections 15 and 16.
- If the disclaimer of warranty and limitation of liability provided
+If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
@@ -620,11 +620,11 @@ copy of the Program in return for a fee.
How to Apply These Terms to Your New Programs
- If you develop a new program, and you want it to be of the greatest
+If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
- To do so, attach the following notices to the program. It is safest
+To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
@@ -647,15 +647,15 @@ the "copyright" line and a pointer to where the full notice is found.
Also add information on how to contact you by electronic and paper mail.
- If your software can interact with users remotely through a computer
+If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
-get its source. For example, if your program is a web application, its
+get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
-of the code. There are many ways you could offer source, and different
+of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
- You should also get your employer (if you work as a programmer) or school,
+You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<https://www.gnu.org/licenses/>.
diff --git a/README.md b/README.md
index 43075559..b5089c0f 100644
--- a/README.md
+++ b/README.md
@@ -13,6 +13,7 @@ This repository contains the code for the API server. The frontend code is at <a
1. Start the Docker application.
2. Run the start up script:
+
```bash
chmod +x setup.sh
./setup.sh
@@ -23,6 +24,7 @@ The above script will setup docker containers for the different components that
## Understanding Coinos:
Coinos comprises of the folowing components:
+
- **The Coinos Server:** This is the main server implementation that setups and handles the API requests. Depends on the Bitcoin node, the Lightning node and the KeyDB database.
- **[Bitcoin node](https://github.com/bitcoin/bitcoin):** This is the Bitcoin Core implementation that upholds the chains consensus rules.
- **[Liquid Implementation](https://liquid.net/):** This is a Bitcoin layer-2 network that uses Bitcoin as its native asset and allows users to issue their own assets.
@@ -31,12 +33,12 @@ Coinos comprises of the folowing components:
- **[Nostr](https://nostr.com/):** Nostr is a simple, open protocol that enables global, decentralized, and censorship-resistant social media.
- **[Cashu Nutshell](https://github.com/cashubtc/nutshell):** Nutshell is an Ecash wallet and mint for Bitcoin Lightning based on the Cashu protocol.
-A complete Coinos site utilizes all of the above components to support it's features. However,
-its important to note the most important ones: **Coinos Server**, **Bitcoin node**, **Core Lightning** and **KeyDB**. Without these,
-none of the Coinos features would work and the server would probably not start.
+A complete Coinos site utilizes all of the above components to support it's features. However,
+its important to note the most important ones: **Coinos Server**, **Bitcoin node**, **Core Lightning** and **KeyDB**. Without these,
+none of the Coinos features would work and the server would probably not start.
-If you want to run thin, you can remove the other containers
-from the setup(You will get to see where to do this later).
+If you want to run thin, you can remove the other containers
+from the setup(You will get to see where to do this later).
### How Coinos Works
@@ -44,12 +46,12 @@ Running the startup script `./setup.sh` runs a few commands for you in the backg
1. `cp config.ts.sample config.ts`:
-A `config.ts` file is created and it's contents copied from the sample file `config.ts.sample`. This file holds the configuration options
+A `config.ts` file is created and it's contents copied from the sample file `config.ts.sample`. This file holds the configuration options
the various Coinos components discussed above.
2. `cp compose.yml.sample compose.yml`
-A `compose.yml` file is created and it's contents copied from the sample file `compose.yml.sample`. This file conatins instructions
+A `compose.yml` file is created and it's contents copied from the sample file `compose.yml.sample`. This file conatins instructions
on the various Docker containers required to start Coinos. You will also notice duplicate component containers with different names such as cl,clb and clc. These are meant to easen the testing and development process locally as you can simulate transactions and connections.
3. `cp -r sampledata data`
@@ -58,7 +60,7 @@ A folder `data` is created and it's contents copied from the `sampledata` folder
4. `docker compose up -d` and `docker run -it -v $(pwd):/home/bun/app --entrypoint bun asoltys/coinos-server i`
-Finally, the various Docker containers configured above are started and the Coinos server application is run. At this point, all containers should be running, otherwise it could indicate a problem with the previous tasks execution. You can check your container's status by running this command: `docker ps -a`.
+Finally, the various Docker containers configured above are started and the Coinos server application is run. At this point, all containers should be running, otherwise it could indicate a problem with the previous tasks execution. You can check your container's status by running this command: `docker ps -a`.
5. `docker exec -it bc bitcoin-cli createwallet coinos` and `docker exec -it bc bitcoin-cli rescanblockchain`
diff --git a/biome.json b/biome.json
deleted file mode 100644
index d6693595..00000000
--- a/biome.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "formatter": {
- "indentStyle": "space"
- },
- "vcs": {
- "enabled": true,
- "clientKind": "git",
- "useIgnoreFile": false
- }
-}
diff --git a/bun.lock b/bun.lock
index 755fa0e7..f15e4d20 100644
--- a/bun.lock
+++ b/bun.lock
@@ -53,9 +53,12 @@
"ws": "^8.19.0",
},
"devDependencies": {
- "@biomejs/biome": "^2.3.14",
"@types/bun": "^1.3.8",
+ "husky": "^9.1.7",
+ "lint-staged": "^16.2.7",
"nodemon": "^2",
+ "oxfmt": "^0.35.0",
+ "oxlint": "^1.50.0",
"typescript": "^5.9.3",
},
},
@@ -147,24 +150,6 @@
"@babel/runtime": ["@babel/[email protected]", "", {}, "sha512-05WQkdpL9COIMz4LjTxGpPNCdlpyimKppYNoJ5Di5EUObifl8t4tuLuUBBZEpoLYOmfvIWrsp9fCl0HoPRVTdA=="],
- "@biomejs/biome": ["@biomejs/[email protected]", "", { "optionalDependencies": { "@biomejs/cli-darwin-arm64": "2.3.14", "@biomejs/cli-darwin-x64": "2.3.14", "@biomejs/cli-linux-arm64": "2.3.14", "@biomejs/cli-linux-arm64-musl": "2.3.14", "@biomejs/cli-linux-x64": "2.3.14", "@biomejs/cli-linux-x64-musl": "2.3.14", "@biomejs/cli-win32-arm64": "2.3.14", "@biomejs/cli-win32-x64": "2.3.14" }, "bin": { "biome": "bin/biome" } }, "sha512-QMT6QviX0WqXJCaiqVMiBUCr5WRQ1iFSjvOLoTk6auKukJMvnMzWucXpwZB0e8F00/1/BsS9DzcKgWH+CLqVuA=="],
-
- "@biomejs/cli-darwin-arm64": ["@biomejs/[email protected]", "", { "os": "darwin", "cpu": "arm64" }, "sha512-UJGPpvWJMkLxSRtpCAKfKh41Q4JJXisvxZL8ChN1eNW3m/WlPFJ6EFDCE7YfUb4XS8ZFi3C1dFpxUJ0Ety5n+A=="],
-
- "@biomejs/cli-darwin-x64": ["@biomejs/[email protected]", "", { "os": "darwin", "cpu": "x64" }, "sha512-PNkLNQG6RLo8lG7QoWe/hhnMxJIt1tEimoXpGQjwS/dkdNiKBLPv4RpeQl8o3s1OKI3ZOR5XPiYtmbGGHAOnLA=="],
-
- "@biomejs/cli-linux-arm64": ["@biomejs/[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-KT67FKfzIw6DNnUNdYlBg+eU24Go3n75GWK6NwU4+yJmDYFe9i/MjiI+U/iEzKvo0g7G7MZqoyrhIYuND2w8QQ=="],
-
- "@biomejs/cli-linux-arm64-musl": ["@biomejs/[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-LInRbXhYujtL3sH2TMCH/UBwJZsoGwfQjBrMfl84CD4hL/41C/EU5mldqf1yoFpsI0iPWuU83U+nB2TUUypWeg=="],
-
- "@biomejs/cli-linux-x64": ["@biomejs/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-ZsZzQsl9U+wxFrGGS4f6UxREUlgHwmEfu1IrXlgNFrNnd5Th6lIJr8KmSzu/+meSa9f4rzFrbEW9LBBA6ScoMA=="],
-
- "@biomejs/cli-linux-x64-musl": ["@biomejs/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-KQU7EkbBBuHPW3/rAcoiVmhlPtDSGOGRPv9js7qJVpYTzjQmVR+C9Rfcz+ti8YCH+zT1J52tuBybtP4IodjxZQ=="],
-
- "@biomejs/cli-win32-arm64": ["@biomejs/[email protected]", "", { "os": "win32", "cpu": "arm64" }, "sha512-+IKYkj/pUBbnRf1G1+RlyA3LWiDgra1xpS7H2g4BuOzzRbRB+hmlw0yFsLprHhbbt7jUzbzAbAjK/Pn0FDnh1A=="],
-
- "@biomejs/cli-win32-x64": ["@biomejs/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-oizCjdyQ3WJEswpb3Chdngeat56rIdSYK12JI3iI11Mt5T5EXcZ7WLuowzEaFPNJ3zmOQFliMN8QY1Pi+qsfdQ=="],
-
"@bleskomat/form": ["@bleskomat/[email protected]", "", { "dependencies": { "express-handlebars": "6.0.7" } }, "sha512-7Q1/IWRTWs+WhCvnvRnH0XcmuVEfFChTpGiw6SgRCt9PbVtKXpse3QgvCjiIF3nLtIFq34CAVoA456tTLsu/Mg=="],
"@borewit/text-codec": ["@borewit/[email protected]", "", {}, "sha512-k7vvKPbf7J2fZ5klGRD9AeKfUvojuZIQ3BT5u7Jfv+puwXkUBUT5PVyMDfJZpy30CBDXGMgw7fguK/lpOMBvgw=="],
@@ -287,6 +272,82 @@
"@otplib/preset-v11": ["@otplib/[email protected]", "", { "dependencies": { "@otplib/core": "^12.0.1", "@otplib/plugin-crypto": "^12.0.1", "@otplib/plugin-thirty-two": "^12.0.1" } }, "sha512-9hSetMI7ECqbFiKICrNa4w70deTUfArtwXykPUvSHWOdzOlfa9ajglu7mNCntlvxycTiOAXkQGwjQCzzDEMRMg=="],
+ "@oxfmt/binding-android-arm-eabi": ["@oxfmt/[email protected]", "", { "os": "android", "cpu": "arm" }, "sha512-BaRKlM3DyG81y/xWTsE6gZiv89F/3pHe2BqX2H4JbiB8HNVlWWtplzgATAE5IDSdwChdeuWLDTQzJ92Lglw3ZA=="],
+
+ "@oxfmt/binding-android-arm64": ["@oxfmt/[email protected]", "", { "os": "android", "cpu": "arm64" }, "sha512-/O+EbuAJYs6nde/anv+aID6uHsGQApyE9JtYBo/79KyU8e6RBN3DMbT0ix97y1SOnCglurmL2iZ+hlohjP2PnQ=="],
+
+ "@oxfmt/binding-darwin-arm64": ["@oxfmt/[email protected]", "", { "os": "darwin", "cpu": "arm64" }, "sha512-pGqRtqlNdn9d4VrmGUWVyQjkw79ryhI6je9y2jfqNUIZCfqceob+R97YYAoG7C5TFyt8ILdLVoN+L2vw/hSFyA=="],
+
+ "@oxfmt/binding-darwin-x64": ["@oxfmt/[email protected]", "", { "os": "darwin", "cpu": "x64" }, "sha512-8GmsDcSozTPjrCJeGpp+sCmS9+9V5yRrdEZ1p/sTWxPG5nYeAfSLuS0nuEYjXSO+CtdSbStIW6dxa+4NM58yRw=="],
+
+ "@oxfmt/binding-freebsd-x64": ["@oxfmt/[email protected]", "", { "os": "freebsd", "cpu": "x64" }, "sha512-QyfKfTe0ytHpFKHAcHCGQEzN45QSqq1AHJOYYxQMgLM3KY4xu8OsXHpCnINjDsV4XGnQzczJDU9e04Zmd8XqIQ=="],
+
+ "@oxfmt/binding-linux-arm-gnueabihf": ["@oxfmt/[email protected]", "", { "os": "linux", "cpu": "arm" }, "sha512-u+kv3JD6P3J38oOyUaiCqgY5TNESzBRZJ5lyZQ6c2czUW2v5SIN9E/KWWa9vxoc+P8AFXQFUVrdzGy1tK+nbPQ=="],
+
+ "@oxfmt/binding-linux-arm-musleabihf": ["@oxfmt/[email protected]", "", { "os": "linux", "cpu": "arm" }, "sha512-1NiZroCiV57I7Pf8kOH4XGR366kW5zir3VfSMBU2D0V14GpYjiYmPYFAoJboZvp8ACnZKUReWyMkNKSa5ad58A=="],
+
+ "@oxfmt/binding-linux-arm64-gnu": ["@oxfmt/[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-7Q0Xeg7ZnW2nxnZ4R7aF6DEbCFls4skgHZg+I63XitpNvJCbVIU8MFOTZlvZGRsY9+rPgWPQGeUpLHlyx0wvMA=="],
+
+ "@oxfmt/binding-linux-arm64-musl": ["@oxfmt/[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-5Okqi+uhYFxwKz8hcnUftNNwdm8BCkf6GSCbcz9xJxYMm87k1E4p7PEmAAbhLTk7cjSdDre6TDL0pDzNX+Y22Q=="],
+
+ "@oxfmt/binding-linux-ppc64-gnu": ["@oxfmt/[email protected]", "", { "os": "linux", "cpu": "ppc64" }, "sha512-9k66pbZQXM/lBJWys3Xbc5yhl4JexyfqkEf/tvtq8976VIJnLAAL3M127xHA3ifYSqxdVHfVGTg84eiBHCGcNw=="],
+
+ "@oxfmt/binding-linux-riscv64-gnu": ["@oxfmt/[email protected]", "", { "os": "linux", "cpu": "none" }, "sha512-aUcY9ofKPtjO52idT6t0SAQvEF6ctjzUQa1lLp7GDsRpSBvuTrBQGeq0rYKz3gN8dMIQ7mtMdGD9tT4LhR8jAQ=="],
+
+ "@oxfmt/binding-linux-riscv64-musl": ["@oxfmt/[email protected]", "", { "os": "linux", "cpu": "none" }, "sha512-C6yhY5Hvc2sGM+mCPek9ZLe5xRUOC/BvhAt2qIWFAeXMn4il04EYIjl3DsWiJr0xDMTJhvMOmD55xTRPlNp39w=="],
+
+ "@oxfmt/binding-linux-s390x-gnu": ["@oxfmt/[email protected]", "", { "os": "linux", "cpu": "s390x" }, "sha512-RG2hlvOMK4OMZpO3mt8MpxLQ0AAezlFqhn5mI/g5YrVbPFyoCv9a34AAvbSJS501ocOxlFIRcKEuw5hFvddf9g=="],
+
+ "@oxfmt/binding-linux-x64-gnu": ["@oxfmt/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-wzmh90Pwvqj9xOKHJjkQYBpydRkaXG77ZvDz+iFDRRQpnqIEqGm5gmim2s6vnZIkDGsvKCuTdtxm0GFmBjM1+w=="],
+
+ "@oxfmt/binding-linux-x64-musl": ["@oxfmt/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-+HCqYCJPCUy5I+b2cf+gUVaApfgtoQT3HdnSg/l7NIcLHOhKstlYaGyrFZLmUpQt4WkFbpGKZZayG6zjRU0KFA=="],
+
+ "@oxfmt/binding-openharmony-arm64": ["@oxfmt/[email protected]", "", { "os": "none", "cpu": "arm64" }, "sha512-kFYmWfR9YL78XyO5ws+1dsxNvZoD973qfVMNFOS4e9bcHXGF7DvGC2tY5UDFwyMCeB33t3sDIuGONKggnVNSJA=="],
+
+ "@oxfmt/binding-win32-arm64-msvc": ["@oxfmt/[email protected]", "", { "os": "win32", "cpu": "arm64" }, "sha512-uD/NGdM65eKNCDGyTGdO8e9n3IHX+wwuorBvEYrPJXhDXL9qz6gzddmXH8EN04ejUXUujlq4FsoSeCfbg0Y+Jg=="],
+
+ "@oxfmt/binding-win32-ia32-msvc": ["@oxfmt/[email protected]", "", { "os": "win32", "cpu": "ia32" }, "sha512-oSRD2k8J2uxYDEKR2nAE/YTY9PobOEnhZgCmspHu0+yBQ665yH8lFErQVSTE7fcGJmJp/cC6322/gc8VFuQf7g=="],
+
+ "@oxfmt/binding-win32-x64-msvc": ["@oxfmt/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-WCDJjlS95NboR0ugI2BEwzt1tYvRDorDRM9Lvctls1SLyKYuNRCyrPwp1urUPFBnwgBNn9p2/gnmo7gFMySRoQ=="],
+
+ "@oxlint/binding-android-arm-eabi": ["@oxlint/[email protected]", "", { "os": "android", "cpu": "arm" }, "sha512-G7MRGk/6NCe+L8ntonRdZP7IkBfEpiZ/he3buLK6JkLgMHgJShXZ+BeOwADmspXez7U7F7L1Anf4xLSkLHiGTg=="],
+
+ "@oxlint/binding-android-arm64": ["@oxlint/[email protected]", "", { "os": "android", "cpu": "arm64" }, "sha512-GeSuMoJWCVpovJi/e3xDSNgjeR8WEZ6MCXL6EtPiCIM2NTzv7LbflARINTXTJy2oFBYyvdf/l2PwHzYo6EdXvg=="],
+
+ "@oxlint/binding-darwin-arm64": ["@oxlint/[email protected]", "", { "os": "darwin", "cpu": "arm64" }, "sha512-w3SY5YtxGnxCHPJ8Twl3KmS9oja1gERYk3AMoZ7Hv8P43ZtB6HVfs02TxvarxfL214Tm3uzvc2vn+DhtUNeKnw=="],
+
+ "@oxlint/binding-darwin-x64": ["@oxlint/[email protected]", "", { "os": "darwin", "cpu": "x64" }, "sha512-hNfogDqy7tvmllXKBSlHo6k5x7dhTUVOHbMSE15CCAcXzmqf5883aPvBYPOq9AE7DpDUQUZ1kVE22YbiGW+tuw=="],
+
+ "@oxlint/binding-freebsd-x64": ["@oxlint/[email protected]", "", { "os": "freebsd", "cpu": "x64" }, "sha512-ykZevOWEyu0nsxolA911ucxpEv0ahw8jfEeGWOwwb/VPoE4xoexuTOAiPNlWZNJqANlJl7yp8OyzCtXTUAxotw=="],
+
+ "@oxlint/binding-linux-arm-gnueabihf": ["@oxlint/[email protected]", "", { "os": "linux", "cpu": "arm" }, "sha512-hif3iDk7vo5GGJ4OLCCZAf2vjnU9FztGw4L0MbQL0M2iY9LKFtDMMiQAHmkF0PQGQMVbTYtPdXCLKVgdkiqWXQ=="],
+
+ "@oxlint/binding-linux-arm-musleabihf": ["@oxlint/[email protected]", "", { "os": "linux", "cpu": "arm" }, "sha512-dVp9iSssiGAnTNey2Ruf6xUaQhdnvcFOJyRWd/mu5o2jVbFK15E5fbWGeFRfmuobu5QXuROtFga44+7DOS3PLg=="],
+
+ "@oxlint/binding-linux-arm64-gnu": ["@oxlint/[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-1cT7yz2HA910CKA9NkH1ZJo50vTtmND2fkoW1oyiSb0j6WvNtJ0Wx2zoySfXWc/c+7HFoqRK5AbEoL41LOn9oA=="],
+
+ "@oxlint/binding-linux-arm64-musl": ["@oxlint/[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-++B3k/HEPFVlj89cOz8kWfQccMZB/aWL9AhsW7jPIkG++63Mpwb2cE9XOEsd0PATbIan78k2Gky+09uWM1d/gQ=="],
+
+ "@oxlint/binding-linux-ppc64-gnu": ["@oxlint/[email protected]", "", { "os": "linux", "cpu": "ppc64" }, "sha512-Z9b/KpFMkx66w3gVBqjIC1AJBTZAGoI9+U+K5L4QM0CB/G0JSNC1es9b3Y0Vcrlvtdn8A+IQTkYjd/Q0uCSaZw=="],
+
+ "@oxlint/binding-linux-riscv64-gnu": ["@oxlint/[email protected]", "", { "os": "linux", "cpu": "none" }, "sha512-jvmuIw8wRSohsQlFNIST5uUwkEtEJmOQYr33bf/K2FrFPXHhM4KqGekI3ShYJemFS/gARVacQFgBzzJKCAyJjg=="],
+
+ "@oxlint/binding-linux-riscv64-musl": ["@oxlint/[email protected]", "", { "os": "linux", "cpu": "none" }, "sha512-x+UrN47oYNh90nmAAyql8eQaaRpHbDPu5guasDg10+OpszUQ3/1+1J6zFMmV4xfIEgTcUXG/oI5fxJhF4eWCNA=="],
+
+ "@oxlint/binding-linux-s390x-gnu": ["@oxlint/[email protected]", "", { "os": "linux", "cpu": "s390x" }, "sha512-i/JLi2ljLUIVfekMj4ISmdt+Hn11wzYUdRRrkVUYsCWw7zAy5xV7X9iA+KMyM156LTFympa7s3oKBjuCLoTAUQ=="],
+
+ "@oxlint/binding-linux-x64-gnu": ["@oxlint/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-/C7brhn6c6UUPccgSPCcpLQXcp+xKIW/3sji/5VZ8/OItL3tQ2U7KalHz887UxxSQeEOmd1kY6lrpuwFnmNqOA=="],
+
+ "@oxlint/binding-linux-x64-musl": ["@oxlint/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-oDR1f+bGOYU8LfgtEW8XtotWGB63ghtcxk5Jm6IDTCk++rTA/IRMsjOid2iMd+1bW+nP9Mdsmcdc7VbPD3+iyQ=="],
+
+ "@oxlint/binding-openharmony-arm64": ["@oxlint/[email protected]", "", { "os": "none", "cpu": "arm64" }, "sha512-4CmRGPp5UpvXyu4jjP9Tey/SrXDQLRvZXm4pb4vdZBxAzbFZkCyh0KyRy4txld/kZKTJlW4TO8N1JKrNEk+mWw=="],
+
+ "@oxlint/binding-win32-arm64-msvc": ["@oxlint/[email protected]", "", { "os": "win32", "cpu": "arm64" }, "sha512-Fq0M6vsGcFsSfeuWAACDhd5KJrO85ckbEfe1EGuBj+KPyJz7KeWte2fSFrFGmNKNXyhEMyx4tbgxiWRujBM2KQ=="],
+
+ "@oxlint/binding-win32-ia32-msvc": ["@oxlint/[email protected]", "", { "os": "win32", "cpu": "ia32" }, "sha512-qTdWR9KwY/vxJGhHVIZG2eBOhidOQvOwzDxnX+jhW/zIVacal1nAhR8GLkiywW8BIFDkQKXo/zOfT+/DY+ns/w=="],
+
+ "@oxlint/binding-win32-x64-msvc": ["@oxlint/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-682t7npLC4G2Ca+iNlI9fhAKTcFPYYXJjwoa88H4q+u5HHHlsnL/gHULapX3iqp+A8FIJbgdylL5KMYo2LaluQ=="],
+
"@peculiar/asn1-android": ["@peculiar/[email protected]", "", { "dependencies": { "@peculiar/asn1-schema": "^2.6.0", "asn1js": "^3.0.6", "tslib": "^2.8.1" } }, "sha512-cBRCKtYPF7vJGN76/yG8VbxRcHLPF3HnkoHhKOZeHpoVtbMYfY9ROKtH3DtYUY9m8uI1Mh47PRhHf2hSK3xcSQ=="],
"@peculiar/asn1-cms": ["@peculiar/[email protected]", "", { "dependencies": { "@peculiar/asn1-schema": "^2.6.0", "@peculiar/asn1-x509": "^2.6.1", "@peculiar/asn1-x509-attr": "^2.6.1", "asn1js": "^3.0.6", "tslib": "^2.8.1" } }, "sha512-vdG4fBF6Lkirkcl53q6eOdn3XYKt+kJTG59edgRZORlg/3atWWEReRCx5rYE1ZzTTX6vLK5zDMjHh7vbrcXGtw=="],
@@ -447,6 +508,12 @@
"ajv-formats": ["[email protected]", "", { "dependencies": { "ajv": "^8.0.0" } }, "sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ=="],
+ "ansi-escapes": ["[email protected]", "", { "dependencies": { "environment": "^1.0.0" } }, "sha512-BvU8nYgGQBxcmMuEeUEmNTvrMVjJNSH7RgW24vXexN4Ven6qCvy4TntnvlnwnMLTVlcRQQdbRY8NKnaIoeWDNg=="],
+
+ "ansi-regex": ["[email protected]", "", {}, "sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg=="],
+
+ "ansi-styles": ["[email protected]", "", {}, "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg=="],
+
"anymatch": ["[email protected]", "", { "dependencies": { "normalize-path": "^3.0.0", "picomatch": "^2.0.4" } }, "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw=="],
"array-flatten": ["[email protected]", "", {}, "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg=="],
@@ -539,6 +606,10 @@
"cipher-base": ["[email protected]", "", { "dependencies": { "inherits": "^2.0.4", "safe-buffer": "^5.2.1", "to-buffer": "^1.2.2" } }, "sha512-Mz9QMT5fJe7bKI7MH31UilT5cEK5EHHRCccw/YRFsRY47AuNgaV6HY3rscp0/I4Q+tTW/5zoqpSeRRI54TkDWA=="],
+ "cli-cursor": ["[email protected]", "", { "dependencies": { "restore-cursor": "^5.0.0" } }, "sha512-aCj4O5wKyszjMmDT4tZj93kxyydN/K5zPWSCe6/0AV/AA1pqe5ZBIw0a2ZfPQV7lL5/yb5HsUreJ6UFAF1tEQw=="],
+
+ "cli-truncate": ["[email protected]", "", { "dependencies": { "slice-ansi": "^7.1.0", "string-width": "^8.0.0" } }, "sha512-SroPvNHxUnk+vIW/dOSfNqdy1sPEFkrTk6TUtqLCnBlo3N7TNYYkzzN7uSD6+jVjrdO4+p8nH7JzH6cIvUem6A=="],
+
"clightning-client": ["@asoltys/clightning-client@github:asoltys/lightning-client-js#7eba654", { "dependencies": { "debug": "^4.1.1" } }, "asoltys-lightning-client-js-7eba654"],
"cluster-key-slot": ["[email protected]", "", {}, "sha512-RMr0FhtfXemyinomL4hrWcYJxmX6deFdCxpJzhDttxgO1+bcCnkk+9drydLVDmAMG7NE6aN/fl4F7ucU/90gAA=="],
@@ -555,7 +626,7 @@
"combined-stream": ["[email protected]", "", { "dependencies": { "delayed-stream": "~1.0.0" } }, "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg=="],
- "commander": ["[email protected]", "", {}, "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA=="],
+ "commander": ["[email protected]", "", {}, "sha512-H+y0Jo/T1RZ9qPP4Eh1pkcQcLRglraJaSLoyOtHxu6AapkjWVCy2Sit1QQ4x3Dng8qDlSsZEet7g5Pq06MvTgw=="],
"commist": ["[email protected]", "", {}, "sha512-4PIMoPniho+LqXmpS5d3NuGYncG6XWlkBSVGiWycL22dd42OYdUGil2CWuzklaJoNxyxUSpO4MKIBU94viWNAw=="],
@@ -607,10 +678,14 @@
"elliptic": ["[email protected]", "", { "dependencies": { "bn.js": "^4.11.9", "brorand": "^1.1.0", "hash.js": "^1.0.0", "hmac-drbg": "^1.0.1", "inherits": "^2.0.4", "minimalistic-assert": "^1.0.1", "minimalistic-crypto-utils": "^1.0.1" } }, "sha512-RaddvvMatK2LJHqFJ+YA4WysVN5Ita9E35botqIYspQ4TkRAlCicdzKOjlyv/1Za5RyTNn7di//eEV0uTAfe3g=="],
+ "emoji-regex": ["[email protected]", "", {}, "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A=="],
+
"encodeurl": ["[email protected]", "", {}, "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w=="],
"end-of-stream": ["[email protected]", "", { "dependencies": { "once": "^1.4.0" } }, "sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg=="],
+ "environment": ["[email protected]", "", {}, "sha512-xUtoPkMggbz0MPyPiIWr1Kp4aeWJjDZ6SMvURhimjdZgsRuDplF5/s9hcgGhyXMhs+6vpnuoiZ2kFiu3FMnS8Q=="],
+
"es-define-property": ["[email protected]", "", {}, "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g=="],
"es-errors": ["[email protected]", "", {}, "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw=="],
@@ -625,6 +700,8 @@
"event-target-shim": ["[email protected]", "", {}, "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ=="],
+ "eventemitter3": ["[email protected]", "", {}, "sha512-mlsTRyGaPBjPedk6Bvw+aqbsXDtoAyAzm5MO7JgU+yVRyMQ5O8bD4Kcci7BS85f93veegeCPkL8R4GLClnjLFw=="],
+
"events": ["[email protected]", "", {}, "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q=="],
"eventsource": ["[email protected]", "", { "dependencies": { "eventsource-parser": "^3.0.1" } }, "sha512-2GuF51iuHX6A9xdTccMTsNb7VO0lHZihApxhvQzJB5A03DvHDd2FQepodbMaztPBmBcE/ox7o2gqaxGhYB9LhQ=="],
@@ -691,6 +768,8 @@
"function-bind": ["[email protected]", "", {}, "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA=="],
+ "get-east-asian-width": ["[email protected]", "", {}, "sha512-CQ+bEO+Tva/qlmw24dCejulK5pMzVnUOFOijVogd3KQs07HnRIgp8TGipvCCRT06xeYEbpbgwaCxglFyiuIcmA=="],
+
"get-intrinsic": ["[email protected]", "", { "dependencies": { "call-bind-apply-helpers": "^1.0.2", "es-define-property": "^1.0.1", "es-errors": "^1.3.0", "es-object-atoms": "^1.1.1", "function-bind": "^1.1.2", "get-proto": "^1.0.1", "gopd": "^1.2.0", "has-symbols": "^1.1.0", "hasown": "^2.0.2", "math-intrinsics": "^1.1.0" } }, "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ=="],
"get-proto": ["[email protected]", "", { "dependencies": { "dunder-proto": "^1.0.1", "es-object-atoms": "^1.0.0" } }, "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g=="],
@@ -739,6 +818,8 @@
"https-proxy-agent": ["[email protected]", "", { "dependencies": { "agent-base": "^7.1.2", "debug": "4" } }, "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw=="],
+ "husky": ["[email protected]", "", { "bin": { "husky": "bin.js" } }, "sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA=="],
+
"iconv-lite": ["[email protected]", "", { "dependencies": { "safer-buffer": ">= 2.1.2 < 3" } }, "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA=="],
"ieee754": ["[email protected]", "", {}, "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA=="],
@@ -761,6 +842,8 @@
"is-extglob": ["[email protected]", "", {}, "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ=="],
+ "is-fullwidth-code-point": ["[email protected]", "", { "dependencies": { "get-east-asian-width": "^1.3.1" } }, "sha512-5XHYaSyiqADb4RnZ1Bdad6cPp8Toise4TzEjcOYDHZkTCbKgiUl7WTUCpNWHuxmDt91wnsZBc9xinNzopv3JMQ=="],
+
"is-glob": ["[email protected]", "", { "dependencies": { "is-extglob": "^2.1.1" } }, "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg=="],
"is-number": ["[email protected]", "", {}, "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng=="],
@@ -793,6 +876,10 @@
"lightning-backends": ["[email protected]", "", { "dependencies": { "@bleskomat/form": "1.3.2", "async": "3.2.6", "bolt11": "1.4.1", "secp256k1": "5.0.0", "socks-proxy-agent": "8.0.4" } }, "sha512-jVYaWLhbgGRugndh/W30nd0AjP9D1CcZnbf3tZwGFpG700cuEx2rrufdov8Q28gC3//mfheOQjnRNgf0xPU6Ww=="],
+ "lint-staged": ["[email protected]", "", { "dependencies": { "commander": "^14.0.2", "listr2": "^9.0.5", "micromatch": "^4.0.8", "nano-spawn": "^2.0.0", "pidtree": "^0.6.0", "string-argv": "^0.3.2", "yaml": "^2.8.1" }, "bin": { "lint-staged": "bin/lint-staged.js" } }, "sha512-lDIj4RnYmK7/kXMya+qJsmkRFkGolciXjrsZ6PC25GdTfWOAWetR0ZbsNXRAj1EHHImRSalc+whZFg56F5DVow=="],
+
+ "listr2": ["[email protected]", "", { "dependencies": { "cli-truncate": "^5.0.0", "colorette": "^2.0.20", "eventemitter3": "^5.0.1", "log-update": "^6.1.0", "rfdc": "^1.4.1", "wrap-ansi": "^9.0.0" } }, "sha512-ME4Fb83LgEgwNw96RKNvKV4VTLuXfoKudAmm2lP8Kk87KaMK0/Xrx/aAkMWmT8mDb+3MlFDspfbCs7adjRxA2g=="],
+
"lnurl": ["[email protected]", "", { "dependencies": { "async": "3.2.6", "bech32": "2.0.0", "bignumber.js": "9.1.2", "bolt11": "1.4.1", "commander": "12.1.0", "debug": "4.3.6", "express": "4.19.2", "lightning-backends": "1.7.0", "lnurl-offline": "1.2.0", "secp256k1": "5.0.0" }, "bin": { "lnurl": "cli.js" } }, "sha512-H/Rv5Xb2JEPbD4bry7QhuBZmgVUhfH6CFwfR8YSRp32aCTSBr3m78ZcGLyzWF3hY3SuIgPgcE4kALQwMd4/62Q=="],
"lnurl-offline": ["[email protected]", "", {}, "sha512-orNcYGfRYgM5IFmLeCIG4Zm2bN29uYQSwDo4bK8KOrU4mEB+ff18Yg5sQ1vCJ/fz0qWUJx1Dd0/GsEs3d+eaqA=="],
@@ -817,6 +904,8 @@
"lodash.once": ["[email protected]", "", {}, "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg=="],
+ "log-update": ["[email protected]", "", { "dependencies": { "ansi-escapes": "^7.0.0", "cli-cursor": "^5.0.0", "slice-ansi": "^7.1.0", "strip-ansi": "^7.1.0", "wrap-ansi": "^9.0.0" } }, "sha512-9ie8ItPR6tjY5uYJh8K/Zrv/RMZ5VOlOWvtZdEHYSTFKZfIBPQa9tOAEeAWhd+AnIneLJ22w5fjOYtoutpWq5w=="],
+
"lowercase-keys": ["[email protected]", "", {}, "sha512-ozCC6gdQ+glXOQsveKD0YsDy8DSQFjDTz4zyzEHNV5+JP5D62LmfDZ6o1cycFx9ouG940M5dE8C8CTewdj2YWQ=="],
"lru-cache": ["[email protected]", "", {}, "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ=="],
@@ -833,12 +922,16 @@
"micro-packed": ["[email protected]", "", { "dependencies": { "@scure/base": "2.0.0" } }, "sha512-AKb8znIvg9sooythbXzyFeChEY0SkW0C6iXECpy/ls0e5BtwXO45J9wD9SLzBztnS4XmF/5kwZknsq+jyynd/A=="],
+ "micromatch": ["[email protected]", "", { "dependencies": { "braces": "^3.0.3", "picomatch": "^2.3.1" } }, "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA=="],
+
"mime": ["[email protected]", "", { "bin": { "mime": "cli.js" } }, "sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A=="],
"mime-db": ["[email protected]", "", {}, "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg=="],
"mime-types": ["[email protected]", "", { "dependencies": { "mime-db": "1.52.0" } }, "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw=="],
+ "mimic-function": ["[email protected]", "", {}, "sha512-VP79XUPxV2CigYP3jWwAUFSku2aKqBH7uTAapFWCBqutsbmDo96KY5o8uh6U+/YSIn5OxJnXp73beVkpqMIGhA=="],
+
"mimic-response": ["[email protected]", "", {}, "sha512-e5ISH9xMYU0DzrT+jl8q2ze9D6eWBto+I8CNpe+VI+K2J/F/k3PdkdTdz4wvGVH4NTpo+NRYTVIuMQEMMcsLqg=="],
"minimalistic-assert": ["[email protected]", "", {}, "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A=="],
@@ -857,6 +950,8 @@
"ms": ["[email protected]", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="],
+ "nano-spawn": ["[email protected]", "", {}, "sha512-tacvGzUY5o2D8CBh2rrwxyNojUsZNU2zjNTzKQrkgGJQTbGAfArVWXSKMBokBeeg6C7OLRGUEyoFlYbfeWQIqw=="],
+
"negotiator": ["[email protected]", "", {}, "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg=="],
"neo-async": ["[email protected]", "", {}, "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw=="],
@@ -891,8 +986,14 @@
"once": ["[email protected]", "", { "dependencies": { "wrappy": "1" } }, "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w=="],
+ "onetime": ["[email protected]", "", { "dependencies": { "mimic-function": "^5.0.0" } }, "sha512-VXJjc87FScF88uafS3JllDgvAm+c/Slfz06lorj2uAY34rlUu0Nt+v8wreiImcrgAjjIHp1rXpTDlLOGw29WwQ=="],
+
"otplib": ["[email protected]", "", { "dependencies": { "@otplib/core": "^12.0.1", "@otplib/preset-default": "^12.0.1", "@otplib/preset-v11": "^12.0.1" } }, "sha512-xDGvUOQjop7RDgxTQ+o4pOol0/3xSZzawTiPKRrHnQWAy0WjhNs/5HdIDJCrqC4MBynmjXgULc6YfioaxZeFgg=="],
+ "oxfmt": ["[email protected]", "", { "dependencies": { "tinypool": "2.1.0" }, "optionalDependencies": { "@oxfmt/binding-android-arm-eabi": "0.35.0", "@oxfmt/binding-android-arm64": "0.35.0", "@oxfmt/binding-darwin-arm64": "0.35.0", "@oxfmt/binding-darwin-x64": "0.35.0", "@oxfmt/binding-freebsd-x64": "0.35.0", "@oxfmt/binding-linux-arm-gnueabihf": "0.35.0", "@oxfmt/binding-linux-arm-musleabihf": "0.35.0", "@oxfmt/binding-linux-arm64-gnu": "0.35.0", "@oxfmt/binding-linux-arm64-musl": "0.35.0", "@oxfmt/binding-linux-ppc64-gnu": "0.35.0", "@oxfmt/binding-linux-riscv64-gnu": "0.35.0", "@oxfmt/binding-linux-riscv64-musl": "0.35.0", "@oxfmt/binding-linux-s390x-gnu": "0.35.0", "@oxfmt/binding-linux-x64-gnu": "0.35.0", "@oxfmt/binding-linux-x64-musl": "0.35.0", "@oxfmt/binding-openharmony-arm64": "0.35.0", "@oxfmt/binding-win32-arm64-msvc": "0.35.0", "@oxfmt/binding-win32-ia32-msvc": "0.35.0", "@oxfmt/binding-win32-x64-msvc": "0.35.0" }, "bin": { "oxfmt": "bin/oxfmt" } }, "sha512-QYeXWkP+aLt7utt5SLivNIk09glWx9QE235ODjgcEZ3sd1VMaUBSpLymh6ZRCA76gD2rMP4bXanUz/fx+nLM9Q=="],
+
+ "oxlint": ["[email protected]", "", { "optionalDependencies": { "@oxlint/binding-android-arm-eabi": "1.50.0", "@oxlint/binding-android-arm64": "1.50.0", "@oxlint/binding-darwin-arm64": "1.50.0", "@oxlint/binding-darwin-x64": "1.50.0", "@oxlint/binding-freebsd-x64": "1.50.0", "@oxlint/binding-linux-arm-gnueabihf": "1.50.0", "@oxlint/binding-linux-arm-musleabihf": "1.50.0", "@oxlint/binding-linux-arm64-gnu": "1.50.0", "@oxlint/binding-linux-arm64-musl": "1.50.0", "@oxlint/binding-linux-ppc64-gnu": "1.50.0", "@oxlint/binding-linux-riscv64-gnu": "1.50.0", "@oxlint/binding-linux-riscv64-musl": "1.50.0", "@oxlint/binding-linux-s390x-gnu": "1.50.0", "@oxlint/binding-linux-x64-gnu": "1.50.0", "@oxlint/binding-linux-x64-musl": "1.50.0", "@oxlint/binding-openharmony-arm64": "1.50.0", "@oxlint/binding-win32-arm64-msvc": "1.50.0", "@oxlint/binding-win32-ia32-msvc": "1.50.0", "@oxlint/binding-win32-x64-msvc": "1.50.0" }, "peerDependencies": { "oxlint-tsgolint": ">=0.14.1" }, "optionalPeers": ["oxlint-tsgolint"], "bin": { "oxlint": "bin/oxlint" } }, "sha512-iSJ4IZEICBma8cZX7kxIIz9PzsYLF2FaLAYN6RKu7VwRVKdu7RIgpP99bTZaGl//Yao7fsaGZLSEo5xBrI5ReQ=="],
+
"p-cancelable": ["[email protected]", "", {}, "sha512-wBowNApzd45EIKdO1LaU+LrMBwAcjfPaYtVzV3lmfM3gf8Z4CHZsiIqlM8TZZ8okYvh5A1cP6gTfCRQtwUpaUg=="],
"parseurl": ["[email protected]", "", {}, "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ=="],
@@ -909,6 +1010,8 @@
"picomatch": ["[email protected]", "", {}, "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA=="],
+ "pidtree": ["[email protected]", "", { "bin": { "pidtree": "bin/pidtree.js" } }, "sha512-eG2dWTVw5bzqGRztnHExczNxt5VGsE6OwTeCG3fdUf9KBsZzO3R5OIIIzWR+iZA0NtZ+RDVdaoE2dK1cn6jH4g=="],
+
"pino": ["[email protected]", "", { "dependencies": { "@pinojs/redact": "^0.4.0", "atomic-sleep": "^1.0.0", "on-exit-leak-free": "^2.1.0", "pino-abstract-transport": "^3.0.0", "pino-std-serializers": "^7.0.0", "process-warning": "^5.0.0", "quick-format-unescaped": "^4.0.3", "real-require": "^0.2.0", "safe-stable-stringify": "^2.3.1", "sonic-boom": "^4.0.1", "thread-stream": "^4.0.0" }, "bin": { "pino": "bin.js" } }, "sha512-0GNPNzHXBKw6U/InGe79A3Crzyk9bcSyObF9/Gfo9DLEf5qj5RF50RSjsu0W1rZ6ZqRGdzDFCRBQvi9/rSGPtA=="],
"pino-abstract-transport": ["[email protected]", "", { "dependencies": { "split2": "^4.0.0" } }, "sha512-wlfUczU+n7Hy/Ha5j9a/gZNy7We5+cXp8YL+X+PG8S0KXxw7n/JXA3c46Y0zQznIJ83URJiwy7Lh56WLokNuxg=="],
@@ -967,6 +1070,8 @@
"responselike": ["[email protected]", "", { "dependencies": { "lowercase-keys": "^3.0.0" } }, "sha512-cGk8IbWEAnaCpdAt1BHzJ3Ahz5ewDJa0KseTsE3qIRMJ3C698W8psM7byCeWVpd/Ha7FUYzuRVzXoKoM6nRUbA=="],
+ "restore-cursor": ["[email protected]", "", { "dependencies": { "onetime": "^7.0.0", "signal-exit": "^4.1.0" } }, "sha512-oMA2dcrw6u0YfxJQXm342bFKX/E4sG9rbTzO9ptUcR/e8A33cHuvStiYOwH7fszkZlZ1z/ta9AAoPk2F4qIOHA=="],
+
"ret": ["[email protected]", "", {}, "sha512-I1XxrZSQ+oErkRR4jYbAyEEu2I0avBvvMM5JN+6EBprOGRCs63ENqZ3vjavq8fBw2+62G5LF5XelKwuJpcvcxw=="],
"reusify": ["[email protected]", "", {}, "sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw=="],
@@ -1011,10 +1116,14 @@
"side-channel-weakmap": ["[email protected]", "", { "dependencies": { "call-bound": "^1.0.2", "es-errors": "^1.3.0", "get-intrinsic": "^1.2.5", "object-inspect": "^1.13.3", "side-channel-map": "^1.0.1" } }, "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A=="],
+ "signal-exit": ["[email protected]", "", {}, "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw=="],
+
"simple-swizzle": ["[email protected]", "", { "dependencies": { "is-arrayish": "^0.3.1" } }, "sha512-nAu1WFPQSMNr2Zn9PGSZK9AGn4t/y97lEm+MXTtUDwfP0ksAIX4nO+6ruD9Jwut4C49SB1Ws+fbXsm/yScWOHw=="],
"simple-update-notifier": ["[email protected]", "", { "dependencies": { "semver": "~7.0.0" } }, "sha512-VpsrsJSUcJEseSbMHkrsrAVSdvVS5I96Qo1QAQ4FxQ9wXFcB+pjj7FB7/us9+GcgfW4ziHtYMc1J0PLczb55mg=="],
+ "slice-ansi": ["[email protected]", "", { "dependencies": { "ansi-styles": "^6.2.1", "is-fullwidth-code-point": "^5.0.0" } }, "sha512-iOBWFgUX7caIZiuutICxVgX1SdxwAVFFKwt1EvMYYec/NWO5meOJ6K5uQxhrYBdQJne4KxiqZc+KptFOWFSI9w=="],
+
"smart-buffer": ["[email protected]", "", {}, "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg=="],
"socks": ["[email protected]", "", { "dependencies": { "ip-address": "^10.0.1", "smart-buffer": "^4.2.0" } }, "sha512-HLpt+uLy/pxB+bum/9DzAgiKS8CX1EvbWxI4zlmgGCExImLdiad2iCwXT5Z4c9c3Eq8rP2318mPW2c+QbtjK8A=="],
@@ -1039,8 +1148,14 @@
"strfry-rpc": ["[email protected]", "", { "peerDependencies": { "typescript": "^5.0.0" } }, "sha512-jbfycgsU41pgIMHprZeMnmmgO57o7G1IRgmMgkY08BAEvzf0YFzTfSG8TWAXudAnMLHSqYLPfHwOueBn1g6roA=="],
+ "string-argv": ["[email protected]", "", {}, "sha512-aqD2Q0144Z+/RqG52NeHEkZauTAUWJO8c6yTftGJKO3Tja5tUgIfmIl6kExvhtxSDP7fXB6DvzkfMpCd/F3G+Q=="],
+
+ "string-width": ["[email protected]", "", { "dependencies": { "get-east-asian-width": "^1.5.0", "strip-ansi": "^7.1.2" } }, "sha512-6hJPQ8N0V0P3SNmP6h2J99RLuzrWz2gvT7VnK5tKvrNqJoyS9W4/Fb8mo31UiPvy00z7DQXkP2hnKBVav76thw=="],
+
"string_decoder": ["[email protected]", "", { "dependencies": { "safe-buffer": "~5.2.0" } }, "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA=="],
+ "strip-ansi": ["[email protected]", "", { "dependencies": { "ansi-regex": "^6.0.1" } }, "sha512-gmBGslpoQJtgnMAvOVqGZpEz9dyoKTCzy2nfz/n8aIFhN/jCE/rCmcxabB6jOOHV+0WNnylOxaxBQPSvcWklhA=="],
+
"strip-json-comments": ["[email protected]", "", {}, "sha512-1tB5mhVo7U+ETBKNf92xT4hrQa3pm0MZ0PQvuDnWgAAGHDsfp4lPSpiS6psrSiet87wyGPh9ft6wmhOMQ0hDiw=="],
"strnum": ["[email protected]", "", {}, "sha512-l63NF9y/cLROq/yqKXSLtcMeeyOfnSQlfMSlzFt/K73oIaD8DGaQWd7Z34X9GPiKqP5rbSh84Hl4bOlLcjiSrQ=="],
@@ -1057,6 +1172,8 @@
"tiny-warning": ["[email protected]", "", {}, "sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA=="],
+ "tinypool": ["[email protected]", "", {}, "sha512-Pugqs6M0m7Lv1I7FtxN4aoyToKg1C4tu+/381vH35y8oENM/Ai7f7C4StcoK4/+BSw9ebcS8jRiVrORFKCALLw=="],
+
"to-buffer": ["[email protected]", "", { "dependencies": { "isarray": "^2.0.5", "safe-buffer": "^5.2.1", "typed-array-buffer": "^1.0.3" } }, "sha512-db0E3UJjcFhpDhAF4tLo03oli3pwl3dbnzXOUIlRKrp+ldk/VUxzpWYZENsw2SZiuBjHAk7DfB0VU7NKdpb6sw=="],
"to-regex-range": ["[email protected]", "", { "dependencies": { "is-number": "^7.0.0" } }, "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ=="],
@@ -1129,10 +1246,14 @@
"worker-timers-worker": ["[email protected]", "", { "dependencies": { "@babel/runtime": "^7.28.6", "tslib": "^2.8.1", "worker-factory": "^7.0.48" } }, "sha512-qjn18szGb1kjcmh2traAdki1eiIS5ikFo+L90nfMOvSRpuDw1hAcR1nzkP2+Hkdqz5thIRnfuWx7QSpsEUsA6Q=="],
+ "wrap-ansi": ["[email protected]", "", { "dependencies": { "ansi-styles": "^6.2.1", "string-width": "^7.0.0", "strip-ansi": "^7.1.0" } }, "sha512-42AtmgqjV+X1VpdOfyTGOYRi0/zsoLqtXQckTmqTeybT+BDIbM/Guxo7x3pE2vtpr1ok6xRqM9OpBe+Jyoqyww=="],
+
"wrappy": ["[email protected]", "", {}, "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ=="],
"ws": ["[email protected]", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-blAT2mjOEIi0ZzruJfIhb3nps74PRWTCz1IjglWEEpQl5XS/UNama6u2/rjFkDDouqr4L67ry+1aGIALViWjDg=="],
+ "yaml": ["[email protected]", "", { "bin": { "yaml": "bin.mjs" } }, "sha512-mplynKqc1C2hTVYxd0PU2xQAc22TI1vShAYGksCCfxbn/dFwnHTNi1bvYsBTkhdUNtGIf5xNOg938rrSSYvS9A=="],
+
"@asoltys/clightning-client/debug": ["[email protected]", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA=="],
"@aws-crypto/sha256-browser/@smithy/util-utf8": ["@smithy/[email protected]", "", { "dependencies": { "@smithy/util-buffer-from": "^2.2.0", "tslib": "^2.6.2" } }, "sha512-R8Rdn8Hy72KKcebgLiv8jQcQkXoLMOGGv5uI1/k0l+snqkOzQ1R0ChUBCxWMlBsFMekWjq0wRudIweFs7sKT5A=="],
@@ -1201,6 +1322,8 @@
"lnurl/async": ["[email protected]", "", {}, "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA=="],
+ "lnurl/commander": ["[email protected]", "", {}, "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA=="],
+
"lnurl/debug": ["[email protected]", "", { "dependencies": { "ms": "2.1.2" } }, "sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg=="],
"mqtt/debug": ["[email protected]", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA=="],
@@ -1227,6 +1350,8 @@
"tsyringe/tslib": ["[email protected]", "", {}, "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg=="],
+ "wrap-ansi/string-width": ["[email protected]", "", { "dependencies": { "emoji-regex": "^10.3.0", "get-east-asian-width": "^1.0.0", "strip-ansi": "^7.1.0" } }, "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ=="],
+
"@aws-crypto/sha256-browser/@smithy/util-utf8/@smithy/util-buffer-from": ["@smithy/[email protected]", "", { "dependencies": { "@smithy/is-array-buffer": "^2.2.0", "tslib": "^2.6.2" } }, "sha512-IJdWBbTcMQ6DA0gdNhh/BwrLkDR+ADW5Kr1aZmd4k3DIF6ezMV4R2NIAmT08wQJ3yUK82thHWmC/TnK/wpMMIA=="],
"@aws-crypto/util/@smithy/util-utf8/@smithy/util-buffer-from": ["@smithy/[email protected]", "", { "dependencies": { "@smithy/is-array-buffer": "^2.2.0", "tslib": "^2.6.2" } }, "sha512-IJdWBbTcMQ6DA0gdNhh/BwrLkDR+ADW5Kr1aZmd4k3DIF6ezMV4R2NIAmT08wQJ3yUK82thHWmC/TnK/wpMMIA=="],
diff --git a/index.ts b/index.ts
index 391dfaef..ab20e388 100644
--- a/index.ts
+++ b/index.ts
@@ -4,7 +4,13 @@ import { admin, auth, optional } from "$lib/auth";
import { fixBolt12, listenForLightning, replay } from "$lib/lightning";
import { startHealthCheck } from "$lib/health";
import { getLocations } from "$lib/locations";
-import { migrateAccounts, migrateAutowithdraw, migrateBalancesToTB, migrateFundsToTB, migrateToMicrosats } from "$lib/migrate";
+import {
+ migrateAccounts,
+ migrateAutowithdraw,
+ migrateBalancesToTB,
+ migrateFundsToTB,
+ migrateToMicrosats,
+} from "$lib/migrate";
import nwc from "$lib/nwc";
import { catchUp, check } from "$lib/payments";
import { getFx } from "$lib/rates";
diff --git a/inspect-ark.ts b/inspect-ark.ts
index 8c1a551b..d6f55bc8 100644
--- a/inspect-ark.ts
+++ b/inspect-ark.ts
@@ -16,7 +16,7 @@ try {
const balanceAfter = await wallet.getBalance();
console.log("Balance after:", JSON.stringify(balanceAfter));
-} catch(e: any) {
+} catch (e: any) {
console.error("Error:", e.message);
}
diff --git a/lib/app.ts b/lib/app.ts
index b8bcb610..da29d9fe 100644
--- a/lib/app.ts
+++ b/lib/app.ts
@@ -149,8 +149,6 @@ app.setErrorHandler((error, _, reply) => {
}
});
-app.setNotFoundHandler((_, reply) =>
- reply.code(404).type("text/html").send("Not Found"),
-);
+app.setNotFoundHandler((_, reply) => reply.code(404).type("text/html").send("Not Found"));
export default app;
diff --git a/lib/ark.ts b/lib/ark.ts
index ad708b7f..6558a74a 100644
--- a/lib/ark.ts
+++ b/lib/ark.ts
@@ -2,13 +2,7 @@ import { EventSource } from "eventsource";
if (!globalThis.EventSource) globalThis.EventSource = EventSource;
import config from "$config";
-import {
- SingleKey,
- Wallet,
- Ramps,
- RestArkProvider,
- VtxoManager,
-} from "@arkade-os/sdk";
+import { SingleKey, Wallet, Ramps, RestArkProvider, VtxoManager } from "@arkade-os/sdk";
import { l, warn } from "$lib/logging";
let wallet: any;
@@ -31,9 +25,7 @@ const failedBoardingOutpoints = new Set<string>();
const withTimeout = <T>(promise: Promise<T>, ms: number, label: string) =>
Promise.race([
promise,
- new Promise<T>((_, reject) =>
- setTimeout(() => reject(new Error(`${label} timed out`)), ms),
- ),
+ new Promise<T>((_, reject) => setTimeout(() => reject(new Error(`${label} timed out`)), ms)),
]);
export const refreshArkWallet = async (force = false) => {
@@ -58,11 +50,7 @@ export const refreshArkWallet = async (force = false) => {
// Recover swept/expired VTXOs
if (balance.recoverable > 0) {
try {
- const txid = await withTimeout(
- manager.recoverVtxos(),
- 60_000,
- "ark recovery",
- );
+ const txid = await withTimeout(manager.recoverVtxos(), 60_000, "ark recovery");
l("ark recovered swept vtxos, txid:", txid);
} catch (e: any) {
warn("ark vtxo recovery failed:", e.message);
@@ -74,11 +62,7 @@ export const refreshArkWallet = async (force = false) => {
const expiring = await manager.getExpiringVtxos();
if (expiring.length > 0) {
l("ark renewing", expiring.length, "expiring vtxos");
- const txid = await withTimeout(
- manager.renewVtxos(),
- 60_000,
- "ark renewal",
- );
+ const txid = await withTimeout(manager.renewVtxos(), 60_000, "ark renewal");
l("ark renewed vtxos, txid:", txid);
}
} catch (e: any) {
@@ -98,10 +82,7 @@ export const refreshArkWallet = async (force = false) => {
const outpointKey = (u: any) => `${u.txid}:${u.vout}`;
const sorted = [...confirmed]
.filter((u: any) => !failedBoardingOutpoints.has(outpointKey(u)))
- .sort(
- (a: any, b: any) =>
- (b.status?.block_height || 0) - (a.status?.block_height || 0),
- );
+ .sort((a: any, b: any) => (b.status?.block_height || 0) - (a.status?.block_height || 0));
for (const utxo of sorted) {
try {
diff --git a/lib/auth.ts b/lib/auth.ts
index 79c04e9d..c2eca6d4 100644
--- a/lib/auth.ts
+++ b/lib/auth.ts
@@ -50,8 +50,7 @@ export const jwtStrategy = new jwt.Strategy(
let { id } = payload;
const wl = { GET: ["/invoice", "/payments"], POST: ["/invoice"] };
- if (id.endsWith("-ro") && wl[m].some((p) => u.startsWith(p)))
- id = id.slice(0, -3);
+ if (id.endsWith("-ro") && wl[m].some((p) => u.startsWith(p))) id = id.slice(0, -3);
const user = await getUser(id);
next(null, user);
diff --git a/lib/ecash.ts b/lib/ecash.ts
index bcd2b7f4..5a5776b5 100644
--- a/lib/ecash.ts
+++ b/lib/ecash.ts
@@ -13,7 +13,6 @@ import {
getEncodedTokenV4,
} from "@cashu/cashu-ts";
-
const { URL } = process.env;
const m = new CashuMint(config.mintUrl);
const w = new CashuWallet(m);
diff --git a/lib/esplora.ts b/lib/esplora.ts
index 4fd81b32..d92fad0c 100644
--- a/lib/esplora.ts
+++ b/lib/esplora.ts
@@ -91,8 +91,7 @@ export const getTxHex = async (txid: string) => {
// Address derivation
const hdVersionsForKey = (pubkey: string) => {
- if (pubkey.startsWith("tpub") || pubkey.startsWith("tprv"))
- return REGTEST_VERSIONS;
+ if (pubkey.startsWith("tpub") || pubkey.startsWith("tprv")) return REGTEST_VERSIONS;
// xpub/xprv use default BITCOIN_VERSIONS (mainnet) — pass undefined
return undefined;
};
@@ -136,11 +135,7 @@ export const parseDescriptor = (desc: string) => {
return { fingerprint: match[1], pubkey: match[2] };
};
-export const findLastUsedIndex = async (
- pubkey: string,
- fingerprint: string,
- maxScan = 100,
-) => {
+export const findLastUsedIndex = async (pubkey: string, fingerprint: string, maxScan = 100) => {
let lastUsed = -1;
for (let i = 0; i < maxScan; i++) {
const { address } = deriveAddress(pubkey, fingerprint, i, false);
diff --git a/lib/health.ts b/lib/health.ts
index c2e268c6..fbefa8fa 100644
--- a/lib/health.ts
+++ b/lib/health.ts
@@ -22,13 +22,16 @@ export function getHealthStatus() {
function withTimeout<T>(promise: Promise<T>, ms: number, label: string): Promise<T> {
return new Promise((resolve, reject) => {
- const timer = setTimeout(
- () => reject(new Error(`${label} timed out after ${ms}ms`)),
- ms,
- );
+ const timer = setTimeout(() => reject(new Error(`${label} timed out after ${ms}ms`)), ms);
promise.then(
- (v) => { clearTimeout(timer); resolve(v); },
- (e) => { clearTimeout(timer); reject(e); },
+ (v) => {
+ clearTimeout(timer);
+ resolve(v);
+ },
+ (e) => {
+ clearTimeout(timer);
+ reject(e);
+ },
);
});
}
@@ -79,11 +82,7 @@ async function checkLightningHealth(): Promise<boolean> {
const errorCode = e?.code ?? e?.errno ?? "unknown";
const errorMsg = e?.message ?? String(e);
- err(
- `health check: FAILED after ${duration}ms`,
- `code=${errorCode}`,
- `error=${errorMsg}`,
- );
+ err(`health check: FAILED after ${duration}ms`, `code=${errorCode}`, `error=${errorMsg}`);
if (e instanceof LightningUnavailableError) {
err("health check: lightning RPC socket unavailable");
@@ -102,18 +101,14 @@ export async function runHealthCheck() {
if (healthy) {
if (consecutiveFailures > 0) {
- l(
- `health check: recovered after ${consecutiveFailures} consecutive failures`,
- );
+ l(`health check: recovered after ${consecutiveFailures} consecutive failures`);
}
consecutiveFailures = 0;
lastSuccessTime = Date.now();
lastFailureReason = "";
} else {
consecutiveFailures++;
- warn(
- `health check: failure ${consecutiveFailures}/${MAX_CONSECUTIVE_FAILURES}`,
- );
+ warn(`health check: failure ${consecutiveFailures}/${MAX_CONSECUTIVE_FAILURES}`);
if (consecutiveFailures >= MAX_CONSECUTIVE_FAILURES) {
err(
diff --git a/lib/lightning.ts b/lib/lightning.ts
index 4824d9ab..a259b601 100644
--- a/lib/lightning.ts
+++ b/lib/lightning.ts
@@ -66,8 +66,7 @@ export async function listenForLightning() {
handleZap(inv, pubkey);
}
} catch (e) {
- if (!e.message.includes("Unexpected"))
- warn("failed to handle zap", e.message);
+ if (!e.message.includes("Unexpected")) warn("failed to handle zap", e.message);
}
}
@@ -88,11 +87,7 @@ export async function listenForLightning() {
const errorCode = e?.code ?? e?.errno ?? "unknown";
const errorMsg = e?.message ?? String(e);
- err(
- `lightning listener: error waiting for invoice`,
- `code=${errorCode}`,
- `error=${errorMsg}`
- );
+ err(`lightning listener: error waiting for invoice`, `code=${errorCode}`, `error=${errorMsg}`);
if (e instanceof LightningUnavailableError) {
err("lightning listener: RPC socket unavailable");
@@ -103,7 +98,7 @@ export async function listenForLightning() {
if (listenerRetries >= MAX_LISTENER_RETRIES) {
err(
`lightning listener: ${MAX_LISTENER_RETRIES} consecutive failures, ` +
- `last error: ${errorMsg}`
+ `last error: ${errorMsg}`,
);
err("lightning listener: exiting process to trigger container restart");
@@ -115,7 +110,7 @@ export async function listenForLightning() {
warn(
`lightning listener: retry ${listenerRetries}/${MAX_LISTENER_RETRIES} ` +
- `in ${LISTENER_RETRY_DELAY / 1000}s`
+ `in ${LISTENER_RETRY_DELAY / 1000}s`,
);
setTimeout(listenForLightning, LISTENER_RETRY_DELAY);
}
@@ -150,8 +145,7 @@ export async function replay(index) {
handleZap(inv, pubkey);
}
} catch (e) {
- if (!e.message.includes("Unexpected"))
- warn("failed to handle zap", e.message);
+ if (!e.message.includes("Unexpected")) warn("failed to handle zap", e.message);
}
}
diff --git a/lib/ln.ts b/lib/ln.ts
index 0ef99fc5..b4bd148d 100644
--- a/lib/ln.ts
+++ b/lib/ln.ts
@@ -47,7 +47,7 @@ function lightningProxy(rpcPath: string) {
if (isUnavailable(e)) {
throw new LightningUnavailableError(
- `Lightning RPC unavailable at ${rpcPath} (${e?.code ?? e?.errno ?? "error"})`
+ `Lightning RPC unavailable at ${rpcPath} (${e?.code ?? e?.errno ?? "error"})`,
);
}
throw e;
@@ -75,7 +75,7 @@ function lightningProxy(rpcPath: string) {
}
};
},
- }
+ },
);
}
diff --git a/lib/locales/index.ts b/lib/locales/index.ts
index c3aaa7c8..c902a8d2 100644
--- a/lib/locales/index.ts
+++ b/lib/locales/index.ts
@@ -1,5 +1,7 @@
import fs from "fs";
-export default "ar,bn,de,el,en,es,fa,fr,hi,it,ja,ko,nl,pl,pt,ru,th,tr,zh".split(",").reduce((a, l) => {
- a[l] = JSON.parse(fs.readFileSync(`lib/locales/${l}.json`));
+export default "ar,bn,de,el,en,es,fa,fr,hi,it,ja,ko,nl,pl,pt,ru,th,tr,zh"
+ .split(",")
+ .reduce((a, l) => {
+ a[l] = JSON.parse(fs.readFileSync(`lib/locales/${l}.json`));
return a;
-}, {});
+ }, {});
diff --git a/lib/locations.ts b/lib/locations.ts
index 660645a8..91bc4599 100644
--- a/lib/locations.ts
+++ b/lib/locations.ts
@@ -6,10 +6,7 @@ import got from "got";
const dedup = (array) =>
Object.values(
array.reduce((acc, obj) => {
- if (
- !acc[obj.id] ||
- new Date(obj.updated_at) > new Date(acc[obj.id].updated_at)
- ) {
+ if (!acc[obj.id] || new Date(obj.updated_at) > new Date(acc[obj.id].updated_at)) {
acc[obj.id] = obj;
}
return acc;
diff --git a/lib/migrate.ts b/lib/migrate.ts
index d4bfd61a..e3cfa9bc 100644
--- a/lib/migrate.ts
+++ b/lib/migrate.ts
@@ -40,10 +40,7 @@ export const migrateAccounts = async () => {
account.pubkey = parsed.pubkey;
account.fingerprint = parsed.fingerprint;
try {
- account.nextIndex = await findLastUsedIndex(
- parsed.pubkey,
- parsed.fingerprint,
- );
+ account.nextIndex = await findLastUsedIndex(parsed.pubkey, parsed.fingerprint);
} catch (e) {
warn("account migration index scan skipped", key, e.message);
account.nextIndex = account.nextIndex || 0;
diff --git a/lib/nostr.ts b/lib/nostr.ts
index 354f928b..bcb20ea1 100644
--- a/lib/nostr.ts
+++ b/lib/nostr.ts
@@ -12,13 +12,9 @@ import { Relay } from "nostr-tools/relay";
export const EX = 60 * 60 * 24;
const coinos = await Relay.connect(config.nostr);
-export const serverSecret = bytesToHex(
- nip19.decode(config.nostrKey).data as Uint8Array,
-);
+export const serverSecret = bytesToHex(nip19.decode(config.nostrKey).data as Uint8Array);
-export const serverSecret2 = bytesToHex(
- nip19.decode(config.nostrKey2).data as Uint8Array,
-);
+export const serverSecret2 = bytesToHex(nip19.decode(config.nostrKey2).data as Uint8Array);
export const serverPubkey = getPublicKey(hexToBytes(serverSecret));
export const serverPubkey2 = getPublicKey(hexToBytes(serverSecret2));
@@ -54,29 +50,21 @@ export async function handleZap(invoice, sender = undefined) {
fail("No tags found");
}
- const ptags = zapreq.tags.filter(
- (t) => t?.length && t.length >= 2 && t[0] === "p",
- );
+ const ptags = zapreq.tags.filter((t) => t?.length && t.length >= 2 && t[0] === "p");
if (ptags.length !== 1) {
fail("None or multiple p tags found");
}
- const etags = zapreq.tags.filter(
- (t) => t?.length && t.length >= 2 && t[0] === "e",
- );
+ const etags = zapreq.tags.filter((t) => t?.length && t.length >= 2 && t[0] === "e");
if (!(etags.length === 0 || etags.length === 1)) {
fail("Expected none or 1 e tags");
}
- const atags = zapreq.tags.filter(
- (t) => t?.length && t.length >= 2 && t[0] === "a",
- );
+ const atags = zapreq.tags.filter((t) => t?.length && t.length >= 2 && t[0] === "a");
- const relays_tag = zapreq.tags.find(
- (t) => t?.length && t.length >= 2 && t[0] === "relays",
- );
+ const relays_tag = zapreq.tags.find((t) => t?.length && t.length >= 2 && t[0] === "relays");
if (!relays_tag) {
fail("No relays tag found");
@@ -168,8 +156,7 @@ export const getCount = async (pubkey) => {
if (follows === null) {
const result = await get({ authors: [pubkey], kinds: [3] });
follows = result ? result.tags.filter((t) => t[0] === "p").length : 0;
- if (follows?.length)
- await db.set(`${pubkey}:follows:n`, JSON.stringify(follows), { EX });
+ if (follows?.length) await db.set(`${pubkey}:follows:n`, JSON.stringify(follows), { EX });
}
const k = `${pubkey}:followers:n`;
diff --git a/lib/notes.ts b/lib/notes.ts
index 84d157ee..6e8e6afc 100644
--- a/lib/notes.ts
+++ b/lib/notes.ts
@@ -20,8 +20,7 @@ const first = (list: any) => (list ? list[0] : undefined);
export const fromNostrURI = (s: string) => s.replace(/^[\w+]+:\/?\/?/, "");
export const urlIsMedia = (url: string) =>
- !url.match(/\.(apk|docx|xlsx|csv|dmg)/) &&
- last(url.split("://"))?.includes("/");
+ !url.match(/\.(apk|docx|xlsx|csv|dmg)/) && last(url.split("://"))?.includes("/");
type ContentArgs = {
content: string;
@@ -35,13 +34,10 @@ export type ParsedPart = {
value: any;
};
-export const isEmbeddableMedia = (url: string) =>
- isImage(url) || isVideo(url) || isAudio(url);
+export const isEmbeddableMedia = (url: string) => isImage(url) || isVideo(url) || isAudio(url);
-export const isImage = (url: string) =>
- url?.match(/^.*\.(jpg|jpeg|png|webp|gif|avif|svg)/gi);
-export const isVideo = (url: string) =>
- url?.match(/^.*\.(mov|mkv|mp4|avi|m4v|webm)/gi);
+export const isImage = (url: string) => url?.match(/^.*\.(jpg|jpeg|png|webp|gif|avif|svg)/gi);
+export const isVideo = (url: string) => url?.match(/^.*\.(mov|mkv|mp4|avi|m4v|webm)/gi);
export const isAudio = (url: string) => url?.match(/^.*\.(ogg|mp3|wav)/gi);
/**
@@ -70,9 +66,7 @@ export function groupContent(parts: ParsedPart[]): ParsedPart[] {
parts.forEach((part, index) => {
if (
part.type === LINK &&
- (isImage(part.value.url) ||
- isVideo(part.value.url) ||
- isAudio(part.value.url))
+ (isImage(part.value.url) || isVideo(part.value.url) || isAudio(part.value.url))
) {
if (!buffer) {
buffer = {
@@ -87,8 +81,7 @@ export function groupContent(parts: ParsedPart[]): ParsedPart[] {
for (const nextPart of parts.slice(index + 1)) {
const isNewline = nextPart.type === NEWLINE;
- const isBlankText =
- nextPart.type === TEXT && nextPart.value.trim() === "";
+ const isBlankText = nextPart.type === TEXT && nextPart.value.trim() === "";
const isLink = nextPart.type === LINK;
// This is a noop, keep checking the next part
@@ -114,11 +107,7 @@ export function groupContent(parts: ParsedPart[]): ParsedPart[] {
return result;
}
-export const parseContent = ({
- content,
- tags = [],
- html = false,
-}: ContentArgs): ParsedPart[] => {
+export const parseContent = ({ content, tags = [], html = false }: ContentArgs): ParsedPart[] => {
const result: ParsedPart[] = [];
let text = content.trim();
let buffer = "";
@@ -174,9 +163,7 @@ export const parseContent = ({
const parseBech32 = () => {
const bech32 = first(
- text.match(
- /^(web\+)?(nostr:)?\/?\/?n(event|ote|profile|pub|addr)1[\d\w]+/i,
- ),
+ text.match(/^(web\+)?(nostr:)?\/?\/?n(event|ote|profile|pub|addr)1[\d\w]+/i),
);
if (bech32) {
@@ -211,9 +198,7 @@ export const parseContent = ({
};
const parseUrl = () => {
- const raw = first(
- text.match(/^([a-z+:]{2,30}:\/\/)?[^\s]+\.[a-z]{2,6}[^\s]*[^.!?,:\s]/gi),
- );
+ const raw = first(text.match(/^([a-z+:]{2,30}:\/\/)?[^\s]+\.[a-z]{2,6}[^\s]*[^.!?,:\s]/gi));
// Skip url if it's just the end of a filepath
if (raw) {
@@ -290,10 +275,7 @@ export const parseContent = ({
return result;
};
-export const truncateContent = (
- content,
- { showEntire, maxLength, showMedia = false },
-) => {
+export const truncateContent = (content, { showEntire, maxLength, showMedia = false }) => {
if (showEntire) {
return content;
}
@@ -303,13 +285,8 @@ export const truncateContent = (
const truncateAt = maxLength * 0.6;
content.every((part, i) => {
- const isText =
- [TOPIC, TEXT].includes(part.type) ||
- (part.type === LINK && !part.value.isMedia);
- const isMedia =
- part.type === INVOICE ||
- part.type.startsWith("nostr:") ||
- part.value.isMedia;
+ const isText = [TOPIC, TEXT].includes(part.type) || (part.type === LINK && !part.value.isMedia);
+ const isMedia = part.type === INVOICE || part.type.startsWith("nostr:") || part.value.isMedia;
if (isText) {
length += part.value.length;
diff --git a/lib/notifications.ts b/lib/notifications.ts
index d1e43392..261ad4bb 100644
--- a/lib/notifications.ts
+++ b/lib/notifications.ts
@@ -12,11 +12,7 @@ import { finalizeEvent, nip04 } from "nostr-tools";
import webpush from "web-push";
if (config.vapid) {
- webpush.setVapidDetails(
- `mailto:${config.support}`,
- config.vapid.pk,
- config.vapid.sk,
- );
+ webpush.setVapidDetails(`mailto:${config.support}`, config.vapid.pk, config.vapid.sk);
}
export const notify = async (p, user, withdrawal) => {
@@ -62,12 +58,10 @@ export const notify = async (p, user, withdrawal) => {
};
for (const s of subscriptions) {
- webpush
- .sendNotification(JSON.parse(s), JSON.stringify(payload))
- .catch((e) => {
- warn("sub failed", e.message);
- db.sRem(`${user.id}:subscriptions`, s);
- });
+ webpush.sendNotification(JSON.parse(s), JSON.stringify(payload)).catch((e) => {
+ warn("sub failed", e.message);
+ db.sRem(`${user.id}:subscriptions`, s);
+ });
}
if (config.mqtt) {
diff --git a/lib/nwc.ts b/lib/nwc.ts
index 47b632f7..b635f665 100644
--- a/lib/nwc.ts
+++ b/lib/nwc.ts
@@ -3,13 +3,7 @@ import { archive, db, g, gf } from "$lib/db";
import { generate } from "$lib/invoices";
import ln from "$lib/ln";
import { err, l, warn } from "$lib/logging";
-import {
- handleZap,
- serverPubkey,
- serverPubkey2,
- serverSecret,
- serverSecret2,
-} from "$lib/nostr";
+import { handleZap, serverPubkey, serverPubkey2, serverSecret, serverSecret2 } from "$lib/nostr";
import { sendInternal, sendKeysend, sendLightning } from "$lib/payments";
import { getBalance } from "$lib/tb";
import { fail, getInvoice, sleep } from "$lib/utils";
@@ -89,64 +83,62 @@ export default () => {
r.on("error", () => {});
r.on("event", async (sub, ev) => {
- try {
- if (sub !== "nwc") return;
- const now = Math.floor(Date.now() / 1000);
- if (ev.created_at && now - ev.created_at > nwcEventMaxAgeSeconds) return;
- if (await db.zScore(handledKey, ev.id)) return;
+ try {
+ if (sub !== "nwc") return;
+ const now = Math.floor(Date.now() / 1000);
+ if (ev.created_at && now - ev.created_at > nwcEventMaxAgeSeconds) return;
+ if (await db.zScore(handledKey, ev.id)) return;
- db.zAdd(handledKey, { score: now, value: ev.id });
- db.zRemRangeByScore(handledKey, 0, now - nwcEventMaxAgeSeconds);
- const size = await db.zCard(handledKey);
- if (size > handledMaxSize) {
- await db.zRemRangeByRank(handledKey, 0, size - handledMaxSize - 1);
- }
- let { content, pubkey } = ev;
- const pk = ev.tags.find((t) => t[0] === "p")[1];
- const sk = serverKeys[pk];
- const { params, method } = JSON.parse(
- await nip04.decrypt(sk, pubkey, content),
- );
+ db.zAdd(handledKey, { score: now, value: ev.id });
+ db.zRemRangeByScore(handledKey, 0, now - nwcEventMaxAgeSeconds);
+ const size = await db.zCard(handledKey);
+ if (size > handledMaxSize) {
+ await db.zRemRangeByRank(handledKey, 0, size - handledMaxSize - 1);
+ }
+ let { content, pubkey } = ev;
+ const pk = ev.tags.find((t) => t[0] === "p")[1];
+ const sk = serverKeys[pk];
+ const { params, method } = JSON.parse(await nip04.decrypt(sk, pubkey, content));
- // console.log("nwc", method, params, pubkey);
+ // console.log("nwc", method, params, pubkey);
- if (!methods.includes(method)) return;
+ if (!methods.includes(method)) return;
- try {
- const app = await g(`app:${pubkey}`);
- if (!app) fail("pubkey not found");
- const user = await g(`user:${app.uid}`);
+ try {
+ const app = await g(`app:${pubkey}`);
+ if (!app) fail("pubkey not found");
+ const user = await g(`user:${app.uid}`);
- const result = await handle(method, params, ev, app, user);
- const payload = JSON.stringify({ result_type: method, ...result });
- content = await nip04.encrypt(sk, pubkey, payload);
+ const result = await handle(method, params, ev, app, user);
+ const payload = JSON.stringify({ result_type: method, ...result });
+ content = await nip04.encrypt(sk, pubkey, payload);
- let response: UnsignedEvent = {
- created_at: Math.floor(Date.now() / 1000),
- kind: 23195,
- pubkey: serverPubkey,
- tags: [
- ["p", pubkey],
- ["e", ev.id],
- ],
- content,
- };
+ let response: UnsignedEvent = {
+ created_at: Math.floor(Date.now() / 1000),
+ kind: 23195,
+ pubkey: serverPubkey,
+ tags: [
+ ["p", pubkey],
+ ["e", ev.id],
+ ],
+ content,
+ };
- response = await finalizeEvent(response, hexToBytes(sk));
- r.send(["EVENT", response]);
+ response = await finalizeEvent(response, hexToBytes(sk));
+ r.send(["EVENT", response]);
+ } catch (e) {
+ // err(
+ // "problem with nwc",
+ // pubkey,
+ // method,
+ // JSON.stringify(params),
+ // e.message,
+ // );
+ }
} catch (e) {
- // err(
- // "problem with nwc",
- // pubkey,
- // method,
- // JSON.stringify(params),
- // e.message,
- // );
+ // err("problem with nwc", e.message);
}
- } catch (e) {
- // err("problem with nwc", e.message);
- }
- });
+ });
}
connect();
@@ -171,9 +163,7 @@ const handle = (method, params, ev, app, user) =>
const pids = await db.lRange(`${pubkey}:payments`, 0, -1);
let payments = await Promise.all(pids.map((pid) => g(`payment:${pid}`)));
- payments = payments.filter(
- (p) => p?.created > Date.now() - periods[budget_renewal],
- );
+ payments = payments.filter((p) => p?.created > Date.now() - periods[budget_renewal]);
const spent = payments.reduce(
(a, b) =>
@@ -186,14 +176,7 @@ const handle = (method, params, ev, app, user) =>
);
if (!created) {
- warn(
- "old nwc token",
- pubkey,
- user?.username,
- spent,
- amount,
- max_amount,
- );
+ warn("old nwc token", pubkey, user?.username, spent, amount, max_amount);
return error({
code: "UNAUTHORIZED",
message: `This NWC connection is no longer valid please create a new one at https://coinos.io/settings/nostr`,
@@ -344,11 +327,7 @@ const handle = (method, params, ev, app, user) =>
expiry,
};
- const {
- hash,
- created: created_at,
- paymentHash,
- } = await generate({ invoice, user });
+ const { hash, created: created_at, paymentHash } = await generate({ invoice, user });
return result({
type: "incoming",
@@ -401,8 +380,7 @@ const handle = (method, params, ev, app, user) =>
const { pays } = await ln.listpays({ bolt11: invoice, payment_hash });
- if (!pays.length)
- return error({ code: "NOT_FOUND", message: "Invoice not found" });
+ if (!pays.length) return error({ code: "NOT_FOUND", message: "Invoice not found" });
const {
amount_msat: amount,
diff --git a/lib/passkey.ts b/lib/passkey.ts
index b2cb96b4..29b9b095 100644
--- a/lib/passkey.ts
+++ b/lib/passkey.ts
@@ -4,9 +4,7 @@ import {
generateAuthenticationOptions,
verifyAuthenticationResponse,
} from "@simplewebauthn/server";
-import type {
- AuthenticatorTransportFuture,
-} from "@simplewebauthn/types";
+import type { AuthenticatorTransportFuture } from "@simplewebauthn/types";
import { db, g, s } from "$lib/db";
import { fail, getUser } from "$lib/utils";
import { v4 } from "uuid";
@@ -102,9 +100,7 @@ export async function verifyPasskeyLogin(response: any, challengeId: string, ori
if (!user) fail("User not found");
const passkeys = user.passkeys || [];
- const passkey = passkeys.find(
- (p: any) => p.credentialID === response.id,
- );
+ const passkey = passkeys.find((p: any) => p.credentialID === response.id);
if (!passkey) fail("Passkey not found");
const expectedChallenge = await db.get(`challenge:passkey:${challengeId}`);
diff --git a/lib/payments.ts b/lib/payments.ts
index 8fee1a26..841beac5 100644
--- a/lib/payments.ts
+++ b/lib/payments.ts
@@ -134,34 +134,16 @@ export const debit = async ({
}) => {
amount = Number.parseInt(amount);
- const whitelisted = await db.sIsMember(
- "whitelist",
- user?.username?.toLowerCase().trim(),
- );
+ const whitelisted = await db.sIsMember("whitelist", user?.username?.toLowerCase().trim());
- const blacklisted = await db.sIsMember(
- "blacklist",
- user?.username?.toLowerCase().trim(),
- );
+ const blacklisted = await db.sIsMember("blacklist", user?.username?.toLowerCase().trim());
const serverLimit = await g(`${type}:limit`);
const userLimit = await g("limit");
- const frozen =
- (await g("hardfreeze")) ||
- ((await g("freeze")) && type !== PaymentType.internal);
+ const frozen = (await g("hardfreeze")) || ((await g("freeze")) && type !== PaymentType.internal);
if (frozen || (amount > userLimit && !whitelisted) || amount > serverLimit) {
- warn(
- "Blocking",
- user.username,
- amount,
- hash,
- user.id,
- type,
- frozen,
- userLimit,
- serverLimit,
- );
+ warn("Blocking", user.username, amount, hash, user.id, type, frozen, userLimit, serverLimit);
fail("Problem sending payment");
}
@@ -184,8 +166,7 @@ export const debit = async ({
ref = invoice.uid;
- const equivalentRate =
- invoice.rate * (rates[currency] / rates[invoice.currency]);
+ const equivalentRate = invoice.rate * (rates[currency] / rates[invoice.currency]);
if (Math.abs(invoice.rate / rates[invoice.currency] - 1) < 0.01) {
rate = equivalentRate;
@@ -201,17 +182,12 @@ export const debit = async ({
let creditType = type;
if (creditType === PaymentType.bolt12) creditType = PaymentType.lightning;
- let ourfee: any = [
- PaymentType.bitcoin,
- PaymentType.liquid,
- PaymentType.lightning,
- ].includes(type)
+ let ourfee: any = [PaymentType.bitcoin, PaymentType.liquid, PaymentType.lightning].includes(type)
? Math.round((amount + fee + tip) * config.fee[creditType])
: 0;
if (aid !== uid) ourfee = 0;
- const frozenBalance =
- !blacklisted || whitelisted ? 0 : await getBalance(uid);
+ const frozenBalance = !blacklisted || whitelisted ? 0 : await getBalance(uid);
ourfee = await tbDebit(
aid,
@@ -334,8 +310,7 @@ export const credit = async ({
items: undefined,
};
- if ([PaymentType.bitcoin, PaymentType.liquid].includes(type))
- inv.pending += amount;
+ if ([PaymentType.bitcoin, PaymentType.liquid].includes(type)) inv.pending += amount;
else {
inv.received += amount;
inv.preimage = ref;
@@ -506,9 +481,7 @@ const pay = async ({ aid = undefined, amount, to, user }) => {
if (URL.includes(domain)) to = name;
lnurl = `https://${domain}/.well-known/lnurlp/${name}`;
} else if (to.startsWith("lnurl")) {
- lnurl = Buffer.from(
- bech32.fromWords(bech32.decode(to, 20000).words),
- ).toString();
+ lnurl = Buffer.from(bech32.fromWords(bech32.decode(to, 20000).words)).toString();
}
const recipient = await getUser(to);
@@ -552,8 +525,7 @@ const pay = async ({ aid = undefined, amount, to, user }) => {
const localInv = await getInvoice(to).catch(() => null);
if (localInv) {
const recipient = await getUser(localInv.uid);
- if (recipient)
- return sendInternal({ amount, invoice: localInv, recipient, sender: user });
+ if (recipient) return sendInternal({ amount, invoice: localInv, recipient, sender: user });
}
}
@@ -568,9 +540,12 @@ const pay = async ({ aid = undefined, amount, to, user }) => {
const { id: source } = await ln.getinfo();
const { offer_issuer_id } = await ln.decode(to);
const { routes } = await ln.getroutes(
- source, offer_issuer_id, amount * 1000,
+ source,
+ offer_issuer_id,
+ amount * 1000,
["auto.localchans", "auto.sourcefree"],
- Math.round(amount * 0.02) * 1000, 6,
+ Math.round(amount * 0.02) * 1000,
+ 6,
);
fee = routes.length
? Math.max(5, Math.round((routes[0].path[0].amount_msat - routes[0].amount_msat) / 1000))
@@ -627,12 +602,8 @@ const sendNonCustodial = async (params) => {
// Build set of own addresses for change detection
const ownAddresses = new Set<string>();
for (let i = 0; i <= nextIndex; i++) {
- ownAddresses.add(
- deriveAddress(account.pubkey, account.fingerprint, i, false).address,
- );
- ownAddresses.add(
- deriveAddress(account.pubkey, account.fingerprint, i, true).address,
- );
+ ownAddresses.add(deriveAddress(account.pubkey, account.fingerprint, i, false).address);
+ ownAddresses.add(deriveAddress(account.pubkey, account.fingerprint, i, true).address);
}
let totalIn = 0;
@@ -704,8 +675,7 @@ export const sendOnchain = async (params) => {
inflight[txid] = true;
if (!signed) {
- if (config[type].walletpass)
- await node.walletPassphrase(config[type].walletpass, 300);
+ if (config[type].walletpass) await node.walletPassphrase(config[type].walletpass, 300);
({ hex } = await node.signRawTransactionWithWallet(
type === PaymentType.liquid ? await node.blindRawTransaction(hex) : hex,
@@ -825,13 +795,7 @@ export const sendKeysend = async ({
}
};
-export const sendLightning = async ({
- user,
- pr,
- amount,
- fee = undefined,
- memo = undefined,
-}) => {
+export const sendLightning = async ({ user, pr, amount, fee = undefined, memo = undefined }) => {
let p;
if (typeof amount !== "undefined") {
@@ -842,8 +806,7 @@ export const sendLightning = async ({
}
}
- let { type, invoice_amount_msat, amount_msat, invoice_node_id, payee } =
- await ln.decode(pr);
+ let { type, invoice_amount_msat, amount_msat, invoice_node_id, payee } = await ln.decode(pr);
if (type.includes("bolt12")) {
amount_msat = invoice_amount_msat;
payee = invoice_node_id;
@@ -857,11 +820,9 @@ export const sendLightning = async ({
if (fee < 0) fail("Fee cannot be negative");
const { pays } = await ln.listpays(pr);
- if (pays.find((p) => p.status === "complete"))
- fail("Invoice has already been paid");
+ if (pays.find((p) => p.status === "complete")) fail("Invoice has already been paid");
- if (pays.find((p) => p.status === "pending"))
- fail("Payment is already underway");
+ if (pays.find((p) => p.status === "pending")) fail("Payment is already underway");
p = await debit({
hash: pr,
@@ -941,23 +902,16 @@ const getAddressType = async (a) => {
}
};
-const buildNonCustodial = async ({
- aid,
- amount,
- address,
- feeRate,
- subtract,
- user,
-}) => {
+const buildNonCustodial = async ({ aid, amount, address, feeRate, subtract, user }) => {
const account = await g(`account:${aid}`);
if (!account?.pubkey) fail("account missing pubkey");
amount = Number.parseInt(amount);
if (amount < 0) fail("invalid amount");
- const fees: any = await fetch(
- `${api[PaymentType.bitcoin]}/fees/recommended`,
- ).then((r) => r.json());
+ const fees: any = await fetch(`${api[PaymentType.bitcoin]}/fees/recommended`).then((r) =>
+ r.json(),
+ );
fees.hourFee = fees.halfHourFee;
fees.halfHourFee = fees.fastestFee;
@@ -969,18 +923,8 @@ const buildNonCustodial = async ({
const nextIndex = account.nextIndex || 0;
// Derive all used external + internal addresses and fetch UTXOs
- const externalAddrs = deriveAddresses(
- account.pubkey,
- account.fingerprint,
- nextIndex + 1,
- false,
- );
- const internalAddrs = deriveAddresses(
- account.pubkey,
- account.fingerprint,
- nextIndex + 1,
- true,
- );
+ const externalAddrs = deriveAddresses(account.pubkey, account.fingerprint, nextIndex + 1, false);
+ const internalAddrs = deriveAddresses(account.pubkey, account.fingerprint, nextIndex + 1, true);
const allAddrs = [...externalAddrs, ...internalAddrs];
const rawUtxos = await getAddressUtxos(allAddrs);
@@ -989,26 +933,14 @@ const buildNonCustodial = async ({
// Build address-to-path lookup
const addrToPath = {};
for (let i = 0; i <= nextIndex; i++) {
- const { address: extAddr } = deriveAddress(
- account.pubkey,
- account.fingerprint,
- i,
- false,
- );
+ const { address: extAddr } = deriveAddress(account.pubkey, account.fingerprint, i, false);
addrToPath[extAddr] = `m/0/${i}`;
- const { address: intAddr } = deriveAddress(
- account.pubkey,
- account.fingerprint,
- i,
- true,
- );
+ const { address: intAddr } = deriveAddress(account.pubkey, account.fingerprint, i, true);
addrToPath[intAddr] = `m/1/${i}`;
}
// Convert esplora UTXOs to selectUTXO input format
- const keyVersions = account.pubkey.startsWith("tpub")
- ? hdVersions
- : undefined;
+ const keyVersions = account.pubkey.startsWith("tpub") ? hdVersions : undefined;
const accountKey = HDKey.fromExtendedKey(account.pubkey, keyVersions);
const utxoInputs = rawUtxos.map((u) => {
@@ -1072,12 +1004,8 @@ const buildNonCustodial = async ({
// Build input metadata for client signing
const inputs = selected.inputs.map((input) => {
const inputTxid =
- typeof input.txid === "string"
- ? input.txid
- : Buffer.from(input.txid).toString("hex");
- const utxo = rawUtxos.find(
- (u) => u.txid === inputTxid && u.vout === input.index,
- );
+ typeof input.txid === "string" ? input.txid : Buffer.from(input.txid).toString("hex");
+ const utxo = rawUtxos.find((u) => u.txid === inputTxid && u.vout === input.index);
const path = utxo ? addrToPath[utxo.address] : undefined;
return {
witnessUtxo: {
@@ -1093,14 +1021,7 @@ const buildNonCustodial = async ({
return { feeRate, ourfee, fee, fees, hex, inputs, subtract };
};
-export const build = async ({
- aid,
- amount,
- address,
- feeRate,
- subtract,
- user,
-}) => {
+export const build = async ({ aid, amount, address, feeRate, subtract, user }) => {
const type = await getAddressType(address);
if (!aid) aid = user.id;
@@ -1138,8 +1059,7 @@ export const build = async ({
let outs = [{ [address]: btc(amount) }];
- if (type === PaymentType.liquid)
- outs = outs.map((o) => ({ ...o, asset: config.liquid.btc }));
+ if (type === PaymentType.liquid) outs = outs.map((o) => ({ ...o, asset: config.liquid.btc }));
let raw = await node.createRawTransaction([], outs, 0, replaceable);
@@ -1168,9 +1088,7 @@ export const build = async ({
if (subtract || amount + fee + ourfee > balance) {
subtract = true;
if (amount <= fee + ourfee + dust) {
- fail(
- `insufficient funds ⚡️${balance} of ⚡️${amount + fee + ourfee + dust}`,
- );
+ fail(`insufficient funds ⚡️${balance} of ⚡️${amount + fee + ourfee + dust}`);
}
outs = [{ [address]: btc(amount - ourfee) }];
@@ -1269,9 +1187,7 @@ export const importAccountHistory = async (account) => {
const addressSet = new Set(allAddrs);
const utxos = await getAddressUtxos(allAddrs);
- const confirmedUtxos = utxos.filter(
- (u) => u.status.confirmed && u.value >= 300,
- );
+ const confirmedUtxos = utxos.filter((u) => u.status.confirmed && u.value >= 300);
const total = confirmedUtxos.reduce((sum, u) => sum + u.value, 0);
const rates = await g("rates");
@@ -1294,9 +1210,7 @@ export const importAccountHistory = async (account) => {
continue;
}
- const created = u.status?.block_time
- ? u.status.block_time * 1000
- : Date.now();
+ const created = u.status?.block_time ? u.status.block_time * 1000 : Date.now();
const p = {
id: v4(),
aid: id,
@@ -1371,9 +1285,7 @@ export const importAccountHistory = async (account) => {
if (amount <= 0) continue;
const fee = Math.max(0, totalIn - totalOut);
- const created = tx.status?.block_time
- ? tx.status.block_time * 1000
- : Date.now();
+ const created = tx.status?.block_time ? tx.status.block_time * 1000 : Date.now();
const p = {
id: v4(),
@@ -1409,7 +1321,6 @@ export const importAccountHistory = async (account) => {
}
};
-
export const check = async () => {
if (process.env.URL.includes("dev")) return;
try {
@@ -1495,9 +1406,7 @@ const reverse = async (p) => {
const freezeCheck = async () => {
const funds = await ln.listfunds();
- const lnbalance = Math.round(
- funds.channels.reduce((a, b) => a + b.our_amount_msat, 0) / 1000,
- );
+ const lnbalance = Math.round(funds.channels.reduce((a, b) => a + b.our_amount_msat, 0) / 1000);
const bcbalance = Math.round((await bc.getBalance()) * SATS);
const { bitcoin } = await lq.getBalance();
diff --git a/lib/rates.ts b/lib/rates.ts
index dcb44464..74dfa50d 100644
--- a/lib/rates.ts
+++ b/lib/rates.ts
@@ -27,9 +27,7 @@ const connect = async () => {
try {
rates.IRT = (
- (await got(
- "https://api.nobitex.ir/v2/orderbook/BTCIRT",
- ).json()) as any
+ (await got("https://api.nobitex.ir/v2/orderbook/BTCIRT").json()) as any
).lastTradePrice;
} catch (e) {}
diff --git a/lib/register.ts b/lib/register.ts
index e99238b1..ac1997db 100644
--- a/lib/register.ts
+++ b/lib/register.ts
@@ -19,8 +19,7 @@ export default async (user, ip) => {
const reserved = ["ecash"];
if (!username) fail("Username required");
username = username.toLowerCase().replace(/\s/g, "");
- if (!valid.test(username))
- fail("Usernames can only have letters and numbers");
+ if (!valid.test(username)) fail("Usernames can only have letters and numbers");
if (reserved.includes(username)) fail("Invalid username");
if (username.includes("undefined")) fail("Invalid username");
@@ -41,7 +40,9 @@ export default async (user, ip) => {
if (config.ipregistry) {
try {
const {
- location: { country: { code } },
+ location: {
+ country: { code },
+ },
}: any = await got(
`https://api.ipregistry.co/${ip}?key=${config.ipregistry}&fields=location.country.code`,
).json();
diff --git a/lib/sockets.ts b/lib/sockets.ts
index 2e1c98e9..88817728 100644
--- a/lib/sockets.ts
+++ b/lib/sockets.ts
@@ -120,12 +120,8 @@ Bun.serve({
await track(ws, data);
} catch (e) {
- if (e.message.includes("not found"))
- ws.send(JSON.stringify({ type: "logout" }));
- setTimeout(
- () => ws?.close(code, `closing due to error ${e.message}`),
- 1000,
- );
+ if (e.message.includes("not found")) ws.send(JSON.stringify({ type: "logout" }));
+ setTimeout(() => ws?.close(code, `closing due to error ${e.message}`), 1000);
}
break;
case "token":
@@ -139,7 +135,7 @@ Bun.serve({
subscriptions.push({ invoice: data, ws });
break;
default:
- // warn("received socket message of unknown type", type, data);
+ // warn("received socket message of unknown type", type, data);
}
},
open(ws: any) {
@@ -158,8 +154,7 @@ Bun.serve({
}
let i;
- ~(i = subscriptions.findIndex((s) => s.ws.id === id)) &&
- subscriptions.splice(i, 1);
+ ~(i = subscriptions.findIndex((s) => s.ws.id === id)) && subscriptions.splice(i, 1);
if (all[id]) delete all[id];
} catch (e) {
diff --git a/lib/tb.ts b/lib/tb.ts
index ae1ac576..29411fef 100644
--- a/lib/tb.ts
+++ b/lib/tb.ts
@@ -1,11 +1,6 @@
import config from "$config";
import { warn } from "$lib/logging";
-import {
- createClient,
- CreateAccountError,
- AccountFlags,
- TransferFlags,
-} from "tigerbeetle-node";
+import { createClient, CreateAccountError, AccountFlags, TransferFlags } from "tigerbeetle-node";
import { createHash } from "crypto";
let client: any;
@@ -231,10 +226,7 @@ export async function tbDebit(
let coveredMicro = 0n;
if (ourfee > 0 && creditType && creditLedger[creditType]) {
const creditAcct = await getAccount(
- creditId(
- uid === aid ? uid : "00000000-0000-0000-0000-000000000000",
- creditType,
- ),
+ creditId(uid === aid ? uid : "00000000-0000-0000-0000-000000000000", creditType),
);
const creditBalMicro = accountBalanceMicro(creditAcct);
const ourfeeMicro = BigInt(ourfee) * MSATS;
@@ -349,9 +341,7 @@ export async function tbCredit(
// Add fee credit if applicable - MICROSATS for sub-satoshi precision!
// e.g., 2% of 10 sats = 0.2 sats = 200,000 microsats (accumulates over time)
if (creditType && creditLedger[creditType] && config.fee[creditType]) {
- const creditAmountMicro = BigInt(
- Math.round(amount * MSATS_NUM * config.fee[creditType]),
- );
+ const creditAmountMicro = BigInt(Math.round(amount * MSATS_NUM * config.fee[creditType]));
if (creditAmountMicro > 0n) {
transfers.push({
id: nextTransferId(),
@@ -421,11 +411,7 @@ export async function tbConfirm(aid: string, amount: number) {
}
}
-export async function tbReverse(
- uid: string,
- total: number,
- creditAmount: number,
-) {
+export async function tbReverse(uid: string, total: number, creditAmount: number) {
const transfers: any[] = [];
const linked = TransferFlags.linked;
@@ -650,11 +636,7 @@ export async function tbFundCredit(name: string, amount: number) {
}
}
-export async function tbFundDebit(
- name: string,
- amount: number,
- errMsg: string,
-): Promise<any> {
+export async function tbFundDebit(name: string, amount: number, errMsg: string): Promise<any> {
const transfers = [
{
id: nextTransferId(),
@@ -700,11 +682,7 @@ export async function tbMultiplyForMicrosats(uid: string): Promise<number> {
const MULTIPLIER = 999999n; // Adding this turns X into X*1000000
let count = 0;
- const multiplyAccount = async (
- accountId: bigint,
- ledger: number,
- houseId: bigint,
- ) => {
+ const multiplyAccount = async (accountId: bigint, ledger: number, houseId: bigint) => {
const acct = await client.lookupAccounts([u128(accountId)]);
if (!acct.length) return;
const current = acct[0].credits_posted - acct[0].debits_posted;
@@ -736,11 +714,7 @@ export async function tbMultiplyForMicrosats(uid: string): Promise<number> {
await multiplyAccount(balId, LEDGER_SATS, HOUSE_SATS);
await multiplyAccount(pendId, LEDGER_SATS, HOUSE_SATS);
await multiplyAccount(creditId(uid, "bitcoin"), LEDGER_CREDIT_BTC, HOUSE_BTC);
- await multiplyAccount(
- creditId(uid, "lightning"),
- LEDGER_CREDIT_LN,
- HOUSE_LN,
- );
+ await multiplyAccount(creditId(uid, "lightning"), LEDGER_CREDIT_LN, HOUSE_LN);
await multiplyAccount(creditId(uid, "liquid"), LEDGER_CREDIT_LQ, HOUSE_LQ);
return count;
diff --git a/lib/upload.ts b/lib/upload.ts
index 7b5ad86d..2ed5d905 100644
--- a/lib/upload.ts
+++ b/lib/upload.ts
@@ -16,15 +16,10 @@ export default async (req, res) => {
const [format, ext] = (await fileTypeFromBuffer(buf)).mime.split("/");
- if (format !== "image" && !["jpg", "jpeg", "png"].includes(ext))
- fail("unsupported file type");
+ if (format !== "image" && !["jpg", "jpeg", "png"].includes(ext)) fail("unsupported file type");
const w = type === "banner" ? 1920 : 240;
- buf = await sharp(buf, { failOnError: false })
- .rotate()
- .resize(w)
- .webp()
- .toBuffer();
+ buf = await sharp(buf, { failOnError: false }).rotate().resize(w).webp().toBuffer();
const hash = createHash("sha256").update(buf).digest("hex");
diff --git a/lib/utils.ts b/lib/utils.ts
index 878ef037..7a3d4c13 100644
--- a/lib/utils.ts
+++ b/lib/utils.ts
@@ -49,7 +49,7 @@ export const bip21 = (address, { amount, memo, tip, type }) => {
export const getAccount = async (id) => {
return g(`account:${id}`);
-}
+};
export const getUser = async (username, fields = undefined) => {
if (username === "undefined") fail("invalid user");
@@ -121,22 +121,17 @@ export function formatReceipt(items, currency) {
};
}
const maxLineWidth = 32;
- const { quantityColumnWidth, priceColumnWidth } =
- calculateColumnWidths(items);
+ const { quantityColumnWidth, priceColumnWidth } = calculateColumnWidths(items);
const nameColumnWidth = maxLineWidth - quantityColumnWidth - priceColumnWidth;
return items
.map((item) => {
const quantityStr = String(item.quantity).padEnd(quantityColumnWidth);
- const priceStr = f(item.price * item.quantity, currency).padStart(
- priceColumnWidth,
- );
+ const priceStr = f(item.price * item.quantity, currency).padStart(priceColumnWidth);
const nameLines = wrapText(item.name, nameColumnWidth);
// Construct the full line(s) with the first line including the price
- const fullLines = [
- `${quantityStr}${nameLines[0].padEnd(nameColumnWidth)}${priceStr}`,
- ];
+ const fullLines = [`${quantityStr}${nameLines[0].padEnd(nameColumnWidth)}${priceStr}`];
// Add any additional name lines, properly indented
for (let i = 1; i < nameLines.length; i++) {
fullLines.push(" ".repeat(quantityColumnWidth) + nameLines[i]);
@@ -162,9 +157,7 @@ export const time = (() => {
})();
export const fmt = (sats) =>
- `⚡️${new Intl.NumberFormat("en-US", { maximumFractionDigits: 0 }).format(
- sats,
- )}`;
+ `⚡️${new Intl.NumberFormat("en-US", { maximumFractionDigits: 0 }).format(sats)}`;
export const link = (id) => `${URL}/payment/${id}`;
diff --git a/lib/zmq.ts b/lib/zmq.ts
index 09f5a4ba..bce898d4 100644
--- a/lib/zmq.ts
+++ b/lib/zmq.ts
@@ -23,17 +23,14 @@ const TX_OPTS = {
const enc = new TextEncoder();
const dec = new TextDecoder();
-const reverseHex = (buf: Uint8Array) =>
- bytesToHex(Uint8Array.from(buf).reverse());
+const reverseHex = (buf: Uint8Array) => bytesToHex(Uint8Array.from(buf).reverse());
const readVarInt = (data: Uint8Array, offset: number) => {
const first = data[offset];
if (first < 0xfd) return { value: first, size: 1 };
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
- if (first === 0xfd)
- return { value: view.getUint16(offset + 1, true), size: 3 };
- if (first === 0xfe)
- return { value: view.getUint32(offset + 1, true), size: 5 };
+ if (first === 0xfd) return { value: view.getUint16(offset + 1, true), size: 3 };
+ if (first === 0xfe) return { value: view.getUint32(offset + 1, true), size: 5 };
return { value: Number(view.getBigUint64(offset + 1, true)), size: 9 };
};
@@ -150,10 +147,7 @@ const frame = (flags: number, body: Uint8Array) => {
};
const command = (name: string, props: Record<string, string> = {}) => {
- const parts: Uint8Array[] = [
- Uint8Array.of(name.length),
- enc.encode(name),
- ];
+ const parts: Uint8Array[] = [Uint8Array.of(name.length), enc.encode(name)];
for (const [k, v] of Object.entries(props)) {
const kb = enc.encode(k);
const vb = enc.encode(v);
@@ -169,23 +163,14 @@ const subscribeCommand = (topic: string) => {
const t = enc.encode(topic);
return frame(
0x04,
- concatBytes(
- Uint8Array.of(9),
- enc.encode("SUBSCRIBE"),
- Uint8Array.of(t.length),
- t,
- ),
+ concatBytes(Uint8Array.of(9), enc.encode("SUBSCRIBE"), Uint8Array.of(t.length), t),
);
};
const legacySubscribe = (topic: string) =>
frame(0x00, concatBytes(Uint8Array.of(1), enc.encode(topic)));
-const startSub = (
- url: string,
- topic: string,
- onMessage: (b: Uint8Array) => void,
-) =>
+const startSub = (url: string, topic: string, onMessage: (b: Uint8Array) => void) =>
new Promise<void>((resolve) => {
const [host, port] = url.replace("tcp://", "").split(":");
const socket = net.connect({ host, port: Number(port) });
@@ -212,11 +197,7 @@ const startSub = (
let header: number;
if (flags & 0x02) {
if (buffer.length < 9) return;
- const view = new DataView(
- buffer.buffer,
- buffer.byteOffset,
- buffer.byteLength,
- );
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
size = Number(view.getBigUint64(1));
header = 9;
} else {
@@ -262,11 +243,7 @@ export const startZmq = async () => {
if (process.env.DISABLE_ZMQ === "1") return;
l("zmq connecting", RAWTX_URL, RAWBLOCK_URL);
- const retry = async (
- url: string,
- topic: string,
- handler: (b: Uint8Array) => Promise<void>,
- ) => {
+ const retry = async (url: string, topic: string, handler: (b: Uint8Array) => Promise<void>) => {
let delay = 1000;
const maxDelay = 30000;
while (true) {
diff --git a/mint.ts b/mint.ts
index 8cf3e744..489e06ef 100644
--- a/mint.ts
+++ b/mint.ts
@@ -1,11 +1,6 @@
import config from "$config";
import { createClient } from "redis";
-import {
- CashuMint,
- CashuWallet,
- getEncodedTokenV4,
- MintQuoteState,
-} from "@cashu/cashu-ts";
+import { CashuMint, CashuWallet, getEncodedTokenV4, MintQuoteState } from "@cashu/cashu-ts";
const mintUrl = "http://mint:3338"; // the mint URL
const mint = new CashuMint(mintUrl);
diff --git a/package.json b/package.json
index f93facad..af93a981 100644
--- a/package.json
+++ b/package.json
@@ -2,10 +2,14 @@
"name": "coinos",
"version": "0.0.1",
"private": true,
+ "type": "module",
"scripts": {
"start": "bun index.ts",
"dev": "nodemon --exec bun index.ts",
- "format": "biome format *.js **/*.js --write"
+ "lint": "oxlint . && oxfmt --check .",
+ "lint:fix": "oxlint --fix . && oxfmt .",
+ "format": "oxfmt .",
+ "prepare": "husky"
},
"dependencies": {
"@arkade-os/sdk": "0.3.13",
@@ -56,14 +60,16 @@
"ws": "^8.19.0"
},
"devDependencies": {
- "@biomejs/biome": "^2.3.14",
"@types/bun": "^1.3.8",
+ "husky": "^9.1.7",
+ "lint-staged": "^16.2.7",
"nodemon": "^2",
+ "oxfmt": "^0.35.0",
+ "oxlint": "^1.50.0",
"typescript": "^5.9.3"
},
"apidoc": {
"title": "CoinOS Server API Documentation",
"url": "https://coinos.io/api"
- },
- "type": "module"
+ }
}
diff --git a/routes/ecash.ts b/routes/ecash.ts
index 57cc49c1..b4c16404 100644
--- a/routes/ecash.ts
+++ b/routes/ecash.ts
@@ -104,17 +104,7 @@ export default {
const { lightning: type } = PaymentType;
if (user.username !== "mint") fail("unauthorized");
const { id: uid, currency } = user;
- const ourfee = await tbDebit(
- uid,
- uid,
- type,
- amount || 0,
- 0,
- 0,
- 0,
- 0,
- "Insufficient funds",
- );
+ const ourfee = await tbDebit(uid, uid, type, amount || 0, 0, 0, 0, 0, "Insufficient funds");
const rates = await g("rates");
const rate = rates[currency];
diff --git a/routes/email.ts b/routes/email.ts
index 9f0a8228..25c90ee7 100644
--- a/routes/email.ts
+++ b/routes/email.ts
@@ -40,9 +40,7 @@ export default {
},
Subject: {
Charset,
- Data:
- body.subject ||
- `Support Request${username ? ` From ${username}` : ""}`,
+ Data: body.subject || `Support Request${username ? ` From ${username}` : ""}`,
},
},
ReplyToAddresses: [email],
diff --git a/routes/info.ts b/routes/info.ts
index a0ac7693..35d1c315 100644
--- a/routes/info.ts
+++ b/routes/info.ts
@@ -23,15 +23,10 @@ export default {
// }
const funds = await ln.listfunds();
- const lnchannel = parseInt(
- funds.channels.reduce((a, b) => a + b.channel_sat, 0),
- );
+ const lnchannel = parseInt(funds.channels.reduce((a, b) => a + b.channel_sat, 0));
const lnwallet = parseInt(funds.outputs.reduce((a, b) => a + b.value, 0));
- const cash = getDecodedToken(await g("cash")).proofs.reduce(
- (a, b) => a + b.amount,
- 0,
- );
+ const cash = getDecodedToken(await g("cash")).proofs.reduce((a, b) => a + b.amount, 0);
const info = {
cash,
diff --git a/routes/invoices.ts b/routes/invoices.ts
index bc96c3f0..7f44a28d 100644
--- a/routes/invoices.ts
+++ b/routes/invoices.ts
@@ -42,12 +42,7 @@ export default {
} catch (e) {
console.trace();
console.log(e);
- err(
- "problem generating invoice",
- req.user?.username,
- body.user?.username,
- e.message,
- );
+ err("problem generating invoice", req.user?.username, body.user?.username, e.message);
bail(res, e.message);
}
},
@@ -84,9 +79,7 @@ export default {
async list(req, res) {
const { id } = req.user;
let invoices = await db.lRange(`${id}:invoices`, 0, -1);
- invoices = (await Promise.all(invoices.map((i) => getInvoice(i)))).filter(
- Boolean,
- );
+ invoices = (await Promise.all(invoices.map((i) => getInvoice(i)))).filter(Boolean);
res.send(invoices);
},
@@ -95,8 +88,7 @@ export default {
const { address, message, type = "bitcoin" } = req.body;
const node = rpc(config[type]);
- if (config[type].walletpass)
- await node.walletPassphrase(config[type].walletpass, 300);
+ if (config[type].walletpass) await node.walletPassphrase(config[type].walletpass, 300);
const signature = await node.signMessage({ address, message });
res.send({ signature });
diff --git a/routes/lnurl.ts b/routes/lnurl.ts
index 0358488e..cb74e2b5 100644
--- a/routes/lnurl.ts
+++ b/routes/lnurl.ts
@@ -19,9 +19,7 @@ export default {
query: { address },
} = req;
const [name, domain] = address.split("@");
- const url = `https://${domain}/.well-known/lnurlp/${name
- .toLowerCase()
- .replace(/\s/g, "")}`;
+ const url = `https://${domain}/.well-known/lnurlp/${name.toLowerCase().replace(/\s/g, "")}`;
try {
const r = await got(url).json();
@@ -41,9 +39,7 @@ export default {
query: { text },
} = req;
try {
- const url = Buffer.from(
- bech32.fromWords(bech32.decode(text, 20000).words),
- ).toString();
+ const url = Buffer.from(bech32.fromWords(bech32.decode(text, 20000).words)).toString();
const r = await got(url).json();
res.send(r);
@@ -59,11 +55,7 @@ export default {
} = req;
try {
const user = await getUser(
- username
- .replace("lightning:", "")
- .replace(/\s/g, "")
- .replace("=", "")
- .toLowerCase(),
+ username.replace("lightning:", "").replace(/\s/g, "").replace("=", "").toLowerCase(),
);
if (!user) fail(`User ${username} not found`);
@@ -208,9 +200,8 @@ export default {
]);
const id = v4();
-
- const total =
- (parseInt(invoice.amount || 0) + parseInt(invoice.tip || 0)) * 1000;
+
+ const total = (parseInt(invoice.amount || 0) + parseInt(invoice.tip || 0)) * 1000;
await s(`lnurl:${id}`, uid);
if (total > 0) await s(`lnurl:${id}:invoice`, invoice.id);
diff --git a/routes/nostr.ts b/routes/nostr.ts
index 9c61bf16..4436a1c7 100644
--- a/routes/nostr.ts
+++ b/routes/nostr.ts
@@ -40,9 +40,7 @@ export default {
const parts = parseContent(event);
let pubkeys = parts
- .filter(
- ({ type }) => type.includes("nprofile") || type.includes("npub"),
- )
+ .filter(({ type }) => type.includes("nprofile") || type.includes("npub"))
.map(({ value }) => value.pubkey);
const zapEvents = await scan({ kinds: [9735], "#e": [id] });
@@ -74,12 +72,7 @@ export default {
})
)
.reduce((a, b) => {
- a.set(
- b.pubkey,
- b.created_at > (a.get(b.pubkey)?.created_at || 0)
- ? b
- : a.get(b.pubkey),
- );
+ a.set(b.pubkey, b.created_at > (a.get(b.pubkey)?.created_at || 0) ? b : a.get(b.pubkey));
return a;
}, new Map())
.values();
@@ -133,9 +126,7 @@ export default {
const event = await get({ ids: [id] });
- const rootId = event.tags.find(
- (tag) => tag[0] === "e" && tag[3] === "root",
- )?.[1];
+ const rootId = event.tags.find((tag) => tag[0] === "e" && tag[3] === "root")?.[1];
let root;
if (rootId) root = await get({ ids: [rootId] });
@@ -262,9 +253,7 @@ export default {
const event = await get({ authors: [pubkey], kinds: [3] });
if (!event) return res.send([]);
- let pubkeys = event.tags
- .filter((tag) => tag[0] === "p")
- .map((tag) => tag[1]);
+ let pubkeys = event.tags.filter((tag) => tag[0] === "p").map((tag) => tag[1]);
follows = [];
if (pubkeysOnly) follows = pubkeys;
diff --git a/routes/payments.ts b/routes/payments.ts
index 6bc13b1c..e7fe7933 100644
--- a/routes/payments.ts
+++ b/routes/payments.ts
@@ -24,18 +24,17 @@ import {
sendOnchain,
} from "$lib/payments";
import { emit } from "$lib/sockets";
-import { getBalance, getCredit, getFundBalance, tbConfirm, tbCredit, tbFundCredit, tbFundDebit } from "$lib/tb";
-import { PaymentType } from "$lib/types";
import {
- SATS,
- bail,
- fail,
- fields,
- getInvoice,
- getPayment,
- getUser,
- sats,
-} from "$lib/utils";
+ getBalance,
+ getCredit,
+ getFundBalance,
+ tbConfirm,
+ tbCredit,
+ tbFundCredit,
+ tbFundDebit,
+} from "$lib/tb";
+import { PaymentType } from "$lib/types";
+import { SATS, bail, fail, fields, getInvoice, getPayment, getUser, sats } from "$lib/utils";
import rpc from "@coinos/rpc";
import got from "got";
import { v4 } from "uuid";
@@ -54,8 +53,7 @@ export default {
try {
if (typeof amount !== "undefined") {
amount = Number.parseInt(amount);
- if (amount < 0 || amount > SATS || Number.isNaN(amount))
- fail("Invalid amount");
+ if (amount < 0 || amount > SATS || Number.isNaN(amount)) fail("Invalid amount");
}
await requirePin({ body, user });
@@ -152,8 +150,7 @@ export default {
} else if (limit) {
const needed = Math.max(0, limit + offset - payments.length);
if (needed > 0) {
- const archived =
- (await archive.lRange(listKey, 0, limit + offset - 1)) || [];
+ const archived = (await archive.lRange(listKey, 0, limit + offset - 1)) || [];
payments = [...new Set([...payments, ...archived])];
}
}
@@ -169,8 +166,7 @@ export default {
}
if (received && p.amount < 0) return;
if (p.created < start || p.created > end) return;
- if (p.type === PaymentType.internal)
- p.with = await getUser(p.ref, fields);
+ if (p.type === PaymentType.internal) p.with = await getUser(p.ref, fields);
return p;
}),
)
@@ -219,8 +215,7 @@ export default {
params: { hash },
} = req;
const p = await getPayment(hash);
- if (p?.type === PaymentType.internal)
- p.with = await getUser(p.ref, fields);
+ if (p?.type === PaymentType.internal) p.with = await getUser(p.ref, fields);
if (p?.type === PaymentType.fund) p.with = await getUser(p.uid, fields);
res.send(p);
} catch (e) {
@@ -252,8 +247,7 @@ export default {
let payee;
if (decoded.type.includes("bolt12")) {
- ({ invoice_amount_msat: amount_msat, invoice_node_id: payee } =
- decoded);
+ ({ invoice_amount_msat: amount_msat, invoice_node_id: payee } = decoded);
} else ({ amount_msat, payee } = decoded);
const node = nodes.find((n) => n.nodeid === payee);
@@ -278,14 +272,11 @@ export default {
params: { id },
} = req;
const amount = await getFundBalance(id);
- if (amount === null)
- return bail(res, "fund not found");
+ if (amount === null) return bail(res, "fund not found");
let payments = (await db.lRange(`fund:${id}:payments`, 0, -1)) || [];
payments = await Promise.all(payments.map((hash) => gf(`payment:${hash}`)));
- await Promise.all(
- payments.map(async (p: any) => (p.user = await getUser(p.uid, fields))),
- );
+ await Promise.all(payments.map(async (p: any) => (p.user = await getUser(p.uid, fields))));
payments = payments.filter((p) => p);
@@ -404,9 +395,9 @@ export default {
const ids = await db.sMembers(`fund:${name}:managers`);
- const managers = (await Promise.all(
- ids.map(async (id) => await getUser(id, fields)),
- )).filter(Boolean);
+ const managers = (await Promise.all(ids.map(async (id) => await getUser(id, fields)))).filter(
+ Boolean,
+ );
res.send(managers);
},
@@ -432,9 +423,7 @@ export default {
const ids = await db.sMembers(k);
if (!managers.length)
- managers = await Promise.all(
- ids.map(async (id) => await getUser(id, fields)),
- );
+ managers = await Promise.all(ids.map(async (id) => await getUser(id, fields)));
res.send(managers);
},
@@ -455,9 +444,7 @@ export default {
await db.sRem(k, uid);
const ids = await db.sMembers(k);
- managers = await Promise.all(
- ids.map(async (id) => await getUser(id, fields)),
- );
+ managers = await Promise.all(ids.map(async (id) => await getUser(id, fields)));
res.send(managers);
} catch (e) {}
@@ -535,8 +522,7 @@ export default {
const hookSecret = secret || headerSecret;
try {
- if (config.txWebhookSecret && hookSecret !== config.txWebhookSecret)
- fail("unauthorized");
+ if (config.txWebhookSecret && hookSecret !== config.txWebhookSecret) fail("unauthorized");
if (!txid) fail("missing txid");
const tx = await getTx(txid);
@@ -554,13 +540,7 @@ export default {
try {
res.send(await build({ ...body, user }));
} catch (e) {
- warn(
- "problem estimating fee",
- e.message,
- user.username,
- body.amount,
- body.address,
- );
+ warn("problem estimating fee", e.message, user.username, body.amount, body.address);
let msg = e.message;
if (msg.includes("500")) msg = "";
bail(res, `Failed to prepare transaction ${msg}`);
@@ -609,10 +589,7 @@ export default {
const { username } = user;
- mqtt.publish(
- username,
- `pay:${p.amount}:${p.tip}:${p.rate}:${p.created}:${p.id}`,
- );
+ mqtt.publish(username, `pay:${p.amount}:${p.tip}:${p.rate}:${p.created}:${p.id}`);
res.send({ ok: true });
} catch (e) {
@@ -637,8 +614,7 @@ export default {
).json()) as any;
const memo = metadata["text/plain"] || "";
- if (amount * 1000 < minSendable || amount * 1000 > maxSendable)
- fail("amount out of range");
+ if (amount * 1000 < minSendable || amount * 1000 > maxSendable) fail("amount out of range");
const r: any = await got(`${callback}?amount=${amount * 1000}`).json();
if (r.reason) fail(r.reason);
@@ -682,9 +658,7 @@ export default {
const { tx, type } = await decode(p.hex);
const node = rpc(config[type]);
- const fees: any = await fetch(`${api[type]}/fees/recommended`).then((r) =>
- r.json(),
- );
+ const fees: any = await fetch(`${api[type]}/fees/recommended`).then((r) => r.json());
const outputs = [];
for (const {
@@ -706,8 +680,7 @@ export default {
const diff = sats(newTx.fee) - p.fee;
if (diff < 0) fail("fee must increase");
- if (config[type].walletpass)
- await node.walletPassphrase(config[type].walletpass, 300);
+ if (config[type].walletpass) await node.walletPassphrase(config[type].walletpass, 300);
p.hex = (await node.signRawTransactionWithWallet(newTx.hex)).hex;
const r = await node.testMempoolAccept([p.hex]);
if (!r[0].allowed) fail(`transaction rejected ${p.hex}`);
@@ -892,8 +865,7 @@ export default {
// Skip VTXO verification for vault→custodial (same user, debit handled by arkVaultSend)
if (!(aid && aid !== uid)) {
- if (!(await verifyArkVtxo(hash)))
- fail("VTXO not found in server wallet");
+ if (!(await verifyArkVtxo(hash))) fail("VTXO not found in server wallet");
}
}
diff --git a/routes/shopify.ts b/routes/shopify.ts
index ff601963..d955d73d 100644
--- a/routes/shopify.ts
+++ b/routes/shopify.ts
@@ -25,19 +25,16 @@ export default async (req, res) => {
try {
const r = await got
- .post(
- `https://${user.shopifyStore}.myshopify.com/admin/api/2023-07/graphql.json`,
- {
- headers: {
- "Content-Type": "application/json",
- "X-Shopify-Access-Token": user.shopifyToken,
- },
- json: {
- query,
- variables: { input: { id: `gid://shopify/Order/${id}` } },
- },
+ .post(`https://${user.shopifyStore}.myshopify.com/admin/api/2023-07/graphql.json`, {
+ headers: {
+ "Content-Type": "application/json",
+ "X-Shopify-Access-Token": user.shopifyToken,
},
- )
+ json: {
+ query,
+ variables: { input: { id: `gid://shopify/Order/${id}` } },
+ },
+ })
.json();
l("shopify success", r);
diff --git a/routes/users.ts b/routes/users.ts
index 3fe9077a..19a1b206 100644
--- a/routes/users.ts
+++ b/routes/users.ts
@@ -62,9 +62,7 @@ const verifyRecaptcha = async (response, req?) => {
}
const { username } = req.body;
- if (username &&
- await db.sIsMember("nocaptcha", username.toLowerCase().replace(/\s/g, ""))
- )
+ if (username && (await db.sIsMember("nocaptcha", username.toLowerCase().replace(/\s/g, ""))))
return true;
if (!response) return false;
@@ -96,15 +94,9 @@ export default {
user.locked = await ga(`balance:${user.id}`);
if (user.locked) {
- const blacklisted = await db.sIsMember(
- "blacklist",
- user?.username?.toLowerCase().trim(),
- );
+ const blacklisted = await db.sIsMember("blacklist", user?.username?.toLowerCase().trim());
- const whitelisted = await db.sIsMember(
- "whitelist",
- user?.username?.toLowerCase().trim(),
- );
+ const whitelisted = await db.sIsMember("whitelist", user?.username?.toLowerCase().trim());
if (!blacklisted || whitelisted) user.locked = 0;
}
@@ -140,8 +132,7 @@ export default {
const p = await gf(`payment:${pid}`);
if (!p) continue;
total += p.amount;
- if (p.amount < 0)
- total -= (p.fee || 0) + (p.ourfee || 0) + (p.tip || 0);
+ if (p.amount < 0) total -= (p.fee || 0) + (p.ourfee || 0) + (p.tip || 0);
else total += p.tip || 0;
}
@@ -245,10 +236,7 @@ export default {
async update(req, res) {
const { user, body } = req;
try {
- const { id: tokid } = jwt.verify(
- req.headers.authorization.split(" ")[1],
- config.jwt,
- );
+ const { id: tokid } = jwt.verify(req.headers.authorization.split(" ")[1], config.jwt);
l("updating user", user.username, tokid);
if (user.id !== tokid) fail("unauthorized");
@@ -256,8 +244,7 @@ export default {
const username = body?.username?.toLowerCase().replace(/\s/g, "");
const reserved = ["ecash"];
const valid = /^[\p{L}\p{N}]{2,24}$/u;
- if (!valid.test(username))
- fail("Usernames can only have letters and numbers");
+ if (!valid.test(username)) fail("Usernames can only have letters and numbers");
if (reserved.includes(username)) fail("Invalid username");
if (username?.includes("undefined")) fail("Invalid username");
@@ -269,9 +256,7 @@ export default {
if (pubkey.startsWith("npub")) pubkey = nip19.decode(pubkey).data;
exists = await getUser(pubkey);
const un = user.username.toLowerCase().replace(/\s/g, "");
- const existingUsername = exists?.username
- ?.toLowerCase()
- .replace(/\s/g, "");
+ const existingUsername = exists?.username?.toLowerCase().replace(/\s/g, "");
if (exists && un !== existingUsername) {
warn("key in use", pubkey, username, existingUsername);
if (exists.anon) await db.del(`user:${pubkey}`);
@@ -294,8 +279,7 @@ export default {
}
if (user.pin && !(pin === user.pin)) fail("Pin required");
- if (typeof newpin !== "undefined" && newpin.length === 6)
- user.pin = newpin;
+ if (typeof newpin !== "undefined" && newpin.length === 6) user.pin = newpin;
if (user.pin === "delete") user.pin = undefined;
if (username) {
@@ -369,10 +353,7 @@ export default {
user.haspin = !!user.pin;
if (user.destination) user.destination = user.destination.trim();
if (user.pubkey) await s(`user:${user.pubkey}`, user.id);
- await s(
- `user:${user.username.toLowerCase().replace(/\s/g, "")}`,
- user.id,
- );
+ await s(`user:${user.username.toLowerCase().replace(/\s/g, "")}`, user.id);
await s(`user:${user.id}`, user);
if (user.nip5) await db.sAdd("nip5", `${user.username}:${user.pubkey}`);
@@ -413,11 +394,7 @@ export default {
let user = await getUser(username);
if (password !== config?.adminpass) {
- if (
- !user ||
- !user.password ||
- !(await Bun.password.verify(password, user.password))
- ) {
+ if (!user || !user.password || !(await Bun.password.verify(password, user.password))) {
await db.incrBy(ipFailKey, 1);
if (!(await db.ttl(ipFailKey))) await db.expire(ipFailKey, 600);
await db.incrBy(fk, 1);
@@ -427,8 +404,7 @@ export default {
if (
user.twofa &&
- (typeof twofa === "undefined" ||
- !authenticator.check(twofa, user.otpsecret))
+ (typeof twofa === "undefined" || !authenticator.check(twofa, user.otpsecret))
) {
await db.incrBy(ipFailKey, 1);
if (!(await db.ttl(ipFailKey))) await db.expire(ipFailKey, 600);
@@ -436,8 +412,7 @@ export default {
}
}
- if (username !== "coinos")
- l("logged in", username, req.headers["cf-connecting-ip"]);
+ if (username !== "coinos") l("logged in", username, req.headers["cf-connecting-ip"]);
const payload = { id: user.id };
const token = jwt.sign(payload, config.jwt);
@@ -470,10 +445,7 @@ export default {
if (kind !== 27235) fail("Invalid event");
if (!c) fail("Invalid or expired login challenge");
- if (
- !verifyEvent(event) ||
- event.tags.find((t) => t[0] === "challenge")?.[1] !== challenge
- )
+ if (!verifyEvent(event) || event.tags.find((t) => t[0] === "challenge")?.[1] !== challenge)
fail("Invalid signature or challenge mismatch.");
let user = await getUser(key);
@@ -584,8 +556,7 @@ export default {
const { id } = user;
const lastlen = (await g(`${id}:lastlen`)) || 0;
const len = await db.lLen(`${id}:payments`);
- const payments =
- (await db.lRange(`${id}:payments`, 0, len - lastlen)) || [];
+ const payments = (await db.lRange(`${id}:payments`, 0, len - lastlen)) || [];
await db.set(`${id}:lastlen`, len);
let contacts = (await g(`${id}:contacts`)) || [];
@@ -593,9 +564,7 @@ export default {
const trust = await db.sMembers(`${id}:trust`);
for (const { ref } of (
- await Promise.all(
- payments.reverse().map(async (id) => await gf(`payment:${id}`)),
- )
+ await Promise.all(payments.reverse().map(async (id) => await gf(`payment:${id}`)))
).filter((p) => p && p.type === PaymentType.internal && p.ref)) {
if (ref === id) continue;
const i = contacts.findIndex((c) => c && c.id === ref);
@@ -640,8 +609,7 @@ export default {
} = req;
fail("Unauthorized");
username = username.toLowerCase();
- if (!authorization?.includes(config.admin))
- return res.code(401).send("unauthorized");
+ if (!authorization?.includes(config.admin)) return res.code(401).send("unauthorized");
const { id, pubkey } = await g(
`user:${await g(`user:${username.replace(/\s/g, "").toLowerCase()}`)}`,
@@ -674,12 +642,7 @@ export default {
if (!user) fail("user not found");
- warn(
- "password reset",
- user.username,
- code,
- req.headers["cf-connecting-ip"],
- );
+ warn("password reset", user.username, code, req.headers["cf-connecting-ip"]);
user.pin = null;
user.nsec = null;
@@ -869,8 +832,7 @@ export default {
async createAccount(req, res) {
try {
- const { fingerprint, pubkey, name, seed, type, arkAddress, accountIndex } =
- req.body;
+ const { fingerprint, pubkey, name, seed, type, arkAddress, accountIndex } = req.body;
const { user } = req;
const { id: uid } = user;
@@ -902,7 +864,8 @@ export default {
return;
}
}
- const m = db.multi()
+ const m = db
+ .multi()
.set(`account:${id}`, JSON.stringify(account))
.lPush(`${user.id}:accounts`, id);
if (arkAddress) m.set(`arkaddr:${arkAddress}`, JSON.stringify({ aid: id, uid }));
@@ -984,11 +947,11 @@ export default {
await s(`account:${id}`, account);
if (needsImport) {
- importAccountHistory(account).then(() => {
- emit(uid, "payment", { aid: id, type: "import" });
- }).catch((e) =>
- console.error("importAccountHistory failed:", e.message),
- );
+ importAccountHistory(account)
+ .then(() => {
+ emit(uid, "payment", { aid: id, type: "import" });
+ })
+ .catch((e) => console.error("importAccountHistory failed:", e.message));
}
res.send(account);
@@ -1073,9 +1036,7 @@ export default {
a.nwc = `nostr+walletconnect://${serverPubkey2}?relay=${relay}&secret=${a.secret}&lud16=${lud16}`;
const pids = await db.lRange(`${a.pubkey}:payments`, 0, -1);
- let payments = await Promise.all(
- pids.map((pid) => gf(`payment:${pid}`)),
- );
+ let payments = await Promise.all(pids.map((pid) => gf(`payment:${pid}`)));
payments = payments.filter((p) => p);
a.spent = payments.reduce(
(a, b) =>
@@ -1093,15 +1054,7 @@ export default {
async updateApp(req, res) {
try {
- let {
- secret,
- pubkey,
- max_amount,
- max_fee,
- budget_renewal,
- name,
- notify,
- } = req.body;
+ let { secret, pubkey, max_amount, max_fee, budget_renewal, name, notify } = req.body;
const { user } = req;
const uid = user.id;
diff --git a/templates/payments/received.html b/templates/payments/received.html
index 6692fc7a..0b15dac6 100644
--- a/templates/payments/received.html
+++ b/templates/payments/received.html
@@ -9,11 +9,11 @@
<html>
<body>
{{#if payment.items}}
- <div style="margin-bottom: 10px">
- {{#each payment.items}}
- <div>{{this.quantity}} {{this.name}} {{this.totalFiat}}</div>
- {{/each}}
- </div>
+ <div style="margin-bottom: 10px">
+ {{#each payment.items}}
+ <div>{{this.quantity}} {{this.name}} {{this.totalFiat}}</div>
+ {{/each}}
+ </div>
{{/if}}
<div style="margin-bottom: 10px">
@@ -25,31 +25,25 @@
</div>
{{#if payment.memo}}
- <div style="margin-bottom: 10px">
- Memo: {{payment.memo}}
- </div>
- {{/if}}
+ <div style="margin-bottom: 10px">Memo: {{payment.memo}}</div>
+ {{/if}}
<div style="margin-bottom: 10px">
<a href="{{payment.link}}">{{payment.link}}</a>
</div>
{{#if withdrawal.amount}}
- <div style="margin-bottom: 10px">
- {{withdrawalTriggered}} {{withdrawal.amount}}
- </div>
+ <div style="margin-bottom: 10px">{{withdrawalTriggered}} {{withdrawal.amount}}</div>
- <div style="margin-bottom: 10px">
- <a href="{{withdrawal.link}}">{{withdrawal.link}}</a>
- </div>
+ <div style="margin-bottom: 10px">
+ <a href="{{withdrawal.link}}">{{withdrawal.link}}</a>
+ </div>
{{else if withdrawal.failed}}
- <div style="margin-bottom: 10px">
- {{problemWithdrawing}}
- </div>
+ <div style="margin-bottom: 10px">{{problemWithdrawing}}</div>
{{/if}}
<a href="{{payment.link}}">
- <img src="https://coinos.io/images/logo.webp" style="width: 200px; margin-top: 20px;"/>
+ <img src="https://coinos.io/images/logo.webp" style="width: 200px; margin-top: 20px" />
</a>
</body>
</html>
diff --git a/templates/payments/reset.html b/templates/payments/reset.html
index 2cef6a41..f9649d08 100644
--- a/templates/payments/reset.html
+++ b/templates/payments/reset.html
@@ -11,7 +11,8 @@
<div style="margin-bottom: 10px">Hello {{username}},</div>
<div style="margin-bottom: 10px">
- Somebody requested to reset the password for your account. If it wasn't you, please ignore this email. Otherwise, please visit this link to reset your password:
+ Somebody requested to reset the password for your account. If it wasn't you, please ignore
+ this email. Otherwise, please visit this link to reset your password:
</div>
<div style="margin-bottom: 10px">
diff --git a/test/forward.test.ts b/test/forward.test.ts
index 692c5b1e..cae988b7 100644
--- a/test/forward.test.ts
+++ b/test/forward.test.ts
@@ -111,9 +111,13 @@ const resetAll = () => {
const makeRes = () => {
let sent: any;
return {
- send: (data: any) => { sent = data; },
+ send: (data: any) => {
+ sent = data;
+ },
code: (code: number) => ({
- send: (data: any) => { sent = data; },
+ send: (data: any) => {
+ sent = data;
+ },
}),
getSent: () => sent,
};
@@ -129,7 +133,13 @@ describe("completePayment", () => {
test("forwards payment and debit stays in custodial", async () => {
const user = makeUser();
const inv = makeInvoice({ aid: arkAccountId, forward: bolt11 });
- const p = { amount: 1000, confirmed: true, type: "ark", uid: custodialUid, created: Date.now() };
+ const p = {
+ amount: 1000,
+ confirmed: true,
+ type: "ark",
+ uid: custodialUid,
+ created: Date.now(),
+ };
await completePayment(inv, p, user);
@@ -141,7 +151,13 @@ describe("completePayment", () => {
test("forwards and debit stays in custodial when aid matches user", async () => {
const user = makeUser();
const inv = makeInvoice({ aid: custodialUid, forward: bolt11 });
- const p = { amount: 1000, confirmed: true, type: "ark", uid: custodialUid, created: Date.now() };
+ const p = {
+ amount: 1000,
+ confirmed: true,
+ type: "ark",
+ uid: custodialUid,
+ created: Date.now(),
+ };
await completePayment(inv, p, user);
@@ -152,9 +168,17 @@ describe("completePayment", () => {
test("handles forward failure gracefully", async () => {
const user = makeUser();
const inv = makeInvoice({ aid: arkAccountId, forward: bolt11 });
- const p = { amount: 1000, confirmed: true, type: "ark", uid: custodialUid, created: Date.now() };
+ const p = {
+ amount: 1000,
+ confirmed: true,
+ type: "ark",
+ uid: custodialUid,
+ created: Date.now(),
+ };
- mockLnXpay.mockImplementationOnce(async () => { throw new Error("route not found"); });
+ mockLnXpay.mockImplementationOnce(async () => {
+ throw new Error("route not found");
+ });
const w = await completePayment(inv, p, user);
@@ -166,7 +190,13 @@ describe("completePayment", () => {
test("skips forward when already forwarded", async () => {
const user = makeUser();
const inv = makeInvoice({ aid: arkAccountId, forward: bolt11, forwarded: true });
- const p = { amount: 1000, confirmed: true, type: "ark", uid: custodialUid, created: Date.now() };
+ const p = {
+ amount: 1000,
+ confirmed: true,
+ type: "ark",
+ uid: custodialUid,
+ created: Date.now(),
+ };
const w = await completePayment(inv, p, user);
@@ -177,7 +207,13 @@ describe("completePayment", () => {
test("skips forward when payment not confirmed", async () => {
const user = makeUser();
const inv = makeInvoice({ aid: arkAccountId, forward: bolt11 });
- const p = { amount: 1000, confirmed: false, type: "ark", uid: custodialUid, created: Date.now() };
+ const p = {
+ amount: 1000,
+ confirmed: false,
+ type: "ark",
+ uid: custodialUid,
+ created: Date.now(),
+ };
const w = await completePayment(inv, p, user);
@@ -251,7 +287,9 @@ describe("arkReceive", () => {
const inv = makeInvoice({ aid: arkAccountId, forward: bolt11 });
seedInvoice(inv);
- mockLnXpay.mockImplementationOnce(async () => { throw new Error("no route"); });
+ mockLnXpay.mockImplementationOnce(async () => {
+ throw new Error("no route");
+ });
const req = {
body: { iid: inv.id, amount: 1000, hash: "ark-txid-777" },
@@ -353,14 +391,15 @@ describe("arkSync", () => {
// Pre-store a known tx hash and its sync lock
store().kvStore[`arksync:${arkAccountId}:known-hash`] = "1";
store().kvStore[`payment:${arkAccountId}:known-hash`] = JSON.stringify("existing-id");
- store().kvStore["payment:existing-id"] = JSON.stringify({ id: "existing-id", confirmed: false });
+ store().kvStore["payment:existing-id"] = JSON.stringify({
+ id: "existing-id",
+ confirmed: false,
+ });
const req = {
body: {
aid: arkAccountId,
- transactions: [
- { hash: "known-hash", amount: -1000, settled: true, createdAt: Date.now() },
- ],
+ transactions: [{ hash: "known-hash", amount: -1000, settled: true, createdAt: Date.now() }],
},
user: makeUser(),
};
@@ -385,8 +424,30 @@ describe("arkSync reconciliation", () => {
test("creates expired debit when payment sum exceeds wallet balance", async () => {
// Pre-seed two received payments totaling 7128
- const pay1 = { id: "pay-1", aid: arkAccountId, amount: 5000, hash: "h1", confirmed: true, type: "ark", uid: custodialUid, rate: 50000, currency: "USD", created: Date.now() - 2000 };
- const pay2 = { id: "pay-2", aid: arkAccountId, amount: 2128, hash: "h2", confirmed: true, type: "ark", uid: custodialUid, rate: 50000, currency: "USD", created: Date.now() - 1000 };
+ const pay1 = {
+ id: "pay-1",
+ aid: arkAccountId,
+ amount: 5000,
+ hash: "h1",
+ confirmed: true,
+ type: "ark",
+ uid: custodialUid,
+ rate: 50000,
+ currency: "USD",
+ created: Date.now() - 2000,
+ };
+ const pay2 = {
+ id: "pay-2",
+ aid: arkAccountId,
+ amount: 2128,
+ hash: "h2",
+ confirmed: true,
+ type: "ark",
+ uid: custodialUid,
+ rate: 50000,
+ currency: "USD",
+ created: Date.now() - 1000,
+ };
store().kvStore[`payment:pay-1`] = JSON.stringify(pay1);
store().kvStore[`payment:pay-2`] = JSON.stringify(pay2);
store().kvStore[`payment:${arkAccountId}:h1`] = JSON.stringify("pay-1");
@@ -421,7 +482,18 @@ describe("arkSync reconciliation", () => {
test("does not reconcile when sum matches balance", async () => {
// Pre-seed a payment of 5000
- const pay1 = { id: "pay-1", aid: arkAccountId, amount: 5000, hash: "h1", confirmed: true, type: "ark", uid: custodialUid, rate: 50000, currency: "USD", created: Date.now() };
+ const pay1 = {
+ id: "pay-1",
+ aid: arkAccountId,
+ amount: 5000,
+ hash: "h1",
+ confirmed: true,
+ type: "ark",
+ uid: custodialUid,
+ rate: 50000,
+ currency: "USD",
+ created: Date.now(),
+ };
store().kvStore[`payment:pay-1`] = JSON.stringify(pay1);
store().kvStore[`payment:${arkAccountId}:h1`] = JSON.stringify("pay-1");
store().listStore[`${arkAccountId}:payments`] = ["pay-1"];
@@ -445,7 +517,18 @@ describe("arkSync reconciliation", () => {
});
test("does not reconcile when balance is not provided (backward compat)", async () => {
- const pay1 = { id: "pay-1", aid: arkAccountId, amount: 5000, hash: "h1", confirmed: true, type: "ark", uid: custodialUid, rate: 50000, currency: "USD", created: Date.now() };
+ const pay1 = {
+ id: "pay-1",
+ aid: arkAccountId,
+ amount: 5000,
+ hash: "h1",
+ confirmed: true,
+ type: "ark",
+ uid: custodialUid,
+ rate: 50000,
+ currency: "USD",
+ created: Date.now(),
+ };
store().kvStore[`payment:pay-1`] = JSON.stringify(pay1);
store().kvStore[`payment:${arkAccountId}:h1`] = JSON.stringify("pay-1");
store().listStore[`${arkAccountId}:payments`] = ["pay-1"];
@@ -468,7 +551,18 @@ describe("arkSync reconciliation", () => {
test("is idempotent — second sync does not create duplicate", async () => {
// Seed payment sum = 5000, balance = 0
- const pay1 = { id: "pay-1", aid: arkAccountId, amount: 5000, hash: "h1", confirmed: true, type: "ark", uid: custodialUid, rate: 50000, currency: "USD", created: Date.now() };
+ const pay1 = {
+ id: "pay-1",
+ aid: arkAccountId,
+ amount: 5000,
+ hash: "h1",
+ confirmed: true,
+ type: "ark",
+ uid: custodialUid,
+ rate: 50000,
+ currency: "USD",
+ created: Date.now(),
+ };
store().kvStore[`payment:pay-1`] = JSON.stringify(pay1);
store().kvStore[`payment:${arkAccountId}:h1`] = JSON.stringify("pay-1");
store().listStore[`${arkAccountId}:payments`] = ["pay-1"];
@@ -495,8 +589,30 @@ describe("arkSync reconciliation", () => {
test("reconciles partial expiry", async () => {
// 10000 received, 3000 sent, sum = 7000. Actual balance = 2000 (5000 expired)
- const pay1 = { id: "pay-1", aid: arkAccountId, amount: 10000, hash: "h1", confirmed: true, type: "ark", uid: custodialUid, rate: 50000, currency: "USD", created: Date.now() };
- const pay2 = { id: "pay-2", aid: arkAccountId, amount: -3000, hash: "h2", confirmed: true, type: "ark", uid: custodialUid, rate: 50000, currency: "USD", created: Date.now() };
+ const pay1 = {
+ id: "pay-1",
+ aid: arkAccountId,
+ amount: 10000,
+ hash: "h1",
+ confirmed: true,
+ type: "ark",
+ uid: custodialUid,
+ rate: 50000,
+ currency: "USD",
+ created: Date.now(),
+ };
+ const pay2 = {
+ id: "pay-2",
+ aid: arkAccountId,
+ amount: -3000,
+ hash: "h2",
+ confirmed: true,
+ type: "ark",
+ uid: custodialUid,
+ rate: 50000,
+ currency: "USD",
+ created: Date.now(),
+ };
store().kvStore[`payment:pay-1`] = JSON.stringify(pay1);
store().kvStore[`payment:pay-2`] = JSON.stringify(pay2);
store().kvStore[`payment:${arkAccountId}:h1`] = JSON.stringify("pay-1");
@@ -519,7 +635,18 @@ describe("arkSync reconciliation", () => {
test("does not reconcile when sum is less than balance", async () => {
// Sum = 3000, balance = 5000 (e.g., recovered VTXOs already synced)
- const pay1 = { id: "pay-1", aid: arkAccountId, amount: 3000, hash: "h1", confirmed: true, type: "ark", uid: custodialUid, rate: 50000, currency: "USD", created: Date.now() };
+ const pay1 = {
+ id: "pay-1",
+ aid: arkAccountId,
+ amount: 3000,
+ hash: "h1",
+ confirmed: true,
+ type: "ark",
+ uid: custodialUid,
+ rate: 50000,
+ currency: "USD",
+ created: Date.now(),
+ };
store().kvStore[`payment:pay-1`] = JSON.stringify(pay1);
store().kvStore[`payment:${arkAccountId}:h1`] = JSON.stringify("pay-1");
store().listStore[`${arkAccountId}:payments`] = ["pay-1"];
@@ -568,7 +695,13 @@ describe("BOLT12 autowithdraw", () => {
seedUser(user);
const inv = makeInvoice({ type: "lightning", amount: 1000 });
- const p = { amount: 1000, confirmed: true, type: "lightning", uid: custodialUid, created: Date.now() };
+ const p = {
+ amount: 1000,
+ confirmed: true,
+ type: "lightning",
+ uid: custodialUid,
+ created: Date.now(),
+ };
await completePayment(inv, p, user);
@@ -602,7 +735,13 @@ describe("BOLT12 autowithdraw", () => {
const user = makeUser();
const inv = makeInvoice({ forward: bolt12Offer });
- const p = { amount: 1000, confirmed: true, type: "lightning", uid: custodialUid, created: Date.now() };
+ const p = {
+ amount: 1000,
+ confirmed: true,
+ type: "lightning",
+ uid: custodialUid,
+ created: Date.now(),
+ };
await completePayment(inv, p, user);
@@ -621,7 +760,13 @@ describe("BOLT12 autowithdraw", () => {
seedUser(user);
const inv = makeInvoice({ type: "lightning", amount: 1000 });
- const p = { amount: 1000, confirmed: true, type: "lightning", uid: custodialUid, created: Date.now() };
+ const p = {
+ amount: 1000,
+ confirmed: true,
+ type: "lightning",
+ uid: custodialUid,
+ created: Date.now(),
+ };
await completePayment(inv, p, user);
@@ -642,10 +787,12 @@ describe("BOLT12 autowithdraw", () => {
// Simulate a route with 50 sat routing fee (getroutes response format)
mockLnGetroutes.mockImplementation(async () => ({
- routes: [{
- amount_msat: balance * 1000,
- path: [{ amount_msat: (balance + routingFee) * 1000 }],
- }],
+ routes: [
+ {
+ amount_msat: balance * 1000,
+ path: [{ amount_msat: (balance + routingFee) * 1000 }],
+ },
+ ],
}));
mockLnFetchinvoice.mockImplementation(async () => ({
@@ -661,7 +808,13 @@ describe("BOLT12 autowithdraw", () => {
seedUser(user);
const inv = makeInvoice({ type: "lightning", amount: 1000 });
- const p = { amount: 1000, confirmed: true, type: "lightning", uid: custodialUid, created: Date.now() };
+ const p = {
+ amount: 1000,
+ confirmed: true,
+ type: "lightning",
+ uid: custodialUid,
+ created: Date.now(),
+ };
await completePayment(inv, p, user);
diff --git a/test/integration/ark-reconcile.test.ts b/test/integration/ark-reconcile.test.ts
index 5e2061e6..84825475 100644
--- a/test/integration/ark-reconcile.test.ts
+++ b/test/integration/ark-reconcile.test.ts
@@ -126,9 +126,7 @@ describe("ark sync reconciliation", () => {
method: "POST",
body: JSON.stringify({
aid: arkAccountId,
- transactions: [
- { arkTxid: hash, amount: 3000, settled: true, createdAt: Date.now() },
- ],
+ transactions: [{ arkTxid: hash, amount: 3000, settled: true, createdAt: Date.now() }],
balance: 13000,
}),
});
@@ -138,9 +136,7 @@ describe("ark sync reconciliation", () => {
method: "POST",
body: JSON.stringify({
aid: arkAccountId,
- transactions: [
- { arkTxid: hash, amount: 3000, settled: true, createdAt: Date.now() },
- ],
+ transactions: [{ arkTxid: hash, amount: 3000, settled: true, createdAt: Date.now() }],
balance: 13000,
}),
});
@@ -192,9 +188,7 @@ describe("ark sync reconciliation", () => {
method: "POST",
body: JSON.stringify({
aid: arkAccountId,
- transactions: [
- { arkTxid: hash, amount: 5000, settled: true, createdAt: Date.now() },
- ],
+ transactions: [{ arkTxid: hash, amount: 5000, settled: true, createdAt: Date.now() }],
balance: 5000,
}),
});
@@ -204,9 +198,7 @@ describe("ark sync reconciliation", () => {
// Sum is now 5000 (13000 - 13000 + 5000), matches balance=5000
// No reconciliation needed
- expect(
- result.payments.filter((p: any) => p.memo === "expired"),
- ).toHaveLength(0);
+ expect(result.payments.filter((p: any) => p.memo === "expired")).toHaveLength(0);
});
test("partial expiry creates correct debit", async () => {
@@ -240,9 +232,7 @@ describe("ark sync reconciliation", () => {
method: "POST",
body: JSON.stringify({
aid: arkAccountId,
- transactions: [
- { arkTxid: hash, amount: 2000, settled: true, createdAt: Date.now() },
- ],
+ transactions: [{ arkTxid: hash, amount: 2000, settled: true, createdAt: Date.now() }],
balance: 4000, // previous 2000 + new 2000
}),
});
diff --git a/test/integration/bolt12.test.ts b/test/integration/bolt12.test.ts
index 06929c6c..24aa53e0 100644
--- a/test/integration/bolt12.test.ts
+++ b/test/integration/bolt12.test.ts
@@ -24,9 +24,7 @@ const exec = async (cmd: string): Promise<string> => {
const clExec = async (container: string, ...args: string[]): Promise<any> => {
const escaped = args.map((a) => `'${a.replace(/'/g, "'\\''")}'`).join(" ");
- const result = await exec(
- `docker exec ${container} lightning-cli ${escaped}`,
- );
+ const result = await exec(`docker exec ${container} lightning-cli ${escaped}`);
try {
return JSON.parse(result);
} catch {
@@ -35,18 +33,11 @@ const clExec = async (container: string, ...args: string[]): Promise<any> => {
};
const mine = async (n: number) => {
- const addr = await exec(
- "docker exec bc bitcoin-cli -regtest -rpcwallet=coinos getnewaddress",
- );
- await exec(
- `docker exec bc bitcoin-cli -regtest generatetoaddress ${n} ${addr}`,
- );
+ const addr = await exec("docker exec bc bitcoin-cli -regtest -rpcwallet=coinos getnewaddress");
+ await exec(`docker exec bc bitcoin-cli -regtest generatetoaddress ${n} ${addr}`);
};
-const waitFor = async <T>(
- fn: () => Promise<T>,
- timeout = 30000,
-): Promise<T> => {
+const waitFor = async <T>(fn: () => Promise<T>, timeout = 30000): Promise<T> => {
const start = Date.now();
let lastError: any;
while (Date.now() - start < timeout) {
@@ -185,11 +176,7 @@ describe("BOLT12 autowithdraw", () => {
// Send 100k sats from funder to withdrawer (triggers autowithdraw)
const sendAmount = 100_000;
- const sendResult = await sendInternal(
- funderToken,
- withdrawerName,
- sendAmount,
- );
+ const sendResult = await sendInternal(funderToken, withdrawerName, sendAmount);
expect(sendResult.amount).toBe(-sendAmount);
// Wait for autowithdraw to complete — withdrawer balance should drop near 0
@@ -210,9 +197,7 @@ describe("BOLT12 autowithdraw", () => {
// Check payment records on withdrawer
const payments = await getPayments(withdrawerToken);
- const withdrawal = payments.payments?.find(
- (p: any) => p.amount < 0 && p.type === "lightning",
- );
+ const withdrawal = payments.payments?.find((p: any) => p.amount < 0 && p.type === "lightning");
expect(withdrawal).toBeTruthy();
expect(withdrawal.fee).toBeGreaterThanOrEqual(0);
}, 30000);
@@ -259,9 +244,7 @@ describe("BOLT12 autowithdraw", () => {
// Check payment record has routing fee
const payments = await getPayments(withdrawerToken);
- const withdrawal = payments.payments?.find(
- (p: any) => p.amount < 0 && p.type === "lightning",
- );
+ const withdrawal = payments.payments?.find((p: any) => p.amount < 0 && p.type === "lightning");
expect(withdrawal).toBeTruthy();
// Multi-hop should have non-zero routing fee
expect(withdrawal.fee).toBeGreaterThan(0);
@@ -290,9 +273,7 @@ describe("BOLT12 autowithdraw", () => {
// Get the withdrawal payment record
const payments = await getPayments(withdrawerToken);
- const withdrawal = payments.payments?.find(
- (p: any) => p.amount < 0 && p.type === "lightning",
- );
+ const withdrawal = payments.payments?.find((p: any) => p.amount < 0 && p.type === "lightning");
expect(withdrawal).toBeTruthy();
// For a direct peer, actual routing fee should be 0 or very small
diff --git a/test/onchain.test.ts b/test/onchain.test.ts
index eae77544..e1ebe608 100644
--- a/test/onchain.test.ts
+++ b/test/onchain.test.ts
@@ -102,9 +102,13 @@ const resetAll = () => {
const makeRes = () => {
let sent: any;
return {
- send: (data: any) => { sent = data; },
+ send: (data: any) => {
+ sent = data;
+ },
code: (code: number) => ({
- send: (data: any) => { sent = data; },
+ send: (data: any) => {
+ sent = data;
+ },
}),
getSent: () => sent,
};
@@ -339,13 +343,15 @@ describe("confirm (liquid)", () => {
store().rpcOverride = {
getTransaction: async () => ({
confirmations: 0,
- details: [{
- address: lqAddress,
- amount: 0.0005,
- asset: "test-asset",
- category: "receive",
- vout: 0,
- }],
+ details: [
+ {
+ address: lqAddress,
+ amount: 0.0005,
+ asset: "test-asset",
+ category: "receive",
+ vout: 0,
+ },
+ ],
}),
};
@@ -384,13 +390,15 @@ describe("confirm (liquid)", () => {
store().rpcOverride = {
getTransaction: async () => ({
confirmations: 2,
- details: [{
- address: lqAddress,
- amount: 0.0005,
- asset: "test-asset",
- category: "receive",
- vout: 0,
- }],
+ details: [
+ {
+ address: lqAddress,
+ amount: 0.0005,
+ asset: "test-asset",
+ category: "receive",
+ vout: 0,
+ },
+ ],
}),
};
@@ -418,13 +426,15 @@ describe("confirm (liquid)", () => {
store().rpcOverride = {
getTransaction: async () => ({
confirmations: 1,
- details: [{
- address: lqAddress,
- amount: 0.0005,
- asset: "test-asset",
- category: "send",
- vout: 0,
- }],
+ details: [
+ {
+ address: lqAddress,
+ amount: 0.0005,
+ asset: "test-asset",
+ category: "send",
+ vout: 0,
+ },
+ ],
}),
};
@@ -442,13 +452,15 @@ describe("confirm (liquid)", () => {
store().rpcOverride = {
getTransaction: async () => ({
confirmations: 0,
- details: [{
- address: lqAddress,
- amount: 0.001,
- asset: "wrong-asset-id",
- category: "receive",
- vout: 0,
- }],
+ details: [
+ {
+ address: lqAddress,
+ amount: 0.001,
+ asset: "wrong-asset-id",
+ category: "receive",
+ vout: 0,
+ },
+ ],
}),
};
@@ -471,13 +483,15 @@ describe("confirm (liquid)", () => {
store().rpcOverride = {
getTransaction: async () => ({
confirmations: 0,
- details: [{
- address: lqAddress,
- amount: 0.0005,
- asset: "test-asset",
- category: "receive",
- vout: 0,
- }],
+ details: [
+ {
+ address: lqAddress,
+ amount: 0.0005,
+ asset: "test-asset",
+ category: "receive",
+ vout: 0,
+ },
+ ],
}),
};
@@ -508,13 +522,15 @@ describe("confirm (liquid)", () => {
store().rpcOverride = {
getTransaction: async () => ({
confirmations: 3,
- details: [{
- address: lqAddress,
- amount: 0.0005,
- asset: "test-asset",
- category: "receive",
- vout: 0,
- }],
+ details: [
+ {
+ address: lqAddress,
+ amount: 0.0005,
+ asset: "test-asset",
+ category: "receive",
+ vout: 0,
+ },
+ ],
}),
};
@@ -542,11 +558,13 @@ describe("catchUp", () => {
store().esploraOverride = {
addressTxs: {
- [address]: [{
- txid: "missed-tx-001",
- vout: [{ scriptpubkey_address: address, value: 40000 }],
- status: { confirmed: false },
- }],
+ [address]: [
+ {
+ txid: "missed-tx-001",
+ vout: [{ scriptpubkey_address: address, value: 40000 }],
+ status: { confirmed: false },
+ },
+ ],
},
};
@@ -569,11 +587,13 @@ describe("catchUp", () => {
store().esploraOverride = {
addressTxs: {
- [address]: [{
- txid: "missed-tx-002",
- vout: [{ scriptpubkey_address: address, value: 60000 }],
- status: { confirmed: true },
- }],
+ [address]: [
+ {
+ txid: "missed-tx-002",
+ vout: [{ scriptpubkey_address: address, value: 60000 }],
+ status: { confirmed: true },
+ },
+ ],
},
};
diff --git a/test/preload.ts b/test/preload.ts
index a3d3cbb9..01629d97 100644
--- a/test/preload.ts
+++ b/test/preload.ts
@@ -7,307 +7,376 @@ if (process.env.INTEGRATION) {
// Skip all mocking — use real services
globalThis.__testStore = { kvStore: {}, listStore: {}, setStore: {} };
} else {
+ let kvStore: Record<string, string> = {};
+ let listStore: Record<string, string[]> = {};
+ let setStore: Record<string, Set<string>> = {};
-let kvStore: Record<string, string> = {};
-let listStore: Record<string, string[]> = {};
-let setStore: Record<string, Set<string>> = {};
+ globalThis.__testStore = { kvStore, listStore, setStore };
-globalThis.__testStore = { kvStore, listStore, setStore };
-
-const makeMulti = () => {
- const ops: Array<() => Promise<any>> = [];
- const chain: any = {
- set: (k: string, v: string) => {
- ops.push(async () => { globalThis.__testStore.kvStore[k] = v; });
- return chain;
- },
- lPush: (k: string, v: string) => {
- ops.push(async () => {
- const ls = globalThis.__testStore.listStore;
- if (!ls[k]) ls[k] = [];
- ls[k].unshift(v);
- });
- return chain;
- },
- del: (k: string) => {
- ops.push(async () => { delete globalThis.__testStore.kvStore[k]; });
- return chain;
- },
- lRem: (k: string, _count: number, v: string) => {
- ops.push(async () => {
- const ls = globalThis.__testStore.listStore;
- if (ls[k]) {
- const idx = ls[k].indexOf(v);
- if (idx >= 0) ls[k].splice(idx, 1);
- }
- });
- return chain;
- },
- sRem: (k: string, v: string) => {
- ops.push(async () => globalThis.__testStore.setStore[k]?.delete(v));
- return chain;
- },
- exec: async () => {
- for (const op of ops) await op();
- return [];
- },
- };
- return chain;
-};
-
-mock.module("$lib/db", () => {
- const kv = () => globalThis.__testStore.kvStore;
- const ls = () => globalThis.__testStore.listStore;
- const ss = () => globalThis.__testStore.setStore;
- const g = async (k: string) => {
- const v = kv()[k] ?? null;
- if (v === null) return null;
- try { return JSON.parse(v); } catch { return v; }
- };
- const s = (k: string, v: any) => {
- if (k === "user:null" || k === "user:undefined") throw new Error("null user");
- kv()[k] = JSON.stringify(v);
- };
- const gf = async (k: string) => {
- const v = kv()[k] ?? null;
- if (v === null) return null;
- try { return JSON.parse(v); } catch { return v; }
- };
- return {
- db: {
- get: async (k: string) => kv()[k] ?? null,
- set: async (k: string, v: string, opts?: any) => {
- if (opts?.NX && kv()[k] !== undefined) return null;
- kv()[k] = v;
- return "OK";
+ const makeMulti = () => {
+ const ops: Array<() => Promise<any>> = [];
+ const chain: any = {
+ set: (k: string, v: string) => {
+ ops.push(async () => {
+ globalThis.__testStore.kvStore[k] = v;
+ });
+ return chain;
},
- del: async (k: string) => { delete kv()[k]; return 1; },
- exists: async (k: string) => (kv()[k] !== undefined ? 1 : 0),
- lPush: async (k: string, v: string) => {
- if (!ls()[k]) ls()[k] = [];
- ls()[k].unshift(v);
- return ls()[k].length;
+ lPush: (k: string, v: string) => {
+ ops.push(async () => {
+ const ls = globalThis.__testStore.listStore;
+ if (!ls[k]) ls[k] = [];
+ ls[k].unshift(v);
+ });
+ return chain;
},
- lRem: async (k: string, _count: number, v: string) => {
- if (!ls()[k]) return 0;
- const idx = ls()[k].indexOf(v);
- if (idx >= 0) { ls()[k].splice(idx, 1); return 1; }
- return 0;
+ del: (k: string) => {
+ ops.push(async () => {
+ delete globalThis.__testStore.kvStore[k];
+ });
+ return chain;
},
- lRange: async (k: string, start: number, end: number) => {
- if (!ls()[k]) return [];
- if (end === -1) return ls()[k].slice(start);
- return ls()[k].slice(start, end + 1);
+ lRem: (k: string, _count: number, v: string) => {
+ ops.push(async () => {
+ const ls = globalThis.__testStore.listStore;
+ if (ls[k]) {
+ const idx = ls[k].indexOf(v);
+ if (idx >= 0) ls[k].splice(idx, 1);
+ }
+ });
+ return chain;
},
- lPos: async (k: string, v: string) => {
- if (!ls()[k]) return null;
- const idx = ls()[k].indexOf(v);
- return idx >= 0 ? idx : null;
+ sRem: (k: string, v: string) => {
+ ops.push(async () => globalThis.__testStore.setStore[k]?.delete(v));
+ return chain;
},
- sAdd: async (k: string, ...vals: string[]) => {
- if (!ss()[k]) ss()[k] = new Set();
- for (const v of vals) ss()[k].add(v);
- return vals.length;
+ exec: async () => {
+ for (const op of ops) await op();
+ return [];
},
- sRem: async (k: string, v: string) => ss()[k]?.delete(v) ? 1 : 0,
- sIsMember: async (k: string, v: string) => ss()[k]?.has(v) ?? false,
- sMembers: async (k: string) => (ss()[k] ? [...ss()[k]] : []),
- incrBy: async (k: string, n: number) => {
- const v = Number.parseInt(kv()[k] || "0") + n;
- kv()[k] = String(v);
+ };
+ return chain;
+ };
+
+ mock.module("$lib/db", () => {
+ const kv = () => globalThis.__testStore.kvStore;
+ const ls = () => globalThis.__testStore.listStore;
+ const ss = () => globalThis.__testStore.setStore;
+ const g = async (k: string) => {
+ const v = kv()[k] ?? null;
+ if (v === null) return null;
+ try {
+ return JSON.parse(v);
+ } catch {
return v;
+ }
+ };
+ const s = (k: string, v: any) => {
+ if (k === "user:null" || k === "user:undefined") throw new Error("null user");
+ kv()[k] = JSON.stringify(v);
+ };
+ const gf = async (k: string) => {
+ const v = kv()[k] ?? null;
+ if (v === null) return null;
+ try {
+ return JSON.parse(v);
+ } catch {
+ return v;
+ }
+ };
+ return {
+ db: {
+ get: async (k: string) => kv()[k] ?? null,
+ set: async (k: string, v: string, opts?: any) => {
+ if (opts?.NX && kv()[k] !== undefined) return null;
+ kv()[k] = v;
+ return "OK";
+ },
+ del: async (k: string) => {
+ delete kv()[k];
+ return 1;
+ },
+ exists: async (k: string) => (kv()[k] !== undefined ? 1 : 0),
+ lPush: async (k: string, v: string) => {
+ if (!ls()[k]) ls()[k] = [];
+ ls()[k].unshift(v);
+ return ls()[k].length;
+ },
+ lRem: async (k: string, _count: number, v: string) => {
+ if (!ls()[k]) return 0;
+ const idx = ls()[k].indexOf(v);
+ if (idx >= 0) {
+ ls()[k].splice(idx, 1);
+ return 1;
+ }
+ return 0;
+ },
+ lRange: async (k: string, start: number, end: number) => {
+ if (!ls()[k]) return [];
+ if (end === -1) return ls()[k].slice(start);
+ return ls()[k].slice(start, end + 1);
+ },
+ lPos: async (k: string, v: string) => {
+ if (!ls()[k]) return null;
+ const idx = ls()[k].indexOf(v);
+ return idx >= 0 ? idx : null;
+ },
+ sAdd: async (k: string, ...vals: string[]) => {
+ if (!ss()[k]) ss()[k] = new Set();
+ for (const v of vals) ss()[k].add(v);
+ return vals.length;
+ },
+ sRem: async (k: string, v: string) => (ss()[k]?.delete(v) ? 1 : 0),
+ sIsMember: async (k: string, v: string) => ss()[k]?.has(v) ?? false,
+ sMembers: async (k: string) => (ss()[k] ? [...ss()[k]] : []),
+ incrBy: async (k: string, n: number) => {
+ const v = Number.parseInt(kv()[k] || "0") + n;
+ kv()[k] = String(v);
+ return v;
+ },
+ watch: async () => {},
+ multi: makeMulti,
+ expire: async () => 1,
+ setNX: async (k: string, v: string) => {
+ if (kv()[k]) return false;
+ kv()[k] = v;
+ return true;
+ },
+ zScore: async () => null,
+ zAdd: async () => 1,
+ zCard: async () => 0,
+ zRemRangeByRank: async () => 0,
+ keys: async (pattern: string) => {
+ const ss = globalThis.__testStore.setStore;
+ const prefix = pattern.replace("*", "");
+ return Object.keys(ss).filter((k) => k.startsWith(prefix));
+ },
+ type: async (k: string) => {
+ if (globalThis.__testStore.setStore[k]) return "set";
+ if (globalThis.__testStore.listStore[k]) return "list";
+ if (globalThis.__testStore.kvStore[k] !== undefined) return "string";
+ return "none";
+ },
},
- watch: async () => {},
- multi: makeMulti,
- expire: async () => 1,
- setNX: async (k: string, v: string) => {
- if (kv()[k]) return false;
- kv()[k] = v;
- return true;
- },
- zScore: async () => null,
- zAdd: async () => 1,
- zCard: async () => 0,
- zRemRangeByRank: async () => 0,
- keys: async (pattern: string) => {
- const ss = globalThis.__testStore.setStore;
- const prefix = pattern.replace("*", "");
- return Object.keys(ss).filter((k) => k.startsWith(prefix));
+ g,
+ s,
+ gf,
+ ga: async () => null,
+ archive: { lRange: async () => [] },
+ };
+ });
+
+ mock.module("$config", () => ({
+ default: {
+ bitcoin: {
+ host: "localhost",
+ wallet: "test",
+ user: "u",
+ password: "p",
+ network: "regtest",
+ port: 18443,
},
- type: async (k: string) => {
- if (globalThis.__testStore.setStore[k]) return "set";
- if (globalThis.__testStore.listStore[k]) return "list";
- if (globalThis.__testStore.kvStore[k] !== undefined) return "string";
- return "none";
+ liquid: {
+ host: "localhost",
+ wallet: "test",
+ user: "u",
+ password: "p",
+ btc: "test-asset",
+ port: 7040,
},
+ lightning: "/dev/null",
+ fee: { bitcoin: 0.004, liquid: 0.001, lightning: 0.001 },
+ adminpass: "test",
+ ark: { arkPrivateKey: "0000", arkServerUrl: "http://localhost" },
+ nostr: "ws://localhost:7777",
+ tigerbeetle: { cluster_id: 0n, replica_addresses: ["localhost:3000"] },
+ vapid: { pk: "test", sk: "test" },
+ support: "[email protected]",
+ txWebhookSecret: "test",
},
- g, s, gf,
- ga: async () => null,
- archive: { lRange: async () => [] },
- };
-});
-
-mock.module("$config", () => ({
- default: {
- bitcoin: { host: "localhost", wallet: "test", user: "u", password: "p", network: "regtest", port: 18443 },
- liquid: { host: "localhost", wallet: "test", user: "u", password: "p", btc: "test-asset", port: 7040 },
- lightning: "/dev/null",
- fee: { bitcoin: 0.004, liquid: 0.001, lightning: 0.001 },
- adminpass: "test",
- ark: { arkPrivateKey: "0000", arkServerUrl: "http://localhost" },
- nostr: "ws://localhost:7777",
- tigerbeetle: { cluster_id: 0n, replica_addresses: ["localhost:3000"] },
- vapid: { pk: "test", sk: "test" },
- support: "[email protected]",
- txWebhookSecret: "test",
- },
-}));
-
-mock.module("$lib/tb", () => ({
- getBalance: mock(async () => 10_000_000),
- getCredit: mock(async () => 0),
- tbDebit: mock(async () => 0),
- tbCredit: mock(async () => undefined),
- tbRefund: mock(async () => undefined),
- tbReverse: mock(async () => undefined),
- tbConfirm: mock(async () => undefined),
- tbSetBalance: mock(async () => undefined),
- tbSetPending: mock(async () => undefined),
- fundDebit: mock(async () => ({ err: null })),
- initTigerBeetle: mock(async () => {}),
-}));
+ }));
-mock.module("$lib/ln", () => ({
- default: {
- decode: mock(async () => ({ type: "bolt11", amount_msat: 1_000_000, payee: "test-payee" })),
- listpeerchannels: mock(async () => ({ channels: [] })),
- listpays: mock(async () => ({ pays: [] })),
- xpay: mock(async () => ({ amount_sent_msat: 1_000_000, payment_preimage: "preimage-abc" })),
- getinfo: mock(async () => ({ id: "our-node-id" })),
- listinvoices: mock(async () => ({ invoices: [] })),
- listfunds: mock(async () => ({ channels: [] })),
- keysend: mock(async () => ({})),
- fetchinvoice: mock(async () => ({})),
- getroutes: mock(async () => ({ routes: [] })),
- sendinvoice: mock(async () => ({})),
- },
-}));
+ mock.module("$lib/tb", () => ({
+ getBalance: mock(async () => 10_000_000),
+ getCredit: mock(async () => 0),
+ tbDebit: mock(async () => 0),
+ tbCredit: mock(async () => undefined),
+ tbRefund: mock(async () => undefined),
+ tbReverse: mock(async () => undefined),
+ tbConfirm: mock(async () => undefined),
+ tbSetBalance: mock(async () => undefined),
+ tbSetPending: mock(async () => undefined),
+ fundDebit: mock(async () => ({ err: null })),
+ initTigerBeetle: mock(async () => {}),
+ }));
-mock.module("$lib/logging", () => ({ l: () => {}, warn: mock(() => {}), err: () => {} }));
-mock.module("$lib/notifications", () => ({ notify: () => {}, nwcNotify: () => {} }));
-mock.module("$lib/webhooks", () => ({ callWebhook: mock(() => {}) }));
-mock.module("$lib/sockets", () => ({ emit: mock(() => {}), sendHeartbeat: () => {} }));
-mock.module("$lib/esplora", () => ({
- btcNetwork: { bech32: "bcrt", pubKeyHash: 0x6f, scriptHash: 0xc4, wif: 0xef },
- hdVersions: { private: 0x04358394, public: 0x043587cf },
- getAddressTxs: mock(async (address: string) => {
- const txs = globalThis.__testStore.esploraOverride?.addressTxs?.[address];
- return txs || [];
- }),
- getTxStatus: mock(async (txid: string) => {
- const status = globalThis.__testStore.esploraOverride?.txStatus?.[txid];
- return status || { confirmed: false };
- }),
- getAddressUtxos: mock(async () => []),
- getUtxos: mock(async () => []),
- getTxHex: mock(async () => ""),
- getTx: mock(async () => ({})),
- broadcastTx: mock(async () => ({})),
- getFeeEstimates: mock(async () => ({})),
- deriveAddress: mock(() => ({ address: "bcrt1qmock" })),
- deriveAddresses: mock(() => []),
- parseDescriptor: mock(() => ({})),
- findLastUsedIndex: mock(async () => -1),
-}));
-mock.module("$lib/square", () => ({ squarePayment: () => {} }));
-mock.module("$lib/nostr", () => ({
- handleZap: async () => {}, publish: async () => {},
- serverPubkey: "m", serverPubkey2: "m", serverSecret: "m", serverSecret2: "m",
-}));
-mock.module("$lib/mqtt", () => ({ default: { publish: () => {} } }));
-mock.module("$lib/ark", () => ({
- getArkAddress: async () => "ark-addr", sendArk: async () => "ark-txid", getArkBalance: async () => 0, verifyArkVtxo: async () => true,
-}));
-mock.module("$lib/ecash", () => ({ request: async () => ({}) }));
-mock.module("$lib/lightning", () => ({
- replay: async () => ({}), fixBolt12: () => {}, listenForLightning: () => {},
-}));
-mock.module("$lib/mail", () => ({ mail: async () => {}, templates: {} }));
-mock.module("$lib/auth", () => ({
- requirePin: async () => {}, auth: (_r: any, _s: any, n: any) => n(), optional: (_r: any, _s: any, n: any) => n(), admin: (_r: any, _s: any, n: any) => n(),
-}));
-mock.module("$lib/invoices", () => ({
- generate: mock(async ({ invoice, user }: any) => ({
- id: "gen-inv", hash: "gen-hash", uid: user?.id, received: 0, pending: 0, ...invoice,
- })),
-}));
-mock.module("$lib/api", () => ({ default: { bitcoin: "http://localhost", liquid: "http://localhost" } }));
-mock.module("$lib/store", () => ({ default: { rates: { USD: 50000 } } }));
-mock.module("@coinos/rpc", () => ({
- default: () => new Proxy({}, {
- get: (_target, prop) => async (...args: any[]) => {
- const override = globalThis.__testStore.rpcOverride;
- if (override && typeof override[prop] === "function") {
- return override[prop](...args);
- }
- return {};
+ mock.module("$lib/ln", () => ({
+ default: {
+ decode: mock(async () => ({ type: "bolt11", amount_msat: 1_000_000, payee: "test-payee" })),
+ listpeerchannels: mock(async () => ({ channels: [] })),
+ listpays: mock(async () => ({ pays: [] })),
+ xpay: mock(async () => ({ amount_sent_msat: 1_000_000, payment_preimage: "preimage-abc" })),
+ getinfo: mock(async () => ({ id: "our-node-id" })),
+ listinvoices: mock(async () => ({ invoices: [] })),
+ listfunds: mock(async () => ({ channels: [] })),
+ keysend: mock(async () => ({})),
+ fetchinvoice: mock(async () => ({})),
+ getroutes: mock(async () => ({ routes: [] })),
+ sendinvoice: mock(async () => ({})),
},
- }),
-}));
+ }));
-mock.module("$lib/utils", () => {
- const SATS = 100_000_000;
- const kv = () => globalThis.__testStore.kvStore;
- return {
- SATS,
- btc: (n: number) => Number.parseFloat((n / SATS).toFixed(8)),
- fail: (msg: string) => { throw new Error(msg); },
- fmt: (n: number) => String(n),
- formatReceipt: () => {},
- getInvoice: async (hash: string) => {
- const raw = kv()[`invoice:${hash}`] ?? null;
- if (!raw) return null;
- let iid;
- try { iid = JSON.parse(raw); } catch { iid = raw; }
- if (iid?.id) iid = iid.id;
- else if (iid?.hash) iid = iid.hash;
- const raw2 = kv()[`invoice:${iid}`] ?? null;
- if (!raw2) return null;
- try { return JSON.parse(raw2); } catch { return raw2; }
- },
- getPayment: async (id: string) => {
- const raw = kv()[`payment:${id}`];
- if (!raw) return null;
- try {
- const parsed = JSON.parse(raw);
- if (typeof parsed === "string") {
- const p = kv()[`payment:${parsed}`];
- return p ? JSON.parse(p) : null;
- }
- return parsed;
- } catch { return null; }
- },
- getUser: async (username: string) => {
- const raw = kv()[`user:${username}`];
- return raw ? JSON.parse(raw) : null;
- },
- getAccount: async () => null,
- link: (id: string) => `http://test/${id}`,
- sats: (n: number) => Math.round(n * SATS),
- sleep: async () => {},
- t: () => ({ insufficientFunds: "Insufficient funds" }),
- bail: (res: any, msg: string) => res.code(500).send(msg),
- bip21: () => "",
- fields: [],
- nada: () => {},
- fiat: (n: number, r: number) => (n * r) / SATS,
- f: (s: any) => String(s),
- pick: (O: any, K: string[]) => K.reduce((o: any, k: string) => ((o[k] = O[k]), o), {}),
- prod: false,
- uniq: (a: any[], k: any) => [...new Map(a.map((x: any) => [k(x), x])).values()],
- wait: async () => {},
- time: () => ({ start: () => {}, end: () => {} }),
- };
-});
+ mock.module("$lib/logging", () => ({ l: () => {}, warn: mock(() => {}), err: () => {} }));
+ mock.module("$lib/notifications", () => ({ notify: () => {}, nwcNotify: () => {} }));
+ mock.module("$lib/webhooks", () => ({ callWebhook: mock(() => {}) }));
+ mock.module("$lib/sockets", () => ({ emit: mock(() => {}), sendHeartbeat: () => {} }));
+ mock.module("$lib/esplora", () => ({
+ btcNetwork: { bech32: "bcrt", pubKeyHash: 0x6f, scriptHash: 0xc4, wif: 0xef },
+ hdVersions: { private: 0x04358394, public: 0x043587cf },
+ getAddressTxs: mock(async (address: string) => {
+ const txs = globalThis.__testStore.esploraOverride?.addressTxs?.[address];
+ return txs || [];
+ }),
+ getTxStatus: mock(async (txid: string) => {
+ const status = globalThis.__testStore.esploraOverride?.txStatus?.[txid];
+ return status || { confirmed: false };
+ }),
+ getAddressUtxos: mock(async () => []),
+ getUtxos: mock(async () => []),
+ getTxHex: mock(async () => ""),
+ getTx: mock(async () => ({})),
+ broadcastTx: mock(async () => ({})),
+ getFeeEstimates: mock(async () => ({})),
+ deriveAddress: mock(() => ({ address: "bcrt1qmock" })),
+ deriveAddresses: mock(() => []),
+ parseDescriptor: mock(() => ({})),
+ findLastUsedIndex: mock(async () => -1),
+ }));
+ mock.module("$lib/square", () => ({ squarePayment: () => {} }));
+ mock.module("$lib/nostr", () => ({
+ handleZap: async () => {},
+ publish: async () => {},
+ serverPubkey: "m",
+ serverPubkey2: "m",
+ serverSecret: "m",
+ serverSecret2: "m",
+ }));
+ mock.module("$lib/mqtt", () => ({ default: { publish: () => {} } }));
+ mock.module("$lib/ark", () => ({
+ getArkAddress: async () => "ark-addr",
+ sendArk: async () => "ark-txid",
+ getArkBalance: async () => 0,
+ verifyArkVtxo: async () => true,
+ }));
+ mock.module("$lib/ecash", () => ({ request: async () => ({}) }));
+ mock.module("$lib/lightning", () => ({
+ replay: async () => ({}),
+ fixBolt12: () => {},
+ listenForLightning: () => {},
+ }));
+ mock.module("$lib/mail", () => ({ mail: async () => {}, templates: {} }));
+ mock.module("$lib/auth", () => ({
+ requirePin: async () => {},
+ auth: (_r: any, _s: any, n: any) => n(),
+ optional: (_r: any, _s: any, n: any) => n(),
+ admin: (_r: any, _s: any, n: any) => n(),
+ }));
+ mock.module("$lib/invoices", () => ({
+ generate: mock(async ({ invoice, user }: any) => ({
+ id: "gen-inv",
+ hash: "gen-hash",
+ uid: user?.id,
+ received: 0,
+ pending: 0,
+ ...invoice,
+ })),
+ }));
+ mock.module("$lib/api", () => ({
+ default: { bitcoin: "http://localhost", liquid: "http://localhost" },
+ }));
+ mock.module("$lib/store", () => ({ default: { rates: { USD: 50000 } } }));
+ mock.module("@coinos/rpc", () => ({
+ default: () =>
+ new Proxy(
+ {},
+ {
+ get:
+ (_target, prop) =>
+ async (...args: any[]) => {
+ const override = globalThis.__testStore.rpcOverride;
+ if (override && typeof override[prop] === "function") {
+ return override[prop](...args);
+ }
+ return {};
+ },
+ },
+ ),
+ }));
+ mock.module("$lib/utils", () => {
+ const SATS = 100_000_000;
+ const kv = () => globalThis.__testStore.kvStore;
+ return {
+ SATS,
+ btc: (n: number) => Number.parseFloat((n / SATS).toFixed(8)),
+ fail: (msg: string) => {
+ throw new Error(msg);
+ },
+ fmt: (n: number) => String(n),
+ formatReceipt: () => {},
+ getInvoice: async (hash: string) => {
+ const raw = kv()[`invoice:${hash}`] ?? null;
+ if (!raw) return null;
+ let iid;
+ try {
+ iid = JSON.parse(raw);
+ } catch {
+ iid = raw;
+ }
+ if (iid?.id) iid = iid.id;
+ else if (iid?.hash) iid = iid.hash;
+ const raw2 = kv()[`invoice:${iid}`] ?? null;
+ if (!raw2) return null;
+ try {
+ return JSON.parse(raw2);
+ } catch {
+ return raw2;
+ }
+ },
+ getPayment: async (id: string) => {
+ const raw = kv()[`payment:${id}`];
+ if (!raw) return null;
+ try {
+ const parsed = JSON.parse(raw);
+ if (typeof parsed === "string") {
+ const p = kv()[`payment:${parsed}`];
+ return p ? JSON.parse(p) : null;
+ }
+ return parsed;
+ } catch {
+ return null;
+ }
+ },
+ getUser: async (username: string) => {
+ const raw = kv()[`user:${username}`];
+ return raw ? JSON.parse(raw) : null;
+ },
+ getAccount: async () => null,
+ link: (id: string) => `http://test/${id}`,
+ sats: (n: number) => Math.round(n * SATS),
+ sleep: async () => {},
+ t: () => ({ insufficientFunds: "Insufficient funds" }),
+ bail: (res: any, msg: string) => res.code(500).send(msg),
+ bip21: () => "",
+ fields: [],
+ nada: () => {},
+ fiat: (n: number, r: number) => (n * r) / SATS,
+ f: (s: any) => String(s),
+ pick: (O: any, K: string[]) => K.reduce((o: any, k: string) => ((o[k] = O[k]), o), {}),
+ prod: false,
+ uniq: (a: any[], k: any) => [...new Map(a.map((x: any) => [k(x), x])).values()],
+ wait: async () => {},
+ time: () => ({ start: () => {}, end: () => {} }),
+ };
+ });
} // end INTEGRATION skip