Giter VIP home page Giter VIP logo

bitshares's Introduction

bitshares

A Bitshares API consuming a websocket connection to an active full node. If you need wallet features, specify an optional RPC connection to your local cli_wallet. Look for several examples in tests. This is work in progress and may have breaking changes. No additional cgo dependencies for transaction signing required. Use it at your own risk.

install

go get -u github.com/denkhaus/bitshares

Install dev-dependencies with

make init

This API uses ffjson. If you change this code you have to regenerate the required static MarshalJSON and UnmarshalJSON functions for all API-structures with

make generate

testing

To test this stuff I use a combined Docker based MainNet/TestNet wallet, you can find here. Operations testing uses generated real blockchain sample code by gen package. To test run:

make test_operations
make test_api

or a long running block (deserialize/serialize/compare) range test.

make test_blocks

code

rpcApiUrl    := "http://localhost:8095" 
wsFullApiUrl := "wss://bitshares.openledger.info/ws"

//Note: The RPC endpoint is optional. If you do not need wallet functions
//pass an empty string as second parameter.

api := api.New(wsFullApiUrl, rpcApiUrl)
if err := api.Connect(); err != nil {
	log.Fatal(err)
}

api.OnError(func(err error) {
	log.Fatal(err)
})

UserID   := types.NewGrapheneID("1.2.253") 
AssetBTS := types.NewGrapheneID("1.3.0") 

res, api.GetAccountBalances(UserID, AssetBTS)
if err != nil {
	log.Fatal(err)
}

log.Printf("balances: %v", res)

For a long application lifecycle, you can use an API instance with latency tester that connects to the most reliable node. Note: Because the tester takes time to unleash its magic, use the above-mentioned constructor for quick in and out.

rpcApiUrl    := "http://localhost:8095" 
wsFullApiUrl := "wss://bitshares.openledger.info/ws"

//Note: The RPC endpoint is optional. If you do not need wallet functions
//pass an empty string as second parameter.

//wsFullApiUrl serves as "quick startup" fallback endpoint here, until the latency tester provides the first results.
api, err := api.NewWithAutoEndpoint(wsFullApiUrl, rpcApiUrl)
if err != nil {
	log.Fatal(err)
}

if err := api.Connect(); err != nil {
	log.Fatal(err)
}

api.OnError(func(err error) {
	log.Fatal(err)
})

...

implemented and tested (serialize/unserialize) operations

  • OperationTypeTransfer OperationType
  • OperationTypeLimitOrderCreate
  • OperationTypeLimitOrderCancel
  • OperationTypeCallOrderUpdate
  • OperationTypeFillOrder (test failing)
  • OperationTypeAccountCreate
  • OperationTypeAccountUpdate
  • OperationTypeAccountWhitelist
  • OperationTypeAccountUpgrade
  • OperationTypeAccountTransfer
  • OperationTypeAssetCreate
  • OperationTypeAssetUpdate
  • OperationTypeAssetUpdateBitasset
  • OperationTypeAssetUpdateFeedProducers
  • OperationTypeAssetIssue
  • OperationTypeAssetReserve
  • OperationTypeAssetFundFeePool
  • OperationTypeAssetSettle
  • OperationTypeAssetGlobalSettle
  • OperationTypeAssetPublishFeed
  • OperationTypeWitnessCreate
  • OperationTypeWitnessUpdate
  • OperationTypeProposalCreate
  • OperationTypeProposalUpdate
  • OperationTypeProposalDelete
  • OperationTypeWithdrawPermissionCreate
  • OperationTypeWithdrawPermissionUpdate
  • OperationTypeWithdrawPermissionClaim
  • OperationTypeWithdrawPermissionDelete
  • OperationTypeCommitteeMemberCreate
  • OperationTypeCommitteeMemberUpdate
  • OperationTypeCommitteeMemberUpdateGlobalParameters
  • OperationTypeVestingBalanceCreate
  • OperationTypeVestingBalanceWithdraw
  • OperationTypeWorkerCreate
  • OperationTypeCustom
  • OperationTypeAssert
  • OperationTypeBalanceClaim
  • OperationTypeOverrideTransfer
  • OperationTypeTransferToBlind
  • OperationTypeBlindTransfer
  • OperationTypeTransferFromBlind
  • OperationTypeAssetSettleCancel
  • OperationTypeAssetClaimFees
  • OperationTypeFBADistribute
  • OperationTypeBidColatteral
  • OperationTypeExecuteBid

todo

  • add missing operations
  • add convenience functions

Have fun and feel free to contribute needed operations and tests.

bitshares's People

Contributors

denkhaus avatar liandeliang 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.