Skip to content

Instantly share code, notes, and snippets.

Avatar

Adam Gibson AdamISZ

View GitHub Profile
@AdamISZ
AdamISZ / S5.md
Created Apr 27, 2019
Multiparty symmetrical Schnorrr scriptless script swap (SSSSS)
View S5.md

General idea; generalise the Schnorr scriptless script atomic swap of A Poelstra to multiple parties.

We consider 3-party case with trivial generalisation. Parties are Alice, Bob, Charlie, A, B, C. Payment destinations are D_x. Transactions are TX_x. Adaptor signature secrets are t_x (scalar), T_x (point). Signatures are "sigma", adaptor signatures will be marked with '.

(

@AdamISZ
AdamISZ / recover-old-wallet.py
Created Apr 16, 2019
Tool to get keys from pre-2017 Joinmarket (no segwit or BIP39) if Bitcoin Core is not available.
View recover-old-wallet.py
from __future__ import (absolute_import, division,
print_function, unicode_literals)
from builtins import * # noqa: F401
import os
from optparse import OptionParser
from jmbase import jmprint
from jmclient import load_program_config, open_test_wallet_maybe
def get_wallet_path(file_name, wallet_dir):
# TODO: move default wallet path to ~/.joinmarket
@AdamISZ
AdamISZ / compressed-tx-txfer.md
Last active Mar 6, 2019
Compressed tx transfer
View compressed-tx-txfer.md

Looking for optimally minimal data transfer to send a transaction.

Just throwing this out there; I'm sure we can do better.

Some stuff should be pre-agreed by anyone following this protocol. For example:

  • Preagreed: script type (say legacy P2PKH)
  • Preagreed: version 1, locktime 0, sequence maxint-1, fee 10K sats (tweak this later)

Receiver has address AR, requests X sats.

@AdamISZ
AdamISZ / P2EP-for-JM.md
Created Dec 27, 2018
Basic payjoin/p2ep protocol for Joinmarket wallets
View P2EP-for-JM.md

Described here is a variant of what has previously been published under the name "P2EP" or Pay-to-endpoint, in which A pays B but B contributes utxos, i.e. it's a coinjoin-payment.

I'm using the term "payjoin" here to refer to using that idea, but not including a URI/endpoint specific to B, and not allowing (as a merchant would) arbitrary payments, which opens up certain problems around snooping attackers (more on this below). So payjoin just means "A pays B but B actively participates and passes across utxos as extra inputs".

I'll defer a more features-focused and non-tech friendly description of what this means to a later blogpost.

@AdamISZ
AdamISZ / derivatives_and_manipulation.md
Created Aug 27, 2018
Derivatives and manipulation?
View derivatives_and_manipulation.md

So, why the current narrative around ETFs, futures and similar is wrong, I believe:

Start with the idea of Darwinian natural selection. People say "evolution is a theory, it isn't proven", now you may think they're stupid because the theory is proven, but the error is much more fundamental: natural selection is not really a theory at all. It's an inevitable logical consequence of a simple set of conditions: basically, reproduction through encoding along with random variation. Natural selection has to happen in this case.

There is a similar story around the famous "Efficient Market Hypothesis". People love to say that this theory is wrong, in fact I get the impression many think they're very smart for realizing that this is

@AdamISZ
AdamISZ / test-coinjoin.go
Created Aug 4, 2018
Elementary test of co-signing/coinjoin in lnd
View test-coinjoin.go
// This tests a simple 2 party of coinjoin by first funding a utxo
// for both of Bob and Alice, and then spending both into one
// transaction. The purpose is to test construction and broadcast,
// not sophisticated validation.
func testCospend(r *rpctest.Harness,
alice, bob *lnwallet.LightningWallet, t *testing.T) {
// Start building the coinjoin transaction; we'll append
// inputs and outputs as we build
tx1 := wire.NewMsgTx(2)
@AdamISZ
AdamISZ / Hybrid-swap-min-interac.md
Last active Jun 30, 2018
Hybrid swap design, minimising interactivity
View Hybrid-swap-min-interac.md

Alice has 1 Alice-coin UA on Alice-chain. Bob has 1 BTC UB on Bitcoin. X-rate = 1/1. M() is multisig.

  1. CONNECT
  2. Negotiate keys: A1,A2, A3, B1. Create M(2,2,A1,B1). Alice create txid from UA to M(2,2,A1,B1), give to Bob. Bob pre-sign backout to A2 with nlocktime L1.
  3. Alice gives key A3 as ephem key for BTC side of swap.
  4. A and B do C&C ending with Bob receiving H(k) and E_k(sig on M(2,2,A1,B1)->B2_m) for m distinct cases, and note Alice doesn't know the B2 keys.
  5. DISCONNECT

(everything else does not require communication)

@AdamISZ
AdamISZ / lnhstest.py
Created Jan 15, 2018
Simple BOLT 8 Lightning handshake in Python3
View lnhstest.py
#!/usr/bin/env python
"""
This script implements a handshake with a remote Lightning
Network node; see BOLT8:
https://github.com/lightningnetwork/lightning-rfc/blob/master/08-transport.md
, which is the Noise-based transport protocol
for Lightning network nodes.
Specify server, port and remote node pubkey as three command line arguments;
here's an example invocation:
@AdamISZ
AdamISZ / electrumx-regtest-setup-notes.txt
Created Dec 25, 2017
Electrum X regtest setup (very rough notes)
View electrumx-regtest-setup-notes.txt
pre-requisite: a Bitcoin Core instance, set up regtest and start running it.
Before starting run, set up a bitcoin conf in say ~/bitcoin.conf and put:
rpcuser=user
rpcpassword=password
txindex=1
Then, ./bitcoind -regtest -daemon -conf=/home/username/bitcoin.conf
or whatever. Make sure to generate some blocks.
View try-single-acp.py
#!/usr/bin/env python2
from __future__ import print_function
"""Simple illustration of 2 stage process:
1. Prepare a single (input, output) pair from some wallet
you have, and sign it with SIGHASH_SINGLE|SIGHASH_ANYONECANPAY
(the idea is that a utxo splitter service can do this for a client)
2. Take that partial transaction (serialized), and by feeding in
data from an input file gathered from Electrum GUI, add another
input and output (only one input here, should be OK to increase to more inputs),