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

use a bitcoind hot wallet instead of lnd #272

Closed
nicolasburtey opened this issue Jun 27, 2021 · 11 comments
Closed

use a bitcoind hot wallet instead of lnd #272

nicolasburtey opened this issue Jun 27, 2021 · 11 comments
Assignees
Labels
help wanted Extra attention is needed onchain

Comments

@nicolasburtey
Copy link
Member

nicolasburtey commented Jun 27, 2021

the current hot onchain wallet is based on lnd. we want to move the onchain hot wallet to bitcoind (or maybe bdk could be an alternative, haven't dive into it, but there is an initiative for proof of reserve which is something we want to get into) for the following reasons:

disposable lnd

the lnd nodes are currently being considered disposable. there is no state in lnd that are not being duplicated into mongodb in regards to balances/transactions. so deleting a lnd instance would not create any data loss for the uses perspective.

the reason we want to be able to do that is because nodes can have issues and eventually die (like an irreparable corrupt database).

if lnd dies, then it's possible to recover the funds using a recovery procedure and starts anoter another lnd. (our architecture will allow multi lnd also).

aftter lnd is offline, no more payment can be received on the disposed lnd: even if there were some invoices issued by the disposed lnd that another party tried to pay, the payment would not go through because of the liveness requirement to receive a payment.

all the above logic of payment doesn't apply for the onchain wallet. a user could have shared an onchain address, and received a payment later. if the fees are high (and moving higher) maybe a user will be waiting for its transaction to confirm on chain for weeks/months.

the current issue is that the onchain addresses of the users are tied to a particular lnd. so if this lnd is being disposed, the pending/future onchain payment send to this node would still be eventually received, but unless the node is being restarted, those payment would never be credited to the associated user.

so the best way to mitigate this is create a separate the hot onchain wallet that doesn't have as much state to maintain as a lnd node. a hot bitcoin wallet could be restored easily with an xpriv to another bitcoind node.

this is the key reason as to why moving from the current hot onchain wallet relying on lnd to something that require less state and would likely never need to be recycled.

not focus on onchain

lightning labs doesn't focus on onchain wallet as much as lightning (which is understandable). some example of issues that have been pending:

I would expect bitcoind to not have such issues

@nicolasburtey nicolasburtey added help wanted Extra attention is needed onchain labels Jun 27, 2021
@jotapea
Copy link
Contributor

jotapea commented Jul 7, 2021

@nicolasburtey From what I have been able to study since yesterday, I think that if there are plans to keep adding Bitcoin wallet features, then bdk is a good choice. It uses miniscript + descriptors (both which I am now learning about), which allow building many kinds of transactions. But the project is still early, like in here it still says that only testnet and regtest are supported.

And I also found this, which is a way to do proof of reserves with bitcoind https://github.com/ElementsProject/reserves.

@nicolasburtey
Copy link
Member Author

@bodymindarts do you want to chime in? maybe @moneyball would have some insights for the readiness of bdk for production use?

I think if we don't have a strong conviction we should go with bitcoin-core wallet. bitcoin core will eventually also have descriptors (if they don't already). for miniscript I'm not sure yet, but for what we're doing I don't think miniscript will be useful anytime soon.

@moneyball
Copy link

moneyball commented Jul 9, 2021

It would be great to find an early adopter of BDK! As @jotapea mentioned, it is particularly attractive if you're looking to utilize output descriptors, miniscript, multi-sig, PSBT, coin selection, and fee estimation, as it does all of that for you. Even if you use BDK, you'll still need to use Bitcoin Core (or some form of block data such as Electrum or BIP 157/158), as BDK is not a full node or source of block data.

BDK supports Rust, Java, and Swift right now. It would need language bindings support work to support TypeScript, if that is what your wallet needs.

As for mainnet/production readiness, we'd need to check with the developers on the project, in particular Alekos and Steve Myers. But whatever tasks remain I'm sure they'd prioritize as there is a desire for BDK to be adopted for real usage.

Let me know how I can help.

@bodymindarts
Copy link
Member

@bodymindarts do you want to chime in? maybe @moneyball would have some insights for the readiness of bdk for production use?

I think if we don't have a strong conviction we should go with bitcoin-core wallet. bitcoin core will eventually also have descriptors (if they don't already). for miniscript I'm not sure yet, but for what we're doing I don't think miniscript will be useful anytime soon.

I'm also in the camp of staying with bitcoin-core. Its the safest option and we currently have no need for any of the above mentioned features.
Migrating to another bitcoin node solution would be a complex process that we should not undertake without a clear need.

@moneyball
Copy link

Again to be clear, even if you were to adopt BDK, you aren't moving to a new node solution - you'd still need to use Bitcoin Core (or some mechanism to get block data). BDK works with Core, Electrum, and BIP 157/158 block data sources.

@bodymindarts
Copy link
Member

bodymindarts commented Jul 9, 2021 via email

@bodymindarts
Copy link
Member

bodymindarts commented Jul 9, 2021 via email

@moneyball
Copy link

@bodymindarts yes to both. With BDK (and LDK), they are true libraries, that you call into and link to as opposed to running a separate process and using RPC to interface (like with Core or LND). If someone is building a wallet from scratch, BDK and LDK help immensely so you don't have to reinvent the wheel, yet you still get as much flexibility as you need. However, if you've already developed your wallet application, then it might be less clear.

My main point is that BDK is not a replacement for a full node like Core. BDK is a dev kit that makes building a wallet easier.

@bodymindarts
Copy link
Member

bodymindarts commented Jul 9, 2021 via email

@notmandatory
Copy link

notmandatory commented Jul 9, 2021

... But the project is still early, like in here it still says that only testnet and regtest are supported.

Hi, regarding the above comment this is just for the bdk-cli tool which we only use for manual testing and demos, the rest of the core library is well tested and I think would offer some nice features for GaloyMoney.

As for the Typescript support, BDK can be built into a WebAssembly package with a thin wrapper (primarily to convert inputs/outputs to JSON). You can see a live demo of this working in a browser on the "Playground" page @afilini created. If that's something your team would consider we can work on a NodeJS demo.

@nicolasburtey
Copy link
Member Author

this is done with bria.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed onchain
Projects
None yet
Development

No branches or pull requests

5 participants