Sjors / libwally-swift

Swift wrapper for LibWally, a collection of useful primitives for cryptocurrency wallets
MIT License
41 stars 18 forks source link

Avoid dirty libwally-core submodule after build #64

Open Sjors opened 2 years ago

Sjors commented 2 years ago

Since #54 the build script switches from libsecp256k1-zkp to vanilla libsecp256k1 (and matching the commit used by Bitcoin Core). This uses libwally-core's --enable-standard-secp configure flag (introduced in https://github.com/ElementsProject/libwally-core/pull/301).

The problem is that this switch leaves the libwally-core submodule dirty.

One possible solution would be to patch libwally-core to use libsecp256k1 from a custom directory. In that case we could include it directly as a submodule in libwally-swift and ignore libwally-core's libsecp256k1-zkp submodule.

Not sure how involved this is, cc @jgriffiths.

Perhaps there's another approach that doesn't require an upstream change. The script could do some magic with symlinks, but meh...

jgriffiths commented 2 years ago

@Sjors

You could maybe use a secp from elsewhere by passing -I in $CFLAGS and -L in $LDFLAGS, assuming LIBADD_SECP256K1 in configure.ac doesn't need modifying to ensure you pick up the right object files. That would require that you configure and build secp separately with compatible options following the logic that wally uses to map its own state to secp's in AC_CONFIG_SUBDIRS in configure.ac.

That seems like a huge PITA though, when you can just store the HEAD commit before you change it before building, then make clean in the secp dir and check out the old HEAD again when done.

jgriffiths commented 2 years ago

Worth noting that the upgrade to 0.8.5 includes bip32 derivation directly from string paths, so you could remove your path parsing code in favour of using wallys if you wished to.

Sjors commented 2 years ago

Worth noting that the upgrade to 0.8.5 includes bip32 derivation directly from string paths, so you could remove your path parsing code in favour of using wallys if you wished to.

Nice, that should help clean up some code. Are you planning to implement the opposite direction as well? https://github.com/ElementsProject/libwally-core/issues/241

jgriffiths commented 2 years ago

Are you planning to implement the opposite direction as well?

At some point, yes - there is a backlog of wally features to implement and there hasn't been a lot of time to get to them, that situation should be improving now.