feat(cdk): add payment request and proof to transaction records (#1155)

Add payment_request and payment_proof fields to Transaction model to store Lightning invoice details and payment preimages. Update database migrations and all transaction creation points across wallet operations (mint, melt, send, receive) to populate these fields.
This commit is contained in:
tsk
2025-10-06 14:40:21 +02:00
committed by GitHub
parent c15a79f313
commit c5e5d71701
11 changed files with 54 additions and 9 deletions

View File

@@ -0,0 +1,3 @@
-- Add payment_request and payment_proof to transactions table
ALTER TABLE transactions ADD COLUMN payment_request TEXT;
ALTER TABLE transactions ADD COLUMN payment_proof TEXT;

View File

@@ -0,0 +1,3 @@
-- Add payment_request and payment_proof to transactions table
ALTER TABLE transactions ADD COLUMN payment_request TEXT;
ALTER TABLE transactions ADD COLUMN payment_proof TEXT;

View File

@@ -969,9 +969,9 @@ ON CONFLICT(id) DO UPDATE SET
query(
r#"
INSERT INTO transactions
(id, mint_url, direction, unit, amount, fee, ys, timestamp, memo, metadata, quote_id)
(id, mint_url, direction, unit, amount, fee, ys, timestamp, memo, metadata, quote_id, payment_request, payment_proof)
VALUES
(:id, :mint_url, :direction, :unit, :amount, :fee, :ys, :timestamp, :memo, :metadata, :quote_id)
(:id, :mint_url, :direction, :unit, :amount, :fee, :ys, :timestamp, :memo, :metadata, :quote_id, :payment_request, :payment_proof)
ON CONFLICT(id) DO UPDATE SET
mint_url = excluded.mint_url,
direction = excluded.direction,
@@ -982,7 +982,9 @@ ON CONFLICT(id) DO UPDATE SET
timestamp = excluded.timestamp,
memo = excluded.memo,
metadata = excluded.metadata,
quote_id = excluded.quote_id
quote_id = excluded.quote_id,
payment_request = excluded.payment_request,
payment_proof = excluded.payment_proof
;
"#,
)?
@@ -1000,6 +1002,8 @@ ON CONFLICT(id) DO UPDATE SET
serde_json::to_string(&transaction.metadata).map_err(Error::from)?,
)
.bind("quote_id", transaction.quote_id)
.bind("payment_request", transaction.payment_request)
.bind("payment_proof", transaction.payment_proof)
.execute(&*conn)
.await?;
@@ -1024,7 +1028,9 @@ ON CONFLICT(id) DO UPDATE SET
timestamp,
memo,
metadata,
quote_id
quote_id,
payment_request,
payment_proof
FROM
transactions
WHERE
@@ -1059,7 +1065,9 @@ ON CONFLICT(id) DO UPDATE SET
timestamp,
memo,
metadata,
quote_id
quote_id,
payment_request,
payment_proof
FROM
transactions
"#,
@@ -1297,7 +1305,9 @@ fn sql_row_to_transaction(row: Vec<Column>) -> Result<Transaction, Error> {
timestamp,
memo,
metadata,
quote_id
quote_id,
payment_request,
payment_proof
) = row
);
@@ -1321,5 +1331,7 @@ fn sql_row_to_transaction(row: Vec<Column>) -> Result<Transaction, Error> {
})
.unwrap_or_default(),
quote_id: column_as_nullable_string!(quote_id),
payment_request: column_as_nullable_string!(payment_request),
payment_proof: column_as_nullable_string!(payment_proof),
})
}