Skip to content

Commit

Permalink
expand tx notif upodate
Browse files Browse the repository at this point in the history
  • Loading branch information
Kukks committed May 9, 2024
1 parent 71d4f23 commit 1aec903
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
9 changes: 5 additions & 4 deletions BTCPayApp.Core/Attempt2/BTCPayAppServerClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ public async Task NotifyNetwork(string network)

}

public async Task TransactionDetected(string identifier, string txid)
public async Task TransactionDetected(string identifier, string txId, string[] relatedScripts, bool confirmed)
{
_logger.LogInformation("OnTransactionDetected: {Txid}", txid);
await OnTransactionDetected?.Invoke(this, txid);

_logger.LogInformation("OnTransactionDetected: {Txid}", txId);
await OnTransactionDetected?.Invoke(this, (identifier, txId, relatedScripts, confirmed));
}

public async Task NewBlock(string block)
Expand Down Expand Up @@ -76,7 +77,7 @@ public async Task<List<LightningPayment>> GetLightningInvoices(ListInvoicesParam
}

public event AsyncEventHandler<string>? OnNewBlock;
public event AsyncEventHandler<string>? OnTransactionDetected;
public event AsyncEventHandler<(string identifier, string txId, string[] relatedScripts, bool confirmed)>? OnTransactionDetected;
public event AsyncEventHandler<string>? OnNotifyNetwork;


Expand Down
6 changes: 2 additions & 4 deletions BTCPayApp.Core/Attempt2/OnChainWalletManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,12 @@ protected override async Task ExecuteStopAsync(CancellationToken cancellationTok
State = OnChainWalletState.Init;
}

private Task OnTransactionDetected(object? sender, string e)
private async Task OnTransactionDetected(object? sender, (string identifier, string txId, string[] relatedScripts, bool confirmed) valueTuple)
{
throw new NotImplementedException();
}

private Task OnNewBlock(object? sender, string e)
private async Task OnNewBlock(object? sender, string e)
{
throw new NotImplementedException();
}

public async Task<Script> DeriveScript(string derivation)
Expand Down
10 changes: 5 additions & 5 deletions BTCPayApp.Core/LDK/LDKChannelSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,20 @@ public async Task StartAsync(CancellationToken cancellationToken)
action => _appHubClient.OnNewBlock -= action, OnNewBlock,
cancellationToken));

_disposables.Add(ChannelExtensions.SubscribeToEventWithChannelQueue<string>(
_disposables.Add(ChannelExtensions.SubscribeToEventWithChannelQueue<(string identifier, string txId, string[] relatedScripts, bool confirmed)>(
action => _appHubClient.OnTransactionDetected += action,
action => _appHubClient.OnTransactionDetected -= action, OnTransactionUpdate,
cancellationToken));
}



private async Task OnTransactionUpdate(string txUpdate, CancellationToken cancellationToken)
private async Task OnTransactionUpdate((string identifier, string txId, string[] relatedScripts, bool confirmed) txUpdate, CancellationToken cancellationToken)
{
var txResult = await _connectionManager.HubProxy.FetchTxsAndTheirBlockHeads(new[] {txUpdate});
var tx = txResult.Txs[txUpdate];
var txResult = await _connectionManager.HubProxy.FetchTxsAndTheirBlockHeads(new[] {txUpdate.txId});
var tx = txResult.Txs[txUpdate.txId];

var txHash = new uint256(txUpdate);
var txHash = new uint256(txUpdate.txId);
var txHashBytes = txHash.ToBytes();

byte[]? headerBytes = null;
Expand Down

0 comments on commit 1aec903

Please sign in to comment.