lnlink-server 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.js +1 -1
- package/dist/build-info.json +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +2 -2
- package/dist/package.json +1 -1
- package/dist/public/js/init.js +296 -241
- package/package.json +2 -1
- package/prisma/migrations/20250918020814_/migration.sql +188 -0
- package/prisma/migrations/20251114105314_auto_update/migration.sql +2 -0
- package/prisma/migrations/migration_lock.toml +3 -0
- package/prisma/schema.prisma +181 -0
package/package.json
CHANGED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
-- CreateTable
|
|
2
|
+
CREATE TABLE "lnlink_config" (
|
|
3
|
+
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
4
|
+
"owner_npub" TEXT,
|
|
5
|
+
"node_encrypted_sk" TEXT,
|
|
6
|
+
"node_npub" TEXT,
|
|
7
|
+
"settings" TEXT,
|
|
8
|
+
"create_at" INTEGER,
|
|
9
|
+
"update_at" INTEGER
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
-- CreateTable
|
|
13
|
+
CREATE TABLE "lnlink_nostr_events" (
|
|
14
|
+
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
15
|
+
"event_id" TEXT,
|
|
16
|
+
"content" TEXT,
|
|
17
|
+
"from_npub" TEXT,
|
|
18
|
+
"to_npub" TEXT,
|
|
19
|
+
"kind" INTEGER,
|
|
20
|
+
"tags" TEXT,
|
|
21
|
+
"reply_event_id" TEXT,
|
|
22
|
+
"reply_err" TEXT,
|
|
23
|
+
"status" INTEGER NOT NULL DEFAULT 0,
|
|
24
|
+
"create_at" INTEGER,
|
|
25
|
+
"reply_at" INTEGER
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
-- CreateTable
|
|
29
|
+
CREATE TABLE "lnlink_users" (
|
|
30
|
+
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
31
|
+
"name" TEXT,
|
|
32
|
+
"pubkey" TEXT,
|
|
33
|
+
"npub" TEXT,
|
|
34
|
+
"sk" TEXT,
|
|
35
|
+
"node_pubkey" TEXT,
|
|
36
|
+
"node_npub" TEXT,
|
|
37
|
+
"relay" TEXT,
|
|
38
|
+
"account_type" INTEGER,
|
|
39
|
+
"social_id" TEXT,
|
|
40
|
+
"social_type" INTEGER,
|
|
41
|
+
"auth_limit" TEXT,
|
|
42
|
+
"status" INTEGER DEFAULT 1,
|
|
43
|
+
"permissions" TEXT,
|
|
44
|
+
"asset_id" TEXT,
|
|
45
|
+
"parent_pubkey" TEXT,
|
|
46
|
+
"create_at" INTEGER,
|
|
47
|
+
"expire_time" INTEGER
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
-- CreateTable
|
|
51
|
+
CREATE TABLE "lnlink_transactions" (
|
|
52
|
+
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
53
|
+
"event_id" TEXT,
|
|
54
|
+
"user_npub" TEXT,
|
|
55
|
+
"asset_type" TEXT,
|
|
56
|
+
"asset_id" TEXT,
|
|
57
|
+
"asset_amount" TEXT,
|
|
58
|
+
"invoice" TEXT,
|
|
59
|
+
"status" INTEGER DEFAULT 0,
|
|
60
|
+
"create_at" INTEGER,
|
|
61
|
+
"update_at" INTEGER,
|
|
62
|
+
"node_type" TEXT NOT NULL,
|
|
63
|
+
"transaction_kind" TEXT NOT NULL,
|
|
64
|
+
"direction" TEXT,
|
|
65
|
+
"fees_paid" TEXT,
|
|
66
|
+
"add_index" INTEGER,
|
|
67
|
+
"payment_hash" TEXT,
|
|
68
|
+
"preimage" TEXT,
|
|
69
|
+
"expire_at" INTEGER,
|
|
70
|
+
"settled_at" INTEGER,
|
|
71
|
+
"description" TEXT,
|
|
72
|
+
"description_hash" TEXT,
|
|
73
|
+
"tx_hash" TEXT,
|
|
74
|
+
"tx_type" TEXT,
|
|
75
|
+
"target_address" TEXT,
|
|
76
|
+
"block_height" INTEGER,
|
|
77
|
+
"confirmations" INTEGER DEFAULT 0
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
-- CreateTable
|
|
81
|
+
CREATE TABLE "lnlink_orders" (
|
|
82
|
+
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
83
|
+
"transaction_id" INTEGER NOT NULL,
|
|
84
|
+
"user_id" INTEGER NOT NULL,
|
|
85
|
+
"create_at" INTEGER
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
-- CreateIndex
|
|
89
|
+
CREATE INDEX "nostr_events_event_id_IDX" ON "lnlink_nostr_events"("event_id");
|
|
90
|
+
|
|
91
|
+
-- CreateIndex
|
|
92
|
+
CREATE INDEX "nostr_events_from_npub_IDX" ON "lnlink_nostr_events"("from_npub");
|
|
93
|
+
|
|
94
|
+
-- CreateIndex
|
|
95
|
+
CREATE INDEX "nostr_events_to_npub_IDX" ON "lnlink_nostr_events"("to_npub");
|
|
96
|
+
|
|
97
|
+
-- CreateIndex
|
|
98
|
+
CREATE INDEX "nostr_events_kind_IDX" ON "lnlink_nostr_events"("kind");
|
|
99
|
+
|
|
100
|
+
-- CreateIndex
|
|
101
|
+
CREATE INDEX "nostr_events_status_IDX" ON "lnlink_nostr_events"("status");
|
|
102
|
+
|
|
103
|
+
-- CreateIndex
|
|
104
|
+
CREATE INDEX "nostr_events_create_at_IDX" ON "lnlink_nostr_events"("create_at");
|
|
105
|
+
|
|
106
|
+
-- CreateIndex
|
|
107
|
+
CREATE UNIQUE INDEX "lnlink_users_pubkey_key" ON "lnlink_users"("pubkey");
|
|
108
|
+
|
|
109
|
+
-- CreateIndex
|
|
110
|
+
CREATE UNIQUE INDEX "lnlink_users_npub_key" ON "lnlink_users"("npub");
|
|
111
|
+
|
|
112
|
+
-- CreateIndex
|
|
113
|
+
CREATE INDEX "idx_account_type" ON "lnlink_users"("account_type");
|
|
114
|
+
|
|
115
|
+
-- CreateIndex
|
|
116
|
+
CREATE INDEX "idx_asset_id" ON "lnlink_users"("asset_id");
|
|
117
|
+
|
|
118
|
+
-- CreateIndex
|
|
119
|
+
CREATE INDEX "idx_parent_pubkey" ON "lnlink_users"("parent_pubkey");
|
|
120
|
+
|
|
121
|
+
-- CreateIndex
|
|
122
|
+
CREATE INDEX "idx_expire_time" ON "lnlink_users"("expire_time");
|
|
123
|
+
|
|
124
|
+
-- CreateIndex
|
|
125
|
+
CREATE INDEX "idx_pubkey" ON "lnlink_users"("pubkey");
|
|
126
|
+
|
|
127
|
+
-- CreateIndex
|
|
128
|
+
CREATE UNIQUE INDEX "lnlink_transactions_event_id_key" ON "lnlink_transactions"("event_id");
|
|
129
|
+
|
|
130
|
+
-- CreateIndex
|
|
131
|
+
CREATE INDEX "idx_user_npub" ON "lnlink_transactions"("user_npub");
|
|
132
|
+
|
|
133
|
+
-- CreateIndex
|
|
134
|
+
CREATE INDEX "idx_asset_type" ON "lnlink_transactions"("asset_type");
|
|
135
|
+
|
|
136
|
+
-- CreateIndex
|
|
137
|
+
CREATE INDEX "idx_tx_asset_id" ON "lnlink_transactions"("asset_id");
|
|
138
|
+
|
|
139
|
+
-- CreateIndex
|
|
140
|
+
CREATE INDEX "idx_payment_hash" ON "lnlink_transactions"("payment_hash");
|
|
141
|
+
|
|
142
|
+
-- CreateIndex
|
|
143
|
+
CREATE INDEX "idx_invoice" ON "lnlink_transactions"("invoice");
|
|
144
|
+
|
|
145
|
+
-- CreateIndex
|
|
146
|
+
CREATE INDEX "idx_tx_hash" ON "lnlink_transactions"("tx_hash");
|
|
147
|
+
|
|
148
|
+
-- CreateIndex
|
|
149
|
+
CREATE INDEX "idx_direction" ON "lnlink_transactions"("direction");
|
|
150
|
+
|
|
151
|
+
-- CreateIndex
|
|
152
|
+
CREATE INDEX "idx_tx_type" ON "lnlink_transactions"("tx_type");
|
|
153
|
+
|
|
154
|
+
-- CreateIndex
|
|
155
|
+
CREATE INDEX "idx_status" ON "lnlink_transactions"("status");
|
|
156
|
+
|
|
157
|
+
-- CreateIndex
|
|
158
|
+
CREATE INDEX "idx_transaction_create_at" ON "lnlink_transactions"("create_at");
|
|
159
|
+
|
|
160
|
+
-- CreateIndex
|
|
161
|
+
CREATE INDEX "idx_node_type" ON "lnlink_transactions"("node_type");
|
|
162
|
+
|
|
163
|
+
-- CreateIndex
|
|
164
|
+
CREATE INDEX "idx_transaction_kind" ON "lnlink_transactions"("transaction_kind");
|
|
165
|
+
|
|
166
|
+
-- CreateIndex
|
|
167
|
+
CREATE INDEX "idx_block_height" ON "lnlink_transactions"("block_height");
|
|
168
|
+
|
|
169
|
+
-- CreateIndex
|
|
170
|
+
CREATE INDEX "idx_target_address" ON "lnlink_transactions"("target_address");
|
|
171
|
+
|
|
172
|
+
-- CreateIndex
|
|
173
|
+
CREATE INDEX "idx_user_npub_status" ON "lnlink_transactions"("user_npub", "status");
|
|
174
|
+
|
|
175
|
+
-- CreateIndex
|
|
176
|
+
CREATE INDEX "idx_asset_id_direction" ON "lnlink_transactions"("asset_id", "direction");
|
|
177
|
+
|
|
178
|
+
-- CreateIndex
|
|
179
|
+
CREATE INDEX "idx_user_npub_transaction_kind" ON "lnlink_transactions"("user_npub", "transaction_kind");
|
|
180
|
+
|
|
181
|
+
-- CreateIndex
|
|
182
|
+
CREATE INDEX "idx_status_create_at" ON "lnlink_transactions"("status", "create_at");
|
|
183
|
+
|
|
184
|
+
-- CreateIndex
|
|
185
|
+
CREATE INDEX "idx_transaction_id" ON "lnlink_orders"("transaction_id");
|
|
186
|
+
|
|
187
|
+
-- CreateIndex
|
|
188
|
+
CREATE INDEX "idx_user_id" ON "lnlink_orders"("user_id");
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
// This is your Prisma schema file,
|
|
2
|
+
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
3
|
+
|
|
4
|
+
generator client {
|
|
5
|
+
provider = "prisma-client-js"
|
|
6
|
+
binaryTargets = ["native", "darwin", "darwin-arm64", "windows", "debian-openssl-3.0.x"]
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
datasource db {
|
|
10
|
+
provider = "sqlite"
|
|
11
|
+
url = env("LINK_DATABASE_URL")
|
|
12
|
+
}
|
|
13
|
+
model LnlinkConfig {
|
|
14
|
+
id Int @id @default(autoincrement())
|
|
15
|
+
owner_npub String? @map("owner_npub")
|
|
16
|
+
node_encrypted_sk String? @map("node_encrypted_sk")
|
|
17
|
+
node_npub String? @map("node_npub")
|
|
18
|
+
node_name String? @map("node_name")
|
|
19
|
+
settings String? @map("settings")
|
|
20
|
+
create_at Int? @map("create_at")
|
|
21
|
+
update_at Int? @map("update_at")
|
|
22
|
+
|
|
23
|
+
@@map("lnlink_config")
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Nostr Events Table
|
|
27
|
+
model LnlinkNostrEvent {
|
|
28
|
+
id Int @id @default(autoincrement())
|
|
29
|
+
event_id String? @map("event_id")
|
|
30
|
+
content String?
|
|
31
|
+
from_npub String? @map("from_npub")
|
|
32
|
+
to_npub String? @map("to_npub")
|
|
33
|
+
kind Int?
|
|
34
|
+
tags String? // JSON string
|
|
35
|
+
reply_event_id String? @map("reply_event_id")
|
|
36
|
+
reply_err String? @map("reply_err")
|
|
37
|
+
status Int @default(0)
|
|
38
|
+
create_at Int? @map("create_at")
|
|
39
|
+
reply_at Int? @map("reply_at")
|
|
40
|
+
|
|
41
|
+
@@index([event_id], map: "nostr_events_event_id_IDX")
|
|
42
|
+
@@index([from_npub], map: "nostr_events_from_npub_IDX")
|
|
43
|
+
@@index([to_npub], map: "nostr_events_to_npub_IDX")
|
|
44
|
+
@@index([kind], map: "nostr_events_kind_IDX")
|
|
45
|
+
@@index([status], map: "nostr_events_status_IDX")
|
|
46
|
+
@@index([create_at], map: "nostr_events_create_at_IDX")
|
|
47
|
+
@@map("lnlink_nostr_events")
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// LnLink Users Table
|
|
51
|
+
model LnlinkUser {
|
|
52
|
+
id Int @id @default(autoincrement())
|
|
53
|
+
name String?
|
|
54
|
+
pubkey String? @unique
|
|
55
|
+
npub String? @unique
|
|
56
|
+
sk String?
|
|
57
|
+
node_pubkey String?
|
|
58
|
+
node_npub String?
|
|
59
|
+
relay String?
|
|
60
|
+
account_type Int?
|
|
61
|
+
social_id String?
|
|
62
|
+
social_type Int? @map("social_type")
|
|
63
|
+
auth_limit String?
|
|
64
|
+
status Int? @default(1)
|
|
65
|
+
permissions String?
|
|
66
|
+
asset_id String?
|
|
67
|
+
parent_pubkey String?
|
|
68
|
+
create_at Int?
|
|
69
|
+
expire_time Int?
|
|
70
|
+
|
|
71
|
+
@@index([account_type], map: "idx_account_type")
|
|
72
|
+
@@index([asset_id], map: "idx_asset_id")
|
|
73
|
+
@@index([parent_pubkey], map: "idx_parent_pubkey")
|
|
74
|
+
@@index([expire_time], map: "idx_expire_time")
|
|
75
|
+
@@index([pubkey], map: "idx_pubkey")
|
|
76
|
+
@@map("lnlink_users")
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// LnLink Transactions Table
|
|
80
|
+
model LnlinkTransaction {
|
|
81
|
+
id Int @id @default(autoincrement())
|
|
82
|
+
event_id String? @unique @map("event_id")
|
|
83
|
+
user_npub String? @map("user_npub")
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
asset_type String? @map("asset_type")
|
|
87
|
+
asset_id String? @map("asset_id")
|
|
88
|
+
asset_amount String? @map("asset_amount")
|
|
89
|
+
invoice String? @map("invoice")
|
|
90
|
+
status Int? @default(0)
|
|
91
|
+
create_at Int? @map("create_at")
|
|
92
|
+
update_at Int? @map("update_at")
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
node_type String // "litd" or "rgb"
|
|
96
|
+
transaction_kind String // "onchain" or "lightning"
|
|
97
|
+
direction String? // "in" or "out"
|
|
98
|
+
fees_paid String? @map("fees_paid")
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
add_index Int? @map("add_index")
|
|
102
|
+
payment_hash String? @map("payment_hash")
|
|
103
|
+
preimage String?
|
|
104
|
+
expire_at Int? @map("expire_at")
|
|
105
|
+
settled_at Int? @map("settled_at")
|
|
106
|
+
description String?
|
|
107
|
+
description_hash String? @map("description_hash")
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
tx_hash String? @map("tx_hash")
|
|
111
|
+
tx_type String? @map("tx_type")
|
|
112
|
+
target_address String? @map("target_address")
|
|
113
|
+
block_height Int? @map("block_height")
|
|
114
|
+
confirmations Int? @default(0)
|
|
115
|
+
|
|
116
|
+
@@index([user_npub], map: "idx_user_npub")
|
|
117
|
+
@@index([asset_type], map: "idx_asset_type")
|
|
118
|
+
@@index([asset_id], map: "idx_tx_asset_id")
|
|
119
|
+
@@index([payment_hash], map: "idx_payment_hash")
|
|
120
|
+
@@index([invoice], map: "idx_invoice")
|
|
121
|
+
@@index([tx_hash], map: "idx_tx_hash")
|
|
122
|
+
@@index([direction], map: "idx_direction")
|
|
123
|
+
@@index([tx_type], map: "idx_tx_type")
|
|
124
|
+
@@index([status], map: "idx_status")
|
|
125
|
+
@@index([create_at], map: "idx_transaction_create_at")
|
|
126
|
+
@@index([node_type], map: "idx_node_type")
|
|
127
|
+
@@index([transaction_kind], map: "idx_transaction_kind")
|
|
128
|
+
@@index([block_height], map: "idx_block_height")
|
|
129
|
+
@@index([target_address], map: "idx_target_address")
|
|
130
|
+
@@index([user_npub, status], map: "idx_user_npub_status")
|
|
131
|
+
@@index([asset_id, direction], map: "idx_asset_id_direction")
|
|
132
|
+
@@index([user_npub, transaction_kind], map: "idx_user_npub_transaction_kind")
|
|
133
|
+
@@index([status, create_at], map: "idx_status_create_at")
|
|
134
|
+
@@map("lnlink_transactions")
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// LnLink Orders Table
|
|
138
|
+
model LnlinkOrder {
|
|
139
|
+
id Int @id @default(autoincrement())
|
|
140
|
+
transaction_id Int
|
|
141
|
+
user_id Int
|
|
142
|
+
create_at Int?
|
|
143
|
+
|
|
144
|
+
@@index([transaction_id], map: "idx_transaction_id")
|
|
145
|
+
@@index([user_id], map: "idx_user_id")
|
|
146
|
+
@@map("lnlink_orders")
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
// Enums for better type safety
|
|
151
|
+
enum EventHandleStatus {
|
|
152
|
+
NO_HANDLE @map("0")
|
|
153
|
+
REPLYING @map("1")
|
|
154
|
+
SUCCESS @map("2")
|
|
155
|
+
ERROR @map("255")
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
enum AccountType {
|
|
159
|
+
NWC @map("1")
|
|
160
|
+
FLASH @map("2")
|
|
161
|
+
FLASH_REGISTER @map("3")
|
|
162
|
+
OWNER @map("4")
|
|
163
|
+
READ_ONLY @map("5")
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
enum InvoiceStatus {
|
|
167
|
+
OPEN @map("0")
|
|
168
|
+
SETTLED @map("1")
|
|
169
|
+
CANCELED @map("2")
|
|
170
|
+
ACCEPTED @map("3")
|
|
171
|
+
EXPIRED @map("4")
|
|
172
|
+
FAILED @map("5")
|
|
173
|
+
ERROR @map("99")
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
enum PaymentStatus {
|
|
177
|
+
IN_FLIGHT @map("1")
|
|
178
|
+
SUCCEEDED @map("2")
|
|
179
|
+
FAILED @map("3")
|
|
180
|
+
INITIATED @map("4")
|
|
181
|
+
}
|