mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-07 14:54:15 +00:00
Matt Corallo
4908c241f7
Implement server-side and client-side payment channel protocols.
This implements micropayment payment channels in several parts: * Adds PaymentChannel[Server|Client]State state machines which handle initialization of the payment channel, keep track of basic in-memory state, and check data received from the other side, based on Mike Hearn's initial implementation. * StoredPaymentChannel[Client|Server]States manage channel timeout+broadcasting of relevant transactions at that time, keeping track of state objects which allow for channel resume, and are saved/loaded as a WalletExtension. * Adds PaymentChannel[Client|Server] which manage a connection by getting new protobufs, generating protobufs for the other side, properly stepping the associated State object and ensuring the StoredStates object is properly used to save state in the wallet. * Adds PaymentChannel[ClientConnection|ServerListener] which create TCP sockets to each other and use PaymentChannel[Client|Server] objects to create/use payment channels. The algorithm implemented is the one described at https://en.bitcoin.it/wiki/Contracts#Example_7:_Rapidly-adjusted_.28micro.29payments_to_a_pre-determined_party with a slight tweak to use looser SIGHASH flags so that the Wallet.completeTx code can work its magic by adding more inputs if it saves on fees. Thanks to Mike Hearn for the initial state machine implementations and all his contracts work and Jeremy Spilman for suggesting the protocol modification that works with non-standard nLockTime Transactions.
To get started, ensure you have the latest JDK installed, and download Maven from: http://maven.apache.org/ Then run "mvn clean package" to compile the software. You can also run "mvn site:site" to generate a website with useful information like JavaDocs. The outputs are under the target/ directory. Alternatively, just import the project using your IDE. Most good ones have Maven integration. Now try running one of the example apps: cd examples mvn exec:java -Dexec.mainClass=com.google.bitcoin.examples.PingService It will download the block chain and eventually print a Bitcoin address. If you send coins to it, you should get them back a few minutes later when a block is solved. Now you are ready to follow the tutorial: https://code.google.com/p/bitcoinj/wiki/GettingStarted
Description
Languages
Java
100%