mirror of
https://github.com/barelyprofessional/KfChatDotNet.git
synced 2026-04-30 03:22:04 -04:00
Tried to test 3xpl websocket again but still doesn't work for listening to transactions for individual addresses. Might work just watching the mempool though
This commit is contained in:
@@ -8,8 +8,8 @@ public class ThreeXplClient
|
||||
{
|
||||
private List<string> _addresses =
|
||||
[
|
||||
"MC8TiBEsnQVjxbvLtTsUXjTBZTQaR8fe8X",
|
||||
"ltc1qks2m7hvmhs3c20zrfvptv9pvk82p8g70sgw5mk"
|
||||
"0x3C736854AC7Cf8f24070aa3ceC72B8471d1f9781",
|
||||
"0x2d709a3c76a28b45594d6a54be72d4ab0203c546"
|
||||
];
|
||||
public async Task Start()
|
||||
{
|
||||
@@ -20,19 +20,22 @@ public class ThreeXplClient
|
||||
{
|
||||
var prompt = AnsiConsole.Ask<string>("Channel: ");
|
||||
client.SendSubscribeRequest(prompt);
|
||||
AnsiConsole.MarkupLine($"[green]Subbed at {DateTime.Now:O}[/]");
|
||||
}
|
||||
}
|
||||
|
||||
private void OnThreeXplEvent(object sender, ThreeXplPushModel e, int connectionId)
|
||||
{
|
||||
AnsiConsole.MarkupLine("[blue]Received event from 3xpl[/]");
|
||||
//AnsiConsole.MarkupLine("[blue]Received event from 3xpl[/]");
|
||||
foreach (var txn in e.Pub.Data.Data)
|
||||
{
|
||||
if (txn.Address == null) return;
|
||||
if (_addresses.Contains(txn.Address))
|
||||
{
|
||||
AnsiConsole.MarkupLine($"[green]Saw txn I'm interested in: {txn.Address}, effect {txn.Effect}, currency {txn.Currency}[/]");
|
||||
continue;
|
||||
}
|
||||
//AnsiConsole.MarkupLine($"[gray]Saw txn I'm not interested in: {txn.Address}, effect {txn.Effect}, currency {txn.Currency}[/]");
|
||||
}
|
||||
}
|
||||
}
|
||||
24
ThreeXplWsClient/Converters.cs
Normal file
24
ThreeXplWsClient/Converters.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ThreeXplWsClient;
|
||||
|
||||
public class ThreeXplDateTimeConverter : JsonConverter<DateTime>
|
||||
{
|
||||
// 2025-05-05 23:53:08
|
||||
private const string Format = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
var input = reader.GetString();
|
||||
if (input == null)
|
||||
{
|
||||
throw new NullReferenceException("Tried to convert a string to DateTime that was null");
|
||||
}
|
||||
return DateTime.ParseExact(input, Format, null);
|
||||
}
|
||||
public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteStringValue(value.ToString(Format));
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,8 @@ public class ThreeXplDataModel
|
||||
[JsonPropertyName("sort_key")]
|
||||
public int? SortKey { get; set; }
|
||||
[JsonPropertyName("time")]
|
||||
public DateTimeOffset? Time { get; set; }
|
||||
[JsonConverter(typeof(ThreeXplDateTimeConverter))]
|
||||
public DateTime Time { get; set; }
|
||||
[JsonPropertyName("currency")]
|
||||
public string? Currency { get; set; }
|
||||
[JsonPropertyName("effect")]
|
||||
|
||||
Reference in New Issue
Block a user