Merge pull request #7 from nicksavers/master

Fix sending Transaction to CPP client
This commit is contained in:
romanman 2014-05-21 01:14:01 +03:00
commit 36e0bc5397
2 changed files with 10 additions and 4 deletions

View File

@ -8,6 +8,7 @@ import org.ethereum.util.RLPItem;
import org.ethereum.util.RLPList;
import org.ethereum.util.Utils;
import org.spongycastle.util.BigIntegers;
import org.spongycastle.util.encoders.Hex;
import java.util.Arrays;
@ -256,8 +257,12 @@ public class Transaction {
byte[] data = RLP.encodeElement(this.data);
byte[] v = RLP.encodeByte( signature.v );
byte[] r = RLP.encodeElement(BigIntegers.asUnsignedByteArray(signature.r));
byte[] s = RLP.encodeElement(BigIntegers.asUnsignedByteArray(signature.s));
byte[] rBytes = BigIntegers.asUnsignedByteArray(signature.r);
System.out.println(Hex.toHexString(rBytes));
byte[] r = RLP.encodeElement(rBytes);
byte[] sBytes = BigIntegers.asUnsignedByteArray(signature.s);
System.out.println(Hex.toHexString(sBytes));
byte[] s = RLP.encodeElement(sBytes);
if(Arrays.equals(this.receiveAddress, new byte[0])) {
byte[] init = RLP.encodeElement(this.init);

View File

@ -5,6 +5,7 @@ import org.ethereum.core.Transaction;
import org.ethereum.crypto.HashUtil;
import org.ethereum.manager.MainData;
import org.ethereum.net.client.ClientPeer;
import org.spongycastle.util.BigIntegers;
import org.spongycastle.util.encoders.Hex;
import java.awt.*;
@ -70,8 +71,8 @@ class PayOutDialog extends JDialog {
byte[] gasPrice= Hex.decode("09184e72a000");
byte[] gas = Hex.decode("4255");
Transaction tx = new Transaction(null, value.toByteArray(),
receiveAddress.getAddress(), gasPrice, gas, null);
Transaction tx = new Transaction(null, gasPrice, gas,
receiveAddress.getAddress(), BigIntegers.asUnsignedByteArray(value), null);
try {
tx.sign(senderPrivKey);