public static async Task <bool> SendFromNewAccount(String message, Account newAcc) { KeyPair keyPair = KeyPair.CreateFromPrivateKey(newAcc.PrivateKey); var transaction = TransferTransaction.Create( NetworkType.Types.TEST_NET, Deadline.CreateHours(2), Address.CreateFromEncoded(Config.Address), new List <Mosaic> { Mosaic.CreateFromIdentifier("nem:xem", 10) }, SecureMessage.Create(message, newAcc.PrivateKey, Config.PublicKey) ); TransactionHttp transactionHttp = new TransactionHttp("http://" + Config.Domain + ":7890"); SignedTransaction signedTransaction = transaction.SignWith(keyPair); Thread.Sleep(2000); await transactionHttp.Announce(signedTransaction); Thread.Sleep(2000); Console.WriteLine(signedTransaction.Hash); Console.WriteLine(Config.Address + " recve something from : " + newAcc.Address.Plain); return(true); }
public static async Task getResponse() { try { Account sender = Account.CreateFromPrivateKey("5cd5a454be8045056bd3c5e67c20dea92a8eb4921351d850f0249983a804a903", NetworkType.Types.TEST_NET); KeyPair keyPair1 = sender.KeyPair; Account reciever = Account.CreateFromPrivateKey("5cd5a454be8045056bd3c5e67c20dea92a8eb4921351d850f0249983a804a903", NetworkType.Types.TEST_NET); KeyPair keyPair2 = reciever.KeyPair; var transaction = TransferTransaction.Create( NetworkType.Types.TEST_NET, Deadline.CreateHours(2), Address.CreateFromEncoded("TB2Z7J-R2K3BZ-2TRS6D-H5747F-Y3XKUM-BNWCI4-BPDJ"), new List <Mosaic> { Xem.CreateRelative(1) }, SecureMessage.Create("Well shit. W/ mosaic", sender.PrivateKey, reciever.PublicKey) ); SignedTransaction signedTransaction = transaction.SignWith(keyPair1); TransactionResponse response = await new TransactionHttp(host).Announce(signedTransaction); Console.WriteLine(response.Message); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); } }
public void CanCreateSecureMessage() { var secureMessage = SecureMessage.Create("Hello", "5949fc564c90ac186cd4f9d2b8298b677bca300b9d8f926ca04e1739e4ed0cba", "2ecf1decef6818bd9c38985afd6efc1c981e64e9a1ecc1e7b6b25eb30454cce0"); var decoded = secureMessage.GetDecodedPayload( "5949fc564c90ac186cd4f9d2b8298b677bca300b9d8f926ca04e1739e4ed0cba", "2ecf1decef6818bd9c38985afd6efc1c981e64e9a1ecc1e7b6b25eb30454cce0"); Assert.AreEqual("Hello", decoded); }
public async Task Should_Announce_Transfer_Transaction_With_NetworkCurrencyMosaic_SecureMessage() { var account = Account.GenerateNewAccount(Fixture.NetworkType); Log.WriteLine($"Reciever private key {account.KeyPair.PrivateKeyString}, reciever public key {account.PublicAccount.PublicKey}"); var mosaic = NetworkCurrencyMosaic.CreateRelative(10); Log.WriteLine($"Sender private key {Fixture.SeedAccount.KeyPair.PrivateKeyString}, sender public key {Fixture.SeedAccount.PublicAccount.PublicKey}"); var message = SecureMessage.Create("Test secure message", Fixture.SeedAccount.KeyPair.PrivateKeyString, account.PublicAccount.PublicKey); var result = await Fixture.Transfer(Fixture.SeedAccount, account.Address, mosaic, message, Fixture.GenerationHash); Log.WriteLine($"Transaction confirmed {result.TransactionInfo.Hash}"); result.TransactionInfo.Hash.Should().NotBeNullOrWhiteSpace(); //result.TransactionType.Should().Be(EntityType.TRANSFER); ((TransferTransaction)result).Message.GetMessageType().Should().Be(MessageType.SECURED_MESSAGE.GetValueInByte()); }
public async Task AnnounceTransferTransactionWithMosaicWithSecureMessage() { var keyPair = new KeyPair(Config.PrivateKeyMain); var transaction = TransferTransaction.Create( NetworkType.Types.TEST_NET, Deadline.CreateHours(2), new Address("TAVPDJ-DR3R3X-4FJUKN-PY2IQB-NNRFV2-QR5NJZ-J3WR"), new List <MosaicAmount> { new MosaicAmount("nem:xem", 10) }, SecureMessage.Create("hello2", Config.PrivateKeyMain, "4cc7409929a72019240065c9e53aa339f87ba889238ff9fbe978251fdbb05d9f") ).SignWith(keyPair); var response = await new TransactionHttp(host).Announce(transaction); Assert.AreEqual("SUCCESS", response.Message); }
public IMessage CreateMessage(ProximaxMessagePayloadModel messagePayload, string senderPrivateKey, string recipientPublicKeyRaw, string recipientAddress, bool useBlockchainSecureMessage) { CheckParameter(messagePayload != null, "messagePayload is required"); var jsonPayload = messagePayload.ToJson(); if (useBlockchainSecureMessage) { var recipientPublicKey = this.GetRecipientPublicKey(senderPrivateKey, recipientPublicKeyRaw, recipientAddress); return(SecureMessage.Create(jsonPayload, senderPrivateKey, recipientPublicKey)); } else { return(PlainMessage.Create(jsonPayload)); } }
public async Task AnnounceTransferTransactionWithMultipleMosaicsWithSecureMessage() { var keyPair = new KeyPair(Config.PrivateKeyMain); var transaction = TransferTransaction.Create( NetworkType.Types.TEST_NET, Deadline.CreateHours(2), new Address("TALICE-ROONSJ-CPHC63-F52V6F-Y3SDMS-VAEUGH-MB7C"), new List <MosaicAmount>() { new MosaicAmount("nem:xem", 1000), //Mosaic.CreateFromIdentifier("nis1porttest:test", 10), TODO: fix multiple mosaic transfer }, SecureMessage.Create("hello2", Config.PrivateKeyMain, "5D8BEBBE80D7EA3B0088E59308D8671099781429B449A0BBCA6D950A709BA068") ).SignWith(keyPair); var response = await new TransactionHttp(host).Announce(transaction); Assert.AreEqual("SUCCESS", response.Message); }
public async Task AnnounceTransferTransactionWithMosaicWithSecureMessage() { var keyPair = KeyPair.CreateFromPrivateKey(Config.PrivateKeyMain); var transaction = TransferTransaction.Create( NetworkType.Types.MIJIN_TEST, Deadline.CreateHours(2), Address.CreateFromEncoded("SAAA57-DREOPY-KUFX4O-G7IQXK-ITMBWK-D6KXTV-BBQP"), new List <Mosaic> { Mosaic.CreateFromIdentifier("nem:xem", 10) }, SecureMessage.Create("hello2", Config.PrivateKeyMain, "5D8BEBBE80D7EA3B0088E59308D8671099781429B449A0BBCA6D950A709BA068") ).SignWith(keyPair); await new TransactionHttp("http://" + Config.Domain + ":3000").Announce(transaction); listener.TransactionStatus(Address.CreateFromPublicKey(keyPair.PublicKeyString, NetworkType.Types.MIJIN_TEST)) .Subscribe(e => Console.WriteLine(e.Status)); var status = await listener.ConfirmedTransactionsGiven(Address.CreateFromPublicKey(transaction.Signer, NetworkType.Types.MIJIN_TEST)).Take(1); Assert.AreEqual(keyPair.PublicKeyString, status.Signer.PublicKey); }
public static async void CreateTransaction(Account receiverAcc, String message) { KeyPair keyPair = KeyPair.CreateFromPrivateKey(Config.PrivateKeyMain); var transaction = TransferTransaction.Create( NetworkType.Types.TEST_NET, Deadline.CreateHours(2), Address.CreateFromEncoded(receiverAcc.Address.Plain), new List <Mosaic> { Mosaic.CreateFromIdentifier("nem:xem", 2000000) }, SecureMessage.Create(message, Config.PrivateKeyMain, receiverAcc.PublicKey) ); TransactionHttp transactionHttp = new TransactionHttp("http://" + Config.Domain + ":7890"); SignedTransaction signedTransaction = transaction.SignWith(keyPair); Thread.Sleep(2000); await transactionHttp.Announce(signedTransaction); Console.WriteLine(signedTransaction.Hash); Console.WriteLine(receiverAcc.Address.Plain + " recve something from : " + Config.Address); Thread.Sleep(2000); }
public async Task AnnounceTransferTransactionWithMultipleMosaicsWithSecureMessage() { var keyPair = KeyPair.CreateFromPrivateKey(Config.PrivateKeyMain); var transaction = TransferTransaction.Create( NetworkType.Types.MIJIN_TEST, Deadline.CreateHours(2), Address.CreateFromEncoded("SAOV4Y5W627UXLIYS5O43SVU23DD6VNRCFP222P2"), new List <Mosaic>() { Mosaic.CreateFromIdentifier("nem:xem", 1000000000000), //Mosaic.CreateFromIdentifier("happy:test2", 10), }, SecureMessage.Create("hello2", Config.PrivateKeyMain, "5D8BEBBE80D7EA3B0088E59308D8671099781429B449A0BBCA6D950A709BA068") ).SignWith(keyPair); await new TransactionHttp("http://" + Config.Domain + ":3000").Announce(transaction); var status = await listener.ConfirmedTransactionsGiven(Address.CreateFromPublicKey(transaction.Signer, NetworkType.Types.MIJIN_TEST)).Take(1); Assert.AreEqual(keyPair.PublicKeyString, status.Signer.PublicKey); }
public static async Task <bool> CreateTransaction() { KeyPair keyPair = KeyPair.CreateFromPrivateKey(Config.PrivateKeyMain); var transaction = TransferTransaction.Create( NetworkType.Types.TEST_NET, Deadline.CreateHours(2), Address.CreateFromEncoded("TCPCAZ-7XJ2X4-SWR6AG-6BUEKS-6DQ7DL-Z2D6QB-5M2V"), new List <Mosaic> { Mosaic.CreateFromIdentifier("nem:xem", 10) }, SecureMessage.Create("hello", Config.PrivateKeyMain, "d72f89db8d0a3655168c9d2abe8de2910aaf4506a47d46e22ca48c7e0442e8ef") ); TransactionHttp transactionHttp = new TransactionHttp("http://" + Config.Domain + ":7890"); SignedTransaction signedTransaction = transaction.SignWith(keyPair); Thread.Sleep(2000); await transactionHttp.Announce(signedTransaction); Console.WriteLine(signedTransaction.Hash); Thread.Sleep(2000); return(true); }