bdk icon indicating copy to clipboard operation
bdk copied to clipboard

Make it possible to spend LDK UTXO's in BDK

Open ConorOkus opened this issue 2 years ago • 2 comments

ConorOkus avatar Aug 10 '22 18:08 ConorOkus

That's a bit generic, what do you mean exactly? Which utxos should be spent (normal deposits or channel utxos) and where are those keys stored?

afilini avatar Aug 12 '22 08:08 afilini

I believe the idea here is that the BDK wallet would be able to sync and spend UTXOs created when a LDK channel is closed. I'd also expect that UTXOs in a BDK wallet could be used to open an LDK channel. This should be enabled with #485 and #486. We also need to be able to use LDK as a custom signer for spending UTXOs from LN script template "Descriptors". And LDK would have to be able to use BDK as a input signer.

notmandatory avatar Aug 26 '22 02:08 notmandatory

This should be doable by just creating a custom KeysInterface where you make get_shutdown_scriptpubkey and get_destination_script get addresses from LDK.

benthecarman avatar Dec 13 '22 12:12 benthecarman

This should be doable by just creating a custom KeysInterface where you make get_shutdown_scriptpubkey and get_destination_script get addresses from LDK.

I can now confirm that by implementing a custom KeysInterface we can override the shutdown/destination scripts coming from a BDK wallet, so that the funds show up in the BDK wallet after closing/claiming on-chain. Will be included in LDKLite (see https://github.com/lightningdevkit/ldk-lite/pull/33).

However, it likely still would be nice to allow users the flexibility to go the other way, i.e., allow them to add arbitrary UTXOs to BDK's coin selection.

tnull avatar Dec 15 '22 11:12 tnull

Added an issue to improve this at the bindings layer here

ConorOkus avatar Feb 23 '23 19:02 ConorOkus

What's the status/priority/plan for this?

moneyball avatar Oct 09 '23 20:10 moneyball

@tnull do we only need to expose the existing rust add_foreign_utxo function in the language bindings? That should allow you to create a transaction in BDK that spends a UTXO owned by LDK, though you'd still need LDK to sign for that input.

Otherwise your KeysInterface approach sounds like it already allows BDK to be used to manage the onchain transactions for LDK.

notmandatory avatar Oct 10 '23 00:10 notmandatory

I don't think that's needed, we already have the ability to forward any other descriptors to KeysManager::spend_spendable_outputs and provide guidance here in the docs https://lightningdevkit.org/key_management/#spending-on-chain-funds

ConorOkus avatar Oct 11 '23 00:10 ConorOkus

@tnull do we only need to expose the existing rust add_foreign_utxo function in the language bindings? That should allow you to create a transaction in BDK that spends a UTXO owned by LDK, though you'd still need LDK to sign for that input.

Otherwise your KeysInterface approach sounds like it already allows BDK to be used to manage the onchain transactions for LDK.

Yup, I agree that the KeysInterface approach (by now renamed though) seems to work as expected. I'd say it's fine to close this issue for now until we find a good reason why we'd need to 'go the other way'.

tnull avatar Oct 12 '23 09:10 tnull

Thanks guys, closing for now. Happy to re-open if needed.

notmandatory avatar Oct 12 '23 14:10 notmandatory