Skip to content

Instantly share code, notes, and snippets.

View portlandhodl's full-sized avatar
🍊
💊

Portland.HODL portlandhodl

🍊
💊
View GitHub Profile
@portlandhodl
portlandhodl / README.md
Last active November 20, 2025 20:32
Thoughts about Bitcoin Core. Things that might be useful?

Features

  • Startup flags printout
  • Log manipulation - Viewer

Test

test_mempool_accept.py fails for the wrong reason on line 308 when ScriptSig size is extended because the push style in the test is pushing more than 520 bytes.

@portlandhodl
portlandhodl / bitcoin.sh
Created July 31, 2025 18:20
Bitcoin Core Setup Bash Script
#!/bin/bash
# Bitcoin daemon setup script
# This script sets up bitcoind with proper user, directories, and systemd service
set -e # Exit on error
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
@portlandhodl
portlandhodl / knots-slayer.sh
Created May 31, 2025 18:58
Unix cron script to automatically disconnect Bitcoin Knots peers.
#!/bin/bash
# Get peer info and disconnect any peer with "knots" in the subver field
bitcoin-cli getpeerinfo | jq -r '.[] | select(.subver | ascii_downcase | contains("knots")) | .id' | while read peer_id; do
if [ ! -z "$peer_id" ]; then
echo "Disconnecting peer ID $peer_id with knots client"
bitcoin-cli disconnectnode "" "$peer_id"
fi
done
@portlandhodl
portlandhodl / smt.md
Last active March 8, 2025 12:22
Sparse Merkle Trees

Notes about Sparse Merkle Trees

  • The primary issue with a SMT is the calculation between each leaf and their intersection with other leaves.
  • A tree with a single sparse element is very easy as you just can add that element in an calculate the path up the tree.
  • When you have multiple keys then you need to make sure when you calculate the path up the tree you need to consider the impact other leaves have on your path to get to the root.
@portlandhodl
portlandhodl / sha256_test.cpp
Last active February 8, 2025 21:11
Double Sha256 Benchamrk w/ Hardware Support
#include <iostream>
#include <chrono>
#include <openssl/sha.h>
#include <cpuid.h>
bool check_sha_support() {
unsigned int eax, ebx, ecx, edx;
if (__get_cpuid(7, &eax, &ebx, &ecx, &edx)) {
return (ebx & (1 << 29)) != 0; // Check bit 29 for SHA extensions
}
@portlandhodl
portlandhodl / main.rs
Created December 17, 2024 23:48
Get Block Template Rust Example 1
use actix_web::{get, web, App, HttpResponse, HttpServer, Responder};
use bitcoincore_rpc::{Auth, Client, RpcApi};
use serde_json::Value;
struct AppState {
btc_client: Client,
}
#[get("/blocktemplate")]
async fn get_block_template(data: web::Data<AppState>) -> impl Responder {
@portlandhodl
portlandhodl / aws2_init.sh
Created October 4, 2024 07:19
Amazon AWS Linux2 Quick Docker Init and Update Scrupt
#!/bin/bash
# Update the system
sudo yum update -y
# Install Docker
sudo amazon-linux-extras install docker -y
sudo systemctl start docker
sudo systemctl enable docker
sudo usermod -aG docker ec2-user
@portlandhodl
portlandhodl / mtp-run-plot.py
Created August 27, 2024 22:58
Plotting MTP vs Timestamp Over 10000 Blocks
import requests
import csv
from datetime import datetime
import time
import matplotlib.pyplot as plt
import pandas as pd
# Bitcoin node RPC connection details
rpc_user = 'your_rpc_username'
rpc_password = 'your_rpc_password'
@portlandhodl
portlandhodl / mtp_run_plot.py
Created August 27, 2024 22:56
Plotting MTP vs Timestamp Over 10000 Blocks.
import requests
import csv
from datetime import datetime
import time
import matplotlib.pyplot as plt
import pandas as pd
# Bitcoin node RPC connection details
rpc_user = 'your_rpc_username'
rpc_password = 'your_rpc_password'
@portlandhodl
portlandhodl / bitaxe_diff.go
Created August 4, 2024 01:55
Waybar Bitaxe Difficulty Widget
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
)
type SystemInfo struct {