Giter Club home page Giter Club logo

doichainplaygroundsvelte's Introduction

Vercel

Doichain Developer Playground Svelte

This repository serves as a reference and example for developing Doichain-connected web applications using Svelte. Doichain, a fork of Namecoin (which is itself a Bitcoin fork) created in 2018, supports merge mining with the Bitcoin blockchain.

We believe that a merge-mined blockchain, which utilizes the computational excess from Bitcoin mining to produce blocks, holds big value for storing transactions in a cost-effective and straightforward manner.

Doichain simplifies the process of storing, transferring, finding, displaying name-value pair transactions. Everytime it is doing so, it creates a non-fungible coin (NFC - just like NFTs) For example, the shell command:

doichain-cli name_doi ${name} ${value} [optional ${holder-address}]

clearly demonstrates this capability.

Consequently, Doichain makes it straightforward to store and transfer Doichain-NFTs (non-fungible-coins, somewhat similar to Bitcoin inscriptions) and various proofs of existence, positioning it as an ideal blockchain for emerging local-first, peer-to-peer applications that leverage technologies like libp2p, IPFS, and CRDTs such as OrbitDB.

This project aims to facilitate web application development for Doichain blockchain developers.

With the Doichain Playground you can:

  • create seed phrases and Doichain wallets with javascript in browser (and NodeJS)
  • make and send coin and name (Doichain-NFT & PoE) transactions via Electrumx
  • create multisig addresses and multisig transactions
  • store a non-fungible-coin (NFC) (Doichain-NFT)
  • store other PoE (Proof-Of-Existence)
  • query Doichain blockchain for balances and transactions (non-fungible-coins, Doichain-NFTs) and PoEs

Usage:

  1. Clone this repo.
  2. Optionally for local development, start local Doichaind & Electrumx using docker-compose up -d.
  3. Connect to the regtest container and:
    • Run doichain-cli help to see command help.
    • Run doichain-cli getblockchaininfo to view initial blocks.
    • Run doichain-cli getnewaddress to generate a new address.
    • Run doichain-cli getbalance to check balance.
    • Run doichain-cli generatetoaddress 1 [address] to generate a new block.
    • Run doichain-cli getblock <block hash> to see transactions.
    • Run doichain-cli gettransaction <transaction hash> to view transaction details and note the DOI amount (immature, requiring another 100 blocks to mature).
    • Run doichain-cli generatetoaddress 100 [address] to mature the first block and receive 50 DOI.
    • Run doichain-cli getbalance to see updated balance.
  4. Run npm install
  5. Run npm run dev to start the Doichain Developer Playground.
  6. Go to the "Transactions" menu to query your Doichain address
  7. Mark an unspent output (UTXO) and send it to another address
  8. Create a new block to observe the transaction.

References:

Todos:

  • add Dockerfile and docker-compose.yml with Doichain Node and ElectrumX
    • generating Electrumx self signed server certificates on startup (for secure websocket in local development)
    • adding a network dropdown (Doichain Mainnet / Doichain RegTest) to +layout.svelte
    • connecting to RegTest Electrumx (Remark: doesn't work with Chrome - using self signed certificate! Use Firefox or add exception)
    • add nginx, letsencrypt and enable wss for Electrumx for production use (testnet and mainnet)
      • install mainnet Electrumx on lower power numbers then 10000 (some hotels block higher port numbers e.g. 50002, 50004)
      • enable Electrumx peer-to-peer modus / setup seed nodes
  • upgrade DoichainD to v0.27.0
    • test p2pool mining
  • generate mnemonic
  • create xpriv and xpub from mnemonic
  • generate new (legacy) p2pkh from a derivation path
  • generate wif from a derivation path
  • generate a segwit p2wpkh
  • generate a segwit p2sh from p2wpkh
  • generate a P2WSH (SegWit), pay-to-multisig (3-of-4) addressP2pkh
  • connect to Electrumx (which connects to Doichaind) via local Docker or remote url
    • electrumx (DOI) support secure websockets
    • connection via wss
    • connect to local Electrumx (Docker compose) for developers
  • list txs of a wallet in a datatable component
    • cache txs in IndexedDB
    • default sort txs by blocktime descending
    • filter & paginator
    • display amount received (+) and sent (-)
      • display outputs (utxos) as received
      • display inputs as sent
        • find address in previous tx
      • double check addresses (received & sent)
      • two txids appear twice (change txs) in txs, keep only one but accumulate values
    • display nameId, nameValue, address
  • display wallet balance
    • of a single address
    • of a xpub and it's derivations bip32, bip44, bip49,..
  • create a simple coin (DOI) transaction
    • choose utxos from datatable
    • add an amount, address textfield
    • storing, deleting, displaying mnemonics via IndexDB
    • encryption and decryption of mnemonic via password
    • sign transaction by entering optional private key (wif)
    • sign non-witness transactions (legacy)
    • sign witness transactions (segwit)
    • calculate transaction fee by pre-signing the transaction
    • change address
      • send change back to same address
      • generate change addresses from a derivation path
    • enter fee (and substract from utxos amount to be sent)
    • sign transaction by wif (currently derived from mnemonic and wallet screen)
    • sign transaction by seed phrase (from mnemonic dropdown)
    • sign PSBT by scanning qr-code with DoiWallet (BlueWallet)
    • sign PSBT file / qr code in Electrum-DOI
    • sign by hardware wallet (and check PSBT)
  • create name_op transaction
    • add storage fee to transaction fee calculation
    • add nameId and nameValue to signing modal
    • legacy name_op transactions
    • segwit name_op transactions (untested)
    • index name_op transactions
    • show name op transactions in transaction list
    • create name_show call How is that done in electrum-nmc
    • name_first, name_update transaction
    • scan blockchain for name ops identify & categories
      • namespaces (e.g. did/ id/ d/, doi/, nfc/, libp2p/, jpg/, png/, s/)
  • scan/watch live for name ops
    • scan backwards and display name_ops and collect namespaces
    • scan transactions of current mempoool
    • store found scan results in a orbitdb writable by all
  • create Doichain-NFT (NFC non-fungible-coin) example
    • scan blockchain backwards from now if nft/ found
    • display media (png, jpg, etc.)
  • create a proof-of-existence example
    • add file upload to utxo selction toolbar
    • generate sha256 hash and greate pe/{sha256} hash with it.
  • show min-relay fee in signing modal
  • create libp2p seed node peer discovery (as an alternative for bootstrap and pub sub peer discovery)
    • add nameId/nameValue for a first seed node
    • create script to read multiaddr by nameId
  • create a command line tool to register / show names from command line (and generate a PSBT-QR-Code there to pay in DoiWallet)
  • create multisig wallet
    • support legacy wallets based on pub keys
    • store multisig configs in localstorage / index db / immortaldb with a name / create new / empty
    • support segwit and bip44 (like BlueWallet)
      • use xpub instead of normal pubkey
    • support Electrum wallets (legacy / segwit)
    • show balance of multisig address
    • store multisig config (name, description, redeem code and public keys, wallet labels, publickeys in qr-code
      • use bbqr - https://www.npmjs.com/package/bbqr
      • scan multisig config from qr code
        • scan bbqr - since normal qr codes can't take all the data
      • store config inside ipfs using ipns? (encrypted?)
        • test is local ipfs content accessible to other browsers?
        • can Helia browser nodes connect via peer-to-peer public ipfs-network?
      • share xpubs via libp2p nodes only, when using same url-name (url-name as pubsub topic)
        • show connected nodes (amount / names?)
      • show last transactions of multisig address
      • DoiWallet (aka BlueWallet) can scan a multisig PSBT and produce a signed hex to scan a bbqr?
      • repeat last transaction from multisig address
      • download multisig config as file
      • scan a publickey
        • show error if publicKey is invalid
      • scan mnemonic / try different BIPs (32/44/49/84), show balance, latest derivation and new address / publickey for multisig
  • spend from a multisig address
  • automate spending from a multisig address
  • research and test DoiWallet and Electrum-DOI seed phrases and keys
    • DoiWallet can import Electrum-DOI seeds and shows correct addresses
      • test spending from DoiWallet with Electrum seed
    • mnemonic: implement Electrum-Legacy support
      • generate change addresses (e.g. into second address colum)
    • mnemonic: implement Electrum-Segwit support
      • implement bip32 support
      • generate change addresses
    • implement bip44 support
    • implement bip49 support
    • implement bip84 support

Nice 2 have:

  • add Scanner https://github.com/peerpiper/qrcode-scanner-svelte
  • mnemonic: expandable rows shows privkey, wif, pubKey of address
  • mnemonic/transactions: use OrbitDB to store wallets, history
  • Electrumx connection: retry up to 10 times, recover connection when changing network (e.g. switching wifi / vp network)
  • transactions: amounts should toggle between DOI/schwartz (and store value in localhost default DOI)
  • transaction signing: auto-select enough utxo's from the datatable depending on the amount to send
  • transactions: indexDB cache for transaction history and its txs
  • app: deploy to IPFS
  • mnemonic: use alternatively 24-words for seed phrases
  • mnemonic: use a better entropy / random generator
  • scan QR-code modal when clicking on qr-code icon next to mnemonic, xpub, xpriv, wif,
  • transactions: add xpub support for transaction list (full wallet balance and txs)
  • transactions: show fees in datatable
  • mnemonic / transactions: show mnemonic screen selected legacy (or segwit?) address in transaction list
  • transaction signing: calculate fees depending on transaction size
  • transactions: progress bar or similar when loading many txs
  • mnemonic / transactions: choose current ElectrumX from random list
  • mnemonic: choose from different derivation path standards (electrum, bip32, bip44, bip49, ...)
  • mnemonic: test DoiWallet and ElectrumDoi seed phrases and keys
  • mnemonic: add network dropdown
    • add Bitcoin-Mainnet
  • transactions: expandable datatable rows with raw transaction details
  • transactions: display mempool transactions in transactions

Bugs

  • when generating mnemonic for Electrum it must be generated with another Electrum mnemonic generator otherwise it's not recognized as valid
  • generated mnemonic with m/84'/0'/0' show different addresses then in DoiWallet
  • better error messages and notifications
    • when changing derivation standard (e.g. with incompatible Electrum mnemonic)
    • when mnemonic could not be decrypted, loaded, saved, generated
  • if no or wrong private key, transaction fee cannot be calculated? Could it be partially signed with a public-key instead?
  • when iterating over utxos, datatable doesn't update reactively (but counters are doing so)
  • Chrome does not connect to local Electrum websocket with self signed ssl certificate - warning and fix needed
  • connecting a failing Electrumx node needs to try the next server and remove it from the current list
  • negative amounts (outflows) aren't utxos, they shouldn't be not selectable.
  • transactions: dc1qaflwqfck8tgq9uj7pq8de9zjfxekvqtkf57qv9 should show 7 transactions not just 1
  • auto selected mnemonic generates wrong address set - dropdown needs to re-select mnemonic then its corretc
  • when spending an utxo, for some reason it could be re-used (chosen by checkbox) for a new transaction and caused error when sending - re-read utxos
    • counter check with utxos coming live from Electrumx and exlude utxos not in ElectrumX
  • sending doiAmount to an address sents the fee instead of doiAmount
  • dc1qeefktgyshgm0hackjds55ry2l2936fw2uegw09 doesn't show any transactions or takes very long
  • changing network doesn't result in changing addresses in +page.svelte

doichainplaygroundsvelte's People

Contributors

silkroadnomad avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.