-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds two new tables: blinded_paths and blinded_path_hops. A single invoice can have multiple blinded_path entries and a single blinded_path can have multiple blinded_paths. The commit also adds various queries for the two new tables.
- Loading branch information
1 parent
67f4ead
commit b6e1be7
Showing
6 changed files
with
239 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
DROP TABLE IF EXISTS blinded_paths; | ||
DROP TABLE IF EXISTS blinded_path_hops; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
-- blinded_paths contains information about blinded paths included in the | ||
-- associated invoice. | ||
CREATE TABLE IF NOT EXISTS blinded_paths( | ||
-- The id of the blinded path | ||
id BIGINT PRIMARY KEY, | ||
|
||
-- invoice_id is the reference to the invoice this blinded_path was created | ||
-- for. | ||
invoice_id BIGINT NOT NULL REFERENCES invoices(id) ON DELETE CASCADE, | ||
|
||
-- last_ephemeral_pub is the public key of the last ephemeral blinding | ||
-- point of this path. | ||
last_ephemeral_pub BYTEA NOT NULL UNIQUE, | ||
|
||
-- session_key is the private key used for the first ephemeral blinding | ||
-- key of this path. | ||
session_key BYTEA NOT NULL, | ||
|
||
-- introduction_node is the public key of the first hop of the path. | ||
introduction_node BYTEA NOT NULL, | ||
|
||
-- amount_msat is the total amount in millisatoshis expected to be | ||
-- forwarded along this path. | ||
amount_msat BIGINT NOT NULL | ||
); | ||
|
||
-- blinded_paths_hops holds information about a specific hop of a blinded path in | ||
-- blinded_paths. | ||
CREATE TABLE IF NOT EXISTS blinded_path_hops( | ||
-- blinded_path_id is the reference to the blinded_path_id this | ||
-- blinded_path_hop is part of. | ||
blinded_path_id BIGINT NOT NULL REFERENCES blinded_paths(id) ON DELETE CASCADE, | ||
|
||
-- hop_index is the index of this hop along the associated blinded path. | ||
hop_index BIGINT NOT NULL, | ||
|
||
-- channel_id is the ID of the channel that connects this hop to the previous one. | ||
channel_id BIGINT NOT NULL, | ||
|
||
-- node_pub_key is the public key of the node of this hop | ||
node_pub_key BYTEA NOT NULL, | ||
|
||
-- amount_to_fwd is the amount that this hop was instructed to forward. | ||
amount_to_fwd BIGINT NOT NULL, | ||
|
||
-- The hop_index is unique per path. | ||
UNIQUE (blinded_path_id, hop_index) | ||
); | ||
|
||
CREATE INDEX IF NOT EXISTS blinded_path_hops_path_id_idx ON blinded_path_hops(blinded_path_id); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
-- name: InsertBlindedPath :one | ||
INSERT INTO blinded_paths ( | ||
invoice_id, last_ephemeral_pub, session_key, introduction_node, | ||
amount_msat | ||
) VALUES ( | ||
$1, $2, $3, $4, $5 | ||
) RETURNING id; | ||
|
||
-- name: FetchBlindedPaths :many | ||
SELECT * | ||
FROM blinded_paths | ||
WHERE invoice_id = $1; | ||
|
||
-- name: InsertBlindedPathHop :exec | ||
INSERT INTO blinded_path_hops ( | ||
blinded_path_id, hop_index, channel_id, node_pub_key, | ||
amount_to_fwd | ||
) VALUES ( | ||
$1, $2, $3, $4, $5 | ||
); | ||
|
||
-- name: FetchBlindedPathHops :many | ||
SELECT * | ||
FROM blinded_path_hops | ||
WHERE blinded_path_id = $1 | ||
ORDER BY hop_index; |