-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #250 from JimmyShi22/release-2.0.0-rc2
Release 2.0.0 rc2
- Loading branch information
Showing
60 changed files
with
4,908 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v2.0.0-rc1 | ||
v2.0.0-rc2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
152 changes: 152 additions & 0 deletions
152
src/main/java/org/fisco/bcos/web3j/crypto/ExtendedRawTransaction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
package org.fisco.bcos.web3j.crypto; | ||
|
||
import org.fisco.bcos.web3j.tx.TransactionConstant; | ||
import org.fisco.bcos.web3j.utils.Numeric; | ||
|
||
import java.io.Serializable; | ||
import java.math.BigInteger; | ||
|
||
/** | ||
* Transaction class used for signing transactions locally.<br> | ||
* For the specification, refer to p4 of the <a href="http://gavwood.com/paper.pdf">yellow | ||
* paper</a>. | ||
*/ | ||
public class ExtendedRawTransaction implements Serializable { | ||
|
||
private static final long serialVersionUID = -5580814755985097996L; | ||
private BigInteger randomid; | ||
private BigInteger gasPrice; | ||
private BigInteger gasLimit; | ||
private BigInteger blockLimit; | ||
private String to; | ||
private BigInteger value; | ||
private String data; | ||
private BigInteger fiscoChainId; | ||
private BigInteger groupId; | ||
private String extraData; | ||
private BigInteger version = TransactionConstant.version; | ||
|
||
protected ExtendedRawTransaction( | ||
BigInteger randomid, | ||
BigInteger gasPrice, | ||
BigInteger gasLimit, | ||
BigInteger blockLimit, | ||
String to, | ||
BigInteger value, | ||
String data, | ||
BigInteger fiscoChainId, | ||
BigInteger groupId, | ||
String extraData) { | ||
this.randomid = randomid; | ||
this.gasPrice = gasPrice; | ||
this.gasLimit = gasLimit; | ||
this.blockLimit = blockLimit; | ||
this.fiscoChainId = fiscoChainId; | ||
this.groupId = groupId; | ||
this.extraData = extraData; | ||
this.to = to; | ||
|
||
this.value = value; | ||
|
||
if (data != null) { | ||
this.data = Numeric.cleanHexPrefix(data); | ||
} | ||
} | ||
|
||
public static ExtendedRawTransaction createContractTransaction( | ||
BigInteger randomid, | ||
BigInteger gasPrice, | ||
BigInteger gasLimit, | ||
BigInteger blockLimit, | ||
BigInteger value, | ||
String init, | ||
BigInteger chainId, | ||
BigInteger groupId, | ||
String extraData) { | ||
|
||
return new ExtendedRawTransaction(randomid, gasPrice, gasLimit, blockLimit, "", value, init,chainId,groupId,extraData); | ||
} | ||
// | ||
// | ||
// public static ExtendedRawTransaction createTransaction( | ||
// BigInteger randomid, | ||
// BigInteger gasPrice, | ||
// BigInteger gasLimit, | ||
// BigInteger blockLimit, | ||
// String to, | ||
// String data) { | ||
// return createTransaction(randomid, gasPrice, gasLimit, blockLimit, to, BigInteger.ZERO, data); | ||
// } | ||
|
||
public static ExtendedRawTransaction createTransaction( | ||
BigInteger randomid, | ||
BigInteger gasPrice, | ||
BigInteger gasLimit, | ||
BigInteger blockLimit, | ||
String to, | ||
BigInteger value, | ||
String data, | ||
BigInteger chainId, | ||
BigInteger groupId, | ||
String extraData) { | ||
|
||
return new ExtendedRawTransaction(randomid, gasPrice, gasLimit, blockLimit, to, value, data,chainId, groupId, extraData); | ||
} | ||
|
||
public BigInteger getRandomid() { | ||
return randomid; | ||
} | ||
|
||
public BigInteger getGasPrice() { | ||
return gasPrice; | ||
} | ||
|
||
public BigInteger getGasLimit() { | ||
return gasLimit; | ||
} | ||
|
||
public BigInteger getBlockLimit() { | ||
return blockLimit; | ||
} | ||
|
||
public String getTo() { | ||
return to; | ||
} | ||
|
||
public BigInteger getValue() { | ||
return value; | ||
} | ||
|
||
public String getData() { | ||
return data; | ||
} | ||
|
||
public BigInteger getVersion() { | ||
return version; | ||
} | ||
public BigInteger getGroupId() { | ||
return groupId; | ||
} | ||
|
||
public void setGroupId(BigInteger groupId) { | ||
this.groupId = groupId; | ||
} | ||
|
||
|
||
public String getExtraData() { | ||
return extraData; | ||
} | ||
|
||
public void setExtraData(String extraData) { | ||
this.extraData = extraData; | ||
} | ||
|
||
public BigInteger getFiscoChainId() { | ||
return fiscoChainId; | ||
} | ||
|
||
public void setFiscoChainId(BigInteger fiscoChainId) { | ||
this.fiscoChainId = fiscoChainId; | ||
} | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/org/fisco/bcos/web3j/crypto/ExtendedTransactionDecoder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.fisco.bcos.web3j.crypto; | ||
|
||
import org.fisco.bcos.web3j.rlp.RlpDecoder; | ||
import org.fisco.bcos.web3j.rlp.RlpList; | ||
import org.fisco.bcos.web3j.rlp.RlpString; | ||
import org.fisco.bcos.web3j.utils.Numeric; | ||
|
||
import java.math.BigInteger; | ||
|
||
public class ExtendedTransactionDecoder { | ||
|
||
public static ExtendedRawTransaction decode(String hexTransaction) { | ||
byte[] transaction = Numeric.hexStringToByteArray(hexTransaction); | ||
RlpList rlpList = RlpDecoder.decode(transaction); | ||
RlpList values = (RlpList) rlpList.getValues().get(0); | ||
BigInteger randomid = ((RlpString) values.getValues().get(0)).asPositiveBigInteger(); | ||
BigInteger gasPrice = ((RlpString) values.getValues().get(1)).asPositiveBigInteger(); | ||
BigInteger gasLimit = ((RlpString) values.getValues().get(2)).asPositiveBigInteger(); | ||
BigInteger blockLimit = ((RlpString) values.getValues().get(3)).asPositiveBigInteger(); | ||
String to = ((RlpString) values.getValues().get(4)).asString(); | ||
BigInteger value = ((RlpString) values.getValues().get(5)).asPositiveBigInteger(); | ||
String data = ((RlpString) values.getValues().get(6)).asString(); | ||
|
||
//add extra data | ||
BigInteger chainId = ((RlpString) values.getValues().get(7)).asPositiveBigInteger(); | ||
BigInteger groupId = ((RlpString) values.getValues().get(8)).asPositiveBigInteger(); | ||
String extraData = ((RlpString) values.getValues().get(9)).asString(); | ||
if (values.getValues().size() > 9) { | ||
byte v = ((RlpString) values.getValues().get(10)).getBytes()[0]; | ||
byte[] r = | ||
Numeric.toBytesPadded( | ||
Numeric.toBigInt(((RlpString) values.getValues().get(11)).getBytes()), 32); | ||
byte[] s = | ||
Numeric.toBytesPadded( | ||
Numeric.toBigInt(((RlpString) values.getValues().get(12)).getBytes()), 32); | ||
Sign.SignatureData signatureData = new Sign.SignatureData(v, r, s); | ||
return new SignedExtendedRawTransaction( | ||
randomid, gasPrice, gasLimit, blockLimit, to, value, data,chainId, groupId, extraData, signatureData); | ||
} else { | ||
return ExtendedRawTransaction.createTransaction( | ||
randomid, gasPrice, gasLimit, blockLimit, to, value, data,chainId, groupId, extraData); | ||
} | ||
} | ||
} |
Oops, something went wrong.