We present the Opensource release of the Progressive Web Application HiveCash that allows managing balances in HBD in a secure, decentralized and offline way. Designed to work on both mobile and desktop devices, HiveCash combines advanced cryptography, synchronization with the Hive blockchain and a user experience aligned with the HiveCuba branding.
The 5 basic rules of its operation are:
- Receiving onchain: User: Generates a private key derived from the seed phrase and calculates its hash. And stores it in the list of generated hashes. User: Sends the hash to the Mint with the amount associated to deposit in that hash Mint: Receives the hash and the associated amount and generates a payment invoice with the amount to be received and a one-time memo and sends it to the user. It also stores the data with a status of not paid. User: Deposits using the exact details of the payment invoice and tells the Mint that you have already paid. Mint: Verifies that the payment has been made and campia the status has been paid. But it maintains the status of not paid until the payment is made. User: Verifies that the payment status associated with the hash is paid and if so, adds it to the list of private hashes that can be used.
- Send onchain: User: They choose the paid hashes until they accumulate the amount to be sent and creates a list with the private keys of each hash. It also generates a hash to store the change if the accumulated amount was higher than the one sent, telling the Mint to associate the returned one with that hash. Includes the shipping data amount, recipient and memo. Mint: Receives the list of secret keys and calculates the hashes of each one, verifies and verifies that the accumulated balance is sufficient. If yes, it makes the onchain shipment and associates the return to the hash of returned in paid or used status if there is no return. Every hash used is marked as used.
- Send offline: User: They choose the paid hashes until they accumulate the amount to be sent and creates a list with the private keys of each hash and the value of the amount to be paid. It also generates a hash to store the change if the accumulated amount was higher than the one sent, telling the Mint to associate the returned one with that hash. The information is condensed into a message encrypted with the Mint's public key. After that he shares the check with the other user he pays.
- Receive offline: User: Receives from another user the information encrypted with the mint's public key and appends to it a hash derived from its own private key so that the Mint associates the balance to be received with it. Store that information until it is verified by the Mint and if the payment hash goes to the paid status, it incorporates that hash and its private key to the list of those that can be used. Mint: Receives the list of secret keys and calculates the hashes of each one, verifies and verifies that the accumulated balance is sufficient. In the positive case, it associates the balance in paid state with the received hash and the returned one with the hash of returned in paid state or used if there is no return. Every hash used is marked as used.
- Synchronization: User: Asks the Mint the status of each hash it has generated. Update the list of hash and private leads that can be used when they are in paid status. The total balance is the sum of the amounts associated with the hashes in paid status. Mint: When the user asks for each hash, it tells him its status and associated amount. If that hash has not been registered it returns an error.
This operating scheme was recreated in an entertaining way in the post The Adventure of Honey Bee and the Magic Chests of HiveCash
These functionalities are associated with the HBD Mint API functions that you can find in https://github.com/HiveCuba-DeV/HBD-Mint, that we replicate in this post.
OpenAPI–Style: HiveCash Mint API
POST /mint/tokens
URL
POST https://cash.hivecuba.com/mint/tokens
Request Body
{
"secret_hash": "string",
"amount": 0
}
Responses
- 200 OK
json
{
"signature": "string",
"deposit_uri": "string",
"memo": "string"
}
- 4XX / 5XX Error
text
Error while generating tokens
GET /mint/check_deposit/{secretHash}
URL
GET https://cash.hivecuba.com/mint/check_deposit/{secretHash}
Path Parameter
- secretHash
(string): User-generated secret hash.
Responses
- 200 OK
json
{
"deposit_valid": true
}
- 4XX / 5XX Error
json
{
"message": "Error verifying deposit"
}
POST /mint/internal_transfer
URL
POST https://cash.hivecuba.com/mint/internal_transfer
Request Body
{
"tx": "string",
"payhash": "string"
}
Responses
- 200 OK
json
{
"status": "string",
"message": "string"
}
- 4XX / 5XX Error
json
{
"message": "Error in internal transfer"
}
POST /mint/external_transfer
URL
POST https://cash.hivecuba.com/mint/external_transfer
Request Body
{
"tx": "string"
}
Responses
- 200 OK
json
{
"status": "string",
"message": "string"
}
- 4XX / 5XX Error
json
{
"message": "Error in external transfer"
}
GET /mint/public_key
URL
GET https://cash.hivecuba.com/mint/public_key
Responses
- 200 OK
json
{
"public_key_hex": "string"
}
- 4XX / 5XX Error
json
{
"message": "Error obtaining public key"
}
GET /mint/get_sign/{secretHash}
URL
GET https://cash.hivecuba.com/mint/get_sign/{secretHash}
Path Parameter
- secretHash
(string): Secret hash for which the signature is requested.
Responses
- 200 OK
json
{
"signature": "string",
"amount": 0,
"status": "string",
"msg": "string"
}
- 4XX / 5XX Error
json
{
"message": "Error al obtener firma"
}
In a next step we will also publish the Mint-HBD implementation as an Opensource.
We recommend you to read the HiveCash launch post: HiveCash: Offline Wallet-first for HBD
The source code and installation instructions of HiveCash-PWA can be found at https://github.com/HiveCuba-DeV/HiveCash-PWA
HiveCash is still in Beta testing phase, some functions related to QR or NFC reading are unstable but you can test with small amounts its operation -> https://cash.hivecuba.com
An own domain will be used when we go to production