Skip to content

Commit a25753c

Browse files
committed
loopdb: add asset params to store
1 parent 66e97c4 commit a25753c

File tree

7 files changed

+53
-6
lines changed

7 files changed

+53
-6
lines changed

loopdb/sql_store.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,8 @@ func loopOutToInsertArgs(hash lntypes.Hash,
499499
MaxPrepayRoutingFee: int64(loopOut.MaxPrepayRoutingFee),
500500
PublicationDeadline: loopOut.SwapPublicationDeadline.UTC(),
501501
PaymentTimeout: int32(loopOut.PaymentTimeout.Seconds()),
502+
AssetID: loopOut.AssetId,
503+
AssetEdgeNode: loopOut.AssetEdgeNode,
502504
}
503505
}
504506

@@ -595,6 +597,8 @@ func ConvertLoopOutRow(network *chaincfg.Params, row sqlc.GetLoopOutSwapRow,
595597
PaymentTimeout: time.Duration(
596598
row.PaymentTimeout,
597599
) * time.Second,
600+
AssetId: row.AssetID,
601+
AssetEdgeNode: row.AssetEdgeNode,
598602
},
599603
Loop: Loop{
600604
Hash: swapHash,

loopdb/sql_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ const (
2222
testLabel = "test label"
2323
)
2424

25+
var (
26+
testAssetId = []byte{
27+
1, 1, 1, 1, 2, 2, 2, 2,
28+
3, 3, 3, 3, 4, 4, 4, 4,
29+
1, 1, 1, 1, 2, 2, 2, 2,
30+
3, 3, 3, 3, 4, 4, 4, 4,
31+
}
32+
)
33+
2534
// TestSqliteLoopOutStore tests all the basic functionality of the current
2635
// sqlite swap store.
2736
func TestSqliteLoopOutStore(t *testing.T) {
@@ -80,6 +89,13 @@ func TestSqliteLoopOutStore(t *testing.T) {
8089
t.Run("labelled swap", func(t *testing.T) {
8190
testSqliteLoopOutStore(t, &labelledSwap)
8291
})
92+
93+
assetSwap := unrestrictedSwap
94+
assetSwap.AssetId = testAssetId
95+
96+
t.Run("asset swap", func(t *testing.T) {
97+
testSqliteLoopOutStore(t, &assetSwap)
98+
})
8399
}
84100

85101
// testSqliteLoopOutStore tests the basic functionality of the current sqlite
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE loopout_swaps DROP COLUMN asset_id;
2+
ALTER TABLE loopout_swaps DROP COLUMN asset_edge_node;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-- asset_id is an optional field that can be used to specify the asset id that
2+
-- will be used to pay the swap invoice using a taproot assets channel.
3+
ALTER TABLE loopout_swaps ADD asset_id BYTEA;
4+
5+
-- asset_edge_node is an optional field that can be used to specify the node
6+
-- that will be used to route the asset payment through.
7+
ALTER TABLE loopout_swaps ADD asset_edge_node BYTEA;

loopdb/sqlc/models.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

loopdb/sqlc/queries/swaps.sql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,11 @@ INSERT INTO loopout_swaps (
106106
max_prepay_routing_fee,
107107
publication_deadline,
108108
single_sweep,
109-
payment_timeout
109+
payment_timeout,
110+
asset_id,
111+
asset_edge_node
110112
) VALUES (
111-
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12
113+
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14
112114
);
113115

114116
-- name: InsertLoopIn :exec

loopdb/sqlc/swaps.sql.go

Lines changed: 18 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)