Skip to content

Instantly share code, notes, and snippets.

View prestwich's full-sized avatar
🈚

James Prestwich prestwich

🈚
View GitHub Profile
@prestwich
prestwich / monorepo.md
Last active November 25, 2022 17:15
How to break up a monorepo :)

How to break up a monorepo using git subtree:

  1. Set up some basic stuff:
    • These should be independent, not nested
$ NEW_REPO_PATH=
$ OLD_REPO_PATH=
@prestwich
prestwich / eth2.sh
Created November 15, 2022 22:58
basic Eth2 docker script
GETH_NAME=geth
GETH_IMAGE=ethereum/client-go:latest
PRYSM_NAME=prysm
PRYSM_IMAGE=gcr.io/prysmaticlabs/prysm/beacon-chain:stable
# volumes for containers
STORAGE_LOCATION=~/eth/data
GETH_STORAGE=$STORAGE_LOCATION/geth
PRYSM_STORAGE=$STORAGE_LOCATION/prysm

0x30217b1cff7c7a11cf1b36efdb4ab787e938619f88d975b1eef0bdabd1bf72da

@prestwich
prestwich / scriptsig.md
Last active September 12, 2023 20:48
But what is a scriptsig?

What is a ScriptSig anyway?

Bitcoin legacy transactions (and Zcash transparent sends) use "ScriptSigs" to prove authorization. A ScriptSig contains the user's signature andm maybe some other information. They let the protocol check that the tx came from someone allowed to spend those Bitcoin. Most users never interact with them directly, and with the advent of SegWit, they're slowly being phased out of Bitcoin. But it's still worth knowing how they work.

Basics

@prestwich
prestwich / sapling_htlc_example.py
Created February 28, 2019 22:28
Making and spending an HTLC in riemann
import riemann
from riemann import simple, utils
from riemann.encoding import addresses as addr
riemann.select_network('zcash_sapling_main')
# Needs a 32 byte hash, alice's pubkey, a timeout, and bob's pubkey
htlc_redeem_script = (
'OP_IF '
@prestwich
prestwich / Nonfungibilizer.sol
Last active February 18, 2019 19:11
Nonfungibilizer.sol
// This is an alpha contract designed to be proxied
// It is NOT production ready
contract Nonfungiblizer {
bool initDone;
address owner;
address asset;
uint256 value;
@prestwich
prestwich / abi.py
Created January 2, 2019 22:43
Ethereum ABI event parsing
# I do not recommend using pyethereum, as it is broken on windows
# I do not recommend web3.py as it sucks :)
# $ pip install eth_abi
# $ pip install pycryptodomex
import json
import eth_abi
from Cryptodome.Hash import keccak
import riemann
from riemann import networks
from riemann.script import examples
from riemann.encoding import addresses
pubkey_0 = '00' * 33
pubkey_1 = '11' * 33
msig = examples.msig_two_two
msig = msig.format(pk0=pubkey_0, pk1=pubkey_1)
from riemann.script import serialization
p2pkh_pk_script = 'OP_DUP OP_HASH160 {} OP_EQUALVERIFY OP_CHECKSIG'
script = p2pkh_script.format(pubkey_hash_hex)
stack_script = '{} {}'.format(sig_hex, pubkey_hex)
stack_script = serialization.serialize(stack_script)
import riemann
from riemann.encoding import addresses
# Switch to Litecoin
riemann.select_network('litecoin_main')
addresses.make_p2pkh_address(pubkey_bytes)
# Switch to Bitcoin Cash
riemann.select_network('bitcoin_cash_main')
addresses.make_p2pkh_address(pubkey_bytes)