Skip to content

Instantly share code, notes, and snippets.

View jnewbery's full-sized avatar
🗽

John Newbery jnewbery

🗽
View GitHub Profile

Bitcoin Core wallet design notes

The Bitcoin Core wallet consists of:

  • An in memory keystore (in /src/keystore.cpp), which contains:
    • private keys stored as mapKeys - a map from the CKeyID to the private key.
    • watchonly public keys, stored as mapWatchKeys - a map from the CKeyID to the public key.
    • scripts, stored as mapScripts - a map from the CScriptID to the secrialized script.
    • watchonly scripts, stored as setWatch - a set of serialized scripts.
  • Additional key metadata such as key birthday, hd derivation path. See CKeyMetadata in /src/wallet/walletdb.h
@jnewbery
jnewbery / sighash.md
Created January 16, 2019 22:38
SIGHASH notes
@jnewbery
jnewbery / tx_relay_peer_prioritization.md
Last active July 17, 2019 19:58
P2P peer prioritization logic for tx relay

Scenario

Bitcoin nodes relay txs to each other over the P2P network. If a node receives a valid tx from a peer, it adds it to the mempool and relays it to its other peers. If it receives an invalid tx from a peer, it must decide what action to take. We distinguish three cases:

  1. a transaction which is valid according to consensus rules, but invalid according to the node's policy rules.
  2. a transaction which is valid according to long-established consensus rules,
@jnewbery
jnewbery / git-br.py
Created May 29, 2019 18:57
git tools
#!/usr/bin/env python3
import subprocess
import os
if os.name == 'posix':
RED = "\033[1;31m"
BLUE = "\033[0;34m"
CYAN = "\033[0;36m"
GREEN = "\033[0;32m"
RESET = "\033[0;0m"
@jnewbery
jnewbery / shared_ptr.cpp
Created April 18, 2020 15:42
Passing shared pointers
#include <iostream>
#include <memory>
struct Base
{
Base() { std::cout << " Base::Base()\n"; }
~Base() { std::cout << " Base::~Base()\n"; }
};
struct TraceByVal
@jnewbery
jnewbery / labitcoin_schnorr_notes.md
Last active July 8, 2020 19:02
Labitconf schnorr/taproot presentation links and notes