see https://njump.me/note1artmd2xwklx6mkqfdz539a29z380fyk2uzwfr2c4fau0m3ys3dqqt0rdrx
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
// Bostr config | |
module.exports = { | |
// Server listener [Required] | |
address: "127.0.0.1", | |
port: "8080", | |
// Clusters. | |
// 0 will make bostr run clusters with available parallelism / CPU cores. | |
clusters: 1, |
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
import { fetchWithL402 } from "alby-tools"; | |
import { webln } from "alby-js-sdk"; | |
import 'websocket-polyfill'; | |
import * as crypto from 'crypto'; // or 'node:crypto' | |
globalThis.crypto = crypto; | |
const nwcURL = process.env.NWC_URL; | |
async function main() { | |
const nwc = new webln.NWC({ nostrWalletConnectUrl: nwcURL }); |
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
/** | |
* テキスト投稿イベント(リプライ)を組み立てる | |
* @param {string} content 投稿内容 | |
* @param {import("nostr-tools").Event} targetEvent リプライ対象のイベント | |
*/ | |
const composeReplyPost = (content, targetEvent) => { | |
/* Q-1: これまで学んだことを思い出しながら、 | |
リプライを表現するイベントを組み立てよう */ |
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
const {WebSocket} = require('websocket-polyfill'); | |
const {relayInit, | |
getEventHash, | |
getPublicKey, | |
verifySignature, | |
signEvent, | |
generatePrivateKey} = require('nostr-tools'); | |
const https = require('https'); | |
//********* Constants ********************************************************************** |
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
const {WebSocket} = require('websocket-polyfill'); | |
const {relayInit,nip04, | |
getEventHash, | |
getPublicKey, | |
verifySignature, | |
signEvent, | |
nip42,finishEvent, | |
generatePrivateKey} = require('nostr-tools'); | |
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
const log = console.log; | |
import { hex } from '@scure/base'; | |
import * as btc from '@scure/btc-signer'; | |
import { secp256k1, schnorr as secp256k1_schnorr } from '@noble/curves/secp256k1'; | |
import { bech32 } from '@scure/base'; | |
const privKey = secp256k1.utils.randomPrivateKey(); | |
//const privKey = hex.decode(''); | |
log('privKey', hex.encode(privKey)); |
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
#!/usr/bin/env node | |
import fastify from 'fastify' | |
import fastifyWebsocket from '@fastify/websocket' | |
import { validateEvent, verifySignature } from 'nostr-tools' | |
const port = process.argv[2] || 3000 | |
const events = [] | |
const subscribers = new Map() |
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
const WebSocket = require('ws'); | |
const bitcoin = require('bitcoinjs-lib'); | |
const fetch = require('node-fetch'); | |
const base64 = require('base64-js'); | |
const relays = [ | |
'wss://nostr.wine', | |
'wss://nos.lol', | |
'wss://nostr.fmt.wiz.biz', | |
'wss://nostr.zebedee.cloud', |
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
'use strict'; | |
const assert = require('assert'); | |
const window_of_time_ms = 86400000 * 4; // 96 hours | |
class Note { | |
constructor(event) { | |
this.event = event; | |
this.weight = { |
NewerOlder