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

Release 1.4.0 #105

Merged
merged 8 commits into from
Feb 5, 2023
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
16 changes: 8 additions & 8 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"useTabs": false,
"semi": false,
"singleQuote": true,
"trailingComma": "none",
"printWidth": 100,
"plugins": ["prettier-plugin-svelte"],
"pluginSearchDirs": ["."],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
"useTabs": false,
"semi": false,
"singleQuote": true,
"trailingComma": "none",
"printWidth": 100,
"plugins": ["prettier-plugin-svelte"],
"pluginSearchDirs": ["."],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
}
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "browser-app",
"version": "1.3.0",
"version": "1.4.0",
"scripts": {
"dev": "vite dev",
"dev-http": "vite dev --mode http",
"build": "vite build",
"build-staging": "vite build --mode staging",
"preview": "vite preview",
Expand All @@ -17,15 +18,15 @@
"@playwright/test": "^1.28.1",
"@sveltejs/adapter-static": "^1.0.0",
"@sveltejs/kit": "^1.0.0",
"@typescript-eslint/eslint-plugin": "^5.45.0",
"@typescript-eslint/parser": "^5.45.0",
"@types/big.js": "^6.1.5",
"@types/crypto-js": "^4.1.1",
"@types/hammerjs": "^2.0.41",
"@types/lodash.debounce": "^4.0.7",
"@types/lodash.isequal": "^4.5.6",
"@types/secp256k1": "^4.0.3",
"@types/ua-parser-js": "^0.7.36",
"@typescript-eslint/eslint-plugin": "^5.45.0",
"@typescript-eslint/parser": "^5.45.0",
"@vitejs/plugin-basic-ssl": "^0.1.1",
"autoprefixer": "^10.4.7",
"eslint": "^8.28.0",
Expand All @@ -39,7 +40,7 @@
"svelte": "^3.54.0",
"svelte-check": "^2.9.2",
"svelte-preprocess": "^4.10.7",
"tailwindcss": "^3.1.6",
"tailwindcss": "^3.2.4",
"tslib": "^2.4.1",
"typescript": "^4.9.3",
"vite": "^4.0.0"
Expand All @@ -49,19 +50,20 @@
"big.js": "^6.2.1",
"crypto-js": "^4.1.1",
"date-fns": "^2.28.0",
"date-fns-tz": "^1.3.7",
"hammerjs": "^2.0.8",
"js-lnurl": "^0.5.1",
"jsqr": "^1.4.0",
"light-bolt11-decoder": "^2.1.0",
"lnmessage": "^0.0.13",
"lnmessage": "^0.0.19",
"lodash.debounce": "^4.0.8",
"lodash.isequal": "^4.5.0",
"qr-code-styling": "^1.6.0-rc.1",
"rune-decoder": "0.0.1",
"rxjs": "^7.5.7",
"secp256k1": "^4.0.3",
"sveltekit-i18n": "^2.2.2",
"ua-parser-js": "^1.0.2",
"ua-parser-js": "^1.0.33",
"vconsole": "^3.14.7"
}
}
16 changes: 8 additions & 8 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test'

const config: PlaywrightTestConfig = {
webServer: {
command: 'npm run build && npm run preview',
port: 4173
},
testDir: 'tests'
};
webServer: {
command: 'npm run build && npm run preview',
port: 4173
},
testDir: 'tests'
}

export default config;
export default config
6 changes: 5 additions & 1 deletion src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ section {
}

/* Hide arrows on Firefox number input */
input[type=number] {
input[type='number'] {
-moz-appearance: textfield;
}

input[type='radio'] {
@apply accent-purple-500;
}
2 changes: 1 addition & 1 deletion src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1.0, width=device-width">
<meta name="viewport" content="initial-scale=1.0, width=device-width" />
<meta name="description" content="A user interface for your Core Lightning node" />
<meta name="apple-mobile-web-app-title" content="Clams" />
<meta name="application-name" content="Clams" />
Expand Down
18 changes: 15 additions & 3 deletions src/lib/backends/core-lightning/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import Big from 'big.js'
import type { Auth, Payment } from '$lib/types'
import { formatMsat, parseNodeAddress, sortPaymentsMostRecent } from '$lib/utils'
import { invoiceToPayment, payToPayment } from './utils'
import { WS_PROXY } from '$lib/constants'
import type { Logger } from 'lnmessage/dist/types'
import { settings$ } from '$lib/streams'

import type {
BkprListIncomeResponse,
GetinfoResponse,
InvoiceRequest,
InvoiceResponse,
Expand All @@ -24,13 +25,15 @@ class CoreLn {
public connection: LnMessage
public rune: string

constructor(auth: Auth, wsProxy = WS_PROXY, logger?: Logger) {
constructor(auth: Auth, logger?: Logger) {
const { address, token, sessionSecret } = auth
const { wsProxy, directConnection } = settings$.value
const { publicKey, ip, port } = parseNodeAddress(address)

this.connection = new LnMessage({
remoteNodePublicKey: publicKey,
wsProxy,
wsProxy: directConnection ? undefined : wsProxy,
wsProtocol: directConnection,
ip,
port: port || 9735,
privateKey: sessionSecret,
Expand Down Expand Up @@ -247,6 +250,15 @@ class CoreLn {

return result as SignMessageResponse
}

async bkprListIncome(): Promise<BkprListIncomeResponse> {
const result = await this.connection.commando({
method: 'bkpr-listincome',
rune: this.rune
})

return result as BkprListIncomeResponse
}
}

export default CoreLn
19 changes: 19 additions & 0 deletions src/lib/backends/core-lightning/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,24 @@ export type SignMessageResponse = {
zbase: string
}

export type IncomeEvent = {
account: string
tag: 'deposit' | 'withdrawal' | 'onchain_fee' | 'invoice' | 'invoice_fee' | 'routed' | string
credit_msat: number
debit_msat: number
currency: string
timestamp: number
description?: string
outpoint?: string
txid?: string
payment_id?: string
fee_amount?: string
}

export type BkprListIncomeResponse = {
income_events: IncomeEvent[]
}

export type LNResponse =
| InvoiceResponse
| ListinvoicesResponse
Expand All @@ -567,5 +585,6 @@ export type LNResponse =
| WaitInvoiceResponse
| WaitAnyInvoiceResponse
| SignMessageResponse
| BkprListIncomeResponse

export type RpcRequest = (req: JsonRpcRequest & { rune: string }) => Promise<unknown>
6 changes: 3 additions & 3 deletions src/lib/backends/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ export * from './core-lightning/types'
export type LnAPI = CoreLn
export type LnBackend = 'core_lightning'

export function initLn(options: { backend: LnBackend; auth: Auth; wsProxy?: string }): LnAPI {
const { backend, auth, wsProxy } = options
export function initLn(options: { backend: LnBackend; auth: Auth }): LnAPI {
const { backend, auth } = options

switch (backend) {
case 'core_lightning':
return new CoreLn(auth, wsProxy, logger)
return new CoreLn(auth, logger)
default:
throw new Error(`${backend} is not a valid backend`)
}
Expand Down
Loading