@Test public void signMessageEncryptedFailed() throws AddressMalformedException, MissingPrivateKeyException, KeyIsEncryptedException { WalletPocketHD pocketHD = new WalletPocketHD(rootKey, BTC, null, null); pocketHD.getReceiveAddress(); // Generate the first key pocketHD.encrypt(crypter, aesKey); SignedMessage signedMessage = new SignedMessage("1KUDsEDqSBAgxubSEWszoA9xscNRRCmujM", MESSAGE); pocketHD.signMessage(signedMessage, null); assertEquals(SignedMessage.Status.KeyIsEncrypted, signedMessage.status); }
@Test public void signMessageEncrypted() throws AddressMalformedException, MissingPrivateKeyException, KeyIsEncryptedException { WalletPocketHD pocketHD = new WalletPocketHD(rootKey, BTC, null, null); pocketHD.getReceiveAddress(); // Generate the first key pocketHD.encrypt(crypter, aesKey); SignedMessage signedMessage = new SignedMessage("1KUDsEDqSBAgxubSEWszoA9xscNRRCmujM", MESSAGE); pocketHD.signMessage(signedMessage, aesKey); assertEquals(EXPECTED_BITCOIN_SIG, signedMessage.getSignature()); signedMessage = new SignedMessage("1KUDsEDqSBAgxubSEWszoA9xscNRRCmujM", MESSAGE_UNICODE); pocketHD.signMessage(signedMessage, aesKey); assertEquals(EXPECTED_BITCOIN_SIG_UNICODE, signedMessage.getSignature()); }
@Test public void serializeEncryptedEmpty() throws Exception { pocket.maybeInitializeAllKeys(); pocket.encrypt(crypter, aesKey); Protos.WalletPocket walletPocketProto = pocket.toProtobuf(); WalletPocketHD newPocket = new WalletPocketProtobufSerializer().readWallet(walletPocketProto, crypter); assertEquals(walletPocketProto.toString(), newPocket.toProtobuf().toString()); pocket.decrypt(aesKey); // One is encrypted, so they should not match assertNotEquals(pocket.toProtobuf().toString(), newPocket.toProtobuf().toString()); newPocket.decrypt(aesKey); assertEquals(pocket.toProtobuf().toString(), newPocket.toProtobuf().toString()); }
@Test public void serializeEncryptedNormal() throws Exception { pocket.maybeInitializeAllKeys(); pocket.encrypt(crypter, aesKey); pocket.onConnection(getBlockchainConnection(DOGE)); assertEquals(DOGE.value(11000000000l), pocket.getBalance()); assertAllKeysEncrypted(pocket); WalletPocketHD newPocket = new WalletPocketProtobufSerializer().readWallet(pocket.toProtobuf(), crypter); assertEquals(DOGE.value(11000000000l), newPocket.getBalance()); Map<TrimmedOutPoint, OutPointOutput> expectedUtxoSet = getDummyUtxoSet(); checkUnspentOutputs(expectedUtxoSet, pocket); checkUnspentOutputs(expectedUtxoSet, newPocket); assertAllKeysEncrypted(newPocket); pocket.decrypt(aesKey); newPocket.decrypt(aesKey); assertAllKeysDecrypted(pocket); assertAllKeysDecrypted(newPocket); }