private async Task <FeeRate> GetFeeAsync(SupportedChain chain) { try { return(await chain.RPCClient.EstimateFeeRateAsync(2).ConfigureAwait(false)); } catch { if (chain.Information.IsTest) { return(new FeeRate(Money.Satoshis(50), 1)); } throw; } }
private async Task <uint256> WaitConfirmationCoreAsync(SupportedChain chain, Script scriptPubKey, Money amount, int confCount, CancellationToken cancellation) { var h = await chain.RPCClient.GetBestBlockHashAsync().ConfigureAwait(false); await chain.RPCClient.ImportAddressAsync(scriptPubKey).ConfigureAwait(false); while (true) { cancellation.ThrowIfCancellationRequested(); var unspent = await chain.RPCClient.ListUnspentAsync(confCount, 1000, scriptPubKey.GetDestinationAddress(chain.RPCClient.Network)); var utxo = unspent.FirstOrDefault(u => u.Amount == amount); if (utxo != null) { _Repository.SaveOffer(scriptPubKey, utxo.OutPoint); return(utxo.OutPoint.Hash); } cancellation.WaitHandle.WaitOne(1000); } }