flutter_trust_wallet_core icon indicating copy to clipboard operation
flutter_trust_wallet_core copied to clipboard

build your own android aar lib or else will lookup failed

Open weishirongzhen opened this issue 3 years ago • 28 comments

Because official lib build flag in CmakeLists.txt set(CMAKE_CXX_VISIBILITY_PRESET hidden), that will cause android exception when dart ffi lookup function.

Please refer to My other repo to run full demo, also, replace you own build to ensure safety. build step: follow Official build step to prepare your build env , then change

 set(CMAKE_CXX_VISIBILITY_PRESET hidden)

to

 set(CMAKE_CXX_VISIBILITY_PRESET default)

build project, replace your own output in My other repo.

weishirongzhen avatar Sep 15 '21 07:09 weishirongzhen

I have an issue with dart ffi and lookup function, my app is crashed on start. Can you tell, please, what should I do with this?

sylvestrevgen avatar Sep 20 '21 09:09 sylvestrevgen

I have an issue with dart ffi and lookup function, my app is crashed on start. Can you tell, please, what should I do with this?

Any log? And please refer to README.md , there may some way to solved your issue.

weishirongzhen avatar Sep 20 '21 13:09 weishirongzhen

Now Android Lib are extract to github package.

repositories {
        google()
        jcenter()
        maven {
            url = uri("https://maven.pkg.github.com/weishirongzhen/wallet-core")
            credentials {
                username = "weishirongzhen"
                password = "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" // GH token for only allow read package
            }
        }
    }

then

implementation "com.weishirongzhen:wallet-core:2.6.20"

weishirongzhen avatar Sep 28 '21 07:09 weishirongzhen

How to build the android lib or ios framework from the trust wallet core, what should we modify the code of trust wallet core repo to build succesful for flutter, thank you.

winterdl avatar Oct 07 '21 03:10 winterdl

How to build the android lib or ios framework from the trust wallet core, what we should modify the code of trust wallet core repo to build succesful for flutter, thank you.

build step please refer to this link https://developer.trustwallet.com/wallet-core/developing-the-library/building

and for android, only need to do is modify CMakeLists.txt and

change set(CMAKE_CXX_VISIBILITY_PRESET hidden) to set(CMAKE_CXX_VISIBILITY_PRESET default)

weishirongzhen avatar Oct 08 '21 02:10 weishirongzhen

How to connect to network?

RayOkaah avatar Oct 17 '21 19:10 RayOkaah

How to connect to network?

wallet-core only handle local things, create wallet, sign transaction etc, your can broadcast your sign output to any network you like.

weishirongzhen avatar Oct 18 '21 01:10 weishirongzhen

Thanks. Please point me to any resource I can read up on broadcasting on a network. Thanks for the work.

RayOkaah avatar Oct 18 '21 01:10 RayOkaah

Thanks. Please point me to any resource I can read up on broadcasting on a network. Thanks for the work.

For ETH below link may help

https://infura.io/product/ethereum

https://docs.etherscan.io/

weishirongzhen avatar Oct 18 '21 01:10 weishirongzhen

Hello. How can I use this package? I ask this, cause before, you wrote in README that we need to build trustwallet core and move to flutter plugin. But now, you removed this steps from README.md. So, I can clone this repo and just use without any building?

sylvestrevgen avatar Nov 22 '21 12:11 sylvestrevgen

yes, if you want to use in your own project just add this in your yaml

 flutter_trust_wallet_core:
    git:
      url: https://github.com/weishirongzhen/flutter_trust_wallet_core_lib_include.git

weishirongzhen avatar Nov 22 '21 12:11 weishirongzhen

Okay. But how it works? We are building our wallet app and цe're worried about security. Cause we don't know what is inside android and ios builds. Maybe, mining?)) Sorry, it is joke. But we are a little worried.

sylvestrevgen avatar Nov 22 '21 12:11 sylvestrevgen

But you have done an excellent work and we really want to use your plugin.

sylvestrevgen avatar Nov 22 '21 12:11 sylvestrevgen

if you are worry , you can build your own lib to use. for android only need to change CMakeList.txt line 14 , from "hidden" to "default", and follow the official build step. for iOS, nothing need to change, just follow the official build step. and then replace your lib in to project.

weishirongzhen avatar Nov 22 '21 13:11 weishirongzhen

So, for our own builds, we need just move android build to android/libs/....aar, and ios - ios/frameworks/...? Thats all?

sylvestrevgen avatar Nov 22 '21 13:11 sylvestrevgen

yep, that's all you need to do

weishirongzhen avatar Nov 22 '21 13:11 weishirongzhen

Understood, thank you so much for information. And thank you for all your work. Please, keep going your excellent work.

sylvestrevgen avatar Nov 22 '21 13:11 sylvestrevgen

Understood, thank you so much for information. And thank you for all your work. Please, keep going your excellent work.

Thanks, there still are lots of code to do, I'm busy at other flutter project, this project are quite slow progress, but will keep update.

weishirongzhen avatar Nov 22 '21 13:11 weishirongzhen

Hello. I try to launch on Android and its crashed. I built trustwalletcore.aar from wallet-core repo, put in /android/libs but error occured. Do you know how can I fix this problem, Also, trying to use repo flutter_trust_wallet_core_include_lib, but the same error Screenshot 2021-12-21 at 16 18 40 .

sylvestrevgen avatar Dec 21 '21 14:12 sylvestrevgen

Hello. I try to launch on Android and its crashed. I built trustwalletcore.aar from wallet-core repo, put in /android/libs but error occured. Do you know how can I fix this problem, Also, trying to use repo flutter_trust_wallet_core_include_lib, but the same error Screenshot 2021-12-21 at 16 18 40 .

Didn't try this project run on x86 platform, try use arm device to run it.

weishirongzhen avatar Dec 22 '21 01:12 weishirongzhen

@weishirongzhen Do you know why does it only affect the android build?

hnord-vdx avatar Feb 16 '22 16:02 hnord-vdx

构建 ios 需要 调整这个值吗? set(CMAKE_CXX_VISIBILITY_PRESET default) @weishirongzhen

weixuefeng avatar Jul 19 '23 08:07 weixuefeng

构建 ios 需要 调整这个值吗? set(CMAKE_CXX_VISIBILITY_PRESET default) @weishirongzhen 不需要

weishirongzhen avatar Jul 21 '23 03:07 weishirongzhen

构建 ios 需要 调整这个值吗? set(CMAKE_CXX_VISIBILITY_PRESET default) @weishirongzhen 不需要

好的,多谢。可以帮看看这个问题吗? https://github.com/trustwallet/wallet-core/discussions/3319

我根据官方文档构建出来的 WalletCore.xcframework, 没办法解密keystore,但是官方直接提供的可以解密,是不是我哪个步骤走错了?最后 WalletCore.xcframework 是从 swift/build/WalletCore.xcframework 取的。 @weishirongzhen

weixuefeng avatar Jul 21 '23 03:07 weixuefeng

构建 ios 需要 调整这个值吗? set(CMAKE_CXX_VISIBILITY_PRESET default) @weishirongzhen 不需要

好的,多谢。可以帮看看这个问题吗? trustwallet/wallet-core#3319

我根据官方文档构建出来的 WalletCore.xcframework, 没办法解密keystore,但是官方直接提供的可以解密,是不是我哪个步骤走错了?最后 WalletCore.xcframework 是从 swift/build/WalletCore.xcframework 取的。 @weishirongzhen

请提供下具体的代码调用过程

weishirongzhen avatar Jul 21 '23 04:07 weishirongzhen

构建 ios 需要 调整这个值吗? set(CMAKE_CXX_VISIBILITY_PRESET default) @weishirongzhen 不需要

好的,多谢。可以帮看看这个问题吗? trustwallet/wallet-core#3319 我根据官方文档构建出来的 WalletCore.xcframework, 没办法解密keystore,但是官方直接提供的可以解密,是不是我哪个步骤走错了?最后 WalletCore.xcframework 是从 swift/build/WalletCore.xcframework 取的。 @weishirongzhen

请提供下具体的代码调用过程

@weishirongzhen my build command is:

./tools/install-dependencies
./tools/install-rust-dependencies
./tools/install-wasm-dependencies

./tools/generate-files ios
cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Debug
 make -Cbuild && ./tools/ios-build && ./tools/ios-xcframework

then i got

./swift/build/WalletCore.xcframework/
./swift/build/SwiftProtobuf.xcframework/

then i import WalletCore.xcframework & SwiftProtobuf.xcframework to my ios project, all code is:

//
//  ContentView.swift
//  wallet
//
//

import SwiftUI
import WalletCore
struct ContentView: View {
    var json = """
                {"crypto":{"cipher":"aes-128-ctr","cipherparams":{"iv":"5fe1054ca4ca68c5f8ee1346cd062239"},"ciphertext":"ae7db4237ec6913241dcf7bcfb6e06671ae381906a2866b04771082ed0204ac4","kdf":"scrypt","kdfparams":{"dklen":32,"n":16384,"p":4,"r":8,"salt":""},"mac":"9ed6e105ebcc39ba38706166a24f03ebfa153fc41bc028418dafb08518d6ebae"},"id":"b4c58a86-f609-4c12-88bd-666cc2ee73be","name":"name","type":"private-key","version":3}
""";
    var body: some View {
        
        VStack {
            Image(systemName: "globe")
                .imageScale(.large)
                .foregroundColor(.accentColor)
            Text("Hello, world!")
            Button("click") {
                
         
                print(SegwitAddress.isValidString(string: "bc1qyd9ky0n2dh8nggk8m4thllh0qh0w2ea2asvtl5"))
                print(SegwitAddress.isValidString(string: "1CFx8Qvd3ioDHYWHJMSMNeredCCkW96wAA"))
                let storedKey = StoredKey.importJSON(json: json.data(using: String.Encoding.utf8)!)!
             
                let privatekey = storedKey.decryptPrivateKey(password: "password".data(using: String.Encoding.utf8)!)
                
                
                print(privatekey?.hexString)
            }
        }
        .padding()
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

then i click click, i can not decrypt keystore, privateKeyHex is nil. but when i use official package, i can decrypt then same keystore, so , is there have some problem about my build flow?

weixuefeng avatar Jul 22 '23 07:07 weixuefeng

I think you can try with below two step

./bootstrap.sh
./tools/ios-xcframework

then copy new WalletCore.xcframework and SwiftProtobuf.xcframework to you project

weishirongzhen avatar Jul 26 '23 01:07 weishirongzhen

i got nil too... Did you make it? @weishirongzhen

weixuefeng avatar Jul 26 '23 13:07 weixuefeng