public Task <LedgerEntry> SendMoneyAsync(Account recipient, Amount amount, CreateTransactionParameters.UnencryptedMessage plainMessage, CreateTransactionParameters.AlreadyEncryptedMessage encryptedMessage, CreateTransactionParameters.AlreadyEncryptedMessageToSelf noteToSelfMessage) { return(Task.FromResult(new LedgerEntry())); }
private CreateTransactionParameters.AlreadyEncryptedMessageToSelf GetEncryptedNoteToSelfMessage() { if (!string.IsNullOrEmpty(NoteToSelfMessage)) { var localMessageService = new LocalMessageService(); var nonce = localMessageService.CreateNonce(); var encryptedToSelf = localMessageService.EncryptTextTo(_walletRepository.NxtAccountWithPublicKey.PublicKey, NoteToSelfMessage, nonce, true, _walletRepository.SecretPhrase); var encryptedMessageToSelf = new CreateTransactionParameters.AlreadyEncryptedMessageToSelf(encryptedToSelf, nonce, true, true); return(encryptedMessageToSelf); } return(null); }
private async Task <TransactionCreatedReply> CreateUnsignedSendMoneyReply(Account recipient, Amount amount, CreateTransactionParameters.UnencryptedMessage plainMessage, CreateTransactionParameters.AlreadyEncryptedMessage encryptedMessage, CreateTransactionParameters.AlreadyEncryptedMessageToSelf noteToSelfMessage) { var accountService = _serviceFactory.CreateAccountService(); var createTransactionByPublicKey = new CreateTransactionByPublicKey(1440, Amount.Zero, _walletRepository.NxtAccountWithPublicKey.PublicKey); createTransactionByPublicKey.Message = plainMessage; createTransactionByPublicKey.EncryptedMessage = encryptedMessage; createTransactionByPublicKey.EncryptedMessageToSelf = noteToSelfMessage; var sendMoneyReply = await accountService.SendMoney(createTransactionByPublicKey, recipient, amount); return(sendMoneyReply); }
public async Task <LedgerEntry> SendMoneyAsync(Account recipient, Amount amount, CreateTransactionParameters.UnencryptedMessage plainMessage, CreateTransactionParameters.AlreadyEncryptedMessage encryptedMessage, CreateTransactionParameters.AlreadyEncryptedMessageToSelf noteToSelfMessage) { try { var transactionService = _serviceFactory.CreateTransactionService(); var localTransactionService = new LocalTransactionService(); var sendMoneyReply = await CreateUnsignedSendMoneyReply(recipient, amount, plainMessage, encryptedMessage, noteToSelfMessage); var signedTransaction = localTransactionService.SignTransaction(sendMoneyReply, _walletRepository.SecretPhrase); var broadcastReply = await transactionService.BroadcastTransaction(new TransactionParameter(signedTransaction.ToString())); IsOnline = true; var ledgerEntry = _mapper.Map <LedgerEntry>(sendMoneyReply.Transaction); UpdateIsMyAddress(ledgerEntry); ledgerEntry.TransactionId = broadcastReply.TransactionId; ledgerEntry.NqtFee *= -1; ledgerEntry.NqtAmount *= -1; ledgerEntry.NqtBalance = _walletRepository.NqtBalance + ledgerEntry.NqtAmount + ledgerEntry.NqtFee; ledgerEntry.IsConfirmed = false; return(ledgerEntry); } catch (HttpRequestException) { IsOnline = false; throw; } catch (JsonReaderException e) { IsOnline = false; throw new Exception("Error when parsing response", e); } }