Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to decode signet #3128

Merged
merged 16 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"axios": "^0.27.2",
"bech32": "^2.0.0",
"bitcoinjs-lib": "^6.1.0",
"bolt11": "^1.4.1",
"bolt11-signet": "1.4.1",
"crypto-js": "^4.2.0",
"dayjs": "^1.11.10",
"dexie": "^3.2.7",
Expand Down
2 changes: 1 addition & 1 deletion src/app/screens/ConfirmPayment/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { act, render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import lightningPayReq from "bolt11";
import lightningPayReq from "bolt11-signet";
import { MemoryRouter } from "react-router-dom";
import { settingsFixture as mockSettings } from "~/../tests/fixtures/settings";
import type { OriginData } from "~/types";
Expand Down
2 changes: 1 addition & 1 deletion src/app/screens/ConfirmPayment/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Container from "@components/Container";
import PaymentSummary from "@components/PaymentSummary";
import PublisherCard from "@components/PublisherCard";
import ResultCard from "@components/ResultCard";
import lightningPayReq from "bolt11";
import lightningPayReq from "bolt11-signet";
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { useNavigate } from "react-router-dom";
Expand Down
2 changes: 1 addition & 1 deletion src/app/screens/ConfirmPaymentAsync/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import ConfirmOrCancel from "@components/ConfirmOrCancel";
import Container from "@components/Container";
import PaymentSummary from "@components/PaymentSummary";
import PublisherCard from "@components/PublisherCard";
import lightningPayReq from "bolt11";
import lightningPayReq from "bolt11-signet";
import { useEffect, useState } from "react";
import { Trans, useTranslation } from "react-i18next";
import { useNavigate } from "react-router-dom";
Expand Down
2 changes: 1 addition & 1 deletion src/app/screens/Send/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Header from "@components/Header";
import IconButton from "@components/IconButton";
import TextField from "@components/form/TextField";
import { PopiconsChevronLeftLine } from "@popicons/react";
import lightningPayReq from "bolt11";
import lightningPayReq from "bolt11-signet";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { useLocation, useNavigate } from "react-router-dom";
Expand Down
2 changes: 1 addition & 1 deletion src/common/lib/lnurl.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fetchAdapter from "@vespaiach/axios-fetch-adapter";
import axios from "axios";
import lightningPayReq from "bolt11";
import lightningPayReq from "bolt11-signet";
import { isLNURLDetailsError } from "~/common/utils/typeHelpers";
import {
LNURLAuthServiceResponse,
Expand Down
2 changes: 1 addition & 1 deletion src/common/utils/paymentRequest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import lightningPayReq from "bolt11";
import lightningPayReq from "bolt11-signet";

export function getPaymentRequestDescription(paymentRequest: string): string {
const decodedPaymentRequest = lightningPayReq.decode(paymentRequest);
Expand Down
2 changes: 1 addition & 1 deletion src/extension/background-script/actions/ln/sendPayment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import lightningPayReq from "bolt11";
import lightningPayReq from "bolt11-signet";
import PubSub from "pubsub-js";
import pubsub from "~/common/lib/pubsub";
import state from "~/extension/background-script/state";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import lightningPayReq from "bolt11";
import lightningPayReq from "bolt11-signet";
import utils from "~/common/lib/utils";
import { getHostFromSender } from "~/common/utils/helpers";
import { Message, Sender } from "~/types";
Expand Down Expand Up @@ -61,4 +61,4 @@ async function payWithPrompt(message: Message) {
}
}

export { sendPaymentOrPrompt, payWithPrompt, checkAllowance };
export { checkAllowance, payWithPrompt, sendPaymentOrPrompt };
2 changes: 1 addition & 1 deletion src/extension/background-script/connectors/galoy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fetchAdapter from "@vespaiach/axios-fetch-adapter";
import axios, { AxiosRequestConfig } from "axios";
import lightningPayReq from "bolt11";
import lightningPayReq from "bolt11-signet";
import { ACCOUNT_CURRENCIES, CURRENCIES } from "~/common/constants";
import { getPaymentRequestDescription } from "~/common/utils/paymentRequest";
import { getCurrencyRateWithCache } from "~/extension/background-script/actions/cache/getCurrencyRate";
Expand Down
4 changes: 2 additions & 2 deletions src/extension/background-script/connectors/lnbits.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import lightningPayReq from "bolt11";
import lightningPayReq from "bolt11-signet";
import Hex from "crypto-js/enc-hex";
import sha256 from "crypto-js/sha256";
import utils from "~/common/lib/utils";
Expand Down Expand Up @@ -90,7 +90,7 @@ class LnBits implements Connector {
"fee": 0,
"memo": "LNbits",
"time": 1000000000,
"bolt11": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"bolt11-signet": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"preimage": "0000000000000000000000000000000000000000000000000000000000000000",
"payment_hash": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"extra": {},
Expand Down
2 changes: 1 addition & 1 deletion src/extension/background-script/connectors/lndhub.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fetchAdapter from "@vespaiach/axios-fetch-adapter";
import type { AxiosResponse } from "axios";
import axios, { AxiosRequestConfig, Method } from "axios";
import lightningPayReq from "bolt11";
import lightningPayReq from "bolt11-signet";
import Base64 from "crypto-js/enc-base64";
import Hex from "crypto-js/enc-hex";
import hmacSHA256 from "crypto-js/hmac-sha256";
Expand Down
2 changes: 1 addition & 1 deletion src/extension/background-script/connectors/nwc.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { webln } from "@getalby/sdk";
import { NostrWebLNProvider } from "@getalby/sdk/dist/webln";
import lightningPayReq from "bolt11";
import lightningPayReq from "bolt11-signet";
import Hex from "crypto-js/enc-hex";
import SHA256 from "crypto-js/sha256";
import { Account } from "~/types";
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CreateSwapParams } from "@getalby/sdk/dist/types";
import { PaymentRequestObject } from "bolt11";
import { PaymentRequestObject } from "bolt11-signet";
import { Runtime } from "webextension-polyfill";
import { ACCOUNT_CURRENCIES, CURRENCIES } from "~/common/constants";
import connectors from "~/extension/background-script/connectors";
Expand Down
39 changes: 28 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1526,7 +1526,7 @@

"@types/bn.js@^4.11.3":
version "4.11.6"
resolved "https://registry.npmjs.org/@types/bn.js/-/bn.js-4.11.6.tgz"
resolved "https://registry.yarnpkg.com/@types/bn.js/-/bn.js-4.11.6.tgz#c306c70d9358aaea33cd4eda092a742b9505967c"
integrity sha512-pqr857jrp2kPuO9uRjZ3PwnJTjoQy+fcdxvBTvHm6dkmEL9q+hDD/2j/0ELOBPtPnS8LjCX0gI9nbl8lVkadpg==
dependencies:
"@types/node" "*"
Expand Down Expand Up @@ -2767,7 +2767,7 @@ batch@0.6.1:

bech32@^1.1.2:
version "1.1.4"
resolved "https://registry.npmjs.org/bech32/-/bech32-1.1.4.tgz"
resolved "https://registry.yarnpkg.com/bech32/-/bech32-1.1.4.tgz#e38c9f37bf179b8eb16ae3a772b40c356d4832e9"
integrity sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ==

bech32@^2.0.0:
Expand All @@ -2790,14 +2790,31 @@ bip174@^2.1.0:
resolved "https://registry.npmjs.org/bip174/-/bip174-2.1.0.tgz"
integrity sha512-lkc0XyiX9E9KiVAS1ZiOqK1xfiwvf4FXDDdkDq5crcDzOq+xGytY+14qCsqz7kCiy8rpN1CRNfacRhf9G3JNSA==

bip174@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/bip174/-/bip174-2.1.1.tgz#ef3e968cf76de234a546962bcf572cc150982f9f"
integrity sha512-mdFV5+/v0XyNYXjBS6CQPLo9ekCx4gtKZFnJm5PMto7Fs9hTTDpkkzOB7/FtluRI6JbUUAu+snTYfJRgHLZbZQ==

bip66@^1.1.0:
version "1.1.5"
resolved "https://registry.npmjs.org/bip66/-/bip66-1.1.5.tgz"
integrity sha512-nemMHz95EmS38a26XbbdxIYj5csHd3RMP3H5bwQknX0WYHF01qhpufP42mLOwVICuH2JmhIhXiWs89MfUGL7Xw==
dependencies:
safe-buffer "^5.0.1"

bitcoinjs-lib@^6.0.0, bitcoinjs-lib@^6.0.2:
bitcoinjs-lib@^6.0.0:
version "6.1.5"
resolved "https://registry.yarnpkg.com/bitcoinjs-lib/-/bitcoinjs-lib-6.1.5.tgz#3b03509ae7ddd80a440f10fc38c4a97f0a028d8c"
integrity sha512-yuf6xs9QX/E8LWE2aMJPNd0IxGofwfuVOiYdNUESkc+2bHHVKjhJd8qewqapeoolh9fihzHGoDCB5Vkr57RZCQ==
dependencies:
"@noble/hashes" "^1.2.0"
bech32 "^2.0.0"
bip174 "^2.1.1"
bs58check "^3.0.1"
typeforce "^1.11.3"
varuint-bitcoin "^1.1.2"

bitcoinjs-lib@^6.0.2:
version "6.1.0"
resolved "https://registry.yarnpkg.com/bitcoinjs-lib/-/bitcoinjs-lib-6.1.0.tgz#2e3123d63eab5e8e752fd7e2f237314f35ed738f"
integrity sha512-eupi1FBTJmPuAZdChnzTXLv2HBqFW2AICpzXZQLniP0V9FWWeeUQSMKES6sP8isy/xO0ijDexbgkdEyFVrsuJw==
Expand Down Expand Up @@ -2865,10 +2882,10 @@ body-parser@1.19.2:
raw-body "2.4.3"
type-is "~1.6.18"

bolt11@^1.4.1:
bolt11-signet@1.4.1:
version "1.4.1"
resolved "https://registry.npmjs.org/bolt11/-/bolt11-1.4.1.tgz"
integrity sha512-jR0Y+MO+CK2at1Cg5mltLJ+6tdOwNKoTS/DJOBDdzVkQ+R9D6UgZMayTWOsuzY7OgV1gEqlyT5Tzk6t6r4XcNQ==
resolved "https://registry.yarnpkg.com/bolt11-signet/-/bolt11-signet-1.4.1.tgz#22e91ee2c1fe41024824bc1c4a416d4ed3a3091c"
integrity sha512-vkazbwdf4wG5ljvn1qR+epOSn/eSH475ykvI8DJUFInruNPK6pPf0a4FIbx4eTxToyAj0YNrVIZKJBo6HPGqWQ==
dependencies:
"@types/bn.js" "^4.11.3"
bech32 "^1.1.2"
Expand Down Expand Up @@ -7178,7 +7195,7 @@ no-case@^3.0.4:

node-addon-api@^2.0.0:
version "2.0.2"
resolved "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.2.tgz"
resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-2.0.2.tgz#432cfa82962ce494b132e9d72a15b29f71ff5d32"
integrity sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA==

node-fetch@^2.6.12, node-fetch@^2.6.7:
Expand All @@ -7194,9 +7211,9 @@ node-forge@^1:
integrity sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==

node-gyp-build@^4.2.0:
version "4.3.0"
resolved "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.3.0.tgz"
integrity sha512-iWjXZvmboq0ja1pUGULQBexmxq8CV4xBhX7VDOTbL7ZR4FOowwY/VOtRxBN/yKxmdGoIp4j5ysNT4u3S2pDQ3Q==
version "4.8.1"
resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.8.1.tgz#976d3ad905e71b76086f4f0b0d3637fe79b6cda5"
integrity sha512-OSs33Z9yWr148JZcbZd5WiAXhh/n9z8TxQcdMhIOlpN9AhWpLfvVFO73+m77bBABQMaY9XSvIa+qk0jlI7Gcaw==

node-int64@^0.4.0:
version "0.4.0"
Expand Down Expand Up @@ -8742,7 +8759,7 @@ schema-utils@^4.0.1:

secp256k1@^4.0.2:
version "4.0.3"
resolved "https://registry.npmjs.org/secp256k1/-/secp256k1-4.0.3.tgz"
resolved "https://registry.yarnpkg.com/secp256k1/-/secp256k1-4.0.3.tgz#c4559ecd1b8d3c1827ed2d1b94190d69ce267303"
integrity sha512-NLZVf+ROMxwtEj3Xa562qgv2BK5e2WNmXPiOdVIPLgs6lyTzMvBq0aWTYMI5XCP9jZMVKOcqZLw/Wc4vDkuxhA==
dependencies:
elliptic "^6.5.4"
Expand Down
Loading