I'd like to use the bitcoin library (which is C++)...
# kotlin-native
r
I'd like to use the bitcoin library (which is C++) in Kotlin. Is there a way to do this (via Interop?)? https://github.com/bitcoin/bitcoin Ideally I would like to be able to call it from common code in my Kotlin Multiplatform project eventually. Other "option" would be porting the complete library, which is not feasable both in amount of work as in efforts to maintain/sync with original code.
e
You could also use the nodes’ JSON rpc
r
Yes, thanks for thinking out of the box 😉 it does not match my requirements though, I really want to use the source code
k
create a C shim for the API that you need
☝🏼 2
r
Sooo I'm not that experienced with C..how would that looks like?
k
I should also mention that Cinterop is specific to Kotlin/Native, so if you are targeting non-native platforms you'll need to consider that as well
r
But from what I understood it still does not support c++
r
Do you maybe have an example @Kris Wong?
k
no I do not. if you're not experienced with C it's going to be a pretty steep learning curve to get up and running
💪 1
r
I guess I'll figure it out eventually, just would be nice to have an idea how it fits together. It sounds like you mean to include the library in a seperate C library and just forward the calls. And bind the latter to Kotlin..?
k
that's correct
r
But that still wouldnt make it possible to use it via multiplatform on for example JS I guess? Maybe iOS or Android?
k
iOS
if you want to use it on iOS and Android, frankly you'd probably be better off using something like Djinni. as for JS, my very naive understanding is that would require Web Assembly - but I stay far away from web development
r
Haha, okay it is helpfull anyway, I'll dive into it a bit