Skip to content

Commit

Permalink
Fix problem with new change in nbxplorer when tracking btc addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
Jossec101 committed Jun 24, 2024
1 parent bd5dca9 commit b4ed8a4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/Services/BitcoinService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ ICoinSelectionService coinSelectionService
if (wallet == null) throw new ArgumentNullException(nameof(wallet));

var balance = await _nbXplorerService.GetBalanceAsync(wallet.GetDerivationStrategy(), default);
var confirmedBalanceMoney = (Money) balance.Confirmed;
var confirmedBalanceMoney = (Money)balance.Confirmed;

return (confirmedBalanceMoney.ToUnit(MoneyUnit.BTC), confirmedBalanceMoney.Satoshi);
}
Expand Down Expand Up @@ -149,7 +149,7 @@ public async Task<PSBT> GenerateTemplatePSBT(WalletWithdrawalRequest walletWithd
{
var balanceResponse = await _nbXplorerService.GetBalanceAsync(derivationStrategy);

walletWithdrawalRequest.Amount = ((Money) balanceResponse.Confirmed).ToUnit(MoneyUnit.BTC);
walletWithdrawalRequest.Amount = ((Money)balanceResponse.Confirmed).ToUnit(MoneyUnit.BTC);

var update = _walletWithdrawalRequestRepository.Update(walletWithdrawalRequest);
if (!update.Item1)
Expand Down Expand Up @@ -217,7 +217,7 @@ await _coinSelectionService.GetTxInputCoins(availableUTXOs, walletWithdrawalRequ
var builder = txBuilder;
builder.AddCoins(scriptCoins);

var changelessAmount = selectedUTXOs.Sum(u => (Money) u.Value);
var changelessAmount = selectedUTXOs.Sum(u => (Money)u.Value);
var amount = new Money(walletWithdrawalRequest.SatsAmount, MoneyUnit.Satoshi);
var destination = BitcoinAddress.Create(walletWithdrawalRequest.DestinationAddress, nbXplorerNetwork);

Expand Down Expand Up @@ -452,7 +452,7 @@ public async Task PerformWithdrawal(WalletWithdrawalRequest walletWithdrawalRequ
walletWithdrawalRequest.DestinationAddress,
CurrentNetworkHelper.GetCurrentNetwork()));

await _nbXplorerService.TrackAsync(trackedSourceAddress, default);
await _nbXplorerService.TrackAsync(trackedSourceAddress, new TrackWalletRequest{}, default);
}
catch (Exception e)
{
Expand Down
10 changes: 5 additions & 5 deletions src/Services/NBXplorerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public interface INBXplorerService
{
public Task TrackAsync(DerivationStrategyBase derivationStrategyBase, CancellationToken cancellation = default);

public Task TrackAsync(TrackedSource trackedSource, CancellationToken cancellation = default);
public Task TrackAsync(TrackedSource trackedSource, TrackWalletRequest trackWalletRequest, CancellationToken cancellation = default);

public Task<TransactionResult?> GetTransactionAsync(uint256 txId, CancellationToken cancellation = default);

Expand All @@ -36,7 +36,7 @@ public Task<GetFeeRateResult> GetFeeRateAsync(int blockCount, FeeRate fallbackFe

public Task<BroadcastResult> BroadcastAsync(Transaction tx, bool testMempoolAccept,
CancellationToken cancellation = default);

public Task<GetTransactionsResponse> GetTransactionsAsync(DerivationStrategyBase derivationStrategy);

public Task ScanUTXOSetAsync(DerivationStrategyBase derivationStrategy,
Expand Down Expand Up @@ -100,10 +100,10 @@ public async Task TrackAsync(DerivationStrategyBase derivationStrategyBase,
await client.TrackAsync(derivationStrategyBase, cancellation: cancellation);
}

public async Task TrackAsync(TrackedSource trackedSource, CancellationToken cancellation = default)
public async Task TrackAsync(TrackedSource trackedSource, TrackWalletRequest trackWalletRequest, CancellationToken cancellation = default)
{
var client = await LightningHelper.CreateNBExplorerClient();
await client.TrackAsync(trackedSource, cancellation);
await client.TrackAsync(trackedSource, trackWalletRequest, cancellation);
}

public async Task<TransactionResult?> GetTransactionAsync(uint256 txId, CancellationToken cancellation = default)
Expand Down Expand Up @@ -209,7 +209,7 @@ public async Task<GetFeeRateResult> GetFeeRateAsync(int blockCount, FeeRate fall
{
var feerate = new GetFeeRateResult
{
FeeRate = new FeeRate((decimal) recommendedFees.FastestFee),
FeeRate = new FeeRate((decimal)recommendedFees.FastestFee),
BlockCount = 1 // 60 mins / 10 mins
};

Expand Down

0 comments on commit b4ed8a4

Please sign in to comment.