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

frontend: update 'My portfolio' with lightning account #2703

Open
wants to merge 1 commit into
base: staging-ln
Choose a base branch
from

Conversation

strmci
Copy link
Collaborator

@strmci strmci commented May 7, 2024

This commit adds functionality to display lightning account in 'My portfolio' in cases where it is active but not associated with a connected or remembered wallet, or when all mainnet accounts in the connected wallet are disabled.

The total coins table is updated to include the Lightning account, and the Lightning configuration now also contains the keystore name.

@strmci strmci force-pushed the lightning_to_my_portfolio branch 2 times, most recently from 4a1bd10 to 3db7734 Compare May 8, 2024 12:52
@strmci strmci requested a review from thisconnect May 8, 2024 13:15
@strmci strmci force-pushed the lightning_to_my_portfolio branch 2 times, most recently from 1dd6252 to 571341f Compare May 10, 2024 06:43
@strmci strmci force-pushed the lightning_to_my_portfolio branch from 571341f to 7e6de8d Compare May 10, 2024 07:44
@Beerosagos
Copy link
Collaborator

Here I found the keystore (c6d..) repeated twice, during my test

image

const hasLightningFromOtherKeystore = (
lightningConfig.accounts.length !== 0
&& (
accountsByKeystore.length === 0
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that you can avoid checking the length, it should be handled by the some condition anyway, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, this check is redundant here, removed.

)
);

const showTotalCoins = accountsByKeystore.length > 1 || (hasLightningFromOtherKeystore && accountsByKeystore.length === 1);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: what about doing smth like

let keystores = accountsByKeystore.length; if (hasLightningFromOtherKeystore) { keystores += 1; }

and check for keystores > 1 below?

I feel like it would be more readable

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I updated this to use keystores

frontends/web/src/routes/account/summary/coinbalance.tsx Outdated Show resolved Hide resolved
@strmci strmci force-pushed the lightning_to_my_portfolio branch 2 times, most recently from 547408d to 2e0ac00 Compare June 24, 2024 15:42
@strmci
Copy link
Collaborator Author

strmci commented Jun 24, 2024

@Beerosagos
I cherry-picked the total coins refactor from master and updated this PR.

Here I found the keystore (c6d..) repeated twice, during my test

Also, this should be resolved now.

PTAL

@thisconnect
Copy link
Collaborator

thisconnect commented Jun 25, 2024

There was some refactoring on master, maybe consider merge master->staging-ln before this?

@Beerosagos
Copy link
Collaborator

There was some refactoring on master, maybe consider merge master->staging-ln before this?

Yes, I agree 👍

@Beerosagos
Copy link
Collaborator

merge master > staging-ln PR: #2782

@strmci strmci force-pushed the lightning_to_my_portfolio branch 2 times, most recently from 6396687 to e11b223 Compare July 3, 2024 10:25
This commit adds functionality to display Lightning account
in 'My portfolio' in cases where it is active but not associated
with a connected or remembered wallet, or when all mainnet
accounts in the connected wallet are disabled.

The total coins table is updated to include the Lightning account,
and the Lightning configuration now also contains the keystore
name.
@strmci strmci force-pushed the lightning_to_my_portfolio branch from e11b223 to 3aed2f7 Compare July 3, 2024 10:27
@strmci
Copy link
Collaborator Author

strmci commented Jul 3, 2024

@Beerosagos rebased
PTAL

Copy link
Collaborator

@Beerosagos Beerosagos left a comment

Choose a reason for hiding this comment

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

Left a couple comments.

Also, I noticed that if the only active account is the lightning one, then the chart in the account summary is empty. Not sure what we want to do with this, the easier is probably to hide it, at least for now. wdyt @thisconnect ?

return nil, err
}
totalCoinsBalances[coin.CodeBTC] = lightningBalance.Available().BigInt()
sortedCoins = append(sortedCoins, coin.CodeBTC)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This potentially breaks the coin sorting, which should be derived by the accounts sorting. The LN balance handling should be done together with the BTC accounts balance

@@ -26,6 +26,8 @@ type LightningAccountConfig struct {
Mnemonic string `json:"mnemonic"`
// RootFingerprint is fingerprint of the keystore that generated the entropy.
RootFingerprint jsonp.HexBytes `json:"rootFingerprint"`
// KeyStoreName is name of the keystore.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I realized that storing the keystore name could lead to issues when the device name is changed by the user.
I didn't look deeply into this, but I think that the proper way of doing it could be to get the persisted keystore info and retrieve the name there (see backend.Config().AccountsConfig()), but we may need to actively persist the current keystore when enabling the LN account).

cc @benma wdyt?

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.

None yet

3 participants