diff --git a/ethereumj-core/src/main/java/org/ethereum/core/Wallet.java b/ethereumj-core/src/main/java/org/ethereum/core/Wallet.java index 71fac7ac..cf36b311 100644 --- a/ethereumj-core/src/main/java/org/ethereum/core/Wallet.java +++ b/ethereumj-core/src/main/java/org/ethereum/core/Wallet.java @@ -97,12 +97,15 @@ public class Wallet { for (Transaction tx : transactions){ + byte[] senderAddress = tx.sender(); AddressState senderState = rows.get(Hex.toHexString(senderAddress)); if (senderState != null){ BigInteger value = new BigInteger(tx.getValue()); senderState.addToBalance(value.negate()); + + senderState.incrementTheNonce(); walletUpdated = true; } diff --git a/ethereumj-core/src/main/java/org/ethereum/gui/PayOutDialog.java b/ethereumj-core/src/main/java/org/ethereum/gui/PayOutDialog.java index 26ec7f23..b7ac22b0 100644 --- a/ethereumj-core/src/main/java/org/ethereum/gui/PayOutDialog.java +++ b/ethereumj-core/src/main/java/org/ethereum/gui/PayOutDialog.java @@ -69,7 +69,7 @@ class PayOutDialog extends JDialog { BigInteger value = new BigInteger(amountInput.getText()); byte[] address = Hex.decode(receiverInput.getText()); - byte[] senderPrivKey = HashUtil.sha3(addressState.getEcKey().getPrivKeyBytes()); + byte[] senderPrivKey = addressState.getEcKey().getPrivKeyBytes(); byte[] nonce = addressState.getNonce() == BigInteger.ZERO ? null : addressState.getNonce().toByteArray(); @@ -88,7 +88,6 @@ class PayOutDialog extends JDialog { } peer.sendTransaction(tx); - addressState.incrementTheNonce(); } } ); diff --git a/ethereumj-core/src/main/java/org/ethereum/util/RLP.java b/ethereumj-core/src/main/java/org/ethereum/util/RLP.java index 985cdc82..d0c37148 100644 --- a/ethereumj-core/src/main/java/org/ethereum/util/RLP.java +++ b/ethereumj-core/src/main/java/org/ethereum/util/RLP.java @@ -788,8 +788,12 @@ public class RLP { public static byte[] encodeElement(byte[] srcData) { - if (srcData == null){ - return new byte[] { (byte) 0x80 }; + if (srcData == null) { + return new byte[]{(byte) 0x80}; + } if (srcData.length == 1 && srcData[0] < 0x80) { + + return srcData; + } else if (srcData.length <= 0x37) { // length = 8X byte length = (byte) (OFFSET_SHORT_ITEM + srcData.length);