diff --git a/kvdb/kvdb_no_postgres.go b/kvdb/kvdb_no_postgres.go index d581c2b55..740f6a276 100644 --- a/kvdb/kvdb_no_postgres.go +++ b/kvdb/kvdb_no_postgres.go @@ -1,3 +1,4 @@ +//go:build !kvdb_postgres // +build !kvdb_postgres package kvdb diff --git a/kvdb/kvdb_postgres.go b/kvdb/kvdb_postgres.go index 023a51840..b0d2edee8 100644 --- a/kvdb/kvdb_postgres.go +++ b/kvdb/kvdb_postgres.go @@ -1,3 +1,4 @@ +//go:build kvdb_postgres // +build kvdb_postgres package kvdb diff --git a/kvdb/postgres/db.go b/kvdb/postgres/db.go index 3276fb557..d2e59bf0c 100644 --- a/kvdb/postgres/db.go +++ b/kvdb/postgres/db.go @@ -1,3 +1,4 @@ +//go:build kvdb_postgres // +build kvdb_postgres package postgres diff --git a/kvdb/postgres/db_test.go b/kvdb/postgres/db_test.go index dab6bf447..84c2b6503 100644 --- a/kvdb/postgres/db_test.go +++ b/kvdb/postgres/db_test.go @@ -1,3 +1,4 @@ +//go:build kvdb_postgres // +build kvdb_postgres package postgres diff --git a/kvdb/postgres/driver.go b/kvdb/postgres/driver.go index 601c0195c..1792eb652 100644 --- a/kvdb/postgres/driver.go +++ b/kvdb/postgres/driver.go @@ -1,3 +1,4 @@ +//go:build kvdb_postgres // +build kvdb_postgres package postgres diff --git a/kvdb/postgres/fixture.go b/kvdb/postgres/fixture.go index 9257f49aa..fe6c323d5 100644 --- a/kvdb/postgres/fixture.go +++ b/kvdb/postgres/fixture.go @@ -1,3 +1,4 @@ +//go:build kvdb_postgres // +build kvdb_postgres package postgres diff --git a/kvdb/postgres/readwrite_bucket.go b/kvdb/postgres/readwrite_bucket.go index b0fb57833..131151d86 100644 --- a/kvdb/postgres/readwrite_bucket.go +++ b/kvdb/postgres/readwrite_bucket.go @@ -1,3 +1,4 @@ +//go:build kvdb_postgres // +build kvdb_postgres package postgres diff --git a/kvdb/postgres/readwrite_cursor.go b/kvdb/postgres/readwrite_cursor.go index 8b95f6470..d56363bbf 100644 --- a/kvdb/postgres/readwrite_cursor.go +++ b/kvdb/postgres/readwrite_cursor.go @@ -1,3 +1,4 @@ +//go:build kvdb_postgres // +build kvdb_postgres package postgres diff --git a/kvdb/postgres/readwrite_tx.go b/kvdb/postgres/readwrite_tx.go index 0b20e19d3..99701a7a8 100644 --- a/kvdb/postgres/readwrite_tx.go +++ b/kvdb/postgres/readwrite_tx.go @@ -1,3 +1,4 @@ +//go:build kvdb_postgres // +build kvdb_postgres package postgres diff --git a/kvdb/postgres_test.go b/kvdb/postgres_test.go index 445f71b73..b26bba537 100644 --- a/kvdb/postgres_test.go +++ b/kvdb/postgres_test.go @@ -1,3 +1,4 @@ +//go:build kvdb_postgres // +build kvdb_postgres package kvdb @@ -35,13 +36,13 @@ func TestPostgres(t *testing.T) { test: testReadWriteCursor, expectedDb: m{ "test_kv": []m{ - m{"id": int64(1), "key": "apple", "parent_id": nil, "sequence": nil, "value": nil}, - m{"id": int64(4), "key": "da", "parent_id": int64(1), "sequence": nil, "value": "3"}, - m{"id": int64(6), "key": "a", "parent_id": int64(1), "sequence": nil, "value": "0"}, - m{"id": int64(7), "key": "f", "parent_id": int64(1), "sequence": nil, "value": "5"}, - m{"id": int64(3), "key": "c", "parent_id": int64(1), "sequence": nil, "value": "3"}, - m{"id": int64(9), "key": "cx", "parent_id": int64(1), "sequence": nil, "value": "x"}, - m{"id": int64(10), "key": "cy", "parent_id": int64(1), "sequence": nil, "value": "y"}, + {"id": int64(1), "key": "apple", "parent_id": nil, "sequence": nil, "value": nil}, + {"id": int64(4), "key": "da", "parent_id": int64(1), "sequence": nil, "value": "3"}, + {"id": int64(6), "key": "a", "parent_id": int64(1), "sequence": nil, "value": "0"}, + {"id": int64(7), "key": "f", "parent_id": int64(1), "sequence": nil, "value": "5"}, + {"id": int64(3), "key": "c", "parent_id": int64(1), "sequence": nil, "value": "3"}, + {"id": int64(9), "key": "cx", "parent_id": int64(1), "sequence": nil, "value": "x"}, + {"id": int64(10), "key": "cy", "parent_id": int64(1), "sequence": nil, "value": "y"}, }, }, }, @@ -50,10 +51,10 @@ func TestPostgres(t *testing.T) { test: testReadWriteCursorWithBucketAndValue, expectedDb: m{ "test_kv": []m{ - m{"id": int64(1), "key": "apple", "parent_id": nil, "sequence": nil, "value": nil}, - m{"id": int64(2), "key": "key", "parent_id": int64(1), "sequence": nil, "value": "val"}, - m{"id": int64(3), "key": "banana", "parent_id": int64(1), "sequence": nil, "value": nil}, - m{"id": int64(4), "key": "pear", "parent_id": int64(1), "sequence": nil, "value": nil}, + {"id": int64(1), "key": "apple", "parent_id": nil, "sequence": nil, "value": nil}, + {"id": int64(2), "key": "key", "parent_id": int64(1), "sequence": nil, "value": "val"}, + {"id": int64(3), "key": "banana", "parent_id": int64(1), "sequence": nil, "value": nil}, + {"id": int64(4), "key": "pear", "parent_id": int64(1), "sequence": nil, "value": nil}, }, }, }, @@ -62,10 +63,10 @@ func TestPostgres(t *testing.T) { test: testBucketCreation, expectedDb: m{ "test_kv": []m{ - m{"id": int64(1), "key": "apple", "parent_id": nil, "sequence": nil, "value": nil}, - m{"id": int64(2), "key": "banana", "parent_id": int64(1), "sequence": nil, "value": nil}, - m{"id": int64(3), "key": "mango", "parent_id": int64(1), "sequence": nil, "value": nil}, - m{"id": int64(4), "key": "pear", "parent_id": int64(2), "sequence": nil, "value": nil}, + {"id": int64(1), "key": "apple", "parent_id": nil, "sequence": nil, "value": nil}, + {"id": int64(2), "key": "banana", "parent_id": int64(1), "sequence": nil, "value": nil}, + {"id": int64(3), "key": "mango", "parent_id": int64(1), "sequence": nil, "value": nil}, + {"id": int64(4), "key": "pear", "parent_id": int64(2), "sequence": nil, "value": nil}, }, }, }, @@ -74,10 +75,10 @@ func TestPostgres(t *testing.T) { test: testBucketDeletion, expectedDb: m{ "test_kv": []m{ - m{"id": int64(1), "key": "apple", "parent_id": nil, "sequence": nil, "value": nil}, - m{"id": int64(2), "key": "banana", "parent_id": int64(1), "sequence": nil, "value": nil}, - m{"id": int64(3), "key": "key1", "parent_id": int64(2), "sequence": nil, "value": "val1"}, - m{"id": int64(5), "key": "key3", "parent_id": int64(2), "sequence": nil, "value": "val3"}, + {"id": int64(1), "key": "apple", "parent_id": nil, "sequence": nil, "value": nil}, + {"id": int64(2), "key": "banana", "parent_id": int64(1), "sequence": nil, "value": nil}, + {"id": int64(3), "key": "key1", "parent_id": int64(2), "sequence": nil, "value": "val1"}, + {"id": int64(5), "key": "key3", "parent_id": int64(2), "sequence": nil, "value": "val3"}, }, }, }, @@ -86,14 +87,14 @@ func TestPostgres(t *testing.T) { test: testBucketForEach, expectedDb: m{ "test_kv": []m{ - m{"id": int64(1), "key": "apple", "parent_id": nil, "sequence": nil, "value": nil}, - m{"id": int64(2), "key": "banana", "parent_id": int64(1), "sequence": nil, "value": nil}, - m{"id": int64(3), "key": "key1", "parent_id": int64(1), "sequence": nil, "value": "val1"}, - m{"id": int64(4), "key": "key1", "parent_id": int64(2), "sequence": nil, "value": "val1"}, - m{"id": int64(5), "key": "key2", "parent_id": int64(1), "sequence": nil, "value": "val2"}, - m{"id": int64(6), "key": "key2", "parent_id": int64(2), "sequence": nil, "value": "val2"}, - m{"id": int64(7), "key": "key3", "parent_id": int64(1), "sequence": nil, "value": "val3"}, - m{"id": int64(8), "key": "key3", "parent_id": int64(2), "sequence": nil, "value": "val3"}, + {"id": int64(1), "key": "apple", "parent_id": nil, "sequence": nil, "value": nil}, + {"id": int64(2), "key": "banana", "parent_id": int64(1), "sequence": nil, "value": nil}, + {"id": int64(3), "key": "key1", "parent_id": int64(1), "sequence": nil, "value": "val1"}, + {"id": int64(4), "key": "key1", "parent_id": int64(2), "sequence": nil, "value": "val1"}, + {"id": int64(5), "key": "key2", "parent_id": int64(1), "sequence": nil, "value": "val2"}, + {"id": int64(6), "key": "key2", "parent_id": int64(2), "sequence": nil, "value": "val2"}, + {"id": int64(7), "key": "key3", "parent_id": int64(1), "sequence": nil, "value": "val3"}, + {"id": int64(8), "key": "key3", "parent_id": int64(2), "sequence": nil, "value": "val3"}, }, }, }, @@ -102,11 +103,11 @@ func TestPostgres(t *testing.T) { test: testBucketForEachWithError, expectedDb: m{ "test_kv": []m{ - m{"id": int64(1), "key": "apple", "parent_id": nil, "sequence": nil, "value": nil}, - m{"id": int64(2), "key": "banana", "parent_id": int64(1), "sequence": nil, "value": nil}, - m{"id": int64(3), "key": "pear", "parent_id": int64(1), "sequence": nil, "value": nil}, - m{"id": int64(4), "key": "key1", "parent_id": int64(1), "sequence": nil, "value": "val1"}, - m{"id": int64(5), "key": "key2", "parent_id": int64(1), "sequence": nil, "value": "val2"}, + {"id": int64(1), "key": "apple", "parent_id": nil, "sequence": nil, "value": nil}, + {"id": int64(2), "key": "banana", "parent_id": int64(1), "sequence": nil, "value": nil}, + {"id": int64(3), "key": "pear", "parent_id": int64(1), "sequence": nil, "value": nil}, + {"id": int64(4), "key": "key1", "parent_id": int64(1), "sequence": nil, "value": "val1"}, + {"id": int64(5), "key": "key2", "parent_id": int64(1), "sequence": nil, "value": "val2"}, }, }, }, @@ -115,8 +116,8 @@ func TestPostgres(t *testing.T) { test: testBucketSequence, expectedDb: m{ "test_kv": []m{ - m{"id": int64(2), "key": "banana", "parent_id": int64(1), "sequence": nil, "value": nil}, - m{"id": int64(1), "key": "apple", "parent_id": nil, "sequence": int64(4), "value": nil}, + {"id": int64(2), "key": "banana", "parent_id": int64(1), "sequence": nil, "value": nil}, + {"id": int64(1), "key": "apple", "parent_id": nil, "sequence": int64(4), "value": nil}, }, }, }, @@ -125,9 +126,9 @@ func TestPostgres(t *testing.T) { test: testKeyClash, expectedDb: m{ "test_kv": []m{ - m{"id": int64(1), "key": "apple", "parent_id": nil, "sequence": nil, "value": nil}, - m{"id": int64(2), "key": "key", "parent_id": int64(1), "sequence": nil, "value": "val"}, - m{"id": int64(3), "key": "banana", "parent_id": int64(1), "sequence": nil, "value": nil}, + {"id": int64(1), "key": "apple", "parent_id": nil, "sequence": nil, "value": nil}, + {"id": int64(2), "key": "key", "parent_id": int64(1), "sequence": nil, "value": "val"}, + {"id": int64(3), "key": "banana", "parent_id": int64(1), "sequence": nil, "value": nil}, }, }, }, @@ -136,8 +137,8 @@ func TestPostgres(t *testing.T) { test: testBucketCreateDelete, expectedDb: m{ "test_kv": []m{ - m{"id": int64(1), "key": "apple", "parent_id": nil, "sequence": nil, "value": nil}, - m{"id": int64(3), "key": "banana", "parent_id": int64(1), "sequence": nil, "value": "value"}, + {"id": int64(1), "key": "apple", "parent_id": nil, "sequence": nil, "value": nil}, + {"id": int64(3), "key": "banana", "parent_id": int64(1), "sequence": nil, "value": "value"}, }, }, }, @@ -146,8 +147,8 @@ func TestPostgres(t *testing.T) { test: testTxManualCommit, expectedDb: m{ "test_kv": []m{ - m{"id": int64(1), "key": "apple", "parent_id": nil, "sequence": nil, "value": nil}, - m{"id": int64(2), "key": "testKey", "parent_id": int64(1), "sequence": nil, "value": "testVal"}, + {"id": int64(1), "key": "apple", "parent_id": nil, "sequence": nil, "value": nil}, + {"id": int64(2), "key": "testKey", "parent_id": int64(1), "sequence": nil, "value": "testVal"}, }, }, }, diff --git a/macaroons/service.go b/macaroons/service.go index 3daccf0e2..c0c0c2cbe 100644 --- a/macaroons/service.go +++ b/macaroons/service.go @@ -4,6 +4,7 @@ import ( "context" "encoding/hex" "fmt" + "github.com/lightningnetwork/lnd/kvdb" "google.golang.org/grpc/metadata" "gopkg.in/macaroon-bakery.v2/bakery"