Skip to content

Instantly share code, notes, and snippets.

@imaginaryusername
Last active August 18, 2019 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imaginaryusername/ac1b70c40c0ef3fb356447155ce307a8 to your computer and use it in GitHub Desktop.
Save imaginaryusername/ac1b70c40c0ef3fb356447155ce307a8 to your computer and use it in GitHub Desktop.
Electron-Cash tentative SLP merge plans

im_uname 20190729

Note: Other high-prioritiy projects like Reusable Addresses and Cashfushion exist. But the following parts can be done piecemeal, and many of the parts will also help Reusable Addresses.

Will recommend the following actions in order:

Note: This roadmap does not account for multisignature wallets (yet).

Derivative path autodetection; migrate to BIP39 default

Autodetection: When creating a new wallet and using existing seed, the current UI can be put into "advanced" UI. A "Wizard" UI will go through the following paths in order, applying passwords entered as appropriate, and return success whenever a historical tx is detected either at 0'/0 (external,"receive") or 0'/1 (internal, "change")

  1. Electrum custom format (current)

  2. BIP39 BCH: m'/44'/145'/0'

  3. BIP39 : m'/44'/0'/0'

  4. Bitcoinj: m'/0'

  5. Bitcoinj-custom: m'/0'/0'

Seed and derivation path must also be recorded in the wallet file for imported BIP39 wallets, which is not currently the case.

Migrate to BIP39 default: After the autodetection work is done, there should no more friction for creating BIP39 wallets. Migrate EC to creating BIP39 m'/44'/145'/0' wallets by default.

Mandatory Labeling

Existing wallets without labels should all be labeled "Bitcoin Cash HD", "Bitcoin Cash watch only", "Bitcoin Cash Imported" and so on, with the exception of SLP wallets (automatically labeled as such if path is m'/44'/245'/0')

Backend: "Attached" wallets

While the frontend remains unchanged yet, enable "attached" wallets in the backend. Suggested action items:

Multiple wallets inside one file: When loading a wallet file, EC should look for other "wallet objects" inside the same file and load it as well, and if that exists, look for the next one and so on. At first these attached wallets can simply be loaded in the background and monitored without any indication in the UI, other than debug outputs. Note that there will be no manual attachment UI except for specific purposes (SLP, reusable addresses) to avoid UX complications. Wallets that do not share the same password (or lack of) shall not be loaded.

Alternatively, "attached" wallet does not have live inside the same file and can be external - it's important to preserve its relative independence, whereever it lives.

Merge into history UI (watch only): Disregard send/receive for the "attached" wallets, but merge their history into the main wallet's History tab. Do not touch coinchooser, Coins, Addresses yet. Cashshuffle shall shuffle from main wallet only. Continue disallowing using "SLP" labeled wallets as main wallet.

Partial "Validation"

Start by recognizing and tagging outputs with SLP OP_RETURNs, even before a full validator is merged. This can be accompanied by freezing said coins to prepare for later validation. From this point onwards, EC mainline cannot burn tokens.

Backend: Validation from EC-SLP

Port Validation backend from EC-SLP, including all token types (type 1 and NFT1). Do not touch UI yet, but turn it on and running for all wallets.

Start indicating the existence of SLP transactions, and whether they are validated or not, in History tab. Even before spawning SLP attached wallets is enabled, this can be tested by renaming existing SLP wallets to "attach" to main wallets, or simply receiving tokens into the main wallet via address translation (warning: might lose tokens before coinchooser is modified!)

Tag unspent outputs as either normal or SLP across all wallets, which can be identified from parsing transaction even before validation.

Port Coin-tagging and history UI from EC-SLP

Port "Tokens" tab from EC-SLP. SLP transactions will show up in the token tab, and can be right-click added just as in EC-SLP.

Add a collapsible column in history "Token". Validated token transactions will, in addition to BCH amounts, also show token amounts there.

Backend: Enable send and receive to attached wallets

For existing HD wallets with a seed and path without an SLP wallet attached, at next load, automatically spawn an SLP attached wallet at BIP39-m'/44'/245'/0'. If there's a collision (aka main wallet is somehow already on the 245 path), rename existing wallet to .1 and create a new main wallet on 145 path. Wallets that has no seed (xprv, xpub, old BIP39 wallets that never got re-imported, imported-key mains) will have to skip all the following functionalities. New HD wallets automatically spawn an attached SLP wallet.

Modify Coinchooser to account for all coins from all wallets, and avoid SLP-tagged coins as well as watch-only coins. More discussion is likely needed wrt handling hardware wallets.

Modify Cashshuffle to account for all BCH coins across wallets, avoiding SLP-tagged and watch-only coins. Cashshuffle still shuffles to change path on the primary wallet.

Enable Receiving tokens - port EC-SLP receiving UI. If displaying simpleledger:xxxx addresses, it should go to the receiving path of attached SLP wallets. Note that bitcoincash: and simpleledger: addresses displayed in receive tab will no longer be simple translations of each other, but come from different parts of the wallet. Maintain existing UI if no SLP attached wallet is present.

Enable Sending tokens - modify coinchooser to allow spending SLP coins only if in an SLP transaction, port EC-SLP sending UI, with Cashshuffle in mind - fee payments for token sends should adhere to the chosen "spend shuffled coins" rule as well. Token change goes to change path of the SLP wallet, while BCH change goes to change path of the main wallet. Maintain existing UI if no SLP attached wallet is present.

Coin and Address tabs

Modify the Coins and Addresses tab to account for all attached wallets. Add column indicating "token", and add one more collapsible layer on top of "Receive" and "Change" to indicate which wallet ("Main", "SLP", "Imported-1" etc etc).

Enable Cashaccount SLP registration: if a wallet has an attached SLP wallet, Type 81/82 Cashaccounts can be registered (add a checkbox in UI), making sure it's on the SLP wallet addresses.

SLP minting and burning

Enable burning in the Coins tab via right-click.

Enable minting and baton-passing transactions in the Tokens tab. Batons should get a special visual indicator in coins tab distinct from normal tokens.

Enable importing EC-SLP wallets

Finally, enable opening SLP-tagged wallets created by EC-SLP (by now, EC-SLP should indicate derivation path in wallets). If opening an EC-SLP wallet, there should be UI prompting if one wants to convert it to EC mainline; if yes, the wallet is renamed to .1, and a new main wallet is created at path 145 to accompany it.

@cculianu
Copy link

Thanks for this. It's already giving me ideas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment