-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
558 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,4 +39,27 @@ jobs: | |
INCLUDE_SYMBOLS: false | ||
VERSION_REGEX: ^\s*<PackageVersion>(.*)<\/PackageVersion>\s*$ | ||
TAG_COMMIT: true | ||
TAG_FORMAT: DotNut/v* | ||
- name: Publish NuGet for nostr | ||
if: ${{ github.ref == 'refs/heads/master' }} # Publish only when the push is on master | ||
uses: Rebel028/[email protected] | ||
with: | ||
PROJECT_FILE_PATH: DotNut.Nostr/DotNut.Nostr.csproj | ||
NUGET_KEY: ${{secrets.NUGET_KEY}} | ||
PACKAGE_NAME: DotNut.Nostr | ||
INCLUDE_SYMBOLS: false | ||
VERSION_REGEX: ^\s*<PackageVersion>(.*)<\/PackageVersion>\s*$ | ||
TAG_COMMIT: true | ||
TAG_FORMAT: DotNut.Nostr/v* | ||
- name: Publish Github Package Registry for nostr | ||
if: ${{ github.ref == 'refs/heads/master' }} # Publish only when the push is on master | ||
uses: Rebel028/[email protected] | ||
with: | ||
PROJECT_FILE_PATH: DotNut.Nostr/DotNut.Nostr.csproj | ||
NUGET_SOURCE: "https://nuget.pkg.github.com/Kukks" | ||
NUGET_KEY: ${{secrets.GH_TOKEN}} | ||
PACKAGE_NAME: DotNut.Nostr | ||
INCLUDE_SYMBOLS: false | ||
VERSION_REGEX: ^\s*<PackageVersion>(.*)<\/PackageVersion>\s*$ | ||
TAG_COMMIT: true | ||
TAG_FORMAT: DotNut/v* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
<Title>DotNut.Nostr</Title> | ||
<Authors>Kukks</Authors> | ||
<Description>Support Cashu payment requests through Nostr </Description> | ||
<Copyright>MIT</Copyright> | ||
<PackageProjectUrl>https://github.com/Kukks/DotNut</PackageProjectUrl> | ||
<PackageVersion>1.0.0</PackageVersion> | ||
<RepositoryUrl>https://github.com/Kukks/DotNut</RepositoryUrl> | ||
<RepositoryType>git</RepositoryType> | ||
<PackageTags>bitcoin cashu ecash secp256k1 nostr</PackageTags> | ||
<PackageLicenseUrl>https://github.com/Kukks/DotNut/blob/master/LICENSE</PackageLicenseUrl> | ||
|
||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
|
||
<PackageReference Include="NNostr.Client" Version="0.0.53" /> | ||
<ProjectReference Include="..\DotNut\DotNut.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System.Security.Cryptography; | ||
using System.Text.Json; | ||
using NBitcoin.Secp256k1; | ||
using NNostr.Client; | ||
using NNostr.Client.Protocols; | ||
|
||
namespace DotNut.Nostr; | ||
|
||
public class NostrNip17PaymentRequestInterfaceHandler : PaymentRequestInterfaceHandler | ||
{ | ||
public static void Register() | ||
{ | ||
PaymentRequestTransportInitiator.Handlers.Add(new NostrNip17PaymentRequestInterfaceHandler()); | ||
} | ||
|
||
public bool CanHandle(PaymentRequest request) | ||
{ | ||
return request.Transports.Any(t => t.Type == "nostr" && t.Tags.Any( t => t.Key == "n" && t.Value == "17")); | ||
} | ||
|
||
public async Task SendPayment(PaymentRequest request, PaymentRequestPayload payload, | ||
CancellationToken cancellationToken = default) | ||
{ | ||
var nprofileStr = request.Transports.First(t => t.Type == "nostr" && t.Tags.Any( t => t.Key == "n" && t.Value == "17")).Target; | ||
var nprofile = (NIP19.NosteProfileNote) NIP19.FromNIP19Note(nprofileStr); | ||
using var client = new CompositeNostrClient(nprofile.Relays.Select(r => new Uri(r)).ToArray()); | ||
await client.Connect(cancellationToken); | ||
var ephemeralKey = ECPrivKey.Create(RandomNumberGenerator.GetBytes(32)); | ||
var msg = new NostrEvent() | ||
{ | ||
Kind = 14, | ||
Content = JsonSerializer.Serialize(payload), | ||
CreatedAt = DateTimeOffset.Now, | ||
PublicKey = ephemeralKey.CreateXOnlyPubKey().ToHex(), | ||
Tags = new(), | ||
}; | ||
msg.Id = msg.ComputeId(); | ||
|
||
var giftWrap = await NIP17.Create(msg, ephemeralKey,ECXOnlyPubKey.Create(Convert.FromHexString(nprofile.PubKey)), null); | ||
await client.SendEventsAndWaitUntilReceived(new []{giftWrap}, cancellationToken); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,21 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ACBORObject_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003Fevilk_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F1178f88c7f664f88be66f2163788c5392f600_003F8a_003F2c7374c2_003FCBORObject_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> | ||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ACBORReader_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003Fevilk_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F1178f88c7f664f88be66f2163788c5392f600_003Fd6_003F6991e711_003FCBORReader_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> | ||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AEqualityAsserts_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003Fevilk_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fec11489f13fea2ba3e5dfbdea086f41dac024556d53f318c75a75a2cbd73_003FEqualityAsserts_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> | ||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AICBORConverter_00601_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003Fevilk_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F1178f88c7f664f88be66f2163788c5392f600_003Fd2_003F856b4d3b_003FICBORConverter_00601_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> | ||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIGrouping_00602_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003Fevilk_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F93ad1732e6bb4cc0a5b6f0de2317699584908_003F3b_003F8a9e12bf_003FIGrouping_00602_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> | ||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AJsonConverterOfT_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003Fevilk_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fc247cf3d53f062b5bf983a13ed187d7444d3f29fd6b7ae1a3cdc8cd0f3d213_003FJsonConverterOfT_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> | ||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ANostrClient_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003Fevilk_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fd0b54a6fb9f089bd45a21661e5f515f5109c46c869c360abb2ca21edbf267d60_003FNostrClient_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> | ||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AObject_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003Fevilk_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F9a6b1457cbcf17db31a383ba49ef9bcc786cf3ef77146d997eee499b27a46d_003FObject_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> | ||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AStringAsserts_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003Fevilk_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F999ae9cc4ab7b7cfbc5080803e994426e97fd9d87c5b1f44544a799bc114_003FStringAsserts_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> | ||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AThrowHelper_002ESerialization_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003Fevilk_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F60afdfcef9945be6977fa4b76b3d84506e2a2067afb63480aacf49417cfa_003FThrowHelper_002ESerialization_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> | ||
<s:String x:Key="/Default/Environment/Highlighting/HighlightingSourceSnapshotLocation/@EntryValue">C:\Users\evilk\AppData\Local\JetBrains\Rider2024.2\resharper-host\temp\Rider\vAny\CoverageData\_DotNut.1481064820\Snapshot\snapshot.utdcvr</s:String> | ||
|
||
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=7c67fc42_002Dfa49_002D41c5_002Db4e4_002D876bfc07dd62/@EntryIndexedValue"><SessionState ContinuousTestingMode="0" Name="Test1" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
 | ||
<TestAncestor>
 | ||
<TestId>xUnit::0AAAA85C-9FDC-4FD5-9CC2-ED8385B40106::net8.0::DotNuts.Tests.UnitTest1</TestId>
 | ||
<TestId>xUnit::0AAAA85C-9FDC-4FD5-9CC2-ED8385B40106::net8.0::DotNut.Tests.UnitTest1.Nut00Tests_TokenSerialization</TestId>
 | ||
</TestAncestor>
 | ||
</SessionState></s:String> | ||
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=b0637c43_002D4622_002D4768_002D94e5_002D70df8e44a8fe/@EntryIndexedValue"><SessionState ContinuousTestingMode="0" IsActive="True" Name="Nut11_Signatures" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
 | ||
<And>
 | ||
<Namespace>DotNuts.Tests</Namespace>
 | ||
<Project Location="C:\Git\DotNuts\DotNuts.Tests" Presentation="&lt;DotNuts.Tests&gt;" />
 | ||
</And>
 | ||
<Project Location="C:\Git\DotNuts\DotNut.Tests" Presentation="&lt;DotNut.Tests&gt;" />
 | ||
</SessionState></s:String></wpf:ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace DotNut.ApiModels; | ||
|
||
public class ContactInfo | ||
{ | ||
[JsonPropertyName("method")] public string Method { get; set; } | ||
[JsonPropertyName("info")] public string Info { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System.Text; | ||
using System.Text.Json; | ||
|
||
namespace DotNut; | ||
|
||
public class CashuTokenV3Encoder : ICashuTokenEncoder | ||
{ | ||
public string Encode(CashuToken token) | ||
{ | ||
var json = JsonSerializer.Serialize(token); | ||
return Base64UrlSafe.Encode(Encoding.UTF8.GetBytes(json)); | ||
} | ||
|
||
public CashuToken Decode(string token) | ||
{ | ||
var json = Encoding.UTF8.GetString(Base64UrlSafe.Decode(token)); | ||
return JsonSerializer.Deserialize<CashuToken>(json)!; | ||
} | ||
} |
Oops, something went wrong.