public static async Task <BitcoinTransactionParams> SelectTransactionParamsByFeeRateAsync( IEnumerable <BitcoinBasedTxOutput> availableOutputs, string to, decimal amount, decimal feeRate, BitcoinBasedAccount account, CancellationToken cancellationToken = default) { var config = account.Config; var freeInternalAddress = await account .GetFreeInternalAddressAsync() .ConfigureAwait(false); return(await SelectTransactionParamsByFeeRateAsync( availableInputs : availableOutputs.Select(o => new BitcoinInputToSign { Output = o }), destinations : new BitcoinDestination[] { new BitcoinDestination { AmountInSatoshi = config.CoinToSatoshi(amount), Script = BitcoinAddress.Create(to, config.Network).ScriptPubKey, } }, changeAddress : freeInternalAddress.Address, feeRate : feeRate, currencyConfig : config, cancellationToken : cancellationToken) .ConfigureAwait(false)); }
public BitcoinBasedSwap( BitcoinBasedAccount account, ICurrencies currencies) : base(account.Currency, currencies) { _account = account ?? throw new ArgumentNullException(nameof(account)); _transactionFactory = new BitcoinBasedSwapTransactionFactory(); }
private Error Send( BitcoinBasedConfig currency, decimal available, decimal amount, decimal fee, DustUsagePolicy dustUsagePolicy, Action <Mock <IBlockchainApi> > apiSetup = null, Action <Mock <IAccountDataRepository>, WalletAddress> repositorySetup = null) { var apiMock = new Mock <IBlockchainApi>(); apiSetup?.Invoke(apiMock); var wallet = new HdWallet(Network.TestNet); var fromAddress = wallet.GetAddress( currency: currency, account: 0, chain: 0, index: 0, keyType: CurrencyConfig.StandardKey); var fromOutputs = GetOutputs(fromAddress.Address, NBitcoin.Network.TestNet, currency.CoinToSatoshi(available)).ToList(); var repositoryMock = new Mock <IAccountDataRepository>(); repositorySetup?.Invoke(repositoryMock, fromAddress); var currencies = Common.CurrenciesTestNet; currencies.GetByName(currency.Name).BlockchainApi = apiMock.Object; var account = new BitcoinBasedAccount( currency: currency.Name, currencies: currencies, wallet: wallet, dataRepository: repositoryMock.Object); return(account .SendAsync( from: fromOutputs, to: currency.TestAddress(), amount: amount, fee: fee, dustUsagePolicy: dustUsagePolicy) .WaitForResult()); }
public BitcoinBasedSwapSigner(BitcoinBasedAccount account) { Account = account ?? throw new ArgumentNullException(nameof(account)); }
public LocalTxOutputSource(BitcoinBasedAccount account) { _account = account ?? throw new ArgumentNullException(nameof(account)); }