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 spend_unconfirmed param to estimateFee #4764

Closed
lukechilds opened this issue Nov 12, 2020 · 7 comments
Closed

Add spend_unconfirmed param to estimateFee #4764

lukechilds opened this issue Nov 12, 2020 · 7 comments
Labels
feature request Requests for new features fees Related to the fees paid for transactions (both LN and funding/commitment transactions) rpc Related to the RPC interface

Comments

@lukechilds
Copy link

In @getumbrel we want to allow users to open channels with unconfirmed outputs.

Previous discussion: getumbrel/umbrel-lightning#13

We can do this with the spend_unconfirmed param in openChannel.

However we use estimateFee to provide fee estimates to the user in both sat/b and $. We do this by getting an estimation from estimateFee for a normal payment to a random address with the total balance we're expecting to open the channel with so LND should select the same inputs. We then add some weight to the absolute sat value to account for the extra size of a channel open TX to derive a fiat estimate.

If we enable spend_unconfirmed in openChannel, our fee estimation logic errors due to no available inputs, even though there are available unconfirmed inputs which openChannel will use.

Would it be possible to add a spend_unconfirmed param to estimateFee so we can still make these estimations?

I don't think it needs to take into account the feerate of the previous unconfirmed TX for CPFP style calculations or anything like that, but if it does, even better.

If this isn't something you want to implement in LND, is there a way we can do some sort of dry run with openChannel so we can get the size of our channel open TX with some random fee rate without broadcasting it? Then we can use that to do our fee estimation in the UI.

@halseth halseth added feature request Requests for new features fees Related to the fees paid for transactions (both LN and funding/commitment transactions) rpc Related to the RPC interface labels Nov 12, 2020
@jalavosus
Copy link

@lukechilds I'm working on implementing this, I'll open a PR within the next couple days.

@lukechilds
Copy link
Author

@jalavosus awesome!

Might be worth waiting to hear back from the maintainers to see if they're interested in accepting this change before you spend time on it.

@guggero
Copy link
Collaborator

guggero commented Dec 7, 2020

I don't see any reason why we shouldn't add this, so feel free to go ahead with the PR, @jalavosus.
Would be cool if we could add the same parameters as #4653 did, so min_confs and spend_unconfirmed to keep the RPCs as similar as possible.

One thing I do want to mention however, is that we'd like to see RPC users to transition to the new PSBT RPCs in the walletrpc subserver, as those allow for more control. The EstimateFee call is a good example: Even if you query that RPC before opening a channel, it could be (however unlikely) that the UTXOs used for the estimation are no longer unspent and the wallet will select different ones, causing the fee to be different from the estimation.

Using the PSBT calls, you would instead call the FundPsbt call with the desired channel output. The result is a partial transaction with the selected UTXOs, and, most importantly, those UTXOs are now locked for 10 minutes and can't be spent otherwise by the wallet. From the partial transaction you can also estimate the exact fee (because you know all input types and output types, you just need to account for the witness that's not yet in the TX, hence partial).
If the user agrees with the fee, you can just ask the FinalizePsbt to sign the TX and publish it.

My counter proposal therefore is: Do you want to add the min_confs and spend_unconfirmed parameters to the FundPsbt call in lnrpc/walletrpc/walletkit.proto?
I'm also fine with a PR that adds the parameters to both EstimateFee and FundPsbt.

@jalavosus
Copy link

@guggero, I can take a look at adding the same params to FundPsbt. I would like to say that I appreciate you taking the time to explain how it works! I'm still a bit green with the codebase, and slowly figuring out how it all links together, so the pointers on it are appreciated :)

@jalavosus
Copy link

@guggero #4845

@guggero guggero linked a pull request Dec 8, 2020 that will close this issue
15 tasks
@mrfelton
Copy link
Contributor

Support for this was added in #4905

@guggero
Copy link
Collaborator

guggero commented May 14, 2021

Thanks for the reminder @mrfelton!

Fixed in #4905.

@guggero guggero closed this as completed May 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Requests for new features fees Related to the fees paid for transactions (both LN and funding/commitment transactions) rpc Related to the RPC interface
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants