Exemple #1
0
        /// <inheritdoc />
        public async Task <TransactionBuildingResult> BuildTransactionWithManyOutputsAsync(Guid operationId, string fromAddress, string fromAddressContext, IEnumerable <BuildingTransactionOutput> outputs, BlockchainAsset asset)
        {
            ValidateOperationIdIsNotEmpty(operationId);
            ValidateToAddressIsNotEmpty(fromAddress);
            // ReSharper disable once PossibleMultipleEnumeration
            ValidateOutputsNotNull(outputs);
            ValidateAssetIsNotNull(asset);

            try
            {
                var apiResponse = await _runner.RunWithRetriesAsync(() => _api.BuildTransactionWithManyOutputsAsync(
                                                                        new BuildTransactionWithManyOutputsRequest
                {
                    OperationId        = operationId,
                    FromAddress        = fromAddress,
                    FromAddressContext = fromAddressContext,
                    // ReSharper disable once PossibleMultipleEnumeration
                    Outputs = outputs
                              .Select(o => o.ToContract(asset.Accuracy))
                              .ToArray(),
                    AssetId = asset.AssetId
                }));

                return(new TransactionBuildingResult(apiResponse));
            }
            catch (ErrorResponseException ex) when(ex.StatusCode == HttpStatusCode.NotImplemented)
            {
                throw new NotSupportedException("Operation is not supported by the blockchain. See GetCapabilitiesAsync", ex);
            }
            catch (ErrorResponseException ex) when(ex.StatusCode == HttpStatusCode.Conflict)
            {
                throw new TransactionAlreadyBroadcastedException(ex);
            }
        }