Skip to content

Instantly share code, notes, and snippets.

@schildbach
Last active May 14, 2016 12:17
Show Gist options
  • Save schildbach/a1c0c05e205baa229077 to your computer and use it in GitHub Desktop.
Save schildbach/a1c0c05e205baa229077 to your computer and use it in GitHub Desktop.
Currently the bitcoinj wallet API vends transaction objects and consequently wallet apps show their payment history as a list of transactions. This is not ideal in lots of cases. For example, a refund will appear disconnected from the original payment.
Here is a proposal for how to aggregate transactions (and more) into payments. Note payments are mutable, because they will collect data as time passes.
A payment consists of:
- Payment request. This can be either a BIP70 payment request or a BIP21 (URI) payment request. For payments that are sender initiated this part is missing (a payment will be more or less just a wrapper around a single transaction in this case).
- Transactions. We're interested in those which pay towards the payment request or refund money already paid.
- Confidences of these transactions.
- User notes
After enough time has passed, we will want to squeeze payments into a flat structure for archival purposes, e.g. log-structured. This will get rid of some bulky data, e.g. X509 signatures. For the remaining data, the API should try to make this transition seamless.
Here are some questions that want to be answered on payments, in addition to what we can do on transactions and payment requests already:
- Has the payment request been settled? Is it underpaid/overpaid?
- For the sender: have other parties already paid towards the request, e.g. in a restaurant when splitting a bill.
Special consideration has to be taken for blockchain reset+replay. Currently, any transaction metadata that cannot be derived from the blockchain is lost. The purpose of the Payment object is to keep this data.
Out of scope for now:
- Recurring payments. Wether or not e.g. a monthly payment for a lease will go into the same payment is undecided, probably not.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment