pinheadmz/bcoin-guide

[JOURNAL] Week 1

Opened this issue · 2 comments

  1. Why npm rebuild and not npm install?

Node modules are stored on github, not relying on npm

gpk, nodegyp - language bindings between C++ and Javascript

  1. I learned:
  • bcoin has no signet like bitcoin-core
  • regtest - no peers, only me in network, for learning and testing
  • json RPC is similar to rest api
  • Confirmed is a subset of unconfirmed and not mutually exclusive like bitcoincore
  1. Still need to explore:
  • Taproot
  • apidocs
  1. What I can do:
  • use bcoin to develop some project
  • improve bcoin by writing tests
  • bring it to pace with bitcoin core by writing features that dont exist

Bitcoin wallet practice

  1. bwallet-cli master
{
  "encrypted": false,
  "key": {
    "xprivkey": "tprv8ZgxMBicQKsPfC8gLWcHksF3v5vHJ6YYxE7VWcUoRYTH1RnyjkFhD674Kw8ZySYr6ja4DZoCTbaicvByUPhhmWcYM4ykN8HhnYSdGVXeSUu"
  },
  "mnemonic": {
    "bits": 128,
    "language": "english",
    "entropy": "d4da09aa0fd0f033682fcc685578bb14",
    "phrase": "state space hedgehog cabbage audit boost pass wet hair profit conduct cinnamon"
  }
}
  1. bwallet-cli account=default address (to Recieve)
{
  "name": "default",
  "account": 0,
  "branch": 0,
  "index": 4,
  "witness": false,
  "nested": false,
  "publicKey": "0234822ad169884d87e2e2b207b8fd4626505a21c021bc08bea93b92eb11c4d366",
  "script": null,
  "program": null,
  "type": "pubkeyhash",
  "address": "mjW2JPbEyhitki4ktBH9WdWHAuaGth1qDZ"
}
  1. bcoin-cli rpc generatetoaddress 300 mjW2JPbEyhitki4ktBH9WdWHAuaGth1qDZ

  2. bwallet-cli balance

    {
      "account": -1,
      "tx": 300,
      "coin": 300,
      "unconfirmed": 1121250000000,
      "confirmed": 1121250000000
    }
  3. bwallet-cli mkwallet --id=Raj --witness=true

{
  "network": "regtest",
  "wid": 2,
  "id": "Raj",
  "watchOnly": false,
  "accountDepth": 1,
  "token": "3e839d6b1f5cc744a9ffd9b49f2f419d390acd104817be1fb81c562ae17bac63",
  "tokenDepth": 0,
  "master": {
    "encrypted": false
  },
  "balance": {
    "tx": 0,
    "coin": 0,
    "unconfirmed": 0,
    "confirmed": 0
  }
}
  1. bwallet-cli --id=Raj --account=default address
{
  "name": "default",
  "account": 0,
  "branch": 0,
  "index": 1,
  "witness": true,
  "nested": false,
  "publicKey": "03bee7e3c9a839349a7552714e6b053ebdb08b7c325b5a9fc7741d3d76bc295c61",
  "script": null,
  "program": "0014fb21fcc014942c98b5e371635aca16eadad9e549",
  "type": "witness",
  "address": "bcrt1qlvslesq5jskf3d0rw9344jskatddne2fwh2vg8"
}
  1. bwallet-cli send bcrt1qlvslesq5jskf3d0rw9344jskatddne2fwh2vg8 30.55
    (coins from Default to Raj Wallet)
{
  "hash": "80ee633d7f54d543f4bc1e3775421afdb1c5740710f2437dbec0e91f30e31442",
  "height": -1,
  "block": null,
  "time": 0,
  "mtime": 1627191686,
  "date": "1970-01-01T00:00:00Z",
  "mdate": "2021-07-25T05:41:26Z",
  "size": 222,
  "virtualSize": 222,
  "fee": 4480,
  "rate": 20180,
  "confirmations": 0,
  "inputs": [
    {
      "value": 5000000000,
      "address": "mv9a92YbQjkSzx3Rk685Qmnu4wrMbseEn5",
      "path": {
        "name": "default",
        "account": 0,
        "change": false,
        "derivation": "m/0'/0/2"
      }
    }
  ],
  "outputs": [
    {
      "value": 1944995520,
      "address": "morANU98jkQRCgfMPyobXpmHztEEGgBuFY",
      "path": {
        "name": "default",
        "account": 0,
        "change": true,
        "derivation": "m/0'/1/0"
      }
    },
    {
      "value": 3055000000,
      "address": "bcrt1qlvslesq5jskf3d0rw9344jskatddne2fwh2vg8",
      "path": null
    }
  ],
  "tx": "01000000017fa12af76eead4a79a9f9ffbd7b3c5f035fb1ef99ef7a7696ee51b45178b0f04000000006a4730440220068be3abf29d201f401e34a36f7e4fe4a8305ed0d28ee9460bcb37a2bdbc155e0220274aef79895c705571215de5871b5e41fa12ab5b9c9e665c1ab8cd508796978b0121025f94b8d11679f227729684fb367538e900fed753a1c4b6e3a98567d391d6570dffffffff02c046ee73000000001976a9145b62fd7c521fc217302ec2e3e08452a60f21b4bd88acc09917b600000000160014fb21fcc014942c98b5e371635aca16eadad9e54900000000"
}
  1. bwallet-cli --id=Raj balance
{
  "account": -1,
  "tx": 1,
  "coin": 1,
  "unconfirmed": 3055000000,
  "confirmed": 0
}

What is a wallet token?

image

Great job, Raj thanks for posting! One thing though - you posted a mnemonic seed phrase! (In your master command). This is a regtest node so no one can steal any real money from you but even still, it's good practice to avoid that ;-)