Skip to content

Instantly share code, notes, and snippets.

use bip39::Mnemonic;
use bitcoin::absolute::LockTime;
use bitcoin::bip32::{DerivationPath, Xpriv, Xpub};
use bitcoin::consensus::{deserialize, serialize};
use bitcoin::hex::{Case, DisplayHex, FromHex};
use bitcoin::{secp256k1, transaction, Network, OutPoint, Psbt, Script, Sequence, Transaction, TxIn, TxOut};
use miniscript::psbt::PsbtExt;
use miniscript::{DefiniteDescriptorKey, Descriptor, DescriptorPublicKey};
use std::str::FromStr;
# If that is inacceptable, pick as internal key a "Nothing Up My Sleeve" (NUMS) point,
# i.e., a point with unknown discrete logarithm.
# One example of such a point is H = lift_x(0x50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0)
# which is constructed by taking the hash of the standard uncompressed encoding of the secp256k1 base point G as X coordinate.
# In order to avoid leaking the information that key path spending is not possible
# it is recommended to pick a fresh integer r in the range 0...n-1 uniformly at random and use H + rG as internal key.
# It is possible to prove that this internal key does not have a known discrete logarithm with respect to G
# by revealing r to a verifier who can then reconstruct how the internal key was created.
import hashlib
[Interface]
PrivateKey = YPRIV
Address = 10.0.0.2/24
# DNS = 1.1.1.1
[Peer]
PublicKey = XPUB
AllowedIPs = 10.0.0.0/24
Endpoint = XPUBLICIP:51820
PersistentKeepalive = 25
// Convert decimal difficulty to target hex
function difficultyToTarget(difficulty) {
// maxTarget is the hex target for difficulty 1
const maxTarget = BigInt("0x00000000FFFF0000000000000000000000000000000000000000000000000000");
// Convert difficulty to BigInt and handle decimal places
const difficultyBigInt = BigInt(Math.floor(difficulty * 100000000)) / BigInt(100000000);
// Calculate target: maxTarget / difficulty
const target = maxTarget / difficultyBigInt;
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
I'm jaonoctus, in control of my PGP key 0x782C165A293D6E18.
writing this and signing with my new subkey ed25519/0x4FE21F5FFF84C9BC created at 2024-10-08 that will expire at 2025-10-08.
Latest bitcoin block hash:
00000000000000000000e1eba946427ab210ec3b9d9d3f7cedd93a73228c38ab
-----BEGIN PGP SIGNATURE-----
testnet=1
rpcauth=bitcoin:1cbc10237553f3b301516af8c1a74ad1$a8606448b6b01a2e63639d58111b92773c89b42b9435009b6f03bd2199446afc
zmqpubrawblock=tcp://0.0.0.0:28332
zmqpubrawtx=tcp://0.0.0.0:28333
[network]
listen=1
whitelist=0.0.0.0/0
[rpc]
#!/bin/bash
# dependencies: base58
# usage
# ./xpub-converter.sh <ZPUB> xpub
main () {
local input="$1"
local prefix="$2"
var base58 = require('bs58')
var { sha256 } = require('@noble/hashes/sha256')
const useBs58check = function (checksumFn) {
// Encode a buffer as a base58-check encoded string
function encode (payload) {
var payloadU8 = Uint8Array.from(payload)
var checksum = checksumFn(payloadU8)
var length = payloadU8.length + 4
var both = new Uint8Array(length)
@jaonoctus
jaonoctus / docker-compose-mempool.yml
Created January 6, 2024 11:58
Mempool.Space docker compose
version: '3.7'
services:
web:
image: mempool/frontend:v2.5.0
user: "1000:1000"
restart: on-failure
stop_grace_period: 1m
command: "./wait-for mariadb:3306 --timeout=720 -- nginx -g 'daemon off;'"
environment:
@jaonoctus
jaonoctus / docker-compose.yml
Last active February 14, 2023 04:20
taro docker-compose.yml for umbrel
version: "3"
services:
taro:
image: jaonoctus/taro:v0.1.99-alpha
command: --network=testnet --debuglevel=debug --lnd.host=10.21.21.9:10009
volumes:
- ./data:/root/.taro/
- ../umbrel2/app-data/lightning/data/lnd:/root/.lnd/
networks: