/// <summary> /// Attaches the specified transactions (trytes) to the Tangle by doing Proof of Work. /// You need to supply branchTransaction as well as trunkTransaction /// (basically the tips which you're going to validate and reference with this transaction) /// - both of which you'll get through the getTransactionsToApprove API call. /// </summary> /// <param name="trunkTransaction">Trunk transaction to approve.</param> /// <param name="branchTransaction">Branch transaction to approve.</param> /// <param name="trytes">List of trytes (raw transaction data) to attach to the tangle.</param> /// <param name="minWeightMagnitude">Proof of Work intensity. Minimum value is 18</param> /// <returns>The returned value contains a different set of tryte values which you can input into broadcastTransactions and storeTransactions. /// The returned tryte value, the last 243 trytes basically consist of the: trunkTransaction + branchTransaction + nonce. /// These are valid trytes which are then accepted by the network.</returns> public AttachToTangleResponse AttachToTangle(string trunkTransaction, string branchTransaction, string[] trytes, int minWeightMagnitude = 18) { InputValidator.CheckIfArrayOfTrytes(trytes); AttachToTangleRequest attachToTangleRequest = new AttachToTangleRequest(trunkTransaction, branchTransaction, trytes, minWeightMagnitude); return(_genericIotaCoreApi.Request <AttachToTangleRequest, AttachToTangleResponse>(attachToTangleRequest)); }
public async Task <APIResult <string[]> > AttachToTangle(string[] trytes, string trunkTransaction, string branchTransaction, CancellationToken cancellationToken) { InputValidator.CheckIfArrayOfTrytes(trytes); AttachToTangleRequest attachToTangleRequest = new AttachToTangleRequest(trunkTransaction, branchTransaction, trytes, MinWeightMagnitude); var response = await genericWebClient.RequestAsync <AttachToTangleResponse>(attachToTangleRequest, cancellationToken); return(response?.RePackage(r => r.Trytes) ?? new APIResult <string[]>(null, "Null response from API")); }
public async Task <string[]> AttachToTangle(string[] trytes, string trunkTransaction, string branchTransaction, CancellationToken cancellationToken) { InputValidator.CheckIfArrayOfTrytes(trytes); AttachToTangleRequest attachToTangleRequest = new AttachToTangleRequest( trunkTransaction, branchTransaction, trytes, MinWeightMagnitude); var response = await genericClient.RequestAsync <AttachToTangleResponse>(attachToTangleRequest, cancellationToken); if (response == null) { throw new NullReferenceException(nameof(response)); } return(response.Trytes); }