Dead simple offchain bitcoin transaction ledger.
localchain lets you easily create as many offchain bitcoin transaction ledgers as you want, with a simple API.
const localchain = require('localchain')
const chain = new localchain()
chain.post({
"path": "my_chain",
"payment": {
merchantData: null,
transaction: '01000000000100000000000000001f006a1c48656c6c6f20776f726c64206174203135373538343135363835373300000000',
refundTo: null,
memo: null
}
})
There is no setup involved, and there is no server running anywhere. It directly writes a BIP270 payment object to the specified path on the file system, as well as create a log data structure called tape.txt
, which lets you handle realtime events.
background
localchain was extracted out of a project called Overpool while trying to simplify and modularize the system.
Overpool is an ambitious project with a lot of features built in, including:
- Append only log of offchain transactions
- HTTP endpoint for submitting and filtering offchain transactions
- DAT based P2P replication
While trying to refactor Overpool, it became clear that all these features can be broken down into simpler modules which interoperate with one another. And localchain was born.
localchain is the core module which does only one thing and does it well: maintaining append only logs of offchain Bitcoin transactions.
highlights
Here's how localchain is different from Overpool:
- Minimal: The goal of localchain is to do one thing and do it well--the append only log for storing offchain Bitcoin transactions. There are no other features such as HTTP server or decentralized replication. These can be built on top of localchain, and the minimalism provides for easier integration into your own workflow.
- Zero setup: Unlike Overpool which requires you to "create" a log before writing to it, localchain has no such restriction. A log is automatically created when you post to it for the first time. No setup process needed.
- Designed for unlimited logs: Overpool was designed with one log in mind. localchain is designed for creating as many logs as needed.
- Global and Local event listener: In addition to listening to events from the global log, you can specifically listen to an individual log.