/// <summary> /// Coin to receive for the transaction. /// </summary> /// <param name="coinNumber">Number of the coin inside the transaction.</param> /// <param name="asset">Asset of the coin.</param> /// <param name="value">Coin value to receive.</param> /// <param name="address">Address which should receive the coin.</param> /// <param name="addressTag"> /// Optional. /// Receiving address tag. /// </param> /// <param name="addressTagType"> /// Optional. /// Type of the receiving address tag. /// </param> public CoinToReceive( int coinNumber, Asset asset, UMoney value, Address address, AddressTag addressTag = null, AddressTagType?addressTagType = null) { if (coinNumber < 0) { throw RequestValidationException.ShouldBeZeroOrPositiveNumber(coinNumber, nameof(coinNumber)); } if (addressTagType.HasValue && addressTag == null) { throw new RequestValidationException("If the tag type is specified, the tag should be specified too", new [] { nameof(addressTagType), nameof(addressTag) }); } CoinNumber = coinNumber; Asset = asset ?? throw RequestValidationException.ShouldBeNotNull(nameof(asset)); Value = value; Address = address ?? throw RequestValidationException.ShouldBeNotNull(nameof(address)); AddressTag = addressTag; AddressTagType = addressTagType; }
public async Task <ActionResult <TransactionStateResponse> > GetState([FromRoute] TransactionId transactionId) { if (transactionId == null) { throw RequestValidationException.ShouldBeNotNull(nameof(transactionId)); } var state = await _transactionsStateProvider.GetStateAsync(transactionId); return(Ok(new TransactionStateResponse(state))); }
/// <summary> /// Coin to spend for the transaction. /// </summary> /// <param name="coinId">Reference to the coin which should be spend.</param> /// <param name="asset">Asset of the coin.</param> /// <param name="value">Coin value to spend.</param> /// <param name="address">Address that owns the coin.</param> /// <param name="addressContext"> /// Optional. /// Address context associated with the owner address. /// </param> /// <param name="addressNonce"> /// Optional. /// Nonce number of the transaction for the owner address. /// </param> public CoinToSpend( CoinId coinId, Asset asset, UMoney value, Address address, Base64String addressContext = null, long?addressNonce = null) { Coin = coinId ?? throw RequestValidationException.ShouldBeNotNull(nameof(coinId)); Asset = asset ?? throw RequestValidationException.ShouldBeNotNull(nameof(asset)); Value = value; Address = address ?? throw RequestValidationException.ShouldBeNotNull(nameof(address)); AddressContext = addressContext; AddressNonce = addressNonce; }
public async Task <ActionResult <AddressFormatsResponse> > GetFormats([FromRoute] Address address) { if (address == null) { throw RequestValidationException.ShouldBeNotNull(nameof(address)); } var response = await _addressFormatsProvider.GetFormatsAsync(address); if (response == null) { throw new InvalidOperationException("Not null response object expected"); } return(Ok(response)); }
public async Task <ActionResult <RawObjectResponse> > GetRaw([FromRoute] TransactionId transactionId) { if (transactionId == null) { throw RequestValidationException.ShouldBeNotNull(nameof(transactionId)); } var raw = await _rawObjectsRepository.GetOrDefaultAsync(RawObjectType.Transaction, transactionId); if (raw == null) { return(NotFound(BlockchainErrorResponse.Create($"Raw transaction [{transactionId}] not found"))); } return(Ok(new RawObjectResponse(raw))); }
public async Task <ActionResult <CreateAddressTagResponse> > CreateAddressTag([FromRoute] Address address, [FromBody] CreateAddressTagRequest request) { if (address == null) { throw RequestValidationException.ShouldBeNotNull(nameof(address)); } var response = await _addressGenerator.CreateAddressTagAsync(address, request); if (response == null) { throw new InvalidOperationException("Not null response object expected"); } return(Ok(response)); }
/// <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; }
public async Task <ActionResult <AddressValidityResponse> > Validate( [FromRoute] Address address, [FromQuery] AddressTagType?tagType = null, [FromQuery] AddressTag tag = null) { if (address == null) { throw RequestValidationException.ShouldBeNotNull(nameof(address)); } if (tagType.HasValue && tag == null) { throw new RequestValidationException("If the tag type is specified, the tag should be specified too", new [] { nameof(tagType), nameof(tag) }); } var response = await _addressValidator.ValidateAsync(address, tagType, tag); if (response == null) { throw new InvalidOperationException("Not null response object expected"); } return(Ok(response)); }
/// <summary> /// Transfer of the transaction. /// </summary> /// <param name="asset">Asset to transfer.</param> /// <param name="amount">Amount to transfer from the source address to the destination address.</param> /// <param name="sourceAddress">Address to transfer from.</param> /// <param name="destinationAddress">Address to transfer to.</param> /// <param name="sourceAddressContext"> /// Optional. /// Source address context associated with the address. /// </param> /// <param name="sourceAddressNonce"> /// Optional. /// Nonce number of the transaction for the source address. /// </param> /// <param name="destinationAddressTag"> /// Optional. /// Destination address tag. /// </param> /// <param name="destinationAddressTagType"> /// Optional. /// Type of the destination address tag. /// </param> public Transfer( Asset asset, UMoney amount, Address sourceAddress, Address destinationAddress, Base64String sourceAddressContext = null, long?sourceAddressNonce = null, AddressTag destinationAddressTag = null, AddressTagType?destinationAddressTagType = null) { if (destinationAddressTagType.HasValue && destinationAddressTag == null) { throw new RequestValidationException("If the tag type is specified, the tag should be specified too", new [] { nameof(destinationAddressTagType), nameof(destinationAddressTag) }); } Asset = asset ?? throw RequestValidationException.ShouldBeNotNull(nameof(asset)); Amount = amount; SourceAddress = sourceAddress ?? throw RequestValidationException.ShouldBeNotNull(nameof(sourceAddress)); SourceAddressContext = sourceAddressContext; SourceAddressNonce = sourceAddressNonce; DestinationAddress = destinationAddress ?? throw RequestValidationException.ShouldBeNotNull(nameof(destinationAddress)); DestinationAddressTag = destinationAddressTag; DestinationAddressTagType = destinationAddressTagType; }