Code Monkey home page Code Monkey logo

multichain-client's Introduction

Golang client library for MultiChain blockchain

This library will allow you to complete a basic set of functions with a MultiChain node.

You should be able to issue, and send assets between addresses.

If you wish to contribute to flesh out the remaining API calls, please make pull requests.

Testing

To fully test this package it is neccesary to have a full hot node running at the given parameters.


  chain := flag.String("chain", "", "is the name of the chain")
  host := flag.String("host", "localhost", "is a string for the hostname")
  port := flag.String("port", "80", "is a string for the host port")
  username := flag.String("username", "multichainrpc", "is a string for the username")
  password := flag.String("password", "12345678", "is a string for the password")

  flag.Parse()

  client := multichain.NewClient(
      *chain,
      *host,
      *port,
      *username,
      *password,
  )

  obj, err := client.GetInfo()
  if err != nil {
      panic(err)
  }

  fmt.Println(obj)

Deterministic Wallets

Using the address package within this repo, you can create a deterministic keypair with WIF-encoded private-key, and Bitcoin or MultiChain encoded public address.


type KeyPair struct {
    Type string
    Index int
    Public string
    Private string
}

Here is an example of making a multichain HD wallet.

package main

import (
    "fmt"
    "gitlab.com/golangdaddy/multichain-client/address"
    "gitlab.com/golangdaddy/multichain-client/params"
)

const (
    CONST_BCRYPT_DIFF = 10
)

func main() {

    // you need to refer to your params.dat file to get the needed config parameters
    cfg, err := params.Open("./multichain-cold/params.dat")
    if err != nil {
        panic(err)
    }

    // The address package handles the encoding of keys, so it needs to be configued.
    address.Configure(&address.Config{
        PrivateKeyVersion: cfg.String("private-key-version"),
        AddressPubkeyhashVersion: cfg.String("address-pubkeyhash-version"),
        AddressChecksumValue: cfg.String("address-checksum-value"),
    })

    seed := []byte("seed")
    keyChildIndex := 0

    // create a new wallet
    keyPair, err := address.MultiChainWallet(seed, CONST_BCRYPT_DIFF, keyChildIndex)
    if err != nil {
        panic(err)
    }

    fmt.Println(keyPair)
}

If you have an existing private key, you can export it as WIF (Wallet Import Format) which can be used with importprivkey API command with MultiChain.


    wif, err := address.MultiChainWIF(privKeyBytes)

...or it's MultiChain address from the public key with the MultiChainAddress function.


    addr, err := address.MultiChainAddress(pubKeyBytes)

multichain-client's People

Contributors

chainetix avatar flibustier avatar golangdaddy avatar gopherdose avatar medeirosfalante avatar nilskuhn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

multichain-client's Issues

Actual state?

Hi there,
I would like to know about the actual state of this project.
I am developing a go application at the moment (for some weeks at least), accessing MultiChain and I will need some of the functionalities, this lib provides.
But I would like to improve and extend some things. Obviously there isn't to much going on here since 2018. Does it make sense to work together on this repo or should I go with a fork?
Thanks for an answer, regards,
Nils

This is not getable

Hi,

first thank you for this. It is great not to start from scratch accessing mc nodes!

Unfortunately when I try to go get this client, to use it in a module based application, I am getting the following errors because of some referenced private gitlab repositories (see below).

I am using go version 1.14:

$ go version
go version go1.14.2 linux/amd64

Any hints on how to handle this?

Thanks in advance, Nils

$ go get github.com/golangdaddy/multichain-client
go: downloading github.com/golangdaddy/multichain-client v0.0.0-20190819002216-6386f7ee525f
go: github.com/golangdaddy/multichain-client upgrade => v0.0.0-20190819002216-6386f7ee525f
go: finding module for package gitlab.com/TheDarkula/jsonrouter/http
go: finding module for package gitlab.com/chainetix-groups/chains/multichain/omega/codebase/libraries/models/network
go: downloading gitlab.com/TheDarkula/jsonrouter v0.0.0-20200219172133-1676a5eaa269
go: found gitlab.com/TheDarkula/jsonrouter/http in gitlab.com/TheDarkula/jsonrouter v0.0.0-20200219172133-1676a5eaa269
go: finding module for package gitlab.com/chainetix-groups/chains/multichain/omega/codebase/libraries/models/network
go: downloading github.com/golangdaddy/go.uuid v2.0.0+incompatible
go: downloading cloud.google.com/go v0.44.3
go: downloading cloud.google.com/go/logging v1.0.0
go: downloading google.golang.org/genproto v0.0.0-20190817000702-55e96fffbd48
go: downloading google.golang.org/api v0.8.0
go: downloading google.golang.org/grpc v1.23.0
go: downloading github.com/googleapis/gax-go/v2 v2.0.5
go: downloading golang.org/x/sync v0.0.0-20190423024810-112230192c58
go: downloading google.golang.org/appengine v1.6.1
go: downloading go.opencensus.io v0.22.0
go: downloading github.com/hashicorp/golang-lru v0.5.3
go: finding module for package gitlab.com/chainetix-groups/chains/multichain/omega/codebase/libraries/models/network
go: finding module for package gitlab.com/chainetix-groups/chains/multichain/omega/codebase/libraries/models/network
/home/nkuhn/go/pkg/mod/github.com/golangdaddy/[email protected]/api_createkeypair.go:4:2: module gitlab.com/chainetix-groups/chains/multichain/omega/codebase/libraries/models/network: git ls-remote -q origin in /home/nkuhn/go/pkg/mod/cache/vcs/5994a3cd96d2f769f2239e47efacf56fdc29aff7e7fea1ca33a5ae25fbc4aa3c: exit status 128:
        fatal: could not read Username for 'https://gitlab.com/chainetix-groups/chains.git': terminal prompts disabled
Confirm the import path was entered correctly.
If this is a private repository, see https://golang.org/doc/faq#git_https for additional information.

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.