All Projects → denkhaus → go-bitshares

denkhaus / go-bitshares

Licence: MIT license
API for Bitshares - supports websocket RPC & Wallet functions

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to go-bitshares

DEXBot
Trading Bot for the BitShares Decentralized Exchange
Stars: ✭ 232 (+954.55%)
Mutual labels:  bitshares
docs.bitshares.org
Please check the new repository https://github.com/bitshares/how.bitshares.works. This repository contains the OLD sources (and the build in a different branch) for docs.bitshares.org
Stars: ✭ 18 (-18.18%)
Mutual labels:  bitshares
bitshares-go
Bitshares golang client
Stars: ✭ 18 (-18.18%)
Mutual labels:  bitshares
bitshares-mobile-app
This is the mobile app for bitshares blockchain
Stars: ✭ 44 (+100%)
Mutual labels:  bitshares
PoolTool
A simple Python tool to help anyone use Liquidity Pools on the BitShares blockchain.
Stars: ✭ 17 (-22.73%)
Mutual labels:  bitshares
bitshares wallet
The bitshares wallet app for Android devices.
Stars: ✭ 31 (+40.91%)
Mutual labels:  bitshares
bsips
BitShares Improvement Proposals and Protocols. These technical documents describe the process of updating and improving the BitShares blockchain and technical ecosystem.
Stars: ✭ 63 (+186.36%)
Mutual labels:  bitshares
BarterDEX
DEPRECATED/OUTDATED!!! Do not use!
Stars: ✭ 189 (+759.09%)
Mutual labels:  decentralised-exchange

go-bitshares

A Bitshares API consuming a websocket connection to an active full node or a RPC connection to your cli_wallet. Look for several examples in examples and tests folder. This is work in progress. To mitigate breaking changes, please use tagged branches. New tagged branches will be created for breaking changes. No additional cgo dependencies for transaction signing required. Use it at your own risk.

install

go get -u github.com/denkhaus/go-bitshares

Install dev-dependencies with

make init

This API uses ffjson. If you change types or operations you have to regenerate the required static MarshalJSON and UnmarshalJSON functions for the new/changed code.

make generate

If you encounter any errors, try:

make generate_new

to generate ffjson helpers from scratch.

generate operation samples

To generate op samples for testing, go to gen package. Generated operation samples get injected automatically while running operation tests.

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

wsFullApiUrl := "wss://bitshares.openledger.info/ws"

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

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

UserID   := types.NewAccountID("1.2.253")
AssetBTS := types.NewAssetID("1.3.0")

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

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

If you need wallet functions, use:

rpcApiUrl    := "http://localhost:8095" 
api := bitshares.NewWalletAPI(rpcApiUrl)

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

...

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.

wsFullApiUrl := "wss://bitshares.openledger.info/ws"

//wsFullApiUrl serves as "quick startup" fallback endpoint here, 
//until the latency tester provides the first results.

api, err := bitshares.NewWithAutoEndpoint(wsFullApiUrl)
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 (virtual)
  • 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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].