-
Notifications
You must be signed in to change notification settings - Fork 82
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
base: staging-ln
Are you sure you want to change the base?
Conversation
4a1bd10
to
3db7734
Compare
1dd6252
to
571341f
Compare
571341f
to
7e6de8d
Compare
const hasLightningFromOtherKeystore = ( | ||
lightningConfig.accounts.length !== 0 | ||
&& ( | ||
accountsByKeystore.length === 0 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
547408d
to
2e0ac00
Compare
@Beerosagos
Also, this should be resolved now. PTAL |
There was some refactoring on master, maybe consider merge master->staging-ln before this? |
Yes, I agree 👍 |
merge master > staging-ln PR: #2782 |
e11b223
to
3aed2f7
Compare
@Beerosagos rebased |
There was a problem hiding this 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 ?
backend/handlers/handlers.go
Outdated
return nil, err | ||
} | ||
totalCoinsBalances[coin.CodeBTC] = lightningBalance.Available().BigInt() | ||
sortedCoins = append(sortedCoins, coin.CodeBTC) |
There was a problem hiding this comment.
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
backend/config/lightning.go
Outdated
@@ -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. |
There was a problem hiding this comment.
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?
ack to hiding the chart for now if there is only lightning. But it would be nice in a future PR to have the chart also is there if there is only the lightining account. |
0853c5d
to
5b11da2
Compare
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. Hide chart in my portfolio when only lightning account is enabled.
5b11da2
to
a81ef45
Compare
Currently, we use the PTAL |
keystoreName := "" | ||
lightningKeystore, err := handlers.backend.Config().AccountsConfig().LookupKeystore(account.RootFingerprint) | ||
if err == nil { | ||
keystoreName = lightningKeystore.Name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an interesting solution, but I think it has a defect: if the keystore device is renamed, the config in the frontend is not updated bc it is served by the provider. That means the keystore name won't be updated until the app is restarted. I think it would be better to add a backend endpoint keystore-name
that given a rootfingerprint looks for a keystore in the config and returns the name.
There is also a more latent bug, which depends on the watch-only implementation: when the device is renamed, the keystore name in the config file is not updated until the device is disconnected and reconnected again. But this deserves its own PR as it is out of scope here, imo.
cc @benma
@@ -158,3 +158,55 @@ export const SummaryBalance = ({ | |||
</div> | |||
); | |||
}; | |||
|
|||
|
|||
export function LightningBalance() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is some code duplication here, I think that it would be nice to move the logic to subscribe and fetch the LN balance inside accountsummary.tsx and pass it to the LightningBalance and SummaryBalance components. wdyt?
Also, I noticed that when the chart is hidden, the |
Yeah, I agree 👍 |
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. Hide chart in my portfolio when only lightning account is
enabled.