TokenCore is a blockchain library. TokenCore provides the relatively consistent API that allows you to manage your wallets and sign transactions in BTC, ETH and EOS chains simultaneously.In addition, TokenCore introduces the concept of 'identity', you can use the same mnemonic to manage wallets on the three chains.
Step 1. Add the JitPack repository to your build fileAdd it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Step 2. Add the dependency
dependencies {
implementation 'com.github.consenlabs:token-core-android:v0.1'
}
Step 3. Add the JAVA8 support to your build.gradle
android {
……
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
……
}
Step 4. (Optional) When you wants to debug your app in Android Oreo you shoud add the blow code to your build.gradle. Pls ref to https://issuetracker.google.com/issues/65941637 for more info.
android {
……
packagingOptions {
exclude 'lib/x86_64/darwin/libscrypt.dylib'
}
……
}
public class MainActivity extends AppCompatActivity implements KeystoreStorage {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WalletManager.storage = this;
WalletManager.scanWallets();
}
public File getKeystoreDir() {
return this.getFilesDir();
}
}
// You should create or recover Identity first before you create other wallets
// The last param, Metadata.P2WPKH means that the derived btc wallet is a SegWit wallet
Identity identity = Identity.createIdentity("MyFirstIdentity", SampleKey.PASSWORD, SampleKey.PASSWORD_HINT, Network.MAINNET, Metadata.P2WPKH);
Wallet ethereumWallet = identity.getWallets().get(0);
Wallet bitcoinWallet = identity.getWallets().get(1);
String prvKey = WalletManager.exportPrivateKey(ethereumWallet.getId(), SampleKey.PASSWORD);
System.out.println(String.format("PrivateKey: %s", prvKey));
String mnemonic = WalletManager.exportMnemonic(ethereumWallet.getId(), SampleKey.PASSWORD).getMnemonic();
System.out.println(String.format("Mnemonic: %s", mnemonic));
String json = WalletManager.exportKeystore(ethereumWallet.getId(), SampleKey.PASSWORD);
System.out.println(String.format("Keystore: %s", json));
// output:
// PrivateKey: f653be3f639f45ea1ed3eb152829b6d881ce62257aa873891e06fa9569a8d9aa
// Mnemonic: tide inmate cloud around wise bargain celery cement jungle melody galaxy grocery
// Keystore: {"id":"c7575eba-3ae3-4cc3-86ba-2eb9c6839cad","version":3,"crypto":{"ciphertext":"7083ba3dd5470ba4be4237604625e05fa6b668954d270beb848365cbf6933ec5","mac":"f4f9ea8d42ff348b11fc146c396da446cc975309b3538e08a58c0b218bddd15d","cipher":"aes-128-ctr","cipherparams":{"iv":"db3f523faf4da4f1c6edcd7bc1386879"},"kdf":"pbkdf2","kdfparams":{"dklen":32,"c":10240,"prf":"hmac-sha256","salt":"0ce830e9f888dfe33c31e6cfc444d6f588161c9d4128d4066ee5dfdcbc5d0079"}},"address":"4a1c2072ac67b616e5c578fd9e2a4d30e0158471"}
EthereumTransaction tran = new EthereumTransaction(BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, String to, BigInteger value, String data)
TxSignResult result = tran.signTransaction(chainId, SampleKey.PASSWORD, ethereumWallet);
String signedTx = result.getSignedTx(); // This is the signature result which you need to broadcast.
String txHash = result.getTxHash(); // This is txHash which you can use for locating your transaction record
Copyright 2018 imToken PTE. LTD.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Thanks bitcoinj, CoreBitcoin and others library.
cpp MD5.cpp #include "MD5.h" using namespace std; /* Constants for MD5Transform routine. */ #define S11 7 #define S12 12 #define S13 17 #define S14 22 #define S21 5 #define S22 9 #define S23 14 #def
原文链接:http://www.dubby.cn/detail.html?id=9069 我们在这里使用jackson-core提供的JsonParser和JsonGenerator来实现基本的序列化和反序列化。 1.数据和实体类 我们先定义出JSON字符串: { "id":123456789, "text":"我是杨正,我在http://www.dubby.cn", "fromUse
问题引入 在新平台开发过程中,测试同学一直抱怨在进入Launcher前,屏幕会黑屏闪现一下,大概2-3s,随后才进入,影响用户体验。刚开始没有特别关注,以为是启动Activity 过程中加载东西太多,导致窗体渲染有点慢。经过后续分析,原来另有原因,而且其中涉及好几个知识点。这里mark 一下。(在另一个平台上,出现了一个“平板正在启动中”的显示,产品同学很想拿掉或者替换,那么我们可以实现了?看完这
目录 android 开发 retrifit 中的token 一、我们先解释一下他的含义: 二、如何使用Token?
TokenCore TokenCore is a blockchain library. TokenCore provides the relatively consistent API that allows you to manage your wallets and sign transactions in BTC, ETH and EOS chains simultaneously.In
令牌表示文档中的文本或单词,其中包含相关详细信息,如元数据(位置,起始偏移,结束偏移,标记类型及其位置增量)。 Class 声明 (Class Declaration) 以下是org.apache.lucene.analysis.Token类的声明: public class Token extends TermAttributeImpl implements TypeAttri
import "go/token" Package token defines constants representing the lexical tokens of the Go programming language and basic operations on tokens (printing, predicates). Index Constants type File func (
定义用于与标准兼容的令牌消息和数据库表进行交互的ABI. 类 struct eosio::price 定义两个令牌之间的固定精确价格 struct eosio::token 详细描述
刷新令牌是可用于获取新访问令牌的凭据。 与访问令牌的生命周期相比,刷新令牌的生命周期要长得多。 刷新令牌也可以过期,但是很长时间都很安静。 当前访问令牌过期或变为无效时,授权服务器向客户端提供刷新令牌以获取新的访问令牌。 下图说明了刷新过期的访问令牌的过程。 Step 1 - 首先,客户端通过授权授权向授权服务器进行身份验证。 Step 2 - 接下来,授权服务器验证客户端,验证授权授权并向客户端
我们一个 SDK 应用在初始化以后,你可以在任何时机从应用中拿到该配置下的 Access Token 实例: use EasyWeChat\Factory; $config = [ //... ]; $app = Factory::officialAccount($config); // 获取 access token 实例 $accessToken = $app->access_t