satindergrewal / kmdgo

Go package for Komodo Platform API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

kmdgo

I created this Go package as part of my learning process of Go language. This as of this stage is working to for the basic things required, like just using the "methods" with "parameters" and it will give you the expected result in Go's native data set, structs, which you can use further to code your application. Would really appreciate if any other experienced Go language developers may push any improvements of fixes required for this package.

As of this stage, this package is compatible with Komodo and all of it's Assetchains.

Documentation and Examples

Install dependencies and setup environemnt

This package depends on saplinglib, so you have to get that package and set environment variables.

For Linux setup these environment variables:

export CGO_CFLAGS="-I$HOME/go/src/github.com/satindergrewal/saplinglib/src/"
export CGO_LDFLAGS="-L$HOME/go/src/github.com/satindergrewal/saplinglib/dist/linux -lsaplinglib -lpthread -ldl -lm"

For macOS x86_64 setup these environment variables:

export CGO_CFLAGS="-I$HOME/go/src/github.com/satindergrewal/saplinglib/src/"
export CGO_LDFLAGS="-L$HOME/go/src/github.com/satindergrewal/saplinglib/dist/darwin -lsaplinglib -framework Security"

For macOS arm64 setup these environment variables:

export CGO_CFLAGS="-I$HOME/go/src/github.com/satindergrewal/saplinglib/src/"
export CGO_LDFLAGS="-L$HOME/go/src/github.com/satindergrewal/saplinglib/dist/darwin_arm64/ -lsaplinglib -framework Security"

For MingW cross-platform windows setup these environment variables:

export CGO_CFLAGS="-I$HOME/go/src/github.com/satindergrewal/saplinglib/src/"
export CGO_LDFLAGS="-L$HOME/go/src/github.com/satindergrewal/saplinglib/dist/win64 -lsaplinglib -lws2_32 -luserenv"
export CC="x86_64-w64-mingw32-gcc"

Install dependency:

go get -u github.com/satindergrewal/saplinglib

Quick Example

To use this package do

go get -u github.com/satindergrewal/kmdgo

Example code:

//main.go
package main

import (
	"fmt"
	"github.com/satindergrewal/kmdgo/kmdutil"
)

func main() {
	appName := "VRSC"
	dir := kmdutil.AppDataDir(appName, false)
	fmt.Println(dir)

	rpcuser, rpcpass, rpcport := kmdutil.AppRPCInfo(appName)
	fmt.Printf("RPC User: %s\nRPC Password: %s\nRPC Port: %s\n", rpcuser, rpcpass, rpcport)
}

Output:

$ go run main.go
/home/satinder/.komodo/VRSC
RPC User: user1773837506
RPC Password: passbae43ecd576o8ariotkgjhasdfiyosidulrkhdf9390bf03b68
RPC Port: 27486

Supported API Calls

KMDUtil Specific Methods

  • AppDataDir - Gives the path of cryptocurrency's Data directory based on it's symbol. Supports Only Komodo and Assetchains so far.
  • AppRPCInfo - Provides RPC username, password and it's port by reading it's config file from data directory.
  • GetTAddress - GetTAddress generates a public address using a seed phrase
  • GetZAddress - GetZAddress generates a shielded sapling address using a seed phrase
  • GetIguanaWallet - GetIguanaWallet returns a set of public and shielded addresses generated based on a mnemonic seed phrase
  • BytesToString - BytesToString converts and returns bytes to string
NOTE: saplinglib is required for kmdutil methods GetZAddress and GetIguanaWallet

CClib

  • cclib method [evalcode] [JSON params]
  • cclibaddress [evalcode] [pubkey]
  • cclibinfo

DEX

  • DEX_anonsend message priority destpub33
  • DEX_broadcast hex [priority [tagA [tagB [pubkey33 [volA [volB]]]]]]
  • DEX_cancel id [pubkey33 [tagA tagB]]
  • DEX_get id
  • DEX_list stopat minpriority tagA tagB pubkey33 [minA maxA minB maxB [stophash]]
  • DEX_notarize coin height
  • DEX_orderbook maxentries minpriority tagA tagB pubkey33 [minA maxA minB maxB]
  • DEX_publish filename priority sliceid
  • DEX_setpubkey pubkey33
  • DEX_stats
  • DEX_stream filename priority
  • DEX_streamsub filename priority pubkey
  • DEX_subscribe filename priority id [publisher33]

FSM

  • FSMaddress [pubkey]
  • FSMcreate name states
  • FSMinfo fundingtxid
  • FSMlist

Addressindex

  • getaddressbalance
  • getaddressdeltas
  • getaddressmempool
  • getaddresstxids
  • getaddressutxos
  • getsnapshot

Auction

  • auctionaddress [pubkey]

Blockchain

  • coinsupply
  • getbestblockhash
  • getblock "hash|height" ( verbosity )
  • getblockchaininfo
  • getblockcount
  • getblockhash index
  • getblockhashes timestamp -- Todo
  • getblockheader "hash" ( verbose )
  • getchaintips
  • getdifficulty
  • getmempoolinfo
  • getrawmempool ( verbose )
  • getspentinfo -- Todo
  • gettxout "txid" n ( includemempool )
  • gettxoutproof ["txid",...] ( blockhash )
  • gettxoutsetinfo
  • kvsearch key -- Todo
  • kvupdate key "value" days passphrase -- Todo
  • minerids needs height
  • notaries height timestamp
  • verifychain ( checklevel numblocks )
  • verifytxoutproof "proof"

Channels

  • channelsaddress destpubkey
  • channelsclose opentxid
  • channelsinfo [opentxid]
  • channelsinfo
  • channelsopen destpubkey numpayments payment
  • channelspayment opentxid amount [secret]
  • channelsrefund opentxid closetxid

Control

  • getinfo
  • help ( "command" )
  • stop

Crosschain

  • MoMoMdata symbol kmdheight ccid
  • assetchainproof needs a txid
  • calc_MoM height MoMdepth
  • getNotarisationsForBlock blockHash
  • height_MoM height
  • migrate_completeimporttransaction importTx
  • migrate_converttoexport rawTx dest_symbol export_amount
  • migrate_createimporttransaction burnTx payouts
  • scanNotarisationsDB blockHeight symbol [blocksLimit=1440]

Dice

  • diceaddfunds name fundingtxid amount
  • diceaddress [pubkey]
  • dicebet name fundingtxid amount odds
  • dicefinish name fundingtxid bettxid
  • dicefund name funds minbet maxbet maxodds timeoutblocks
  • diceinfo fundingtxid
  • dicelist
  • dicestatus name fundingtxid bettxid

Disclosure

  • z_getpaymentdisclosure "txid" "js_index" "output_index" ("message")
  • z_validatepaymentdisclosure "paymentdisclosure"

Faucet

  • faucetaddress [pubkey]
  • faucetfund amount
  • faucetget
  • faucetinfo

Rogue Game

  • cclib newgame [evalcode] "[maxplayers, buyin]"
  • cclib gameinfo [evalcode] "[gametxid]"
  • cclib pending [evalcode]
  • cclib register [evalcode] "[gametxid, [playertxid]]"
  • cclib keystrokes [evalcode] "[gametxid, keystrokes]" -- This is only executed by the ROGUE dApp. Not need to run manully
  • cclib bailout [evalcode] "[gametxid]"
  • cclib highlander [evalcode] "[gametxid]"
  • cclib playerinfo [evalcode] "[playertxid]"
  • cclib players [evalcode]
  • cclib games [evalcode]
  • cclib setname [evalcode] "[pname]"

Gateways

  • gatewaysaddress [pubkey]
  • gatewaysbind tokenid oracletxid coin tokensupply M N pubkey(s)
  • gatewaysclaim bindtxid coin deposittxid destpub amount
  • gatewayscompletesigning withdrawtxid coin hex
  • gatewaysdeposit bindtxid height coin cointxid claimvout deposithex proof destpub amount
  • gatewaysinfo bindtxid
  • gatewayslist
  • gatewaysmarkdone completesigningtx coin
  • gatewaysmultisig txidaddr
  • gatewayspartialsign txidaddr refcoin hex
  • gatewayspending bindtxid coin
  • gatewaysprocessed bindtxid coin
  • gatewayswithdraw bindtxid coin withdrawpub amount

Generating

  • generate numblocks
  • getgenerate
  • setgenerate generate ( genproclimit )

Heir

  • heiraddress func txid amount [destpubkey]

Lotto

  • lottoaddress [pubkey]

Mining

  • getblocksubsidy height
  • getblocktemplate ( "jsonrequestobject" )
  • getlocalsolps
  • getmininginfo
  • getnetworkhashps ( blocks height )
  • getnetworksolps ( blocks height )
  • prioritisetransaction
  • submitblock "hexdata" ( "jsonparametersobject" )

Network

  • addnode "node" "add|remove|onetry"
  • clearbanned
  • disconnectnode "node"
  • getaddednodeinfo dns ( "node" )
  • getconnectioncount
  • getdeprecationinfo
  • getnettotals
  • getnetworkinfo
  • getpeerinfo
  • listbanned
  • ping
  • setban "ip(/netmask)" "add|remove" (bantime) (absolute)

Oracles

  • oraclesaddress [pubkey]
  • oraclescreate name description format
  • oraclesdata oracletxid hexstr
  • oraclesinfo oracletxid
  • oracleslist
  • oraclesregister oracletxid datafee
  • oraclessamples oracletxid batonutxo num
  • oraclessubscribe oracletxid publisher amount

Payments

  • paymentsaddress [pubkey]

Pegs

  • pegssaddress [pubkey]

Prices

  • pricesaddfunding fundingtxid bettoken amount
  • pricesaddress [pubkey]
  • pricesbet fundingtxid bettoken amount leverage
  • pricescreate bettoken oracletxid margin mode longtoken shorttoken maxleverage funding N [pubkeys]
  • pricesfinish fundingtxid bettoken bettxid
  • pricesinfo fundingtxid
  • priceslist
  • pricesstatus fundingtxid bettoken bettxid

Rawtransactions

  • createrawtransaction [{"txid":"id","vout":n},...] {"address":amount,...} ( locktime ) ( expiryheight )
  • decoderawtransaction "hexstring"
  • decodescript "hex"
  • fundrawtransaction "hexstring"
  • getrawtransaction "txid" ( verbose )
  • sendrawtransaction "hexstring" ( allowhighfees )
  • signrawtransaction "hexstring" ( [{"txid":"id","vout":n,"scriptPubKey":"hex","redeemScript":"hex"},...] ["privatekey1",...] sighashtype )

Rewards

  • rewardsaddfunding name fundingtxid amount
  • rewardsaddress [pubkey]
  • rewardscreatefunding name amount APR mindays maxdays mindeposit
  • rewardsinfo fundingtxid
  • rewardslist
  • rewardslock name fundingtxid amount
  • rewardsunlock name fundingtxid [txid]

Tokens

  • tokenaddress [pubkey]
  • tokenask numtokens tokenid price
  • tokenbalance tokenid [pubkey]
  • tokenbid numtokens tokenid price
  • tokencancelask tokenid asktxid
  • tokencancelbid tokenid bidtxid
  • tokenconvert evalcode tokenid pubkey amount
  • tokencreate name supply description
  • tokenfillask tokenid asktxid fillunits
  • tokenfillbid tokenid bidtxid fillamount
  • tokeninfo tokenid
  • tokenlist
  • tokenorders [tokenid]
  • tokentransfer tokenid destpubkey amount

Triggers

  • triggersaddress [pubkey]

Util

  • createmultisig nrequired ["key",...]
  • estimatefee nblocks
  • estimatepriority nblocks
  • invalidateblock "hash"
  • jumblr_deposit "depositaddress"
  • jumblr_pause
  • jumblr_resume
  • jumblr_secret "secretaddress"
  • reconsiderblock "hash"
  • txnotarizedconfirmed txid
  • validateaddress "komodoaddress"
  • verifymessage "komodoaddress" "signature" "message"
  • z_validateaddress "zaddr"

Wallet

  • addmultisigaddress nrequired ["key",...] ( "account" )
  • backupwallet "destination"
  • dumpprivkey "t-addr"
  • dumpwallet "filename"
  • encryptwallet "passphrase"
  • getaccount "KMD_address"
  • getaccountaddress "account"
  • getaddressesbyaccount "account"
  • getbalance ( "account" minconf includeWatchonly )
  • getnewaddress ( "account" )
  • getrawchangeaddress
  • getreceivedbyaccount "account" ( minconf )
  • getreceivedbyaddress "KMD_address" ( minconf )
  • gettransaction "txid" ( includeWatchonly )
  • getunconfirmedbalance
  • getwalletinfo
  • importaddress "address" ( "label" rescan )
  • importprivkey "komodoprivkey" ( "label" rescan )
  • importwallet "filename"
  • keypoolrefill ( newsize )
  • listaccounts ( minconf includeWatchonly)
  • listaddressgroupings
  • listlockunspent
  • listreceivedbyaccount ( minconf includeempty includeWatchonly) -- DEPRECATED
  • listreceivedbyaddress ( minconf includeempty includeWatchonly)
  • listsinceblock ( "blockhash" target-confirmations includeWatchonly)
  • listtransactions ( "account" count from includeWatchonly)
  • listunspent ( minconf maxconf ["address",...] )
  • lockunspent unlock [{"txid":"txid","vout":n},...]
  • move "fromaccount" "toaccount" amount ( minconf "comment" ) -- DEPRECATED
  • resendwallettransactions -- "Intended only for testing;" --- May be Later --- Todo
  • sendfrom "fromaccount" "toKMDaddress" amount ( minconf "comment" "comment-to" )
  • sendmany "fromaccount" {"address":amount,...} ( minconf "comment" ["address",...] )
  • sendtoaddress "KMD_address" amount ( "comment" "comment-to" subtractfeefromamount )
  • setaccount "KMD_address" "account" -- DEPRECATED
  • setpubkey
  • settxfee amount
  • signmessage "t-addr" "message"
  • walletlock
  • walletpassphrase "passphrase" seconds
  • walletpassphrasechange "oldpassphrase" "newpassphrase"
  • z_exportkey "zaddr"
  • z_exportviewingkey "zaddr"
  • z_exportwallet "filename"
  • z_getbalance "address" ( minconf )
  • z_getnewaddress ( type )
  • z_getoperationresult (["operationid", ... ])
  • z_getoperationstatus (["operationid", ... ])
  • z_gettotalbalance ( minconf includeWatchonly )
  • z_importkey "zkey" ( rescan startHeight )
  • z_importviewingkey "vkey" ( rescan startHeight )
  • z_importwallet "filename"
  • z_listaddresses ( includeWatchonly )
  • z_listoperationids
  • z_listreceivedbyaddress "address" ( minconf )
  • z_listunspent ( minconf maxconf includeWatchonly ["zaddr",...] )
  • z_mergetoaddress ["fromaddress", ... ] "toaddress" ( fee ) ( transparent_limit ) ( shielded_limit ) ( memo )
  • z_sendmany "fromaddress" [{"address":... ,"amount":...},...] ( minconf ) ( fee )
  • z_shieldcoinbase "fromaddress" "tozaddress" ( fee ) ( limit )
  • zcbenchmark benchmarktype samplecount -- Todo
  • zcrawjoinsplit rawtx inputs outputs vpub_old vpub_new -- Todo
  • zcrawkeygen -- Todo
  • zcrawreceive zcsecretkey encryptednote -- Todo
  • zcsamplejoinsplit -- Todo

Verus blockchain specific Methods

Verus Identity

  • getidentity "name"
  • listidentities (includecansign) (includewatchonly)
  • recoveridentity "jsonidentity" (returntx)
  • registeridentity "jsonidregistration" feeoffer
  • registernamecommitment "name" "controladdress" ("referralidentity")
  • revokeidentity "nameorID" (returntx)
  • updateidentity "jsonidentity" (returntx)

Verus Multichain

  • addmergedblock "hexdata" ( "jsonparametersobject" )
  • definecurrency '{"name": "BAAS", ..., "nodes":[{"networkaddress":"identity"},..]}'
  • getcrossnotarization "systemid" '["notarizationtxid1", "notarizationtxid2", ...]' - TODO - Need example command/output
  • getcurrency "chainname"
  • getcurrencyconverters ["currency1","currency2",...]'
  • getcurrencystate "n"
  • getexports "chainname"
  • getimports "chainname"
  • getinitialcurrencystate "name"
  • getlastimportin "fromname"
  • getlatestimportsout "name" "lastimporttransaction" "importtxtemplate" - TODO - Need example command/output
  • getblocktemplate ( "jsonrequestobject" ) - TODO - Need example command/output
  • getnotarizationdata "currencyid" accepted
  • getpendingtransfers "chainname" - TODO - need example output
  • getsaplingtree "n" - TODO - Need example command/output
  • listcurrencies (includeexpired)
  • paynotarizationrewards "currencyid" "amount" "billingperiod"
  • refundfailedlaunch "currencyid" - TODO - need example output
  • reserveexchange '[{"toreserve": 1, "recipient": "RRehdmUV7oEAqoZnzEGBH34XysnWaBatct", "amount": 5.0}]'
  • sendcurrency "fromaddress" '[{"address":... ,"amount":...},...]' (returntx)
  • submitacceptednotarization "hextx"

Verus Wallet

  • convertpassphrase "walletpassphrase"
  • signfile "address or identity" "filepath/filename" "curentsig"
  • z_getmigrationstatus
  • z_setmigration enabled
  • z_viewtransaction "txid"

About

Go package for Komodo Platform API

License:GNU General Public License v2.0


Languages

Language:Go 100.0%Language:Shell 0.0%