public async Task <ActionResult <uint256> > WithdrawFunds(string cryptoCode, WithdrawRequest req, CancellationToken ct)
        {
            var n    = _networkProvider.GetByCryptoCode(cryptoCode);
            var addr = BitcoinAddress.Create(req.DestinationAddress, n.NBitcoinNetwork);
            var tx   = await _walletService.GetSendingTxAsync(addr, req.AmountSatoshi, n, ct);

            var cli = _clientProvider.GetClient(n);
            await cli.BroadcastAsync(tx, ct);

            return(CreatedAtRoute($"{cryptoCode}/withdraw", tx.GetHash()));
        }
Exemplo n.º 2
0
        public async ValueTask <DerivationStrategyBase> GetOurDerivationStrategyAsync(NRustLightningNetwork network, CancellationToken ct = default)
        {
            DerivationStrategyBase strategy;

            if (DerivationStrategyBaseCache.TryGetValue(network, out strategy))
            {
                return(strategy);
            }
            var baseKey = GetBaseXPriv(network);

            strategy = network.NbXplorerNetwork.DerivationStrategyFactory.CreateDirectDerivationStrategy(baseKey.Neuter(),
                                                                                                         new DerivationStrategyOptions
            {
                ScriptPubKeyType = ScriptPubKeyType.Segwit,
            });

            _logger.LogInformation($"Tracking new xpub ({strategy}) for {network.CryptoCode} with nbxplorer");
            var cli = _nbXplorerClientProvider.GetClient(network);
            await cli.TrackAsync(strategy, ct);

            DerivationStrategyBaseCache[network] = strategy;
            return(strategy);
        }