Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/denkhaus/go-bitshares
API for Bitshares - supports websocket RPC & Wallet functions
https://github.com/denkhaus/go-bitshares
bitshares bitshares-api cryptocurrency decentralised-exchange rpc websocket
Last synced: 2 months ago
JSON representation
API for Bitshares - supports websocket RPC & Wallet functions
- Host: GitHub
- URL: https://github.com/denkhaus/go-bitshares
- Owner: denkhaus
- License: mit
- Created: 2017-07-30T11:36:30.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-11-29T13:36:02.000Z (about 4 years ago)
- Last Synced: 2024-08-04T03:03:04.168Z (6 months ago)
- Topics: bitshares, bitshares-api, cryptocurrency, decentralised-exchange, rpc, websocket
- Language: Go
- Homepage:
- Size: 1.1 MB
- Stars: 23
- Watchers: 4
- Forks: 26
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-bitshares - go-bitshares - API for BitShares - supports websocket RPC & Wallet functions (Libraries / Go Libraries)
README
# 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](/examples) and [tests](/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
```bash
go get -u github.com/denkhaus/go-bitshares
```Install dev-dependencies with
```bash
make init
```This API uses [ffjson](https://github.com/pquerna/ffjson).
If you change types or operations you have to regenerate the required static `MarshalJSON` and `UnmarshalJSON` functions for the new/changed code.```bash
make generate
```If you encounter any errors, try:
```bash
make generate_new
```to generate ffjson helpers from scratch.
## generate operation samples
To generate op samples for testing, go to [gen](/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](https://github.com/denkhaus/bitshares-docker).
Operations testing uses generated real blockchain sample code by [gen](/gen) package. To test run:```bash
make test_operations
make test_api
```or a long running block (deserialize/serialize/compare) range test.
```bash
make test_blocks
```## code
```go
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:
```go
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.```go
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
- [x] OperationTypeTransfer OperationType
- [x] OperationTypeLimitOrderCreate
- [x] OperationTypeLimitOrderCancel
- [x] OperationTypeCallOrderUpdate
- [x] OperationTypeFillOrder (virtual)
- [x] OperationTypeAccountCreate
- [x] OperationTypeAccountUpdate
- [x] OperationTypeAccountWhitelist
- [x] OperationTypeAccountUpgrade
- [x] OperationTypeAccountTransfer
- [x] OperationTypeAssetCreate
- [x] OperationTypeAssetUpdate
- [x] OperationTypeAssetUpdateBitasset
- [x] OperationTypeAssetUpdateFeedProducers
- [x] OperationTypeAssetIssue
- [x] OperationTypeAssetReserve
- [x] OperationTypeAssetFundFeePool
- [x] OperationTypeAssetSettle
- [x] OperationTypeAssetGlobalSettle
- [x] OperationTypeAssetPublishFeed
- [x] OperationTypeWitnessCreate
- [x] OperationTypeWitnessUpdate
- [x] OperationTypeProposalCreate
- [x] OperationTypeProposalUpdate
- [x] OperationTypeProposalDelete
- [x] OperationTypeWithdrawPermissionCreate
- [x] OperationTypeWithdrawPermissionUpdate
- [x] OperationTypeWithdrawPermissionClaim
- [x] OperationTypeWithdrawPermissionDelete
- [x] OperationTypeCommitteeMemberCreate
- [x] OperationTypeCommitteeMemberUpdate
- [x] OperationTypeCommitteeMemberUpdateGlobalParameters
- [x] OperationTypeVestingBalanceCreate
- [x] OperationTypeVestingBalanceWithdraw
- [x] OperationTypeWorkerCreate
- [x] OperationTypeCustom
- [ ] OperationTypeAssert
- [x] OperationTypeBalanceClaim
- [x] OperationTypeOverrideTransfer
- [x] OperationTypeTransferToBlind
- [ ] OperationTypeBlindTransfer
- [x] OperationTypeTransferFromBlind
- [ ] OperationTypeAssetSettleCancel
- [x] OperationTypeAssetClaimFees
- [ ] OperationTypeFBADistribute
- [x] OperationTypeBidColatteral
- [ ] OperationTypeExecuteBid## todo
- add missing operations
- add convenience functionsHave fun and feel free to contribute needed operations and tests.