Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DEX support for Cryptopower btc wallet #349

Merged
merged 7 commits into from
Jan 8, 2024

Conversation

ukane-philemon
Copy link
Collaborator

@ukane-philemon ukane-philemon commented Dec 22, 2023

Closes #337

EDIT: This PR uses github.com/ukane-philemon/dcrdex/add-custom-wallet-constructor as a temp replacement of decred/dcrdex

@ukane-philemon ukane-philemon marked this pull request as draft December 22, 2023 09:47
@ukane-philemon ukane-philemon marked this pull request as ready for review December 22, 2023 10:59
Comment on lines 119 to 121
func (dw *DEXWallet) WaitForShutdown() {
dw.w.WaitForShutdown()
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method isn't needed upstream, please remove upstream and remove here as well.

If it is actually needed, we might want to do nothing here, because this call to dw.w.WaitForShutdown() will block until the wallet is stopped and there's no telling when that will happen, since the DEX client isn't allowed to stop the wallet.

Copy link
Collaborator Author

@ukane-philemon ukane-philemon Jan 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove upstream and remove here as well

This upstream removal will have to be a separate PR as it does not relate to customer wallet registration. We can just do nothing here, okay?

EDIT: The method is used in dex during wallet rescan, best we can do is leave empty.

Comment on lines +123 to +124
// currently unused
func (dw *DEXWallet) ChainSynced() bool {
return dw.w.ChainSynced()
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove upstream? It can always be re-added when needed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, It'll have to be a separate upstream PR.

Comment on lines 132 to 133
// The below methods are not implemented by *wallet.Wallet, so must be
// implemented by the dexbtc.BTCWallet implementation.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is no longer relevant. *DEXWallet implements all methods, even if it simply calls the same method on the underlying *wallet.Wallet.


// AccountInfo returns the account information of the wallet for use by the
// exchange wallet.
func (dw *DEXWallet) AccountInfo() dexbtc.XCWalletAccount {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we perhaps split this upstream to different methods? AccountNumber() and AccountName()? How often is the account name really needed?

Copy link
Collaborator Author

@ukane-philemon ukane-philemon Jan 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3:1

Yh, we should make these separate methods.

On second thought, buck suggested calling this method once and saving the values on the upstream spv struct. Maybe we should do that instead but only for the account number, that way, we only need to call this method when we need the account name.


unMixedAcctNum := dw.UnmixedAccountNumber()
mixedAcctNum := dw.MixedAccountNumber()
accounts, err := dw.GetAccountsRaw()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't need to get all accounts information; just dw.AccountName(...)

Comment on lines 100 to 102
// We only care about the default account.
if mixedAccName == "" {
log.Errorf("Account name not found for mixed account number %d", mixedAcctNum)
return accts
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment isn't clear. We only care about the default account?

Copy link
Collaborator Author

@ukane-philemon ukane-philemon Jan 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only care about the default account?

Oh, this should say primary account.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

mgr.dexcMtx.Unlock()

err = mgr.PrepareDexSupportForDcrWallet()
// Prepare support for DCR wallet.
err = mgr.PrepareDexSupportForDCRWallet()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this mgr.InitializeDEX method be called multiple times while the app is open? If not, then mgr.PrepareDexSupportForDCRWallet() should not need to worry about duplicate registrations. Also, I don't see why we would want to initialize dexc multiple times.

Copy link
Collaborator Author

@ukane-philemon ukane-philemon Jan 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this mgr.InitializeDEX method be called multiple times while the app is open?

Yes. We can't control what happens in dex core so we try to restart the dex client if it's not yet started(or it started but then exited).

Copy link
Collaborator

@JoeGruffins JoeGruffins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsure if this matters at this point but posting bond with btc it never shows the tx is confirmed:
image

@ukane-philemon
Copy link
Collaborator Author

Unsure if this matters at this point but posting bond with btc it never shows the tx is confirmed: image

Testing on #353? Most fixes on the dex bonding page have been handled there. This PR only focuses on btc.

@JoeGruffins
Copy link
Collaborator

Testing on #353? Most fixes on the dex bonding page have been handled there. This PR only focuses on btc.

No here. I'll try again there. Feel free to ignore here.

Signed-off-by: Philemon Ukane <[email protected]>
Signed-off-by: Philemon Ukane <[email protected]>
Signed-off-by: Philemon Ukane <[email protected]>
Signed-off-by: Philemon Ukane <[email protected]>
Signed-off-by: Philemon Ukane <[email protected]>
Signed-off-by: Philemon Ukane <[email protected]>
@dreacot dreacot merged commit d532250 into crypto-power:master Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make BTC wallet compatible with DCRDEX
4 participants