@@ -97,7 +97,7 @@ type WalletConfigBuilder interface {
9797 BuildWalletConfig (context.Context , * DatabaseInstances ,
9898 * rpcperms.InterceptorChain ,
9999 []* ListenerWithSignal ) (* chainreg.PartialChainControl ,
100- * btcwallet.Config , func (), error )
100+ * btcwallet.Config , func (), [] byte , error )
101101}
102102
103103// ChainControlBuilder is an interface that must be satisfied by a custom wallet
@@ -220,7 +220,7 @@ func (d *DefaultWalletImpl) Permissions() map[string][]bakery.Op {
220220func (d * DefaultWalletImpl ) BuildWalletConfig (ctx context.Context ,
221221 dbs * DatabaseInstances , interceptorChain * rpcperms.InterceptorChain ,
222222 grpcListeners []* ListenerWithSignal ) (* chainreg.PartialChainControl ,
223- * btcwallet.Config , func (), error ) {
223+ * btcwallet.Config , func (), [] byte , error ) {
224224
225225 // Keep track of our various cleanup functions. We use a defer function
226226 // as well to not repeat ourselves with every return statement.
@@ -262,7 +262,7 @@ func (d *DefaultWalletImpl) BuildWalletConfig(ctx context.Context,
262262 err := fmt .Errorf ("unable to initialize neutrino " +
263263 "backend: %v" , err )
264264 d .logger .Error (err )
265- return nil , nil , nil , err
265+ return nil , nil , nil , nil , err
266266 }
267267 cleanUpTasks = append (cleanUpTasks , neutrinoCleanUp )
268268 neutrinoCS = neutrinoBackend
@@ -287,7 +287,7 @@ func (d *DefaultWalletImpl) BuildWalletConfig(ctx context.Context,
287287 d .pwService .SetMacaroonDB (dbs .MacaroonDB )
288288 walletExists , err := d .pwService .WalletExists ()
289289 if err != nil {
290- return nil , nil , nil , err
290+ return nil , nil , nil , nil , err
291291 }
292292
293293 if ! walletExists {
@@ -304,7 +304,7 @@ func (d *DefaultWalletImpl) BuildWalletConfig(ctx context.Context,
304304 if d .cfg .WalletUnlockPasswordFile != "" && ! walletExists &&
305305 ! d .cfg .WalletUnlockAllowCreate {
306306
307- return nil , nil , nil , fmt .Errorf ("wallet unlock password file " +
307+ return nil , nil , nil , nil , fmt .Errorf ("wallet unlock password file " +
308308 "was specified but wallet does not exist; initialize " +
309309 "the wallet before using auto unlocking" )
310310 }
@@ -323,7 +323,7 @@ func (d *DefaultWalletImpl) BuildWalletConfig(ctx context.Context,
323323 "password provided in file" )
324324 pwBytes , err := ioutil .ReadFile (d .cfg .WalletUnlockPasswordFile )
325325 if err != nil {
326- return nil , nil , nil , fmt .Errorf ("error reading " +
326+ return nil , nil , nil , nil , fmt .Errorf ("error reading " +
327327 "password from file %s: %v" ,
328328 d .cfg .WalletUnlockPasswordFile , err )
329329 }
@@ -339,7 +339,7 @@ func (d *DefaultWalletImpl) BuildWalletConfig(ctx context.Context,
339339 pwBytes , 0 ,
340340 )
341341 if err != nil {
342- return nil , nil , nil , fmt .Errorf ("error unlocking " +
342+ return nil , nil , nil , nil , fmt .Errorf ("error unlocking " +
343343 "wallet with password from file: %v" , err )
344344 }
345345
@@ -360,7 +360,7 @@ func (d *DefaultWalletImpl) BuildWalletConfig(ctx context.Context,
360360 // over RPC.
361361 default :
362362 if err := d .interceptor .Notifier .NotifyReady (false ); err != nil {
363- return nil , nil , nil , err
363+ return nil , nil , nil , nil , err
364364 }
365365
366366 params , err := waitForWalletPassword (
@@ -371,7 +371,7 @@ func (d *DefaultWalletImpl) BuildWalletConfig(ctx context.Context,
371371 err := fmt .Errorf ("unable to set up wallet password " +
372372 "listeners: %v" , err )
373373 d .logger .Error (err )
374- return nil , nil , nil , err
374+ return nil , nil , nil , nil , err
375375 }
376376
377377 walletInitParams = * params
@@ -391,7 +391,10 @@ func (d *DefaultWalletImpl) BuildWalletConfig(ctx context.Context,
391391 }
392392 }
393393
394- var macaroonService * macaroons.Service
394+ var (
395+ macaroonService * macaroons.Service
396+ adminMacBytes []byte
397+ )
395398 if ! d .cfg .NoMacaroons {
396399 // Create the macaroon authentication/authorization service.
397400 macaroonService , err = macaroons .NewService (
@@ -403,7 +406,7 @@ func (d *DefaultWalletImpl) BuildWalletConfig(ctx context.Context,
403406 err := fmt .Errorf ("unable to set up macaroon " +
404407 "authentication: %v" , err )
405408 d .logger .Error (err )
406- return nil , nil , nil , err
409+ return nil , nil , nil , nil , err
407410 }
408411 cleanUpTasks = append (cleanUpTasks , func () {
409412 if err := macaroonService .Close (); err != nil {
@@ -419,7 +422,7 @@ func (d *DefaultWalletImpl) BuildWalletConfig(ctx context.Context,
419422 if err != nil && err != macaroons .ErrAlreadyUnlocked {
420423 err := fmt .Errorf ("unable to unlock macaroons: %v" , err )
421424 d .logger .Error (err )
422- return nil , nil , nil , err
425+ return nil , nil , nil , nil , err
423426 }
424427
425428 // In case we actually needed to unlock the wallet, we now need
@@ -428,11 +431,11 @@ func (d *DefaultWalletImpl) BuildWalletConfig(ctx context.Context,
428431 // backup mode, there's nobody listening on the channel and we'd
429432 // block here forever.
430433 if ! d .cfg .NoSeedBackup {
431- adminMacBytes , err : = bakeMacaroon (
434+ adminMacBytes , err = bakeMacaroon (
432435 ctx , macaroonService , adminPermissions (),
433436 )
434437 if err != nil {
435- return nil , nil , nil , err
438+ return nil , nil , nil , nil , err
436439 }
437440
438441 // The channel is buffered by one element so writing
@@ -463,7 +466,7 @@ func (d *DefaultWalletImpl) BuildWalletConfig(ctx context.Context,
463466 err := fmt .Errorf ("unable to create macaroons " +
464467 "%v" , err )
465468 d .logger .Error (err )
466- return nil , nil , nil , err
469+ return nil , nil , nil , nil , err
467470 }
468471 }
469472
@@ -555,7 +558,7 @@ func (d *DefaultWalletImpl) BuildWalletConfig(ctx context.Context,
555558 err := fmt .Errorf ("unable to create partial chain control: %v" ,
556559 err )
557560 d .logger .Error (err )
558- return nil , nil , nil , err
561+ return nil , nil , nil , nil , err
559562 }
560563
561564 walletConfig := & btcwallet.Config {
@@ -580,12 +583,12 @@ func (d *DefaultWalletImpl) BuildWalletConfig(ctx context.Context,
580583 walletConfig .CoinSelectionStrategy = wallet .CoinSelectionRandom
581584
582585 default :
583- return nil , nil , nil , fmt .Errorf ("unknown coin selection " +
586+ return nil , nil , nil , nil , fmt .Errorf ("unknown coin selection " +
584587 "strategy %v" , d .cfg .CoinSelectionStrategy )
585588 }
586589
587590 earlyExit = false
588- return partialChainControl , walletConfig , cleanUp , nil
591+ return partialChainControl , walletConfig , cleanUp , adminMacBytes , nil
589592}
590593
591594// BuildChainControl is responsible for creating a fully populated chain
0 commit comments