Example #1
0
    /// <returns>If the phase is still in OutputRegistration.</returns>
    public async Task <bool> PostOutputAsync(long roundId, ActiveOutput activeOutput)
    {
        Guard.MinimumAndNotNull(nameof(roundId), roundId, 0);
        Guard.NotNull(nameof(activeOutput), activeOutput);

        var request = new OutputRequest {
            OutputAddress = activeOutput.Address, UnblindedSignature = activeOutput.Signature, Level = activeOutput.MixingLevel
        };

        using var requestStringContent = request.ToHttpStringContent();
        using var response             = await HttpClient.SendAsync(HttpMethod.Post, $"/api/v{WasabiClient.ApiVersion}/btc/chaumiancoinjoin/output?roundId={roundId}", requestStringContent).ConfigureAwait(false);

        if (response.StatusCode == HttpStatusCode.Conflict)
        {
            return(false);
        }
        else if (response.StatusCode != HttpStatusCode.NoContent)
        {
            await response.ThrowRequestExceptionFromContentAsync().ConfigureAwait(false);
        }

        return(true);
    }
Example #2
0
        /// <returns>If the phase is still in OutputRegistration.</returns>
        public async Task <bool> PostOutputAsync(long roundId, BitcoinAddress activeOutputAddress, UnblindedSignature unblindedSignature, int level)
        {
            Guard.MinimumAndNotNull(nameof(roundId), roundId, 0);
            Guard.NotNull(nameof(activeOutputAddress), activeOutputAddress);
            Guard.NotNull(nameof(unblindedSignature), unblindedSignature);
            Guard.MinimumAndNotNull(nameof(level), level, 0);

            var request = new OutputRequest {
                OutputAddress = activeOutputAddress, UnblindedSignature = unblindedSignature, Level = level
            };

            using (var response = await TorClient.SendAsync(HttpMethod.Post, $"/api/v{Constants.BackendMajorVersion}/btc/chaumiancoinjoin/output?roundId={roundId}", request.ToHttpStringContent()))
            {
                if (response.StatusCode == HttpStatusCode.Conflict)
                {
                    return(false);
                }
                else if (response.StatusCode != HttpStatusCode.NoContent)
                {
                    await response.ThrowRequestExceptionFromContentAsync();
                }

                return(true);
            }
        }
Example #3
0
        public async Task PostOutputAsync(string roundHash, Script activeOutput, byte[] unblindedSignature)
        {
            var request = new OutputRequest()
            {
                OutputScript = activeOutput.ToString(), SignatureHex = ByteHelpers.ToHex(unblindedSignature)
            };

            using (var response = await TorClient.SendAsync(HttpMethod.Post, $"/api/v1/btc/chaumiancoinjoin/output?roundHash={roundHash}", request.ToHttpStringContent()))
            {
                if (response.StatusCode != HttpStatusCode.NoContent)
                {
                    string error = await response.Content.ReadAsJsonAsync <string>();

                    if (error == null)
                    {
                        throw new HttpRequestException(response.StatusCode.ToReasonString());
                    }
                    else
                    {
                        throw new HttpRequestException($"{response.StatusCode.ToReasonString()}\n{error}");
                    }
                }
            }
        }
Example #4
0
        public async Task PostOutputAsync(string roundHash, BitcoinAddress activeOutputAddress, byte[] unblindedSignature)
        {
            var request = new OutputRequest()
            {
                OutputAddress = activeOutputAddress.ToString(), SignatureHex = ByteHelpers.ToHex(unblindedSignature)
            };

            using (var response = await TorClient.SendAsync(HttpMethod.Post, $"/api/v1/btc/chaumiancoinjoin/output?roundHash={roundHash}", request.ToHttpStringContent()))
            {
                if (response.StatusCode != HttpStatusCode.NoContent)
                {
                    await response.ThrowRequestExceptionFromContentAsync();
                }
            }
        }