コード例 #1
0
ファイル: BTCPayWallet.cs プロジェクト: pensokha/btcpayserver
        public async Task <NetworkCoins> GetCoins(DerivationStrategy strategy, KnownState state, CancellationToken cancellation = default(CancellationToken))
        {
            var client = _Client.GetExplorerClient(strategy.Network);

            if (client == null)
            {
                return new NetworkCoins()
                       {
                           TimestampedCoins = new NetworkCoins.TimestampedCoin[0], State = null, Strategy = strategy
                       }
            }
            ;
            var changes = await client.SyncAsync(strategy.DerivationStrategyBase, state?.ConfirmedHash, state?.UnconfirmedHash, true, cancellation).ConfigureAwait(false);

            return(new NetworkCoins()
            {
                TimestampedCoins = changes.Confirmed.UTXOs.Concat(changes.Unconfirmed.UTXOs).Select(c => new NetworkCoins.TimestampedCoin()
                {
                    Coin = c.AsCoin(), DateTime = c.Timestamp
                }).ToArray(),
                State = new KnownState()
                {
                    ConfirmedHash = changes.Confirmed.Hash, UnconfirmedHash = changes.Unconfirmed.Hash
                },
                Strategy = strategy,
            });
        }
コード例 #2
0
        public async Task <NetworkCoins> GetCoins(DerivationStrategyBase strategy, KnownState state, CancellationToken cancellation = default(CancellationToken))
        {
            var changes = await _Client.GetUTXOsAsync(strategy, state?.PreviousCall, false, cancellation).ConfigureAwait(false);

            return(new NetworkCoins()
            {
                TimestampedCoins = changes.Confirmed.UTXOs.Concat(changes.Unconfirmed.UTXOs).Select(c => new NetworkCoins.TimestampedCoin()
                {
                    Coin = c.AsCoin(), DateTime = c.Timestamp
                }).ToArray(),
                State = new KnownState()
                {
                    PreviousCall = changes
                },
                Strategy = strategy,
                Wallet = this
            });
        }