Skip to content

Commit

Permalink
undo spvWallet.acctNum removal
Browse files Browse the repository at this point in the history
Signed-off-by: Philemon Ukane <[email protected]>
  • Loading branch information
ukane-philemon committed Jan 4, 2024
1 parent b4129a8 commit 19a8ee7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions client/asset/btc/btc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1307,6 +1307,9 @@ func OpenSPVWallet(cfg *BTCCloneCFG, walletConstructor BTCWalletConstructor) (*E
spvw.wallet = walletConstructor(spvw.dir, spvw.cfg, spvw.chainParams, spvw.log)
btc.setNode(spvw)

// Set account number for easy reference.
spvw.acctNum = spvw.wallet.AccountInfo().AccountNumber

w := &ExchangeWalletSPV{
intermediaryWallet: &intermediaryWallet{
baseWallet: btc,
Expand Down
1 change: 1 addition & 0 deletions client/asset/btc/btc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,7 @@ func tNewWallet(segwit bool, walletType string) (*intermediaryWallet, *testData,
cfg: &WalletConfig{},
wallet: &tBtcWallet{data},
cl: neutrinoClient,
acctNum: 0,
tipChan: make(chan *BlockVector, 1),
txBlocks: data.dbBlockForTx,
checkpoints: data.checkpoints,
Expand Down
7 changes: 4 additions & 3 deletions client/asset/btc/spv_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ type spvWallet struct {
cfg *WalletConfig
wallet BTCWallet
cl SPVService
acctNum uint32
dir string
decodeAddr dexbtc.AddressDecoder

Expand Down Expand Up @@ -730,13 +731,13 @@ func (w *spvWallet) listLockUnspent() ([]*RPCOutpoint, error) {
// changeAddress gets a new internal address from the wallet. The address will
// be bech32-encoded (P2WPKH).
func (w *spvWallet) changeAddress() (btcutil.Address, error) {
return w.wallet.NewChangeAddress(w.wallet.AccountInfo().AccountNumber, waddrmgr.KeyScopeBIP0084)
return w.wallet.NewChangeAddress(w.acctNum, waddrmgr.KeyScopeBIP0084)
}

// externalAddress gets a new bech32-encoded (P2WPKH) external address from the
// wallet.
func (w *spvWallet) externalAddress() (btcutil.Address, error) {
return w.wallet.NewAddress(w.wallet.AccountInfo().AccountNumber, waddrmgr.KeyScopeBIP0084)
return w.wallet.NewAddress(w.acctNum, waddrmgr.KeyScopeBIP0084)
}

// signTx attempts to have the wallet sign the transaction inputs.
Expand Down Expand Up @@ -1137,7 +1138,7 @@ func copyDir(src, dst string) error {
// numDerivedAddresses returns the number of internal and external addresses
// that the wallet has derived.
func (w *spvWallet) numDerivedAddresses() (internal, external uint32, err error) {
props, err := w.wallet.AccountProperties(waddrmgr.KeyScopeBIP0084, w.wallet.AccountInfo().AccountNumber)
props, err := w.wallet.AccountProperties(waddrmgr.KeyScopeBIP0084, w.acctNum)
if err != nil {
return 0, 0, err
}
Expand Down

0 comments on commit 19a8ee7

Please sign in to comment.