Bitcoin Plugin

In this post we will describe our Kill Bill Bitcoin plugin. Our Kill Bill Coinbase plugin has been described in a previous entry and the intent here is to focus on the Bitcoin plugin itself. Its goal is twofold: It must verify each Kill Bill payment that occurred in BTC so that payments can transition from their PENDING (unconfirmed) state to SUCCESS (confirmed) state; each BTC payment in Kill Bill will have one matching transaction within the Bitcoin blockchain. The verification relies on some heuristics that are configurable, such as the depth of the blocks where the transaction occurred. It must periodically transfer the BTC to a specific merchant key. Each plugin instance currently has its own instance of a wallet; since we often run Kill Bill as a distributed service– for robustness purpose, or to address needs of scaling horizontally — that means that each node where Kill Bill runs has a different wallet, and the BTC in each wallet need to be transferred to a well known (set of) public merchant keys. The plugins are all initialized with a well known key  that they have inserted in their wallet. The public key is known to Kill Bill and this is where it sends the money to when a payment is made. The plugin listens to both Kill Bill notifications and it relies on the Simplified Payment Verification (SPV) bitcoinj library to be notified of Bitcoin transactions. The flow of operations can be summarized as follows: Each time it detects a new payment whose payment method points to a BTC plugin and whose status is set to PENDING, it keeps track of that payment in its persistent tables. It...