Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: jgarzik on October 12, 2012, 07:21:05 PM



Title: Bitcoin cookbook
Post by: jgarzik on October 12, 2012, 07:21:05 PM
This thread was created as a meta-thread, intended to help collect various bitcoin "recipes."  What is recipe?  It is a concrete example with step-by-step instructions, understandable to programmers, that describes how to execute a specific type of bitcoin-enabled transaction.

Everyone understands the simple, popular send-bitcoins-to-pubkey transaction, but bitcoin offers so much more.  This cookbook, it is hoped, will showcase some of the less common, advanced uses of bitcoin.

If you would like to contribute a recipe, please start your own thread, and then post a link in this thread.  The OP will be updated as needed.  It would be great if these recipes were copied to / linked in the wiki, but since discussion facilities on the forum are better, this seemed like a better home for the cookbook.

Another goal is to eventually have a set of scripts which demonstrate these features.


Recipe:  2-of-2 escrow, using multisig

Link: https://people.xiph.org/~greg/escrowexample.txt

Bob wants to pay Alice 50tnbtc but prevent Alice from cheating him.  A good example of using multisig from start to finish.


Recipe: Trading between two bitcoin-like chains

Link: https://en.bitcoin.it/wiki/Contracts#Example_5:_Trading_across_chains

Currencies that implement the same ideas as Bitcoin can be traded freely against each other without trust.


Recipe:  Atomic Coin Swapping

Link: https://bitcointalk.org/index.php?topic=112007.0

Two parties negotiate to swap bitcoins between themselves.   This is presented in the context of atomically exchanging payment for smartcoins (colored coins), but is not limited to that use case.  P2P mixing was another example use case someone suggested.