The OPTN Badger Mobile rewrite flipstarter campaign is almost halfway through to our end date. We at Bitcoin Bay want to give a quick update on what has been happening in terms of the development efforts and the rewrite process, specifically on how we are approaching balances and utxos.
Please find out flipstarter campaign page at http://flipstarter.optn.tech/ or https://flipstarters.bitcoincash.network/#/active
Recap
To start, let us review the current Badger Mobile implementation with the use of BitDB queries. The BitDB query parameters are used not only for tracing SLP transactions / balances, but also used for fetching regular BCH balances. And while using BitDB to fetch BCH balances may not sound like a bad idea, we have to note that it is only used when calling the updateTransactions
action.
Additionally, the BitDB queries not set up to support SLP NFT token types, nor the ability to track and use the SLP MINT utxos. Here, we seek an alternative to the BitDB query results and related functions that would support all the SLP transaction types while simplifying the balances and UTXOs.
BCH-JS
The OPTN rewrite is heavily utilizing the BCH-JS SDK and APIs provided by Fullstack.cash. Having been forked from Bitbox-SDK, the two libraries share many of the same function calls, with only a few new BCH-js functions and minor differences in output results with the legacy ones. One of UTXO calls we find very useful is bchjs.utxo.get()
https://bchjs.fullstack.cash/#api-UTXO-get
As seen above, this api call sorts all relevant address UTXOs into separate categories (regular BCH UTXOs, SLP Type1 / NFT UTXOs, and null UTXOs that did not pass SLP validation). Even more convenient is that the different UTXO types use the same interface when outputting the results. We only need to call this one api to fetch the UTXOs and easily store them into our UTXO reducers.
Balances
The current Badger Mobile wallet handles address balances by calculating the amounts from the BitDB results for BCH and SLP balances. We have split this up into two separate calls, bchjs.Electrumx.balance()
and bchjs.SLP.Utils.balancesForAddress()
. Both of these calls support arrays of addresses, meaning we would have the same number of calls as the BitDB queries. This avoids having to recalculate and categorize the BCH and SLP balances every time, which occurs very often from the HomePage screen. Additionally, we have created a new reducer to maintain balance states. Note that the format is very similar to the current wallet as we want to reuse as much of the existing code as possible without compromising quality.
https://github.com/BitcoinBay/rewriteOptn/blob/develop/src/data/balances/reducer.ts#L11
Final Thoughts
This is the first of Bitcoin Bay's updates on the OPTN Badger Mobile wallet rewrite. We like to thank @dagur for fixing the OPTN flipstarter URL on https://flipstarters.bitcoincash.network/. Also, we want to thank everyone who has reached out to us regarding collaboration. We are open to everyone who wants to collaborate with us in our efforts to rewrite the Badger Mobile wallet, including new features that were not listed in the originally proposed roadmap (i.e. gRPC support). We have kept the MIT license specifically for this reason.
Lastly, we want to share that Bitcoin Bay is organizing another BlockHack Global hackathon this November as a followup our Spring Edition in May of this year. We have a different organizing team than last year, and are working with a few new faces for the BlockHack this coming fall. Please check out our previous BlockHack and all the submitted projects in the link below.
https://blockhack-2021.devpost.com/project-gallery
Please visit our Meetup.com page to get more regular updates and content - https://www.meetup.com/The-Bitcoin-Bay/