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
// based on: https://github.com/fiatjaf/nos2x/blob/master/extension/nostr-provider.js | |
window.nostr = { | |
_requests: {}, | |
_pubkey: null, | |
_accountChangeCallback: null, | |
_monitoringInterval: null, | |
async getPublicKey() { | |
if (this._pubkey) return this._pubkey |
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
// Need for work on server | |
import { useWebSocketImplementation } from 'nostr-tools/pool' | |
import WebSocket from 'ws' | |
useWebSocketImplementation(WebSocket) | |
import { generateSecretKey, getPublicKey, finalizeEvent, getEventHash } from 'nostr-tools/pure' | |
import { SimplePool } from 'nostr-tools/pool' | |
import { v2 as nip44 } from 'nostr-tools/nip44' | |
const relayArray = [ |
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 encryptedMessage = await nip04.encrypt(this.prvKey, contact.pubKey, message) | |
const notificationEvent = { | |
kind: 4, | |
pubkey: this.pubKey, | |
created_at: Math.floor(Date.now() / 1000), | |
tags: [['p', contact.pubKey]], // Tag the recipient's pubkey | |
content: encryptedMessage | |
} | |
const signedEvent = finalizeEvent(notificationEvent, this.prvKey) |
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 bitcoin = require('bitcoinjs-lib'); | |
const EC = require('elliptic').ec; | |
const ec = new EC('secp256k1'); | |
// Generate a random private key | |
const privateKey = ec.genKeyPair().getPrivate('hex'); | |
// Convert the private key to a BitcoinJS keypair | |
const keyPair = bitcoin.ECPair.fromPrivateKey(Buffer.from(privateKey, 'hex')); |
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 { ECPairFactory } = require('ecpair') | |
const bitcoin = require('bitcoinjs-lib') | |
const ecurve = require('ecurve') | |
const secp256k1 = ecurve.getCurveByName('secp256k1') | |
const schnorr = require('bip-schnorr') | |
const { bech32, bech32m } = require('bech32') | |
const bip38 = require('bip38') | |
const wif = require('wif') |
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
module.exports = { | |
NETWORKS: { | |
dogecoin: { | |
messagePrefix: '\x19Dogecoin Signed Message:\n', | |
bip32: { | |
public: 0x02facafd, | |
private: 0x02fac398 | |
}, | |
pubKeyHash: 0x1e, | |
scriptHash: 0x16, |
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 bjs = require('bitcoinjs-lib') | |
, b58 = require('bs58check') | |
function BIP84(pub) { | |
// mainnet | |
this.pub_types = [ | |
'04b24746', // zpub | |
'02aa7ed3', // Zpub | |
] |
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 isImage = (name, msg, req) => { | |
let proof = typeof req.files[name] !== "undefined" ? req.files[name] : undefined; | |
if (!proof) { | |
throw new Error(msg) | |
} | |
switch (proof.type) { | |
case 'image/jpeg': | |
return 'image/jpeg'; |
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
$breakpoints: "palm" "(max-width: 480px)", "lap" "(min-width: 481px)", "portable" "(max-width: 1023px)", "desk" "(min-width: 1024px)", "desk-wide" "(min-width: 1200px)" !default | |
=media-query($media-query) | |
$breakpoint-found: false | |
@each $breakpoint in $breakpoints | |
$name: nth($breakpoint, 1) | |
$declaration: nth($breakpoint, 2) | |
@if $media-query == $name and $declaration | |
$breakpoint-found: true | |
@media only screen and #{$declaration} |
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 find = ( Model ) => ( query, sort = {} ) => | |
Model.find({}).or( query ).sort( sort ).exec() | |
const findOne = ( Model ) => ( query, populate = '' ) => | |
Model.findOne( query ).populate( populate ).exec() | |
const count = ( Model ) => ( query ) => | |
Model.count( query ).exec() | |
const save = ( Model ) => |
NewerOlder