diff --git a/RELEASES.md b/RELEASES.md index 43a56b0..7f44d6c 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -10,6 +10,7 @@ vNext - Fixed: When using the Echo middleware the invoice response status code was 200 OK instead of 402 Payment Required (issue [#30](https://github.com/philippgille/ln-paywall/issues/30)) - Fixed: When using the Echo middleware error responses (including the invoice) were wrapped in JSON instead of just text (issue [#30](https://github.com/philippgille/ln-paywall/issues/30)) +- Fixed: GoDoc for `storage.NewBoltClient(...)` contained usage suggestions that would lead to the possibility of clients cheating with reusing preimages v0.5.1 (2018-10-02) ------------------- diff --git a/storage/bolt.go b/storage/bolt.go index 68d3b0d..09c0159 100644 --- a/storage/bolt.go +++ b/storage/bolt.go @@ -72,16 +72,23 @@ var DefaultBoltOptions = BoltOptions{ // NewBoltClient creates a new BoltClient. // Note: Bolt uses an exclusive write lock on the database file so it cannot be shared by multiple processes. -// This shouldn't be a problem when you use one file for one middleware, like this: +// For preventing clients from cheating (reusing preimages across different endpoints / middlewares that use +// different Bolt DB files) and for the previous mentioned reason you should use only one BoltClient. +// For example: // // ... -// boltClient, err := storage.NewBoltClient(storage.DefaultBoltOptions) // Uses file "ln-paywall.db" +// storageClient, err := storage.NewBoltClient(storage.DefaultBoltOptions) // Uses file "ln-paywall.db" // if err != nil { // panic(err) // } -// defer boltClient.Close() -// r.Use(wall.NewGinMiddleware(invoiceOptions, lndOptions, boltClient)) +// cheapPaywall := wall.NewGinMiddleware(cheapInvoiceOptions, lnClient, storageClient) +// expensivePaywall := wall.NewGinMiddleware(expensiveInvoiceOptions, lnClient, storageClient) +// router.GET("/ping", cheapPaywall, pingHandler) +// router.GET("/compute", expensivePaywall, computeHandler) // // ... -// Also don't worry about closing the Bolt DB, the middleware opens it once and uses it for the duration of its lifetime. +// If you want to start an additional web service, this would be an additional process, so you can't use the same +// DB file. You should look into the other storage options in this case, for example Redis. +// +// Don't worry about closing the Bolt DB, the middleware opens it once and uses it for the duration of its lifetime. // When the web service is stopped, the DB file lock is released automatically. func NewBoltClient(boltOptions BoltOptions) (BoltClient, error) { result := BoltClient{}