lnd/channeldb
Elle Mouton 68264c70d9
channeldb: recover missing db version
Use strict metadata reads during migration selection so a metadata bucket with a
missing metadata/dbp key is not interpreted as the latest DB version.

Recover this state from mandatory DB version 33, the last mandatory version
before the v0.20.x releases that could initialize a DB without writing the DB
version key. This runs migration 35 without replaying migrations 0 through 33
against a DB that was already created by a modern schema/code path.

After the selected migrations complete, syncVersions writes the latest DB
version as usual.
2026-07-22 11:44:01 -07:00
..
migration multi: upgrade to btcd v2 modules 2026-06-24 10:58:36 -07:00
migration12 multi: upgrade to btcd v2 modules 2026-06-24 10:58:36 -07:00
migration13 multi: start updating various loggers to use the new v2 type 2024-10-22 17:03:55 +02:00
migration16 multi: upgrade to btcd v2 modules 2026-06-24 10:58:36 -07:00
migration20 multi: upgrade to btcd v2 modules 2026-06-24 10:58:36 -07:00
migration21 multi: upgrade to btcd v2 modules 2026-06-24 10:58:36 -07:00
migration23 lint: remove redundant loop var copies in test files 2026-06-03 15:32:45 -03:00
migration24 multi: upgrade to btcd v2 modules 2026-06-24 10:58:36 -07:00
migration25 multi: upgrade to btcd v2 modules 2026-06-24 10:58:36 -07:00
migration26 multi: upgrade to btcd v2 modules 2026-06-24 10:58:36 -07:00
migration27 multi: upgrade to btcd v2 modules 2026-06-24 10:58:36 -07:00
migration29 multi: upgrade to btcd v2 modules 2026-06-24 10:58:36 -07:00
migration30 multi: upgrade to btcd v2 modules 2026-06-24 10:58:36 -07:00
migration31 multi: start updating various loggers to use the new v2 type 2024-10-22 17:03:55 +02:00
migration32 multi: upgrade to btcd v2 modules 2026-06-24 10:58:36 -07:00
migration33 multi: start updating various loggers to use the new v2 type 2024-10-22 17:03:55 +02:00
migration34 channeldb: add migration34 2025-06-21 09:20:17 +02:00
migration35 channeldb: make waiting proof migration repeatable 2026-07-22 11:43:45 -07:00
migration_01_to_11 multi: upgrade to btcd v2 modules 2026-06-24 10:58:36 -07:00
migtest multi: update walletdb package 2025-04-09 18:47:53 +02:00
addr_source.go multi: thread context through to AddrsForNode 2025-06-17 19:20:59 +02:00
addr_source_test.go multi: context.Background() -> t.Context() 2025-08-30 14:13:44 -03:00
channel.go chanstate: move open channel type 2026-07-06 15:50:53 -03:00
channel_test.go chanstate: move open channel type 2026-07-06 15:50:53 -03:00
chanstate_assertions.go chanstate: remove store generics 2026-07-06 15:51:20 -03:00
close_channel_test.go channeldb: store channel state by interface 2026-07-06 15:50:52 -03:00
codec.go multi: upgrade to btcd v2 modules 2026-06-24 10:58:36 -07:00
db.go channeldb: recover missing db version 2026-07-22 11:44:01 -07:00
db_test.go chanstate: move open channel type 2026-07-06 15:50:53 -03:00
error.go channeldb: preserve db version during init 2026-07-22 11:43:45 -07:00
forwarding_log.go channeldb: add DeleteForwardingEvents to ForwardingLog 2026-03-27 20:52:59 +01:00
forwarding_log_test.go channeldb: add tests for DeleteForwardingEvents 2026-03-27 20:52:59 +01:00
forwarding_package.go channeldb: document legacy fwd packager interface 2026-07-06 15:51:20 -03:00
forwarding_package_test.go multi: upgrade to btcd v2 modules 2026-06-24 10:58:36 -07:00
forwarding_policy.go multi+refactor: move models package to graph/db 2024-11-28 13:34:33 +02:00
height_hint.go lint: enable copyloopvar and remove redundant loop var copies in non-test files 2026-06-03 15:32:46 -03:00
height_hint_test.go multi: upgrade to btcd v2 modules 2026-06-24 10:58:36 -07:00
invoice_test.go channeldb+lnd: set invoice bucket tombstone after migration 2025-01-23 15:06:09 +01:00
invoices.go lint: enable copyloopvar and remove redundant loop var copies in non-test files 2026-06-03 15:32:46 -03:00
legacy_serialization.go multi: update "funding locked" comments 2023-04-27 20:02:34 +02:00
log.go channeldb: add type-prefix to waiting proof store records 2026-03-17 11:05:22 +02:00
meta.go channeldb: preserve db version during init 2026-07-22 11:43:45 -07:00
meta_test.go channeldb: recover missing db version 2026-07-22 11:44:01 -07:00
nodes.go multi: upgrade to btcd v2 modules 2026-06-24 10:58:36 -07:00
nodes_test.go multi: upgrade to btcd v2 modules 2026-06-24 10:58:36 -07:00
options.go channeldb: add tombstone option and isOutpointClosed helper 2026-05-04 08:58:32 -03:00
paginate.go channeldb: export pagination method 2025-08-14 08:08:50 +02:00
peers.go chanfitness: exit early when there are no updates 2024-11-14 01:22:32 +08:00
peers_test.go multi: replace defer cleanup with t.Cleanup 2022-10-13 17:46:54 +08:00
README.md scripted-diff: replace ⛰ emoji with $ [skip ci] 2022-10-28 12:06:49 -04:00
reports.go multi: upgrade to btcd v2 modules 2026-06-24 10:58:36 -07:00
reports_test.go multi: upgrade to btcd v2 modules 2026-06-24 10:58:36 -07:00
revocation_log.go chanstate: move revocation log types 2026-07-06 15:50:52 -03:00
revocation_log_test.go multi: upgrade to btcd v2 modules 2026-06-24 10:58:36 -07:00
setup_test.go channeldb/test: test with postgres 2021-10-29 10:54:44 +02:00
waitingproof.go channeldb: add V2 (taproot) waiting proof codec support 2026-03-17 11:10:39 +02:00
waitingproof_test.go lint: remove redundant loop var copies in test files 2026-06-03 15:32:45 -03:00
witness_cache.go multi: fix make fmt 2022-08-23 22:10:24 +08:00
witness_cache_test.go multi: replace defer cleanup with t.Cleanup 2022-10-13 17:46:54 +08:00

channeldb

Build Status MIT licensed GoDoc

The channeldb implements the persistent storage engine for lnd and generically a data storage layer for the required state within the Lightning Network. The backing storage engine is boltdb, an embedded pure-go key-value store based off of LMDB.

The package implements an object-oriented storage model with queries and mutations flowing through a particular object instance rather than the database itself. The storage implemented by the objects includes: open channels, past commitment revocation states, the channel graph which includes authenticated node and channel announcements, outgoing payments, and invoices

Installation and Updating

$  go get -u github.com/lightningnetwork/lnd/channeldb