Skip to content

Instantly share code, notes, and snippets.

basic_diagram

Request flow:

  1. RequestBuilder builds a set of 1 or more filters and has a human readable id, this is used to track the query result sets (NoteCollection)
    1. ID is important for grouping requests, grouping happens when multiple RequestBuilder objects are requested with the same ID. In this case filters are emitted after groupingDelay
    2. The NoteCollection is a container to store events, it stores only the latest version of replaceable events and contains no duplicates, it also track which relays events are seen on.
  2. RequestBuilder is sent to the QueryManager, if the Query already exists (query.id === builder.id) then the new RequestBuilder filters are appended to the query, otherwise a new Query object is created and stored in the QueryManager.
  3. Query object (sometime later) emits an event to send filters to relays (handled in QueryManager).
  4. QueryManager asks `Cach
@v0l
v0l / NostrAuth.cs
Created March 31, 2023 09:20
Nostr auth handler for ASP.NET
using System.Security.Claims;
using System.Text.Encodings.Web;
using System.Text.Json;
using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.Options;
using NNostr.Client;
public static class NostrAuth
{
public const string Scheme = "Nostr";
use bitcoin::consensus::Decodable;
use bitcoin::hashes::hex::FromHex;
use bitcoin::hashes::hex::ToHex;
use bitcoin::Transaction;
use bitcoin::util::psbt::serialize::Serialize;
fn main() {
let amount = 100_000_000u64;
println!();
use std::str::FromStr;
use bitcoin::util::bip32::ExtendedPubKey;
use bitcoin::util::bip32::DerivationPath;
use bitcoin::secp256k1::Secp256k1;
use bitcoin::secp256k1::ffi::types::AlignedType;
use slip132::FromSlip132;
fn main() {
let network = bitcoin::Network::Bitcoin;
@v0l
v0l / NppSerializer
Last active June 24, 2016 15:57
A c# Binary serializer using attribute flags, usefull if you need to do network communication with C++ applications that copy structs directly from memory.
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
namespace npid
{
[AttributeUsage(AttributeTargets.Struct)]