Skip to content

Instantly share code, notes, and snippets.

@kallewoof
kallewoof / bitcoin-rpc.ts
Created May 11, 2021 10:14
Typescript bindings for Bitcoin Core's RPC command
export type Dict<T> = { [type: string]: T };
const Do = async <Retval>(cmd: string, ...args: (string | boolean | number | object | null | undefined)[])
: Promise<Retval> => Promise.reject();
// The above Do command should asynchronously call Bitcoin's RPC interface, e.g. like the bcrpc package.
/////////////////////////////////////////
// RPC: abandontransaction
//
internal_pubkey=efe24af16da45a3e3ce3503b7b7172d64b16b28922011f8df970dd5bf6cc6be7
tapscript=a8206c60f404f8167a38fc70eaf8aa17ac351023bef86bcb9d1086a19afe95bd53338820cc9519ba6fb1cb0cca53743dc90c2418440cf637f8b891ce2f0e2dc5c5b3cf01ac
➜ btcdeb git:(taproot) ✗ ./tap $internal_pubkey 1 $tapscript
tap 0.2.19 -- type `./tap -h` for help
WARNING: This is experimental software. Do not use this with real bitcoin, or you will most likely lose them all. You have been w a r n e d.
LOG: sign segwit taproot
Internal pubkey: efe24af16da45a3e3ce3503b7b7172d64b16b28922011f8df970dd5bf6cc6be7
1 scripts:
- #0: a8206c60f404f8167a38fc70eaf8aa17ac351023bef86bcb9d1086a19afe95bd53338820cc9519ba6fb1cb0cca53743dc90c2418440cf637f8b891ce2f0e2dc5c5b3cf01ac
Initial script:
OP_IF
144
OP_CHECKSEQUENCEVERIFY
<pubkey_alice>
OP_ELSE
OP_SHA256
preimage_hash
OP_EQUALVERIFY

Signet

This is a description of how to get started with Signet. This document assumes you are capable of using git, and that you are able to compile Bitcoin. (If you have not yet done so, you should begin by doing that now.)

Fetch and compile signet

$ git clone https://github.com/kallewoof/bitcoin.git signet
$ cd signet
$ git checkout 2003-signet-consensus
On Debian Jessie PowerPC (Big endian) system (endianness probably unrelated):
```
wallet/walletutil.cpp: In function ‘std::vector<boost::filesystem::path> ListWalletDir()’:
wallet/walletutil.cpp:57:78: error: ‘end’ was not declared in this scope
for (auto it = fs::recursive_directory_iterator(wallet_dir); it != end(it); ++it) {
^
wallet/walletutil.cpp:57:78: note: suggested alternative:
In file included from /usr/include/c++/4.9/bits/basic_string.h:42:0,
from /usr/include/c++/4.9/string:52,
from ./fs.h:9,
@kallewoof
kallewoof / compile-commits.sh
Created July 19, 2018 04:34
Compile commits in a range from current head
#!/bin/bash
if [ $# -lt 1 ]; then
echo "syntax: $0 <commit count> [<make args>]"
echo "will attempt to run 'make' on each commit starting with the commit <commit count> commits ago all the way up to the current HEAD"
echo "e.g. compile-commits 10 -j10"
exit 1
fi
if [ ! -d ".git" ]; then
echo ".git not found or not a dir"
@kallewoof
kallewoof / setup.md
Created April 16, 2018 04:23
Clang Static Analyzer Setup

Setting up Clang Static Analyzer on macOS

Using it

  • Go to e.g. ~/workspace/myproject
  • Compile it from scratch, including autogen parts, with make clean, but prefix each call with the scan-build in the path above. E.g.
@kallewoof
kallewoof / test_vectors.md
Last active April 18, 2022 14:51
Test vectors, Schnorr signatures

Schnorr signature test vectors

Test vector overview

  1. Hash function H(m) = SHA256(m)

Basics

  • For a private key x, the public key is xG.
  • A signature on the message m with private key x is (R, s) where R=kG, s=k+H(R,X,m)x.
  • Verifying a signature is testing whether sG = R+H(R,X,m)X.
.section __TEXT,__text,regular,pure_instructions
.macosx_version_min 10, 12
.globl __Z14memory_cleansePvm
.p2align 4, 0x90
__Z14memory_cleansePvm: ## @_Z14memory_cleansePvm
.cfi_startproc
## BB#0:
pushq %rbp
Ltmp0:
.cfi_def_cfa_offset 16
.file "test_cleanse.cpp"
.text
.p2align 4,,15
.globl _Z14memory_cleansePvm
.type _Z14memory_cleansePvm, @function
_Z14memory_cleansePvm:
.LFB77:
.cfi_startproc
movq %rsi, %rdx
xorl %esi, %esi