/// <summary> /// "Transfer amount" transactions model. /// Should be published for each executed transaction in the block being read if /// integration uses “transfer amount” transactions model. Integration should either /// support “transfer coins” or “transfer amount” transactions model. /// </summary> /// <param name="transactionNumber">Number of the transaction in the block.</param> /// <param name="transactionId">ID of the transaction.</param> /// <param name="balanceChanges">Balance changing operations.</param> /// <param name="fees">Fees in the particular asset, that was spent for the transaction.</param> /// <param name="isIrreversible"> /// Optional. /// Flag which indicates, if transaction is irreversible. /// </param> public TransferAmountExecutedTransaction( int transactionNumber, TransactionId transactionId, IReadOnlyCollection <BalanceChange> balanceChanges, IReadOnlyCollection <Fee> fees, bool?isIrreversible = null) { if (transactionNumber < 0) { throw new ArgumentOutOfRangeException(nameof(transactionNumber), transactionNumber, "Should be zero or positive number"); } if (fees == null) { throw new ArgumentNullException(nameof(fees)); } FeesValidator.ValidateFeesInResponse(fees); TransactionNumber = transactionNumber; TransactionId = transactionId ?? throw new ArgumentNullException(nameof(transactionId)); BalanceChanges = balanceChanges ?? throw new ArgumentNullException(nameof(balanceChanges)); Fees = fees; IsIrreversible = isIrreversible; }
/// <summary> /// Endpoints: /// - [POST] /api/transactions/estimated/transfers/amount /// - [POST] /api/transactions/estimated/transfers/coins /// </summary> /// <param name="estimatedFees">Estimated transaction fee for the particular asset.</param> /// <param name="error"> /// Optional. /// Object describing an failure if it can be mapped to the <see cref="TransactionEstimationError"/>. /// </param> public EstimateTransactionResponse(IReadOnlyCollection <Fee> estimatedFees, TransactionEstimationFailure error = null) { if (estimatedFees == null) { throw new ArgumentNullException(nameof(estimatedFees)); } FeesValidator.ValidateFeesInResponse(estimatedFees); EstimatedFees = estimatedFees; Error = error; }
public void Test_that_asset_duplications_are_not_allowed(string assets, bool shouldThrow) { var fees = assets.Split(',') .Select(a => new Fee(new Asset(a), 10)) .ToArray(); if (shouldThrow) { Assert.Throws <ArgumentException>(() => FeesValidator.ValidateFeesInResponse(fees)); } else { FeesValidator.ValidateFeesInResponse(fees); } }
/// <summary> /// Endpoint: [POST] /api/transactions/built/transfers/amount /// </summary> /// <param name="transfers">Transaction transfers.</param> /// <param name="fees">Fees amount in particular asset to spend for the given transaction.</param> /// <param name="expiration"> /// Optional. /// Transaction expiration options. Used if blockchain /// supports transaction expiration. If blockchain supports /// transaction expiration and the value is omitted, /// it should be interpreted as infinite expiration. /// If several expiration options are specified at once, /// and blockchain supports both of them, then transaction /// should be expired when earliest condition is met. /// </param> public BuildTransferAmountTransactionRequest( IReadOnlyCollection <Transfer> transfers, IReadOnlyCollection <Fee> fees, ExpirationOptions expiration = null) { if (fees == null) { throw RequestValidationException.ShouldBeNotNull(nameof(fees)); } TransactionTransfersValidator.Validate(transfers); FeesValidator.ValidateFeesInRequest(fees); Transfers = transfers; Fees = fees; Expiration = expiration; }
/// <summary> /// Should be published for each failed transaction in the block being read. /// </summary> /// <param name="transactionNumber">One-based number of the transaction in the block.</param> /// <param name="transactionId">ID of the transaction.</param> /// <param name="errorCode">Code of the error.</param> /// <param name="errorMessage"> /// Optional. /// Fee in the particular asset ID, that was spent for the transaction. /// Can be omitted, if there was no fee spent for the transaction. /// </param> /// <param name="fees"> /// Optional. /// Fees in the particular asset, that was spent for the transaction. /// Can be omitted, if there was no fee spent for the transaction. /// </param> public FailedTransaction( int transactionNumber, TransactionId transactionId, TransactionBroadcastingError errorCode, string errorMessage, IReadOnlyCollection <Fee> fees = null) { if (transactionNumber < 0) { throw new ArgumentOutOfRangeException(nameof(transactionNumber), transactionNumber, "Should be zero or positive number"); } FeesValidator.ValidateFeesInResponse(fees); TransactionNumber = transactionNumber; TransactionId = transactionId ?? throw new ArgumentNullException(nameof(transactionId)); ErrorCode = errorCode; ErrorMessage = errorMessage; Fees = fees; }
/// <summary> /// "Transfer coins" transactions model. /// Should be published for each executed transaction in the block being read if /// integration uses “transfer coins” transactions model. Integration should either /// support “transfer coins” or “transfer amount” transactions model. /// </summary> /// <param name="transactionNumber">Number of the transaction in the block.</param> /// <param name="transactionId">ID of the transaction.</param> /// <param name="receivedCoins">Coins which were received within the transaction.</param> /// <param name="spentCoins">Coins which were spent within the transaction.</param> /// <param name="fees"> /// Optional. /// Fees in the particular asset, that was spent for the transaction. /// Can be omitted, if fee can be determined from the received and spent coins. /// </param> /// <param name="isIrreversible"> /// Optional. /// Flag which indicates, if transaction is irreversible. /// </param> public TransferCoinsExecutedTransaction( int transactionNumber, TransactionId transactionId, IReadOnlyCollection <ReceivedCoin> receivedCoins, IReadOnlyCollection <CoinId> spentCoins, IReadOnlyCollection <Fee> fees = null, bool?isIrreversible = null) { if (transactionNumber < 0) { throw new ArgumentOutOfRangeException(nameof(transactionNumber), transactionNumber, "Should be zero or positive number"); } ReceivedCoinsValidator.Validate(receivedCoins); SpentCoinsValidator.Validate(spentCoins); FeesValidator.ValidateFeesInResponse(fees); TransactionNumber = transactionNumber; TransactionId = transactionId ?? throw new ArgumentNullException(nameof(transactionId)); ReceivedCoins = receivedCoins; SpentCoins = spentCoins; Fees = fees; IsIrreversible = isIrreversible; }