-
Notifications
You must be signed in to change notification settings - Fork 27
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
feat: update gonuts dependency #962
base: master
Are you sure you want to change the base?
Conversation
Thanks for picking this up @elnosh !
That sounds better, but I would prefer to not leak individual LNClient-specific code to other parts of the app. It might be best to have a generic "Execute Node Command" button in the debug tools where you can type some text, and then the Cashu implementation can parse it and do what it needs. We originally planned to do something like this but did not yet add it. I will see what we can do and get back to you. CC @rdmitr
This sounds like a good workaround to me! |
lnclient/cashu/cashu.go
Outdated
} | ||
|
||
fee := uint64(transaction.FeesPaid) | ||
totalPaid := balanceBeforeMelt - cs.wallet.GetBalance() |
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.
minor: could this generate an incorrect fee if there were two simultaneous payments? (but I don't think we need to change anything here)
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.
yeah thanks for catching that, if another transaction happens in between it could generate incorrect fee. A better way could be to use the Change
from the melt response and then do FeeReserve
- ChangeAmount
.
@elnosh for now temporarily we could put the reset logic in this function just to test it, and not block this PR:
It's not so good because it's unrelated to resetting the wallet, but it is executed from the dev tools page. |
made some other changes:
|
Adding for reference, if a user gets a message no mint URL was set, we removed it in a previous PR as we incorrectly set an unstable cashu test mint as the default #535 |
I found an old cashu wallet for Alby Hub with mint https://8333.space:3338 which is operational (I can pay with my old balance) and I can send payments, but when I pay I get "no preimage in melt response". My balance then does not update after paying. Is this expected? Update: I paid some more and now my balance says 33 sats - but it is not, I can no longer pay. I managed to restore the proofs at https://wallet.cashu.me/ - nice! afterwards, I could still pay with my hub (I thought the tokens would have become invalid). |
Starting a brand new hub with a new cashu wallet seems to work well. Restoring my sats on the old wallet with the incorrect balance changed it from 33 to 11 sats. With minibits I get the balance issue. |
} | ||
cashuWalletMnemonic := cashuWallet.Mnemonic() | ||
mnemonic, _ := cfg.Get("Mnemonic", encryptionKey) | ||
if mnemonic != cashuWalletMnemonic { |
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 will overwrite an existing mnemonic (there shouldn't be one). But should the check be if mnemonic == ""
?
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.
Actually, if the mnemonic is different and not an empty string, we should probably return an error rather than overwriting it.
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 was first checking if it was empty but while testing it seems a different (from cashu wallet's) mnemonic was being created and set so that's why I put that check. I'm assuming the different one was set in first startup.
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.
So what does this mean for existing hub users? their old mnemonic will be overwritten, 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.
looking at this: https://github.com/getAlby/hub/blob/master/service/keys/keys.go#L63-L75 it seems one is created anyways even if the mnemonic is set to false for any specific backend. So mnemonic would never be empty. Maybe this mnemonic should not be overwritten (?). I'm not sure what it's used for. Should I put the cashu wallet mnemonic in some other key?
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.
Damn, I see. Ideally we use the one that Alby Hub generates as that's the one we ask the user to back up as part of the getting started steps, and then we pass that mnemonic to gonuts. Is this possible?
If gonuts always overwrites the mnemonic it is inconsistent with the rest of our LNClients and will cause other issues later on.
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.
If gonuts always overwrites the mnemonic it is inconsistent with the rest of our LNClients and will cause other issues later on.
Ok, instead of doing it this way maybe it can just be another command with that "Node Command" API you guys are planning? Send command to cashu wallet and that would return the mnemonic.
That way it wouldn't need to overwrite the mnemonic created in first setup.
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 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.
To move cashuWallet.Mnemonic()
to a node command
@@ -304,7 +304,7 @@ export default function DebugTools() { | |||
Get Network Graph | |||
</Button> | |||
</AlertDialogTrigger> | |||
{info?.backendType === "LDK" && ( | |||
{(info?.backendType === "LDK" || info?.backendType === "CASHU") && ( |
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.
{(info?.backendType === "LDK" || info?.backendType === "CASHU") && ( | |
{(info?.backendType === "LDK" || info?.backendType === "CASHU" /* TODO: move to generic node command */) && ( |
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.
We probably can wait for the generic node command feature to be merged and then undo this actually, then merge this PR
I've been testing with some mints (including that one) and I think that happens if you try to pay an invoice that was generated from that same mint. Looking at the response from the melt request, the payment is being settled and hence returning PAID but with an empty preimage and then making this check fail.
I created issue for that here: cashubtc/nutshell#625 |
11 should be the correct balance given some previous payments?
Sorry, I didn't understand this. Could you explain a bit further? You deposited 10 sats to an empty wallet set with minibits mint and got this? |
Yes, I deposited 10 sats into an empty wallet with minibits mint. Then I did a 1 sat payment to [email protected]. I guess the fee was 1 sat. Instead of decreasing the balance to 8 sats (expected) it increased to 12 sats. |
It seems more than this - because in all my test payments I paid to my LDK hub node. I did not pay to the same mint. |
I think so, yes. It just seems something is broken when we make payments, that the balance increases rather than decreases, or it does not omit already used cashu tokens |
I haven't been able to replicate those issues :( I've setup one with minibits mint and have been making payments fine (with preimage in the response). Sent to this address [email protected] and some other nodes and mints and balance has been updating correctly. |
@@ -33,7 +33,7 @@ export const backendTypeConfigs: Record<BackendType, BackendTypeConfig> = { | |||
hasNodeBackup: false, | |||
}, | |||
CASHU: { | |||
hasMnemonic: false, | |||
hasMnemonic: true, |
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.
let's undo this one since the mnemonic is incompatible
} | ||
|
||
func NewCashuService(workDir string, mintUrl string) (result lnclient.LNClient, err error) { | ||
func NewCashuService(cfg config.Config, workDir, encryptionKey, mintUrl string) (result lnclient.LNClient, err error) { |
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.
undo these changes as we will now return the mnemonic from a node command
@@ -231,6 +220,25 @@ func (cs *CashuService) RedeemOnchainFunds(ctx context.Context, toAddress string | |||
} | |||
|
|||
func (cs *CashuService) ResetRouter(key string) error { | |||
mnemonic := cs.wallet.Mnemonic() |
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.
for now we could check if key == "ALL"
do the restore, otherwise get the mnemonic: cashuWallet.Mnemonic()
This is a WIP for #890 so marking as draft.
I have made changes for new gonuts version, however not pointing to v0.3.0 but instead to latest commit in main for now since I have changed some things since v0.3.0.
This should handle pending proofs that are stuck in payments and hence not try to use them in other payments.
Another change for this new version is that it does not have an
Invoice
type anymore and insteadMintQuote
andMeltQuote
s so it has to aggregate those 2 when listing transactions.Regarding point 4 in #890, I think doing a restore if it finds any pending proofs during startup could be undesirable since the restore does not restore previous transaction history. So any time there are pending proofs and the hub starts, it will wipe out the transaction history. Maybe a cashu-backend specific button could be added in Settings > debug tools where if the user experienced the issue of a unusable wallet due to stuck payments, they could trigger a manual restore?
Regarding this issue #651, I know it's not ideal not having the preimage for incoming payments and one is expected but maybe a dummy/placeholder one could be used so that the hub can mark it as settled and show up in the transaction history and don't go into that loop where it would always check that invoice even though it already got paid.
Any thoughts or comments on the changes and suggestions made here are appreciated :)