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

Question to FAILED_LOW_FEE and Sweep #3

Open
eliaspfeffer opened this issue Sep 26, 2024 · 9 comments · May be fixed by #4
Open

Question to FAILED_LOW_FEE and Sweep #3

eliaspfeffer opened this issue Sep 26, 2024 · 9 comments · May be fixed by #4

Comments

@eliaspfeffer
Copy link

eliaspfeffer commented Sep 26, 2024

When sending normal amounts via Lightning, I sometimes get the FAILED_LOW_FEE error. Sometimes I can work around it by splitting the amount I originally wanted to send into smaller amounts and always when I have 1 Satoshi left, then I cant continue sending this 1 remaining satoshi, except of when I sweep the lightning wallet.

So first question: Why does the FAILED_LOW_FEE error even exist? Doesnt make sense, as wos probably has their nodes running all in one node anyways

Second question: Does someone know how you can always avoid the FAILED_LOW_FEE error? I have tried doubling the minimum balance of 1 Sat per failed sending approach, but this only sometimes work. Sometimes it doesnt work for an entire day, no matter what I try. Most of the times it doesnt work, when I dont have big liquidity in the wallet (less than 1E-4 Btc)

Third question: What does sweeping actually do except of sending the entire amount (including the normally minimum 1 Sat per wallet)? I've tested if the wallet can receive sats again. Answer: yes. So does it do anything else than what I've mentioned? Is it a good idea to always use the sweeping mechanism, when sending between wallets, when I then can send it back anyways? Or will the wallet maybe get deactivated in future or what?

https://github.com/conduition/wos/blob/73f3eda457047fb995de7c3100eb19086f11560c/wallet.go#L526C23-L526C37

@eliaspfeffer
Copy link
Author

This is total banans. Just figured out that the following amounts dont work:
3, 6, 12, 24, 48, 96; so a_n =3⋅2^(n−1)
But everything else works.

whyever the ... this is.... ?!?!?

@conduition
Copy link
Owner

conduition commented Sep 26, 2024

The WoS API doesn't behave logically and since they're closed source I unfortunately can't really explain why.

This is total banans. Just figured out that the following amounts dont work:

That seems really absurd. How do you replicate this? Create an invoice for $a_n = 3⋅2^{n−1}$ sats and then try to pay it using WoS?

I'd be curious to see what the WoS app itself is doing to pay invoices of those amounts.

@eliaspfeffer
Copy link
Author

eliaspfeffer commented Sep 26, 2024

That seems really absurd. How do you replicate this? Create an invoice for a n = 3 ⋅ 2 n − 1 sats and then try to pay it using WoS?

Yes, but not via invoice but instead via the [email protected] way, that you have provided some time ago in this issue. Let me know, if you were able to replicate it.

I'd be curious to see what the WoS app itself is doing to pay invoices of those amounts.

Sending these amounts via the app works somehow

@eliaspfeffer
Copy link
Author

127 satoshis also doesnt work

@eliaspfeffer
Copy link
Author

Okay, I guess I've figured it out partly:
2^(x+1) + 2^x dont work
And also 2^(x) - 1, when x >= 7
Not sure, if there are some other mathematical formulas with error-values as well.

@conduition
Copy link
Owner

conduition commented Oct 3, 2024

I tested paying from a wos client to my [email protected] LN address and it worked fine. I tried 48 and 96 sat payments.

Here's what I did:

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

creds1 := &Credentials{
	APISecret: "xxxxxxxxxxxxxxxx",
	APIToken:  "xxxxxxxxxxxxxxxx",
}

wallet1, err := creds1.OpenWallet(ctx, nil)
if err != nil {
	t.Fatal(err)
}

bal1, err := wallet1.Balance(ctx)
if err != nil {
	t.Fatal(err)
}

jsonPrint("bal1", bal1)

addr1, err := ParseLightningAddress("[email protected]")
if err != nil {
	t.Fatal(err)
}

p1, err := wallet1.PayLightningAddress(ctx, addr1, "", 0.00000048)
if err != nil {
	t.Fatal(err)
}

The payments worked, though oddly i didn't always receive the exact correct amounts on the other side. This might be due to the fact that the WoS API uses floating point numbers to represent amounts, instead of integers with guaranteed precision. So far that's my only theory as to why this is happening.

@conduition
Copy link
Owner

I have an explanation for the imprecise payment amounts. The walletofsatoshi API uses integers with millisat amounts when paying a lightning address, but floating point numbers everywhere else.

Perhaps the floating point conversion from BTC to millisat amounts (inside my golang code) is causing problems for you. On my side, it seems to result in situations where I say "Pay 127 sats" but the receiver actually gets 126.999 sats due to floating point conversion imprecision when multiplying 0.00000127 * 100_000_000.

I suppose the easy solution here is to simply change the wos package API to accept a millisat amount when paying to LN addresses. Alternatively I could try a string-based conversion but that would be brittle and complicated.

@conduition
Copy link
Owner

What does sweeping actually do except of sending the entire amount (including the normally minimum 1 Sat per wallet)?

That's all it does - The SweepLightning method computes how much of your balance you can spend via LN after the WoS LN fees, and then uses it to pay a variable-amount invoice.

conduition added a commit that referenced this issue Oct 3, 2024
@conduition conduition linked a pull request Oct 3, 2024 that will close this issue
@conduition
Copy link
Owner

@eliaspfeffer See #4

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 a pull request may close this issue.

2 participants