python-bitcoinlib icon indicating copy to clipboard operation
python-bitcoinlib copied to clipboard

Implement miniscript

Open kanzure opened this issue 5 years ago • 7 comments

https://github.com/bitcoin/bitcoin/pull/17975

kanzure avatar Mar 09 '20 15:03 kanzure

@kanzure Do you insist on a Python re-implementation, or do you think that the Rust impl or C++ impl could be wrapped? This library is already depending on a lot of native code, and it would be a lot easier to wrap an existing implementation.

ysangkok avatar Oct 12 '20 18:10 ysangkok

My instinct is to say python but only because it makes distribution of the library easier than wrapping and compiling other libraries. What do you think?

kanzure avatar Oct 12 '20 23:10 kanzure

As I understand, the native code dependencies are not distributed with bitcoinlib, because they are widespread (openssl and libsecp)

On the other hand, bitcointx has an interface to libbitcoinconsensus with an expectation that the user of bitcointx will make sure that libbitcoinconsensus lib is available, or will load it with explicit path.

Both of the above approaches work well when the underlying libs have a stable API, and there's little chance to hit the incompatibilities, or they can be sensibly handled (like older versions of libsecp lacking some functions)

With newer libs with less stable APIs using these approaches could become problematic.

And the ease of distribution is one of the strengths of bitcoinlib/bitcointx, as there's no additional compilations in the installation steps, which could cause their own problems.

The python-only implementation also has an advantage that it would be more easily readable and instrumentable by the python-oriented users. For example, while libbitcoinconsensus interface exists for bitcointx, having python-only script interpeter is still valuable because of this aspect.

dgpv avatar Oct 13 '20 10:10 dgpv

Just an outside observer but I prefer the idea of this being a Python library as much as possible. I think wrapped code is ok when there is no Python code and no one with the bandwidth to implement it in Python. But at least in this Miniscript example, James has implemented a large part of it in Python and it will probably/possibly get merged into the Core test framework at some stage in the future.

michaelfolkson avatar Oct 13 '20 11:10 michaelfolkson

I'll second the idea of having a pure python library. For security critical code, minimizing dependencies is paramount, and while I like Rust, I don't think wrapping it is the way to go. If you want to write in Rust, write in Rust and there's no reason to use python-bitcoinlib.

mcelrath avatar Oct 13 '20 13:10 mcelrath

For reference: Miniscript in: javascript: https://github.com/thmour/miniscript python: https://github.com/bitcoin/bitcoin/pull/17975 rust: https://github.com/rust-bitcoin/rust-miniscript

mcelrath avatar Oct 13 '20 14:10 mcelrath

Formal spec for miniscript: https://github.com/dgpv/miniscript-alloy-spec

dgpv avatar Nov 25 '20 11:11 dgpv