-
Notifications
You must be signed in to change notification settings - Fork 2.2k
sqldb: add blinded path tables #9003
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| 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; |
| 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 BLOB NOT NULL UNIQUE, | ||
|
|
||
| -- session_key is the private key used for the first ephemeral blinding | ||
| -- key of this path. | ||
| session_key BLOB NOT NULL, | ||
|
|
||
| -- introduction_node is the public key of the first hop of the path. | ||
| introduction_node BLOB 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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: missing the end point |
||
| node_pub_key BLOB 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.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| 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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: missing the end point