@@ -1225,6 +1225,26 @@ func (d *DefaultDatabaseBuilder) BuildDatabase(
12251225
12261226 return nil , nil , err
12271227 }
1228+
1229+ // Create the payments DB.
1230+ //
1231+ // NOTE: In the regular build, this will construct a kvdb
1232+ // backed payments backend. With the test_native_sql tag, it
1233+ // will build a SQL payments backend.
1234+ sqlPaymentsDB , err := d .getPaymentsStore (
1235+ baseDB , dbs .ChanStateDB .Backend ,
1236+ paymentsdb .WithKeepFailedPaymentAttempts (
1237+ cfg .KeepFailedPaymentAttempts ,
1238+ ),
1239+ )
1240+ if err != nil {
1241+ err = fmt .Errorf ("unable to get payments store: %w" ,
1242+ err )
1243+
1244+ return nil , nil , err
1245+ }
1246+
1247+ dbs .PaymentsDB = sqlPaymentsDB
12281248 } else {
12291249 // Check if the invoice bucket tombstone is set. If it is, we
12301250 // need to return and ask the user switch back to using the
@@ -1253,40 +1273,35 @@ func (d *DefaultDatabaseBuilder) BuildDatabase(
12531273 if err != nil {
12541274 return nil , nil , err
12551275 }
1256- }
12571276
1258- dbs .GraphDB , err = graphdb .NewChannelGraph (graphStore , chanGraphOpts ... )
1259- if err != nil {
1260- cleanUp ()
1277+ // Create the payments DB.
1278+ kvPaymentsDB , err := paymentsdb .NewKVStore (
1279+ dbs .ChanStateDB ,
1280+ paymentsdb .WithKeepFailedPaymentAttempts (
1281+ cfg .KeepFailedPaymentAttempts ,
1282+ ),
1283+ )
1284+ if err != nil {
1285+ cleanUp ()
12611286
1262- err = fmt .Errorf ("unable to open channel graph DB: %w" , err )
1263- d .logger .Error (err )
1287+ err = fmt .Errorf ("unable to open payments DB: %w" , err )
1288+ d .logger .Error (err )
12641289
1265- return nil , nil , err
1266- }
1290+ return nil , nil , err
1291+ }
12671292
1268- // Mount the payments DB which is only KV for now.
1269- //
1270- // TODO(ziggie): Add support for SQL payments DB.
1271- // Mount the payments DB for the KV store.
1272- paymentsDBOptions := []paymentsdb.OptionModifier {
1273- paymentsdb .WithKeepFailedPaymentAttempts (
1274- cfg .KeepFailedPaymentAttempts ,
1275- ),
1293+ dbs .PaymentsDB = kvPaymentsDB
12761294 }
1277- kvPaymentsDB , err := paymentsdb .NewKVStore (
1278- dbs .ChanStateDB ,
1279- paymentsDBOptions ... ,
1280- )
1295+
1296+ dbs .GraphDB , err = graphdb .NewChannelGraph (graphStore , chanGraphOpts ... )
12811297 if err != nil {
12821298 cleanUp ()
12831299
1284- err = fmt .Errorf ("unable to open payments DB: %w" , err )
1300+ err = fmt .Errorf ("unable to open channel graph DB: %w" , err )
12851301 d .logger .Error (err )
12861302
12871303 return nil , nil , err
12881304 }
1289- dbs .PaymentsDB = kvPaymentsDB
12901305
12911306 // Wrap the watchtower client DB and make sure we clean up.
12921307 if cfg .WtClient .Active {
0 commit comments