Fixed bug with the memo's nonce serialization format
This commit is contained in:
parent
13faf6c253
commit
4c7c7b29b2
2 changed files with 4 additions and 2 deletions
|
@ -293,7 +293,7 @@ public class Memo implements ByteSerializable, JsonSerializable {
|
||||||
}else{
|
}else{
|
||||||
memoObject.addProperty(KEY_FROM, this.from.toString());
|
memoObject.addProperty(KEY_FROM, this.from.toString());
|
||||||
memoObject.addProperty(KEY_TO, this.to.toString());
|
memoObject.addProperty(KEY_TO, this.to.toString());
|
||||||
memoObject.addProperty(KEY_NONCE, String.format("%x", this.nonce));
|
memoObject.addProperty(KEY_NONCE, this.nonce.toString());
|
||||||
if(this.message != null)
|
if(this.message != null)
|
||||||
memoObject.addProperty(KEY_MESSAGE, Util.bytesToHex(this.message));
|
memoObject.addProperty(KEY_MESSAGE, Util.bytesToHex(this.message));
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import org.junit.Test;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.security.SecureRandom;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -152,7 +153,8 @@ public class TransactionTest {
|
||||||
PublicKey to2 = new PublicKey(ECKey.fromPublicOnly(new BrainKey(BILTHON_16_BRAIN_KEY, 0).getPublicKey()));
|
PublicKey to2 = new PublicKey(ECKey.fromPublicOnly(new BrainKey(BILTHON_16_BRAIN_KEY, 0).getPublicKey()));
|
||||||
|
|
||||||
// Creating memo
|
// Creating memo
|
||||||
BigInteger nonce = BigInteger.ONE;
|
SecureRandom random = new SecureRandom();
|
||||||
|
BigInteger nonce = BigInteger.valueOf(random.nextLong());
|
||||||
byte[] encryptedMessage = Memo.encryptMessage(sourcePrivateKey, to1, nonce, "another message");
|
byte[] encryptedMessage = Memo.encryptMessage(sourcePrivateKey, to1, nonce, "another message");
|
||||||
Memo memo = new Memo(new Address(ECKey.fromPublicOnly(sourcePrivateKey.getPubKey())), new Address(to1.getKey()), nonce, encryptedMessage);
|
Memo memo = new Memo(new Address(ECKey.fromPublicOnly(sourcePrivateKey.getPubKey())), new Address(to1.getKey()), nonce, encryptedMessage);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue