Fix for transaction process RLP and nonce update on block
This commit is contained in:
parent
b52da2cf4a
commit
2f73b98614
|
@ -97,12 +97,15 @@ public class Wallet {
|
||||||
|
|
||||||
for (Transaction tx : transactions){
|
for (Transaction tx : transactions){
|
||||||
|
|
||||||
|
|
||||||
byte[] senderAddress = tx.sender();
|
byte[] senderAddress = tx.sender();
|
||||||
AddressState senderState = rows.get(Hex.toHexString(senderAddress));
|
AddressState senderState = rows.get(Hex.toHexString(senderAddress));
|
||||||
if (senderState != null){
|
if (senderState != null){
|
||||||
BigInteger value = new BigInteger(tx.getValue());
|
BigInteger value = new BigInteger(tx.getValue());
|
||||||
|
|
||||||
senderState.addToBalance(value.negate());
|
senderState.addToBalance(value.negate());
|
||||||
|
|
||||||
|
senderState.incrementTheNonce();
|
||||||
walletUpdated = true;
|
walletUpdated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ class PayOutDialog extends JDialog {
|
||||||
BigInteger value = new BigInteger(amountInput.getText());
|
BigInteger value = new BigInteger(amountInput.getText());
|
||||||
byte[] address = Hex.decode(receiverInput.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 ?
|
byte[] nonce = addressState.getNonce() == BigInteger.ZERO ?
|
||||||
null : addressState.getNonce().toByteArray();
|
null : addressState.getNonce().toByteArray();
|
||||||
|
@ -88,7 +88,6 @@ class PayOutDialog extends JDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
peer.sendTransaction(tx);
|
peer.sendTransaction(tx);
|
||||||
addressState.incrementTheNonce();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -788,8 +788,12 @@ public class RLP {
|
||||||
|
|
||||||
public static byte[] encodeElement(byte[] srcData) {
|
public static byte[] encodeElement(byte[] srcData) {
|
||||||
|
|
||||||
if (srcData == null){
|
if (srcData == null) {
|
||||||
return new byte[] { (byte) 0x80 };
|
return new byte[]{(byte) 0x80};
|
||||||
|
} if (srcData.length == 1 && srcData[0] < 0x80) {
|
||||||
|
|
||||||
|
return srcData;
|
||||||
|
|
||||||
} else if (srcData.length <= 0x37) {
|
} else if (srcData.length <= 0x37) {
|
||||||
// length = 8X
|
// length = 8X
|
||||||
byte length = (byte) (OFFSET_SHORT_ITEM + srcData.length);
|
byte length = (byte) (OFFSET_SHORT_ITEM + srcData.length);
|
||||||
|
|
Loading…
Reference in New Issue