Skip to content

Instantly share code, notes, and snippets.

@jl2012
jl2012 / blocksize.mediawiki
Last active August 29, 2015 14:27 — forked from sipa/blocksize.mediawiki
Block size according to technological growth.

  BIP: ??
  Title: Block size following technological growth
  Author: Pieter Wuille <[email protected]>
  Status: Draft
  Type: Standards Track
  Created: 2015-07-21

Abstract

@jl2012
jl2012 / BIP_segwit
Last active December 18, 2015 18:05 — forked from CodeShark/BIP_segwit
segwit BIP draft
<pre>
SEGWIT BIP...yada yada...
</pre>
==Abstract==
This BIP defines a new structure called a "witness" that is committed to blocks separately from the transaction merkle tree. This structure contains data required to check transaction validity but not required to determine transaction effects. In particular, scripts and signatures are moved into this new structure.
The witness is committed in a tree that is nested into the block's existing merkle root via the coinbase transaction for the purpose of making this BIP soft fork compatible. A future hard fork can place this tree in its own branch.
Traditional Chinese
Title: 比特幣系統擴展
我們連署支持<link to Capacity incresases for the Bitcoin system 比特幣系統擴展>路線圖。我們已在Bitcoin Core計劃內為可擴展性工作多年,認為這是最可以延續我們一直以來努力的方向。
(Signatures)
我們正準備一份常見問答集,完成後會在此連結。
#!/usr/bin/python
# General segwit address by jl2012 2015 (Public domain)
# Damm checksum code by Ilmari Karonen
# reduction bitmasks for GF(2^n), 2 <= n <= 32
masks = (3, 3, 3, 5, 3, 3, 27, 3, 9, 5, 9, 27, 33, 3, 43, 9,
9, 39, 9, 5, 3, 33, 27, 9, 27, 39, 3, 5, 3, 9, 141)
#base32 = "0123456789ABCDEFGHJKMNPQRSTUVWXY"
base32 = "ybndrfg8ejkmcpqxot1uwisza345h769"
Next block and weak block
Objective: to minimize the network and validation lantency when a block is found.
"Next block" committment:
1. We introduce a non-consensus enforced, optional committment in coinbase tx: "next"
2. "next" is a set of txs proposed for the next block, given that this block has full PoW
3. There are 2 miners: Alice and Bob
4. Alice is mining {A,B,C}; Bob is mining {A,B,E}
v0.13.0 (no #8524 or #8654)
Test: 14-of-14 CHECKMULTISIG P2SH/P2WSH inputs with different variations of SIGHASH_ALL
**Non-witness**
Transaction weight : 3987928
Validation time : 5.946058988571167
**Witness**
Transaction weight : 3816865
Validation time : 3.072489023208618
Test: 14-of-14 CHECKMULTISIG P2SH/P2WSH inputs with same SIGHASH_ALL
**Non-witness**
Patched
==========
Test: 14-of-14 CHECKMULTISIG P2SH/P2WSH inputs with different variations of SIGHASH_ALL
**Non-witness**
Transaction weight : 3800384
@jl2012
jl2012 / OP_MASK
Last active November 23, 2018 22:10
int FindAndMask(CScript& script)
{
int masked = 0;
bool skip_next = false;
CScript result;
CScript::const_iterator pc = script.begin(), pc2 = script.begin();
opcodetype opcode;
while (script.GetOp(pc, opcode)) {
if (opcode == OP_MASK) {
int FindAndMaskPush(CScript& script)
{
int masked = 0;
bool skip_next = false;
CScript result;
CScript::const_iterator pc = script.begin(), pc2 = script.begin();
opcodetype opcode;
while (script.GetOp(pc, opcode)) {
if (skip_next) {
const int inputtype = nHashType & SIGHASH2_INPUT_MASK;
const int outputtype = nHashType & SIGHASH2_OUTPUT_MASK;
CHashWriter ss();
ss << static_cast<uint8_t>(nHashType);
// tx-level data
ss << txTo.nVersion;
if (inputtype == SIGHASH2_ALL) {