Skip to content

Commit

Permalink
revert AccountInfo changes in d7a5488
Browse files Browse the repository at this point in the history
Signed-off-by: Philemon Ukane <[email protected]>
  • Loading branch information
ukane-philemon committed Jul 2, 2024
1 parent dec0cbf commit 6ba3240
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 61 deletions.
18 changes: 4 additions & 14 deletions client/asset/bch/spv.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,10 @@ import (
)

const (
DefaultM uint64 = 784931 // From bchutil. Used for gcs filters.
logDirName = "logs"
neutrinoDBName = "neutrino.db"
defaultAcctNum = 0
defaultAcctName = "default"
DefaultM uint64 = 784931 // From bchutil. Used for gcs filters.
logDirName = "logs"
neutrinoDBName = "neutrino.db"
defaultAcctNum = 0
)

var (
Expand Down Expand Up @@ -248,15 +247,6 @@ func (w *bchSPVWallet) txDetails(txHash *bchchainhash.Hash) (*bchwtxmgr.TxDetail

var _ btc.BTCWallet = (*bchSPVWallet)(nil)

// AccountInfo returns the account information of the wallet for use by the
// exchange wallet.
func (w *bchSPVWallet) AccountInfo() btc.XCWalletAccount {
return btc.XCWalletAccount{
AccountName: defaultAcctName,
AccountNumber: defaultAcctNum,
}
}

func (w *bchSPVWallet) PublishTransaction(btcTx *wire.MsgTx, label string) error {
bchTx, err := convertMsgTxToBCH(btcTx)
if err != nil {
Expand Down
5 changes: 2 additions & 3 deletions client/asset/btc/btc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1415,6 +1415,8 @@ func OpenSPVWallet(cfg *BTCCloneCFG, walletConstructor BTCWalletConstructor) (*E
spvw := &spvWallet{
chainParams: cfg.ChainParams,
cfg: walletCfg,
acctNum: defaultAcctNum,
acctName: defaultAcctName,
dir: filepath.Join(cfg.WalletCFG.DataDir, cfg.ChainParams.Name),
log: cfg.Logger.SubLogger("SPV"),
tipChan: make(chan *BlockVector, 8),
Expand All @@ -1425,9 +1427,6 @@ 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
9 changes: 0 additions & 9 deletions client/asset/btc/spv.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,6 @@ func openSPVWallet(dir string, cfg *WalletConfig,
return w
}

// AccountInfo returns the account information of the wallet for use by the
// exchange wallet.
func (w *btcSPVWallet) AccountInfo() XCWalletAccount {
return XCWalletAccount{
AccountName: defaultAcctName,
AccountNumber: defaultAcctNum,
}
}

func (w *btcSPVWallet) Birthday() time.Time {
return w.Manager.Birthday()
}
Expand Down
9 changes: 1 addition & 8 deletions client/asset/btc/spv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,7 @@ type tBtcWallet struct {
*testData
}

func (c *tBtcWallet) AccountInfo() XCWalletAccount {
return XCWalletAccount{
AccountName: defaultAcctName,
AccountNumber: defaultAcctNum,
}
}

func (c *tBtcWallet) GetTransactions(startBlock, endBlock int32, accountName string, cancel <-chan struct{}) (*wallet.GetTransactionsResult, error) {
func (c *tBtcWallet) ListSinceBlock(start, end, syncHeight int32) ([]btcjson.ListTransactionsResult, error) {
return nil, nil
}

Expand Down
16 changes: 4 additions & 12 deletions client/asset/btc/spv_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ type BTCWallet interface {
WaitForShutdown()
ChainSynced() bool // currently unused
AccountProperties(scope waddrmgr.KeyScope, acct uint32) (*waddrmgr.AccountProperties, error)
// AccountInfo returns the account information of the wallet for use by the
// exchange wallet.
AccountInfo() XCWalletAccount
// The below methods are not implemented by *wallet.Wallet, so must be
// implemented by the BTCWallet implementation.
WalletTransaction(txHash *chainhash.Hash) (*wtxmgr.TxDetails, error)
Expand All @@ -120,11 +117,6 @@ type BTCWallet interface {
GetTransactions(startHeight, endHeight int32, accountName string, cancel <-chan struct{}) (*wallet.GetTransactionsResult, error)
}

type XCWalletAccount struct {
AccountName string
AccountNumber uint32
}

// BlockNotification is block hash and height delivered by a BTCWallet when it
// is finished processing a block.
type BlockNotification struct {
Expand Down Expand Up @@ -211,6 +203,7 @@ type spvWallet struct {
wallet BTCWallet
cl SPVService
acctNum uint32
acctName string
dir string
decodeAddr dexbtc.AddressDecoder

Expand Down Expand Up @@ -494,7 +487,6 @@ func (w *spvWallet) ownsInputs(txid string) bool {
}

func (w *spvWallet) ListTransactionsSinceBlock(blockHeight int32) ([]*ListTransactionsResult, error) {
acctName := w.wallet.AccountInfo().AccountName
tip, err := w.cl.BestBlock()
if err != nil {
return nil, fmt.Errorf("BestBlock error: %v", err)
Expand All @@ -503,7 +495,7 @@ func (w *spvWallet) ListTransactionsSinceBlock(blockHeight int32) ([]*ListTransa
// We use GetTransactions instead of ListSinceBlock, because ListSinceBlock
// does not include transactions that pay to a change address, which
// Redeem, Refund, and RedeemBond do.
res, err := w.wallet.GetTransactions(blockHeight, tip.Height, acctName, nil)
res, err := w.wallet.GetTransactions(blockHeight, tip.Height, w.acctName, nil)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -537,7 +529,7 @@ func (w *spvWallet) ListTransactionsSinceBlock(blockHeight int32) ([]*ListTransa
// balances retrieves a wallet's balance details.
func (w *spvWallet) Balances() (*GetBalancesResult, error) {
// Determine trusted vs untrusted coins with listunspent.
unspents, err := w.wallet.ListUnspent(0, math.MaxInt32, w.wallet.AccountInfo().AccountName)
unspents, err := w.wallet.ListUnspent(0, math.MaxInt32, w.acctName)
if err != nil {
return nil, fmt.Errorf("error listing unspent outputs: %w", err)
}
Expand Down Expand Up @@ -574,7 +566,7 @@ func (w *spvWallet) Balances() (*GetBalancesResult, error) {

// ListUnspent retrieves list of the wallet's UTXOs.
func (w *spvWallet) ListUnspent() ([]*ListUnspentResult, error) {
unspents, err := w.wallet.ListUnspent(0, math.MaxInt32, w.wallet.AccountInfo().AccountName)
unspents, err := w.wallet.ListUnspent(0, math.MaxInt32, w.acctName)
if err != nil {
return nil, err
}
Expand Down
20 changes: 5 additions & 15 deletions client/asset/ltc/spv.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,11 @@ import (
)

const (
DefaultM uint64 = 784931 // From ltcutil. Used for gcs filters.
logDirName = "logs"
neutrinoDBName = "neutrino.db"
defaultAcctNum = 0
defaultAcctName = "default"
dbTimeout = 20 * time.Second
DefaultM uint64 = 784931 // From ltcutil. Used for gcs filters.
logDirName = "logs"
neutrinoDBName = "neutrino.db"
defaultAcctNum = 0
dbTimeout = 20 * time.Second
)

var (
Expand Down Expand Up @@ -160,15 +159,6 @@ func createSPVWallet(privPass []byte, seed []byte, bday time.Time, walletDir str
return nil
}

// AccountInfo returns the account information of the wallet for use by the
// exchange wallet.
func (w *ltcSPVWallet) AccountInfo() btc.XCWalletAccount {
return btc.XCWalletAccount{
AccountName: defaultAcctName,
AccountNumber: defaultAcctNum,
}
}

// walletParams works around a bug in ltcwallet that doesn't recognize
// wire.TestNet4 in (*ScopedKeyManager).cloneKeyWithVersion which is called from
// AccountProperties. Only do this for the *wallet.Wallet, not the
Expand Down

0 comments on commit 6ba3240

Please sign in to comment.