Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am achow101 on github.
  • I am achow101 (https://keybase.io/achow101) on keybase.
  • I have a public key whose fingerprint is 1528 1230 0785 C964 44D3 334D 1756 5732 E08E 5E41

To claim this, I am signing this object:

@achow101
achow101 / sendalert.cpp
Created November 1, 2016 19:58 — forked from laanwj/sendalert.cpp
Bitcoin send alert code
/*
So you need to broadcast an alert...
... here's what to do:
1. Copy sendalert.cpp into your bitcoind build directory
2. Decrypt the alert keys
copy the decrypted file as alertkeys.h into the src/ directory.
3. Modify the alert parameters in sendalert.cpp
diff --git a/src/script/ismine.cpp b/src/script/ismine.cpp
index 6b68f0679e8..c4c81715e48 100644
--- a/src/script/ismine.cpp
+++ b/src/script/ismine.cpp
@@ -145,6 +145,27 @@ isminetype IsMine(const CKeyStore &keystore, const CScript& scriptPubKey, bool&
return ISMINE_SPENDABLE;
break;
}
+
+ case TX_CLTV_MULTISIG:
@achow101
achow101 / fees-bitcoin-fees-info-cycle.csv
Created January 22, 2018 18:11
coinselection-simulation-fees
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
40
60
60
50
62
64
42
59
60
41
final value total sent total deposited mean #UTXO final #UTXO #received #spent #payments sent #changes created min change max change mean change stDev of change total fees average fees fees to spend remaining UTXO total cost min input set max input set mean size of input set stdev of input set size Fees file Simulation File BnB Usage
55.88713405 -2484.3994 2540.3143409799973 19.85849529431419568936689756810665130615234375 17 6097 17913 11860 11833 0.00997809 4.15153434 0.10399897 0.28233767 -0.02520509 -0.0000021252184 -0.0000251600000000000030542755824480849469182430766522884368896484375 -0.025230250 1 24 1.510370994940978039977608204935677349567413330078125 1.0410142316722097444170458402368240058422088623046875 fees-bitcoinfees-info-repeats.csv derived-1I-2O.csv 27/1186

All of the BnB simulation results. Some are right, others are wrong.

Results

All of the valid results for varying fee rate simulations, but readable

Type Fees file Simulation File final value mean #UTXO final #UTXO #received #spent #changes created min change max change mean change stDev of change total fees average fees total cost min input set max input set mean size of input set stdev of input set size BnB Usage
BnB+Core fees-bitcoinfees-info-repeats.csv derived-1I-2O.csv 55.88713405 19.86 17 6097 17913 11833 0.00997809 4.15153434 0.10399897 0.28233767 -0.02520509 -0.00000213 -0.02523025 1 24 1.51 1.04 27/11860
Core fees-bitcoinfees-info-repeats.csv derived-1I-2O.csv 55.88712329 27.51 22 6097 17935 11860 0.00001005 10.30069834 0.29223202 0.72740965 -0.02521585
import requests
import pprint
r = requests.get('https://blockchain.info/rawblock/0000000000000000002540e369b106bfd929585e0f059409bd2a956e6a6af79c')
r = r.json()
txs = r['tx']
first = True
packages = []
for i,tx in enumerate(txs):
if first:
import requests
import re
import operator
from bs4 import BeautifulSoup
r = requests.get('https://bitcointalk.org/modlog.php')
p = re.compile('member #\d+')
all_members = p.findall(r.text)
mem_dict = {}

Simulations Results for SRD Fallback strategies

SRD Fallback

Simulation File final value mean #UTXO final #UTXO #received #spent #payments sent #changes created min change max change mean change stDev of change total fees average fees fees to spend remaining UTXO total cost min input set max input set mean size of input set stdev of input set size BnB Usage SRD Usage
derived-1I-2O-statoshi-6block.csv 115.55086265 102.27 139 6097 16424 11565 10467.00000000 0.00007778 10.10469422 0.94600269 1.21818317 -2.35333207 -0.00020349 -0.00020572 -2.35353779 1 14 1.42014700 1.17345193 1098 10467
derived-balanced-statoshi-6block.csv 106.49087057 199.77 287 12194 20883 11600 8976.00000000 0.00002474 9.94578008 0.70230363 1.07709449 -2.54395062 -0.00021931 -0.00042476 -2.54437538 0 22 1.80025862 1.622

Vulnerabilities in the Bitcoin Alert system

Background

The Alert System previously utilized by Bitcoin has several issues (some of which may be classified as vulnerabilities). These issues no longer exist in Bitcoin as of network protocol version 700013 which was released with Bitcoin Core 0.13.0. Many altcoins and Bitcoin client implementations were notified of the Alert System's removal and have since removed the alert system themselves or transitioned to using an Alert system that does not share an Alert Key with Bitcoin.

All of the issues described below allow an attacker in possession of the Alert Key to perform a Denial of Service attack on nodes that still support the Alert system. These issues involve the exhaustion of memory which causes node software to crash or be killed due to excessive memory usage.

Many of these issues were not known until the Alert System was removed as developers inspected the code for vulnerabilities prior to releasing the Alert Key. Due to these issues, the publicat