Skip to content

Commit

Permalink
asset/dcr: use connect context for dcr dex wallet
Browse files Browse the repository at this point in the history
Signed-off-by: Philemon Ukane <[email protected]>
  • Loading branch information
ukane-philemon committed May 4, 2024
1 parent a247b2f commit fd7d1b8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions libwallet/assets/dcr/dex_wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (

// DEXWallet wraps *Asset and implements dexdcr.Wallet.
type DEXWallet struct {
ctx context.Context
w *dcrwallet.Wallet
helper WalletHelper
tradingAccountNumber int32
Expand Down Expand Up @@ -60,7 +61,8 @@ func NewDEXWallet(w *dcrwallet.Wallet, helper WalletHelper, tradingAccountNumber

// Connect establishes a connection to the wallet.
// Part of the Wallet interface.
func (dw *DEXWallet) Connect(_ context.Context) error {
func (dw *DEXWallet) Connect(ctx context.Context) error {
dw.ctx = ctx
return nil
}

Expand All @@ -78,7 +80,7 @@ func (dw *DEXWallet) SpvMode() bool {
// Accounts returns the names of the accounts for use by the exchange wallet.
func (dw *DEXWallet) Accounts() dexdcr.XCWalletAccounts {
var accts dexdcr.XCWalletAccounts
accountName, err := dw.w.AccountName(context.Background(), uint32(dw.tradingAccountNumber))
accountName, err := dw.w.AccountName(dw.ctx, uint32(dw.tradingAccountNumber))
if err == nil {
accts.PrimaryAccount = accountName
} else {
Expand All @@ -91,13 +93,13 @@ func (dw *DEXWallet) Accounts() dexdcr.XCWalletAccounts {

unMixedAcctNum := dw.helper.UnmixedAccountNumber()
mixedAcctNum := dw.helper.MixedAccountNumber()
unMixedAcctName, err := dw.w.AccountName(context.Background(), uint32(unMixedAcctNum))
unMixedAcctName, err := dw.w.AccountName(dw.ctx, uint32(unMixedAcctNum))
if err != nil {
log.Errorf("error retrieving unmixed account name: %v", err)
return accts
}

mixedAcctName, err := dw.w.AccountName(context.Background(), uint32(mixedAcctNum))
mixedAcctName, err := dw.w.AccountName(dw.ctx, uint32(mixedAcctNum))
if err != nil {
log.Errorf("error retrieving mixed account name: %v", err)
return accts
Expand Down

0 comments on commit fd7d1b8

Please sign in to comment.