@@ -504,7 +504,7 @@ func (s accountBranchChildUpdates) UpdateDB(ctx context.Context, w *Wallet, mayb
504504// nextAddress returns the next address of an account branch.
505505func (w * Wallet ) nextAddress (ctx context.Context , op errors.Op ,
506506 updates * accountBranchChildUpdates , maybeDBTX walletdb.ReadWriteTx ,
507- accountName string , account , branch uint32 ,
507+ account , branch uint32 ,
508508 callOpts ... NextAddressCallOption ) (a stdaddr.Address , rerr error ) {
509509
510510 if updates != nil && maybeDBTX != nil {
@@ -633,6 +633,12 @@ func (w *Wallet) nextAddress(ctx context.Context, op errors.Op,
633633 } else {
634634 return nil , errors .E (op , errors .Bug , "no method to update DB with addresses" )
635635 }
636+
637+ accountName , err := w .AccountName (ctx , account )
638+ if err != nil {
639+ return nil , errors .E (op , err )
640+ }
641+
636642 alb .cursor ++
637643 addr := & xpubAddress {
638644 AddressPubKeyHashEcdsaSecp256k1V0 : apkh ,
@@ -751,10 +757,8 @@ func (w *Wallet) NewExternalAddress(ctx context.Context, account uint32, callOpt
751757 if err := w .notVotingAcct (ctx , op , account ); err != nil {
752758 return nil , err
753759 }
754-
755- accountName , _ := w .AccountName (ctx , account )
756760 return w .nextAddress (ctx , op , nil , nil ,
757- accountName , account , udb .ExternalBranch , callOpts ... )
761+ account , udb .ExternalBranch , callOpts ... )
758762}
759763
760764// NewInternalAddress returns an internal address.
@@ -765,10 +769,8 @@ func (w *Wallet) NewInternalAddress(ctx context.Context, account uint32, callOpt
765769 if err := w .notVotingAcct (ctx , op , account ); err != nil {
766770 return nil , err
767771 }
768-
769- accountName , _ := w .AccountName (ctx , account )
770772 return w .nextAddress (ctx , op , nil , nil ,
771- accountName , account , udb .InternalBranch , callOpts ... )
773+ account , udb .InternalBranch , callOpts ... )
772774}
773775
774776// notVotingAcct errors if an account is a special voting type. This account
@@ -793,7 +795,7 @@ func (w *Wallet) notVotingAcct(ctx context.Context, op errors.Op, account uint32
793795}
794796
795797func (w * Wallet ) newChangeAddress (ctx context.Context , op errors.Op , updates * accountBranchChildUpdates ,
796- maybeDBTX walletdb.ReadWriteTx , accountName string , account uint32 , gap gapPolicy ) (stdaddr.Address , error ) {
798+ maybeDBTX walletdb.ReadWriteTx , account uint32 , gap gapPolicy ) (stdaddr.Address , error ) {
797799
798800 // Imported voting accounts must not be used for change.
799801 if err := w .notVotingAcct (ctx , op , account ); err != nil {
@@ -807,7 +809,7 @@ func (w *Wallet) newChangeAddress(ctx context.Context, op errors.Op, updates *ac
807809 if account == udb .ImportedAddrAccount {
808810 account = udb .DefaultAccountNum
809811 }
810- return w .nextAddress (ctx , op , updates , maybeDBTX , accountName , account , udb .InternalBranch , withGapPolicy (gap ))
812+ return w .nextAddress (ctx , op , updates , maybeDBTX , account , udb .InternalBranch , withGapPolicy (gap ))
811813}
812814
813815// NewChangeAddress returns an internal address. This is identical to
@@ -816,8 +818,7 @@ func (w *Wallet) newChangeAddress(ctx context.Context, op errors.Op, updates *ac
816818// policy.
817819func (w * Wallet ) NewChangeAddress (ctx context.Context , account uint32 ) (stdaddr.Address , error ) {
818820 const op errors.Op = "wallet.NewChangeAddress"
819- accountName , _ := w .AccountName (ctx , account )
820- return w .newChangeAddress (ctx , op , nil , nil , accountName , account , gapPolicyWrap )
821+ return w .newChangeAddress (ctx , op , nil , nil , account , gapPolicyWrap )
821822}
822823
823824// BIP0044BranchNextIndexes returns the next external and internal branch child
@@ -949,9 +950,8 @@ type p2PKHChangeSource struct {
949950}
950951
951952func (src * p2PKHChangeSource ) Script () ([]byte , uint16 , error ) {
952- const accountName = "" // not returned, so can be faked.
953953 changeAddress , err := src .wallet .newChangeAddress (src .ctx , "" , nil , src .dbtx ,
954- accountName , src .account , src .gapPolicy )
954+ src .account , src .gapPolicy )
955955 if err != nil {
956956 return nil , 0 , err
957957 }
@@ -977,9 +977,8 @@ type p2PKHTreasuryChangeSource struct {
977977// Script returns the treasury change script and is required for change source
978978// interface.
979979func (src * p2PKHTreasuryChangeSource ) Script () ([]byte , uint16 , error ) {
980- const accountName = "" // not returned, so can be faked.
981980 changeAddress , err := src .wallet .newChangeAddress (src .ctx , "" , nil , src .dbtx ,
982- accountName , src .account , src .gapPolicy )
981+ src .account , src .gapPolicy )
983982 if err != nil {
984983 return nil , 0 , err
985984 }
0 commit comments