Inspiration
We purchased a BSV conference ticket for Coingeek two years ago. After we overpaid by a small amount of BSV, the Coingeek sent us an email asking where to return my overpaid BSV. What if the merchant can decline a payment that they don't want, even before broadcasting it to the miners? Both customers and merchants will benefit greatly from it. The theme of the Hackathon is Peer-to-Peer Applications, which focuses on payment validation and decline, which is only possible with P2P payment services.
What it does
TimeKet is a SPV wallet and payment validation service combined into one. The system can be used by any service that requires scheduling, reservations, and payments. The wallet can be customized. A merchant can choose the level of risk or the waiting time for a callback according to their needs. TimeKet is the abbreviation for Time Market. Merchants can organize events and only accept valid payments from customers. The approved transaction can be used as an admission ticket to the event.
How we built it
The project consists of a server and a PWA client. The models/functions between them are similar, so we extracted the code to the library as much as possible to reduce duplication. In terms of our requirements, NX monorepo provides a seamless development experience. Throughout the project's growth, we were able to constantly refactor/relocate classes and libraries. Using Typescript, we were able to build server and client with shared code, and could utilize great Javascript libraries such as bsv. Typescript worked as a safeguard for the constant refactoring of the code.
Challenges we ran into
Synchronizing block headers was a challenge. First of all, getting the block header dump for BSV was difficult. We downloaded BTC block header dump, and re-synchronized the chain after the BCH / BSV fork, using the WhatsOnChain API. Initially, we used RxDB for all client storage, including block headers. When we synchronized the blockers with the browser, the indexedDB size was over 500MB and processing 690,000 blocks took over 20 minutes. RxDB is not suitable for storing large amounts of data that are simply key-value searches. It was decided to use Dexie only for block header DB, and store the block header as an ArrayBuffer. By doing so, we were able to reduce the size to 120MB and the processing time by 80%.
Accomplishments that we're proud of
Even though implementing the SPV flow itself was a challenging task, we managed to build a service on top of it. A merchant can only accept payments with exact amounts, at exact time, with exact data, from the exact person. A customer can use the UTXOs as if nothing happened. The service shows the unique capability of SPV payments, which was not possible before.
What we learned
We were surprised to learn that all the tools to make a SPV wallet are already there, well documented and working. The peer-to-peer applications aren't just ideal thing for miners and scaling. It has a very unique use case for users. We were thrilled to learn the capabilities of SPV wallets that only existed in theory.
What's next for TimeKet
- Better handling of user privateKey import - securely connect / recover with MoneyButton / HandCash.
- Automatic Utxo consolidation feature, when Utxo set grows too large and takes too much transaction fee.
- Extend Event participation feature. For example a customer can request an approval for an event to the organizer prior to the event start, and the organizer can receive some payment as a reservation fee.
- Provide organizer an option to
- Receive payment everytime the user scans the QR code (current behavior) or
- Receive payment only once, and decline the payment for an already-approved event. In this case a transaction can be both declined but approved. A customer can unlock the smart lock freely during the participating period.
- List up Service features (please look up
spv-lock.feature) and implement E2E test. - Implement PWA service worker notification for Spv Channel messages
- Apply Metanet for calendar event feature, so that user can modify / delete existing events and hierarchical authorization of keys
- Provide better explore view of events such as calendar month view
Links
Built With
- angular.js
- bitcoin
- bsv
- dexie
- nestjs
- nx
- rxdb
- rxjs
Log in or sign up for Devpost to join the conversation.