Skip to content

Commit

Permalink
更改波场依赖结构
Browse files Browse the repository at this point in the history
  • Loading branch information
GalaxySciTech committed Jun 20, 2021
1 parent e8f54a7 commit 12dec9d
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 89 deletions.
55 changes: 26 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,46 +22,44 @@
<a href="LICENSE">
<img src="https://img.shields.io/github/license/paipaipaipai/tokencore.svg">
</a>

</p>

# 联系方式
# contact details

- [我的Telegram](https://t.me/lailaibtc) / @Telegram
- [My Telegram](https://t.me/lailaibtc) / @Telegram

If you need the [java-wallet](https://github.com/paipaipaipai/java-wallet) wallet backend source code or build, you can directly add me to a private chat

如需要 [java-wallet](https://github.com/paipaipaipai/java-wallet) 钱包后台源码或者搭建,可以直接加我私聊
# language selection

# 语言选择
- en [English](README_en.md)
- zh_CN [简体中文](README.md)

# tokencore介绍
- zh_CN [Simplified Chinese](README.md)

##### 区块链钱包后台核心组件,支持BTC,OMNI,ETH,ERC20,TRX,TRC20,BCH,BSV,DOGE,DASH,LTC,FILECOIN
# tokencore introduction

# tokencore使用方式
##### The core components of the blockchain wallet backend, support BTC, OMNI, ETH, ERC20, TRX, TRC20, BCH, BSV, DOGE, DASH, LTC,FILECOIN

#### 引入本库
# tokencore usage

- gradle方式 在你的build.gradle里面

#### Introducing this library
- gradle way
In your build.gradle
```
repositories {
maven { url "https://dl.bintray.com/tronj/tronj" }
maven { url 'https://jitpack.io' }
}
dependencies {
compile 'com.github.lailaibtc:tokencore:1.2.1'
}
```

- maven方式

- maven way
```
<repositories>
<repository>
<id>bintray</id>
<id>tronj</id>
<url>https://dl.bintray.com/tronj/tronj</url>
</repository>
<repository>
Expand All @@ -76,16 +74,16 @@
<version>1.1.1</version>
</dependency>
```
#### 测试样例
[https://github.com/paipaipaipai/tokencore/blob/master/src/test/java/org/consenlabs/tokencore/Test.java](https://github.com/paipaipaipai/tokencore/blob/master/src/test/java/org/consenlabs/tokencore/Test.java)
#### 初始化身份
#### Test sample
[https://github.com/paipaipaipai/tokencore/blob/master/src/test/java/org/consenlabs/tokencore/Test.java](https://github.com/paipaipaipai/tokencore/blob/master/ src/test/java/org/consenlabs/tokencore/Test.java)
#### Initialize identity

```java
try{
Files.createDirectories(Paths.get("${keyStoreProperties.dir}/wallets"))
}catch(Throwable ignored){
}
//KeystoreStorage是接口,实现它的getdir方法
//KeystoreStorage is an interface that implements its getdir method
WalletManager.storage=KeystoreStorage();
WalletManager.scanWallets();
String password="123456";
Expand All @@ -101,7 +99,7 @@
}
```

#### 生成钱包
#### Generate wallet

```java
Identity identity = Identity.getCurrentIdentity();
Expand All @@ -115,17 +113,17 @@

```

#### 离线签名
#### Offline signature

- 比特币
- Bitcoin

```java
String password = "123456";
String toAddress = "33sXfhCBPyHqeVsVthmyYonCBshw5XJZn9";
int changeIdx = 0;
long amount = 1000L;
long fee = 555L;
//utxos需要去节点或者外部api获取
//utxos needs to go to the node or external api to get
ArrayList<BitcoinTransaction.UTXO> utxos = new ArrayList();
BitcoinTransaction bitcoinTransaction = new BitcoinTransaction(
toAddress,
Expand All @@ -143,7 +141,7 @@
System.out.println(txSignResult);
```

- 波场
- TRON

```java
String from = "TJRabPrwbZy45sbavfcjinPJC18kjpRTv8";
Expand All @@ -152,11 +150,10 @@
String password = "123456";
Wallet wallet = WalletManager.findWalletByAddress(ChainType.BITCOIN, "TJRabPrwbZy45sbavfcjinPJC18kjpRTv8");
TronTransaction transaction = new TronTransaction(from, to, amount);
//离线签名,不建议签名和广播放一块
//Offline signature, it is not recommended to sign and broadcast together
TxSignResult txSignResult = transaction.signTransaction(String.valueOf(ChainId.BITCOIN_MAINNET), password, wallet);

System.out.println(txSignResult);
```

#### 注意:这只是一个数字货币的功能组件!!!只供学习使用,不提供完整的区块链业务功能

#### Note: This is just a functional component of a digital currency! ! ! It is only for learning and does not provide complete blockchain business functions
55 changes: 28 additions & 27 deletions README_en.md → README_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,45 +22,45 @@
<a href="LICENSE">
<img src="https://img.shields.io/github/license/paipaipaipai/tokencore.svg">
</a>

</p>

# contact details
# 联系方式

- [My Telegram](https://t.me/lailaibtc) / @Telegram

If you need the [java-wallet](https://github.com/paipaipaipai/java-wallet) wallet backend source code or build, you can directly add me to a private chat
- [我的Telegram](https://t.me/lailaibtc) / @Telegram

# language selection
如需要 [java-wallet](https://github.com/paipaipaipai/java-wallet) 钱包后台源码或者搭建,可以直接加我私聊

# 语言选择
- en [English](README_en.md)
- zh_CN [Simplified Chinese](README.md)
- zh_CN [简体中文](README.md)

# tokencore介绍

# tokencore introduction
##### 区块链钱包后台核心组件,支持BTC,OMNI,ETH,ERC20,TRX,TRC20,BCH,BSV,DOGE,DASH,LTC,FILECOIN

##### The core components of the blockchain wallet backend, support BTC, OMNI, ETH, ERC20, TRX, TRC20, BCH, BSV, DOGE, DASH, LTC,FILECOIN
# tokencore使用方式

# tokencore usage
#### 引入本库

- gradle方式 在你的build.gradle里面

#### Introducing this library
- gradle way
In your build.gradle
```
repositories {
maven { url "https://dl.bintray.com/tronj/tronj" }
maven { url 'https://jitpack.io' }
}
dependencies {
compile 'com.github.lailaibtc:tokencore:1.2.1'
}
```

- maven way
- maven方式

```
<repositories>
<repository>
<id>tronj</id>
<id>bintray</id>
<url>https://dl.bintray.com/tronj/tronj</url>
</repository>
<repository>
Expand All @@ -75,16 +75,16 @@ In your build.gradle
<version>1.1.1</version>
</dependency>
```
#### Test sample
[https://github.com/paipaipaipai/tokencore/blob/master/src/test/java/org/consenlabs/tokencore/Test.java](https://github.com/paipaipaipai/tokencore/blob/master/ src/test/java/org/consenlabs/tokencore/Test.java)
#### Initialize identity
#### 测试样例
[https://github.com/paipaipaipai/tokencore/blob/master/src/test/java/org/consenlabs/tokencore/Test.java](https://github.com/paipaipaipai/tokencore/blob/master/src/test/java/org/consenlabs/tokencore/Test.java)
#### 初始化身份

```java
try{
Files.createDirectories(Paths.get("${keyStoreProperties.dir}/wallets"))
}catch(Throwable ignored){
}
//KeystoreStorage is an interface that implements its getdir method
//KeystoreStorage是接口,实现它的getdir方法
WalletManager.storage=KeystoreStorage();
WalletManager.scanWallets();
String password="123456";
Expand All @@ -100,7 +100,7 @@ In your build.gradle
}
```

#### Generate wallet
#### 生成钱包

```java
Identity identity = Identity.getCurrentIdentity();
Expand All @@ -114,17 +114,17 @@ In your build.gradle

```

#### Offline signature
#### 离线签名

- Bitcoin
- 比特币

```java
String password = "123456";
String toAddress = "33sXfhCBPyHqeVsVthmyYonCBshw5XJZn9";
int changeIdx = 0;
long amount = 1000L;
long fee = 555L;
//utxos needs to go to the node or external api to get
//utxos需要去节点或者外部api获取
ArrayList<BitcoinTransaction.UTXO> utxos = new ArrayList();
BitcoinTransaction bitcoinTransaction = new BitcoinTransaction(
toAddress,
Expand All @@ -142,7 +142,7 @@ In your build.gradle
System.out.println(txSignResult);
```

- TRON
- 波场

```java
String from = "TJRabPrwbZy45sbavfcjinPJC18kjpRTv8";
Expand All @@ -151,10 +151,11 @@ In your build.gradle
String password = "123456";
Wallet wallet = WalletManager.findWalletByAddress(ChainType.BITCOIN, "TJRabPrwbZy45sbavfcjinPJC18kjpRTv8");
TronTransaction transaction = new TronTransaction(from, to, amount);
//Offline signature, it is not recommended to sign and broadcast together
//离线签名,不建议签名和广播放一块
TxSignResult txSignResult = transaction.signTransaction(String.valueOf(ChainId.BITCOIN_MAINNET), password, wallet);

System.out.println(txSignResult);
```

#### Note: This is just a functional component of a digital currency! ! ! It is only for learning and does not provide complete blockchain business functions
#### 注意:这只是一个数字货币的功能组件!!!只供学习使用,不提供完整的区块链业务功能

8 changes: 3 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ allprojects {

repositories {
jcenter()
maven { url "https://dl.bintray.com/tronj/tronj" }
maven { url "https://jitpack.io" }
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
mavenCentral()
}

Expand All @@ -40,9 +39,8 @@ dependencies {

compile 'com.github.paipaipaipai:FilecoinJ:0.0.1'
compile 'com.google.protobuf:protobuf-java:3.11.0'
compile 'org.tron.tronj:abi:0.1.2'
compile 'org.tron.tronj:client:0.1.2'
compile 'org.tron.tronj:utils:0.1.2'

compile 'com.github.lailaibtc:trident:0.0.3'

compile 'com.google.guava:guava:28.0-jre'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@
import org.consenlabs.tokencore.wallet.model.Messages;
import org.consenlabs.tokencore.wallet.model.TokenException;
import org.spongycastle.util.encoders.Hex;
import org.tron.tronj.client.TronClient;
import org.tron.tronj.client.exceptions.IllegalException;
import org.tron.tronj.crypto.SECP256K1;
import org.tron.tronj.crypto.tuweniTypes.Bytes32;
import org.tron.tronj.proto.Chain;
import org.tron.tronj.proto.Response;
import org.tron.tronj.abi.FunctionEncoder;
import org.tron.tronj.abi.TypeReference;
import org.tron.tronj.abi.datatypes.Address;
import org.tron.tronj.abi.datatypes.Bool;
import org.tron.tronj.abi.datatypes.Function;
import org.tron.tronj.abi.datatypes.generated.Uint256;
import org.tron.tronj.proto.Chain.Transaction;
import org.tron.tronj.proto.Contract.TriggerSmartContract;
import org.tron.tronj.proto.Response.TransactionExtention;
import org.tron.trident.abi.FunctionEncoder;
import org.tron.trident.abi.TypeReference;
import org.tron.trident.abi.datatypes.Address;
import org.tron.trident.abi.datatypes.Bool;
import org.tron.trident.abi.datatypes.Function;
import org.tron.trident.abi.datatypes.generated.Uint256;
import org.tron.trident.core.ApiWrapper;
import org.tron.trident.core.exceptions.IllegalException;
import org.tron.trident.crypto.SECP256K1;
import org.tron.trident.crypto.tuwenitypes.Bytes32;
import org.tron.trident.proto.Chain;
import org.tron.trident.proto.Contract;
import org.tron.trident.proto.Response;

import java.math.BigInteger;
import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -68,7 +67,7 @@ public TronTransaction(String from, String to, String contractAddress, long amou

private String contractAddress;

TronClient client = TronClient.ofMainnet("");
ApiWrapper client = ApiWrapper.ofMainnet("");

@Override
public TxSignResult signTransaction(String chainId, String password, Wallet wallet) {
Expand Down Expand Up @@ -114,17 +113,17 @@ public TxSignResult signTrc20Transaction(String chainId, String password, Wallet

String encodedHex = FunctionEncoder.encode(trc20Transfer);

TriggerSmartContract trigger =
TriggerSmartContract.newBuilder()
.setOwnerAddress(TronClient.parseAddress(from))
.setContractAddress(TronClient.parseAddress(contractAddress))
.setData(TronClient.parseHex(encodedHex))
Contract.TriggerSmartContract trigger =
Contract.TriggerSmartContract.newBuilder()
.setOwnerAddress(ApiWrapper.parseAddress(from))
.setContractAddress(ApiWrapper.parseAddress(contractAddress))
.setData(ApiWrapper.parseHex(encodedHex))
.build();

TransactionExtention txnExt = client.blockingStub.triggerContract(trigger);
Response.TransactionExtention txnExt = client.blockingStub.triggerContract(trigger);
String txid = Hex.toHexString(txnExt.getTxid().toByteArray());

Transaction signedTxn = client.signTransaction(txnExt, keyPair);
Chain.Transaction signedTxn = client.signTransaction(txnExt, keyPair);

return new TxSignResult(signedTxn.toString(), txid);
}
Expand Down
9 changes: 4 additions & 5 deletions src/test/java/org/consenlabs/tokencore/Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
import org.consenlabs.tokencore.wallet.transaction.BitcoinTransaction;
import org.consenlabs.tokencore.wallet.transaction.TronTransaction;
import org.consenlabs.tokencore.wallet.transaction.TxSignResult;
import org.tron.tronj.client.TronClient;
import org.tron.tronj.client.exceptions.IllegalException;
import org.tron.tronj.proto.Chain;
import org.tron.tronj.proto.Response;
import org.tron.trident.core.ApiWrapper;
import org.tron.trident.core.exceptions.IllegalException;
import org.tron.trident.proto.Response;

import java.io.File;
import java.nio.file.Files;
Expand Down Expand Up @@ -122,7 +121,7 @@ static public void signTrxTx() {

public static void main(String[] args) throws IllegalException {

TronClient tronClient=TronClient.ofMainnet("");
ApiWrapper tronClient= ApiWrapper.ofMainnet("");
Response.TransactionInfo tx=tronClient.getTransactionInfoById("f3a54e8418edb5a91772e3fe6768a7a4e55fc6c33f212641c239589d8a453a58");
}

Expand Down

0 comments on commit 12dec9d

Please sign in to comment.