mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-24 06:47:50 +01:00
expand tx update notif
This commit is contained in:
parent
20c30cf0d1
commit
5b20aca1f2
2 changed files with 11 additions and 5 deletions
|
@ -11,7 +11,7 @@ namespace BTCPayApp.CommonServer;
|
||||||
public interface IBTCPayAppHubClient
|
public interface IBTCPayAppHubClient
|
||||||
{
|
{
|
||||||
Task NotifyNetwork(string network);
|
Task NotifyNetwork(string network);
|
||||||
Task TransactionDetected(string identifier, string txId);
|
Task TransactionDetected(string identifier, string txId, string[] relatedScripts, bool confirmed);
|
||||||
Task NewBlock(string block);
|
Task NewBlock(string block);
|
||||||
|
|
||||||
Task<LightningPayment> CreateInvoice(CreateLightningInvoiceRequest createLightningInvoiceRequest);
|
Task<LightningPayment> CreateInvoice(CreateLightningInvoiceRequest createLightningInvoiceRequest);
|
||||||
|
|
|
@ -54,19 +54,25 @@ public class BTCPayAppState : IHostedService
|
||||||
_compositeDisposable.Add(
|
_compositeDisposable.Add(
|
||||||
_eventAggregator.Subscribe<NewBlockEvent>(OnNewBlock));
|
_eventAggregator.Subscribe<NewBlockEvent>(OnNewBlock));
|
||||||
_compositeDisposable.Add(
|
_compositeDisposable.Add(
|
||||||
_eventAggregator.Subscribe<NewOnChainTransactionEvent>(OnNewTransaction));
|
_eventAggregator.SubscribeAsync<NewOnChainTransactionEvent>(OnNewTransaction));
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnNewTransaction(NewOnChainTransactionEvent obj)
|
private async Task OnNewTransaction(NewOnChainTransactionEvent obj)
|
||||||
{
|
{
|
||||||
if (obj.CryptoCode != "BTC")
|
if (obj.CryptoCode != "BTC")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var identifier = obj.NewTransactionEvent.TrackedSource.ToString()!;
|
var identifier = obj.NewTransactionEvent.TrackedSource.ToString()!;
|
||||||
_hubContext.Clients
|
var explorer = _explorerClientProvider.GetExplorerClient(obj.CryptoCode);
|
||||||
|
var expandedTx = await explorer.GetTransactionAsync(obj.NewTransactionEvent.TrackedSource,
|
||||||
|
obj.NewTransactionEvent.TransactionData.TransactionHash);
|
||||||
|
var scripts = expandedTx.Inputs.Concat(expandedTx.Outputs).Select(output => output.ScriptPubKey.ToHex()).Distinct().ToArray();
|
||||||
|
|
||||||
|
await _hubContext.Clients
|
||||||
.Group(identifier)
|
.Group(identifier)
|
||||||
.TransactionDetected(identifier, obj.NewTransactionEvent.TransactionData.TransactionHash.ToString());
|
.TransactionDetected(identifier,
|
||||||
|
obj.NewTransactionEvent.TransactionData.TransactionHash.ToString(), scripts, obj.NewTransactionEvent.BlockId is not null && obj.NewTransactionEvent.BlockId != uint256.Zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnNewBlock(NewBlockEvent obj)
|
private void OnNewBlock(NewBlockEvent obj)
|
||||||
|
|
Loading…
Add table
Reference in a new issue