public async Task Broadcast() { Transaction transaction = null; switch (this.Request.Content.Headers.ContentType.MediaType) { case "application/json": transaction = new Transaction(JsonConvert.DeserializeObject <string>(await Request.Content.ReadAsStringAsync())); break; case "application/octet-stream": { transaction = new Transaction(await Request.Content.ReadAsByteArrayAsync()); break; } default: throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType); } var tx = new BroadcastedTransaction(); tx.Transaction = transaction; await Configuration.GetBroadcastedTransactionsListenable() .CreatePublisher() .AddAsync(tx.ToEntity()); }
public async Task <Transaction> SendAsync(string publicKey, string secretPhrase, string recipient, string recipientPublicKey, decimal amount, Message?comment = null) { RawTransaction raw = await SendMoneyAsync(publicKey, secretPhrase, recipient, recipientPublicKey, amount, comment ?? string.Empty); BroadcastedTransaction broadcasted = await BroadcastTransactionAsync(JsonConvert.SerializeObject(raw.Details.Attachment), Convert.BytesToHex(Convert.UnsignedBytesToSigned(Convert.HexToBytes(raw.Bytes), secretPhrase))); return(raw.Prepare(broadcasted, recipientPublicKey)); }
public async Task Broadcast([FromBody] string transaction) { var tx = new BroadcastedTransaction(); tx.Transaction = new Transaction(transaction); await Configuration.GetBroadcastedTransactionsListenable() .CreatePublisher() .AddAsync(tx.ToEntity()); }
private async Task SaveBroadcastedTransaction(BroadcastedTransaction broadcastedTx) { // Store tx Hash to OperationId lookup await _broadcastTxHashRepo.InsertAsync( new BroadcastedTransactionByHash { Hash = broadcastedTx.Hash, OperationId = broadcastedTx.OperationId } ); // Store operation await _broadcastTxRepo.InsertAsync(broadcastedTx); }