In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "what is the use of Bytom-Mobile-Wallet-SDK". In the daily operation, I believe that many people have doubts about the use of Bytom-Mobile-Wallet-SDK. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "what is the use of Bytom-Mobile-Wallet-SDK?" Next, please follow the editor to study!
Bytom-Mobile-Wallet-SDK is the wallet layer code extracted from the bytom source code, and modified the wallet layer code. Using gomobile, the code can be compiled into SDK available on Android and iOS platforms, and the compiled Android and iOS wallet SDK can be used to create bytom keys, accounts, addresses and transaction signatures on the mobile side.
Brief introduction of Bytom-Mobile-Wallet-SDK source code
The SDK source code is placed in the sdk folder of the project. The android and ios folders are demo projects that use SDK. Functions that can be called externally with uppercase initials in bind.go are provided as API for Android and iOS calls. The key pair created by bytom is stored in a separate file on disk, and the private key is encrypted, and the account address data is stored in leveldb implemented by go, so Android and iOS platforms also need to provide a path for data storage.
Func InitWallet (storagePath string) {hsm: = pseudohsm.New (storagePath) walletDB: = db.NewDB ("wallet", "leveldb", storagePath) accounts: = account.NewManager (walletDB) assets: = asset.NewRegistry (walletDB) wallet: = aWallet.NewWallet (walletDB, accounts, assets, hsm) api = aApi.API {Wallet: wallet}}
Android and iOS platforms need to call the InitWallet API before calling other wallet API. The parameter is the absolute path on disk. InitWallet will initialize the entire wallet, of which the most important thing is to initialize the storage of leveldb. Other CreateKey, CreateAccount, CreateAccountReceiver are created keys, accounts, addresses and other API,RestoreWallet API data that can backup and export all the account address assets of the wallet in json format.
Compilation of Bytom-Mobile-Wallet-SDK
The compilation of SDK code first requires the correct installation of golang and gomobile,golang requires version 1.7 or above.
The Android platform needs to install JDK, Android SDK, Android NDK, and the platform-tools and ndk-bundle of Android SDK need to be added to the PATH system environment variable. The compilation environment of the iOS platform is relatively simple to configure as long as you install Xcode.
Clone project to the local $GOPATH/src:
Git clone https://github.com/Bytom-Community/Bytom-Mobile-Wallet-SDK $GOPATH/src/github.com/bytom-community/mobileAndroidgomobile init-ndk ~ / path/to/your/ndkcd $GOPATH/src/github.com/bytom-community/mobilegomobile bind-target=android github.com/bytom-community/mobile/sdk/
If you need to reduce the size of the SDK, add the-ldflags=-s parameter to the gomobile bind instruction:
Gomobile bind-target=android-ldflags=-s github.com/bytom-community/mobile/sdk/
Wallet.aar and wallet-sources.jar files are generated in the mobile folder after the instruction is executed.
IOScd $GOPATH/src/github.com/bytom-community/mobilegomobile bind-target=ios github.com/bytom-community/mobile/sdk/
If you need to reduce the size of the SDK, add the-ldflags=-w parameter to the gomobile bind instruction:
$gomobile bind-target=ios-ldflags=-w github.com/bytom-community/mobile/sdk/
The wallet.framework file is generated in the mobile folder after the instruction is executed.
Since gomobile does not currently support bitcode, the generated iOS SDK does not support bitcode either.
The use of Android for Bytom-Mobile-Wallet-SDK
Copy wallet.aar and wallet-sources.ja to the libs folder of app in the Android project, and add to the build.gradle file in app module:
Android {repositories {flatDir {dirs' libs'}} dependencies {implementation fileTree (include: ['* .jar'], dir: 'libs') implementation (name:' wallet', ext: 'aar')}
After sync project, you can call API of SDK in the Android project:
Package io.bytom.community;import android.app.Activity;import android.os.Bundle;import android.util.Log;import android.widget.TextView;import wallet.Wallet;public class MainActivity extends Activity {@ Override protected void onCreate (Bundle savedInstanceState) {super.onCreate (savedInstanceState); setContentView (R.layout.activity_main); TextView keyTextView = (TextView) findViewById (R.id.key_textview); String storagePath = getFilesDir () .toString () Log.d ("storagePath", storagePath); Wallet.initWallet (storagePath); String keyResult = Wallet.createKey ("Marshall", "123456"); Log.d ("keyResult", keyResult); keyTextView.setText (keyResult);}} iOS
By adding wallet.framework to the project through the Linked frameworks and libraries of the project target, you can call the API of the SDK in the iOS project:
# import "ViewController.h" # import "Wallet/Wallet.h" / / Gomobile bind generated framework@interface ViewController () @ end@implementation ViewController@synthesize textLabel;- (void) loadView {[super loadView]; NSString * docPath = [NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; WalletInitWallet (docPath); textLabel.text = WalletCreateKey (@ "kevin", @ "123456") } @ end at this point, the study of "what is the use of Bytom-Mobile-Wallet-SDK" is over. I hope I can solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.