Skip to content

Instantly share code, notes, and snippets.

@ottosch
ottosch / self-transfer.js
Last active June 12, 2025 14:54
Script to spend an UTXO to a single address, with custom fee rate
#! /usr/bin/env node
// Instructions: place the file inside a directory, run `npm init -y` and install dependencies with
// `npm i bitcoinjs-lib@^6.1.1 ecpair@^2.1.0 tiny-secp256k1@^2.2.1`
const bitcoin = require("bitcoinjs-lib");
const ecc = require("tiny-secp256k1");
const { ECPairFactory } = require("ecpair");
const ECPair = ECPairFactory(ecc);
bitcoin.initEccLib(ecc);
@ottosch
ottosch / tx-ascii-art.js
Created June 8, 2025 17:05
Code used to create transaction 749fdc72f1c99398899425253875deb1d7e5e040db14014ea57db71c610dad26 - #FreeSamourai
#! /usr/bin/env node
const fs = require("fs");
const bitcoin = require("bitcoinjs-lib");
const ecc = require("tiny-secp256k1");
const { ECPairFactory } = require("ecpair");
const ECPair = ECPairFactory(ecc);
bitcoin.initEccLib(ecc);
const network = bitcoin.networks.bitcoin;
@ottosch
ottosch / draw-tx.sh
Created May 3, 2025 22:28
Draws ASCII art from tx 5c4f060e6166a530d891cafd0e9df42441d29b1ed9cff71a1652201b8d50bd72
bitcoin-cli getrawtransaction 5c4f060e6166a530d891cafd0e9df42441d29b1ed9cff71a1652201b8d50bd72 2 | jq -r '.vout[].scriptPubKey.hex | sub("^.{6}"; "")' | while read -r output; do echo "$output" | xxd -p -r; echo; done
@ottosch
ottosch / dinner-inscription.js
Created May 3, 2025 21:50
Extract image inscription of tx 4be3a833ee83b4ca7d157d60fbf7411f7528314ce90df8a844f855118bc6ca11
#! /usr/bin/env node
// Invoke with: bitcoin-cli getrawtransaction 4be3a833ee83b4ca7d157d60fbf7411f7528314ce90df8a844f855118bc6ca11 | ./dinner-inscription.js
const { Transaction } = require('bitcoinjs-lib');
if (process.stdin.isTTY) {
console.error('raw tx needed, quitting...');
process.exit(1);
}
@ottosch
ottosch / restore-grub.md
Created February 25, 2025 02:02
How to restore GRUB using Arch Linux ISO

How to restore GRUB using Arch Linux ISO

Partitions

  • /dev/sda1: ESP (EFI System Partition)
  • /dev/sda2: system + home
  • /dev/sda3: swap

Script

@ottosch
ottosch / verify-grapheneos-signature.md
Created February 10, 2025 23:16
How to verify GrapheneOS releases

Verifying GrapheneOS releases

Instructions taken from Obtaining Factory Images.

Get the signers' public keys

curl -O https://releases.grapheneos.org/allowed_signers
@ottosch
ottosch / twitter-revanced.md
Last active May 17, 2025 00:40
How to patch Twitter (X) with ReVanced

How to patch Twitter (X) with ReVanced

Benefits:

  • Hide ads;
  • Remove tracking when sharing links;
  • Enable video download;
  • Other benefits;

Download X apk

@ottosch
ottosch / laptop-lid.md
Last active January 13, 2025 21:57
Settings to avoid laptop sleeping after lid is closed

Laptop lid configuration

Ignore the lid being closed

sudo nano /etc/systemd/logind.conf, change these values to ignore:

HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore
HandleLidSwitchDocked=ignore
@ottosch
ottosch / dimm.sh
Created January 9, 2025 13:52
Change screen brightness for the terminal
#! /usr/bin/env bash
# Sets brightness to parameter level [0, max_brightness]
# Default: 10_000
default=10000
brightness=${1:-$default}
max="$(cat /sys/class/backlight/*/max_brightness)"
if test "$brightness" -eq "$brightness" 2>/dev/null; then # numeric value
@ottosch
ottosch / seed_picker.sh
Last active December 24, 2023 01:59
Find all possibilities for the last seed word
#! /usr/bin/env bash
function run() {
read_wordlist
local input
printf "Enter seed words: "
read -r input
local seed_words=()