bytom

module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2017 License: AGPL-3.0

README

Bytom

AGPL v3

Table of Contents

What is Bytom?

Bytom is software designed to operate and connect to highly scalable blockchain networks confirming to the Bytom Blockchain Protocol, which allows partipicants to define, issue and transfer digitial assets on a multi-asset shared ledger. Please refer to the White Paper for more details.

In the current state bytom is able to:

  • Issue assets
  • Manage account as well as asset

Build from source

Requirements
  • Go version 1.8 or higher, with $GOPATH set to your preferred directory
Installation

Ensure Go with the supported version is installed properly:

$ go version
$ go env GOROOT GOPATH
Get the source code
$ git clone https://github.com/Bytom/bytom $GOPATH/src/github.com/bytom
Build
  • Bytom
$ cd $GOPATH/src/github.com/bytom
$ make install
$ cd ./cmd/bytom
$ go build
  • Bytomcli
$ cd $GOPATH/src/github.com/bytom/cmd/bytomcli
$ go build

Example

Currently, bytom is still in active development and a ton of work needs to be done, but we also provide the following content for these eager to do something with bytom.

Set up a wallet and manage the key

You can create an account via create-key password, which will generate a keystore directory containing the keys under the project directory.

$ ./bytomcli create-key account_name password   # Create an account named account_name using password
$ ./bytomcli delete-key password pubkey         # Delete account pubkey
$ ./bytomcli reset-password oldpassword newpassword pubkey  # Update password
Create and launch a single node

When successfully building the project, the bytom and bytomcli binary should be present in cmd/bytom/bytom and cmd/bytomcli/bytomcli, respectively. The next step is to initialize the node:

$ cd ./cmd/bytom
$ ./bytom init --home ./.bytom

After that, you'll see .bytom generated in current directory, then launch the single node:

$ ./bytom node --home ./.bytom
Asset issuance test

Given the bytom node is running, the general workflow is as follows:

  • create an account
  • create an asset
  • create/sign/submit a transaction to transfer an asset
  • query the assets on-chain

Create an account named alice:

$ ./bytomcli create-account alice
xprv:<alice_account_private_key>
responses:{acc04K9MCFBG0A04 alice [0xc4200966e0] 1 0xc4204be220}
account id:<alice_account_id>

Create an asset named gold:

$ ./bytomcli create-asset gold
xprv:<gold_asset_private_key>
xpub:[98 55 100 48 102 100 53 101 54 55 55 49 48 52 97 100 50 100 51 51 98 49 56 98 98 100 55 55 50 51 98 53 102 51 101 97 56 55 49 52 48 53 57 54 50 56 55 48 49 97 50 99 97 100 101 51 51 102 100 100 97 53 56 51 49 54 97 50 57 54 101 49 102 100 48 102 53 57 99 55 50 49 53 98 50 54 55 102 50 52 102 52 54 50 48 101 51 48 102 55 99 51 50 56 49 102 97 52 99 55 97 53 102 50 57 97 100 53 51 100 56 100 55 56 50 50 98 98]
responses:[{{4131000809721133708 15036469059929217352 9712753415038655527 16992088508821480533} gold [118 107 170 32 152 106 231 249 212 15 215 121 94 191 102 23 231 61 38 211 121 176 221 199 48 173 145 207 243 201 82 0 215 2 72 243 81 81 173 105 108 0 192] [0xc420020850] 1 0xc4204c1960 0xc4204c1980 true}]
asset id:<gold_asset_id>

Now we can transafer 10000 gold to alice using a single command sub-create-issue-tx:

$ ./bytomcli sub-create-issue-tx <alice_account_id> <gold_asset_id> <asset_private_key> <gold_asset_amount>
To build transaction:
-----------tpl:{version:1 serialized_size:314 result_ids:<71c3b949750c887e466422007cdd1a6a9f3449e3bacd43307e361e84d76fe37b> data:<130994550772:/* unknown wire type 7 */ 1642:/* unknown wire type 7 */ 10:17681930801800169409 159728:7652 9:4897805654558278394 9:/* unexpected EOF */ >min_time_ms:1506587706078 max_time_ms:1506588006078  [0xc4204c9060 0xc4204c91e0] true false}
----------tpl transaction:version:1 serialized_size:314 result_ids:<71c3b949750c887e466422007cdd1a6a9f3449e3bacd43307e361e84d76fe37b> data:<130994550772:/* unknown wire type 7 */ 1642:/* unknown wire type 7 */ 10:17681930801800169409 159728:7652 9:4897805654558278394 9:/* unexpected EOF */ >min_time_ms:1506587706078 max_time_ms:1506588006078 
----------btm inputs:&{1 [123 125] asset_id:</* proto: integer overflow */ >amount:1470000000000000000  [] []}
----------issue inputs:&{1 [] 0xc4204c4120 [] []}
xprv_asset:a89d5d5fa68af8ca8408d405db180bc5b2652d7f34bca753531861be3c1cbb6216a296e1fd0f59c7215b267f24f4620e30f7c3281fa4c7a5f29ad53d8d7822bb
sign tpl:{version:1 serialized_size:314 result_ids:<71c3b949750c887e466422007cdd1a6a9f3449e3bacd43307e361e84d76fe37b> data:<130994550772:/* unknown wire type 7 */ 1642:/* unknown wire type 7 */ 10:17681930801800169409 159728:7652 9:4897805654558278394 9:/* unexpected EOF */ >min_time_ms:1506587706078 max_time_ms:1506588006078  [0xc4204c9060 0xc4204c91e0] true false}
sign tpl's SigningInstructions:&{0 [0xc420010670]}
SigningInstructions's SignatureWitnesses:&{0 [] [32 254 83 225 251 124 27 13 126 32 0 93 132 151 197 166 125 64 222 168 154 133 219 122 187 130 169 176 160 166 8 49 145 174 135] []}
submit transaction:[map[id:cc4313fbae424bb945029adef193154f34de324316036e510bcc751d0013ccb7]]

Query the assets on-chain:

$ ./bytomcli list-balances
0 ----- map[<gold_asset_id>:<gold_asset_amount>]
Multiple node

Get the submodule depenency for the two-node test:

$ git submodule update --init --recursive

Create the first node bytom0 and second node bytom1:

$ cd cmd/bytom/2node-test
$ ./test.sh bytom0  # Start the first node
$ ./test.sh bytom1  # Start the second node

Then we have two nodes:

$ curl -X POST --data '{"jsonrpc":"2.0", "method": "net_info", "params":[], "id":"67"}' http://127.0.0.1:46657

If everything goes well, we'll see the following response:

{
  "jsonrpc": "2.0",
  "id": "67",
  "result": {
    "listening": true,
    "listeners": [
      "Listener(@192.168.199.178:3332)"
    ],
    "peers": [
      {
        "node_info": {
          "pub_key": "03571A5CE8B35E95E2357DB2823E9EB76EB42D5CCC5F8E68315388832878C011",
          "moniker": "anonymous",
          "network": "chain0",
          "remote_addr": "127.0.0.1:51058",
          "listen_addr": "192.168.199.178:3333",
          "version": "0.1.0",
          "other": [
            "wire_version=0.6.2",
            "p2p_version=0.5.0",
            "rpc_addr=tcp://0.0.0.0:46658"
          ]
        },
......

Contributing

Thank you for considering to help out with the source code! Any contributions are highly appreciated, and we are grateful for even the smallest of fixes!

If you run into an issue, feel free to file one in this repository. We are glad to help!

License

AGPL v3

Directories

Path Synopsis
MemStore is a Store implementation that keeps all blockchain state in memory.
MemStore is a Store implementation that keeps all blockchain state in memory.
accesstoken
Package accesstoken provides storage and validation of Chain Core credentials.
Package accesstoken provides storage and validation of Chain Core credentials.
account
Package account stores and tracks accounts within a Chain Core.
Package account stores and tracks accounts within a Chain Core.
query
Package query implements indexing and querying of annotated blockchain data.
Package query implements indexing and querying of annotated blockchain data.
query/filter
Package filter parses and evaluates Chain filter expressions.
Package filter parses and evaluates Chain filter expressions.
rpc
Package rpc implements Chain Core's RPC client.
Package rpc implements Chain Core's RPC client.
signers
Package signers associates signers and their corresponding keys.
Package signers associates signers and their corresponding keys.
txbuilder
Package txbuilder builds a Chain Protocol transaction from a list of actions.
Package txbuilder builds a Chain Protocol transaction from a list of actions.
txdb
Package txdb provides storage for Chain Protocol blockchain data structures.
Package txdb provides storage for Chain Protocol blockchain data structures.
txdb/internal/storage
Package storage is a generated protocol buffer package.
Package storage is a generated protocol buffer package.
cmd
Package bech32 reference implementation for Bech32 and segwit addresses.
Package bech32 reference implementation for Bech32 and segwit addresses.
ed25519
Package ed25519 implements the Ed25519 signature algorithm.
Package ed25519 implements the Ed25519 signature algorithm.
sha3pool
Package sha3pool is a freelist for SHA3-256 hash objects.
Package sha3pool is a freelist for SHA3-256 hash objects.
encoding
base32
Package base32 implements base32 encoding as specified by RFC 4648.
Package base32 implements base32 encoding as specified by RFC 4648.
blockchain
Package blockchain provides the tools for encoding data primitives in blockchain structures
Package blockchain provides the tools for encoding data primitives in blockchain structures
bufpool
Package bufpool is a freelist for bytes.Buffer objects.
Package bufpool is a freelist for bytes.Buffer objects.
Package env provides a convenient way to convert environment variables into Go data.
Package env provides a convenient way to convert environment variables into Go data.
Package errors implements a basic error wrapping pattern, so that errors can be annotated with additional information without losing the original error.
Package errors implements a basic error wrapping pattern, so that errors can be annotated with additional information without losing the original error.
generated
lib
log
Package log implements a standard convention for structured logging.
Package log implements a standard convention for structured logging.
rotation
Package rotation writes and rotates log files.
Package rotation writes and rotates log files.
splunk
Package splunk sends log data to a splunk server.
Package splunk sends log data to a splunk server.
math
checked
Package checked implements basic arithmetic operations with underflow and overflow checks.
Package checked implements basic arithmetic operations with underflow and overflow checks.
Package metrics provides convenient facilities to record on-line high-level performance metrics.
Package metrics provides convenient facilities to record on-line high-level performance metrics.
net
http/httperror
Package httperror defines the format for HTTP error responses from Chain services.
Package httperror defines the format for HTTP error responses from Chain services.
http/httpjson
Package httpjson creates HTTP handlers to map request and response formats onto Go function signatures.
Package httpjson creates HTTP handlers to map request and response formats onto Go function signatures.
http/reqid
Package reqid creates request IDs and stores them in Contexts.
Package reqid creates request IDs and stores them in Contexts.
http/static
Package static provides a handler for serving static assets from an in-memory map.
Package static provides a handler for serving static assets from an in-memory map.
p2p
Uses nacl's secret_box to encrypt a net.Conn.
Uses nacl's secret_box to encrypt a net.Conn.
upnp
Taken from taipei-torrent Just enough UPnP to be able to forward ports
Taken from taipei-torrent Just enough UPnP to be able to forward ports
bc
Package bc is a generated protocol buffer package.
Package bc is a generated protocol buffer package.
bc/bctest
Package bctest provides utilities for constructing blockchain data structures.
Package bctest provides utilities for constructing blockchain data structures.
patricia
Package patricia computes the Merkle Patricia Tree Hash of a set of bit strings, as described in the Chain Protocol spec.
Package patricia computes the Merkle Patricia Tree Hash of a set of bit strings, as described in the Chain Protocol spec.
prottest
Package prottest provides utilities for Chain Protocol testing.
Package prottest provides utilities for Chain Protocol testing.
prottest/memstore
MemStore is a Store implementation that keeps all blockchain state in memory.
MemStore is a Store implementation that keeps all blockchain state in memory.
vm
rpc
client
package client provides a general purpose interface (Client) for connecting to a tendermint node, as well as higher-level functionality.
package client provides a general purpose interface (Client) for connecting to a tendermint node, as well as higher-level functionality.
client/mock
package mock returns a Client implementation that accepts various (mock) implementations of the various methods.
package mock returns a Client implementation that accepts various (mock) implementations of the various methods.
grpc
Package core_grpc is a generated protocol buffer package.
Package core_grpc is a generated protocol buffer package.
lib
lib/server
Commons for HTTP handling
Commons for HTTP handling

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL