ACINQ / bitcoin-kmp

Kotlin Multiplatform Bitcoin Library
Apache License 2.0
68 stars 15 forks source link

Simples changes that are required to support taproot LN channels #129

Closed sstone closed 2 months ago

sstone commented 2 months ago

We need to be able to serialize taproot script trees, compare x-only pubkeys, and create taproot sessions to verify partial signatures. This changes are imported from https://github.com/ACINQ/bitcoin-kmp/pull/128 which includes unrelated more complex changes to our PSBT implementation,

sstone commented 2 months ago

I don't understand why the ScriptTree encoding is necessary, you don't seem to use it for the PSBT fields (which only require encoding/decoding script leaves)? Also, the leaf encoding defined in the PSBT bip doesn't match the encoding you're using?

Because we persist input information along with our peer's signature (or partial signature) in both eclair and lightning-kmp and for taproot outputs that includes a scrip tree. It's not related to PSBT but I'll see if I can reuse the format that has been proposed.

t-bast commented 2 months ago

Got it, that's what confused me, this is unrelated to PSBT. It seems to me that we only need to serialize the leaves in order to re-build the tree, don't we? We would lose the "leafIndex" but maybe we can re-work that to get rid of it?

sstone commented 2 months ago

I've added the serialisation format for script trees defined in BIP371 (and kept ours which I find simpler :)).