Skip to content

Instantly share code, notes, and snippets.

View braydonf's full-sized avatar

Braydon Fuller braydonf

View GitHub Profile
@braydonf
braydonf / nostr-amethyst-top-feed-sketch.js
Last active April 6, 2023 12:16
Nostr Amethyst Top Feed Sketch
'use strict';
const assert = require('assert');
const window_of_time_ms = 86400000 * 4; // 96 hours
class Note {
constructor(event) {
this.event = event;
this.weight = {
@braydonf
braydonf / docker-entrypoint.sh
Created January 10, 2022 20:50
btcpayserver docker entrypoint with user
#!/bin/sh
echo "$(/sbin/ip route|awk '/default/ { print $3 }') host.docker.internal" >> /etc/hosts
if [ ! -z "$BTCPAY_SSHKEYFILE" ] && ! [ -f "$BTCPAY_SSHKEYFILE" ]; then
echo "Creating BTCPay Server SSH key File..."
ssh-keygen -t rsa -f "$BTCPAY_SSHKEYFILE" -q -P "" -m PEM -C btcpayserver > /dev/null
if [ -f "$BTCPAY_SSHAUTHORIZEDKEYS" ]; then
# Because the file is mounted, set -i does not work
sed '/btcpayserver$/d' "$BTCPAY_SSHAUTHORIZEDKEYS" > "$BTCPAY_SSHAUTHORIZEDKEYS.new"
@braydonf
braydonf / amd64.Dockerfile
Created January 10, 2022 20:47
btcpayserver dockerfile with user
# This file is based on:
# https://github.com/btcpayserver/btcpayserver/blob/master/amd64.Dockerfile
#
# There are several changes made:
# - Change to fetch from remote git repository
# - Addition to run as btcpayserver user
FROM mcr.microsoft.com/dotnet/sdk:3.1.413-bullseye AS builder
RUN set -ex && \

Bcoin BlockStore Benchmarks (2019-2-25)

All times for min, max, average and median are in microseconds, and length is in bytes. Benchmarks results include writing, reading, and pruning of 3GiB (3 * 1024 * 1024 * 1024) of data on both HDD and SSD with a block size distribution from mainnet. See the PR at bcoin-org/bcoin#703 for further details.

FileBlockStore (SSD | NVMe)

real	0m6.444s
user	0m4.610s
sys	0m3.884s
@braydonf
braydonf / bcoin-wallet-strategies.md
Last active February 22, 2019 05:13
Bcoin Wallet Strategies

Bcoin Wallet Strategies

This proposes a structure for wallet management stategies for the bcoin wallet.

Motivation

As it is currently you can mix several wallet management strategies within the same wallet in bcoin. This leads to permutations with unintended behavior.

For example, here are a few:

  • HD wallets with many accounts without any transactions that will make address discovery from nearly impossible without
@braydonf
braydonf / bip-xxxx.mediawiki
Last active August 27, 2019 18:41
Multi-Account Hierarchy for P2WSH Multi-signature Deterministic Wallets


  BIP: x
  Layer: Applications
  Title: Multi-Account Hierarchy for P2WSH Multi-signature Deterministic Wallets
  Author&#58; Braydon Fuller <braydon@purse.io>
  Comments&#45;Summary&#58; No comments yet.
  Comments&#45;URI&#58; https&#58;//github.com/bitcoin/bips/wiki/Comments&#58;BIP&#45;x
  Status&#58; Draft
  Type&#58; Standards Track
  Created&#58; 2019&#45;02&#45;12

@braydonf
braydonf / reading-blocks-bcoin.js
Last active February 6, 2019 01:43
Read bitcoin blocks from disk with bcoin
// original: https://gist.github.com/braydonf/e9572bb40c084691fa20
'use strict';
const path = require('path');
const {Block, Network} = require('bcoin');
const fs = require('bfile');
const bufio = require('bufio');
(async function() {
@braydonf
braydonf / sip9-queries.js
Last active November 10, 2017 22:31
Queries for SIP9
// Finding Lost Shards
// --------------------------------------------------------------------------------------
const result = db.storageevents.aggregate([
{
$match: {
$and: [
{storage: {$gt: 0}}
]
}
},
block-stream results:
[ { writes:
[ { msElapsed: 60,
fileKey: 'b2d4baca8ac61c63dcf5ca835d71cb091c62295a',
sBucketIndex: 49,
fileSizeBytes: 8388608 },
{ msElapsed: 250,
fileKey: '70eb91e9659e8d86bc0b6ec5e87a8f65da646bde',
sBucketIndex: 243,
@braydonf
braydonf / tokenminer.js
Created August 17, 2017 03:28
Example script to do basic proof-of-work
#!/usr/bin/env node
'use strict';
//node pow.js '{"challenge": "f8b55e92d345bae0e644419982c2fadcf003289ac3ed638a5651e77ba24d4f5c", "target": "00000560a5e9cfe18772cc5cf6c5e29dc79d118ebcfc5ee72a2d56aff20c0fc6"}'
const web3 = require('web3');
const data = JSON.parse(process.argv[2]);
const challenge = '0x' + data.challenge;
const target = '0x' + data.target;
let nonce = 0;