Skip to content
A Rust RPC client for Komodo (KMD)
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples
src
.gitignore
Cargo.toml
README.md

README.md

Komodo (KMD) RPC client

A RPC client for Komodo (KMD), made in Rust. In the future, you can use this library to create Rust apps that communicate with Komodo blockchains. Since Crypto Conditions is supported in all Komodo assetchains, dApps can be created through this crate. Or at least, that is my goal for this.

With credits to the coblox team's Rust BTC RPC client.

This is a work in progress!

todo:

  • implement all API calls
  • argument Address into type
  • handle empty responses (setaccount)
  • improve error handling Client
  • find redeemScript in previous transactions (if any)
  • make sensible use of references in arguments
  • use Into<String> as argument for String types
  • get rid of needing AddressList for single address in parameter
  • define own Chain if needed assetchain isn't in enum
  • properly expose arguments / types
  • handle special case: wildcard "*" in fromaddresses, z_mergetoaddress
  • supply Client with manual RPC credentials
  • struct Unspent contains account in response, which is deprecated. Need to circumvent
  • listaddressgroupings returns an array with 3 different types, for each distinct address. how to fix in serde

This wrapper aims to:

  • be stateless, i.e. a thin layer. It's up to the app using this library to maintain state.

Features

  • Convert an utxolist retrieved through getaddressutxos to inputs in createrawtransaction
  • Automatically fetches KMD / Assetchain parameters from config file on Win, MacOS and Ubuntu/Debian

Currently supported calls

Below is a list of RPC calls in this Rust client as of KMDversion 0.3.3b

Notes

  • valueSat and valueZat are omitted from getrawtransaction and decoderawtransaction, respectively
  • Several network RPCs return no response from komodod. These RPCs are unsupported until further notice, being:
    • addnode
    • clearbanned
    • z_importkey
    • z_importviewingkey
    • z_importwallet
    • importaddress
    • importwallet
  • Sapling does not support z_exportviewingkey, or viewing keys in general, yet
  • Things checked before actual request:
    • address in address parameter is valid (basic length check for now)
  • sendtoaddress returns a transaction id that is little-endian, which is reversed from what you see on the explorer. Call be_hex_string() on the TransactionId type and you get the big-endian txid.
    • The transaction id that is deserialized will always be little-endian.

RPCs

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" ( verbose )
  • getblockchaininfo
  • getblockcount
  • getwalletinfo
  • getblockhash index
  • getblockhashes timestamp (requires timestampindex=1)
  • getblockheader "hash" ( verbose )
  • getchaintips
  • getdifficulty
  • getlastsegidstakes depth
  • getmempoolinfo
  • getrawmempool ( verbose ) //
  • getspentinfo "txid" index
  • gettxout "txid" n ( includemempool )
  • gettxoutproof ["txid",...] ( blockhash ) needs -txindex
  • gettxoutsetinfo
  • kvsearch key
  • kvupdate key "value" days passphrase
  • minerids needs height
  • notaries height timestamp
  • verifychain ( checklevel numblocks )
  • verifytxoutproof "proof"
Channels
  • channelsaddress destpubkey
  • channelsclose opentxid
  • channelsinfo [opentxid]
  • channelsinfo [opentxid]
  • channelsopen destpubkey numpayments payment
  • channelspayment prevtxid origtxid n amount
  • channelsrefund stoptxid origtxid
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
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 cointxid
  • 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]
Marmara
  • marmaraadress [pubkey]
Mining
  • getblocksubsidy height
  • getblocktemplate ( "jsonrequestobject" )
  • getlocalsolps
  • getmininginfo
  • getnetworkhashps ( blocks height )
  • getnetworksolps ( blocks height )
  • prioritisetransaction
  • submitblock "hexdata" ( "jsonparametersobject" )
Network
  • addnode "node" "add|remove|onetry" (empty response)
  • clearbanned (empty response)
  • 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,...}
  • 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
Util
  • createmultisig nrequired ["key",...]
  • decodeccopret hex
  • 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" (requires -exportdir to be set)
  • dumpprivkey "komodoaddress"
  • dumpwallet "filename" (requires -exportdir to be set)
  • encryptwallet "passphrase"
  • getaccount "KMD_address" (deprecated)
  • getaccountaddress "account" (deprecated)
  • getaddressesbyaccount "account" (deprecated)
  • getbalance ( "account" minconf includeWatchonly ) (account deprecated)
  • getnewaddress ( "account" ) (account deprecated)
  • getrawchangeaddress
  • getreceivedbyaccount "account" ( minconf ) (account deprecated)
  • getreceivedbyaddress "KMD_address" ( minconf )
  • gettransaction "txid" ( includeWatchonly )
  • getunconfirmedbalance
  • getwalletinfo
  • importaddress "address" ( "label" rescan ) (empty response)
  • importprivkey "komodoprivkey" ( "label" rescan )
  • importwallet "filename" (empty response)
  • keypoolrefill ( newsize ) (empty response)
  • listaccounts ( minconf includeWatchonly) (deprecated)
  • 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
  • sendfrom "fromaccount" "toKMDaddress" amount ( minconf "comment" "comment-to" ) (deprecated)
  • sendmany "fromaccount" {"address":amount,...} ( minconf "comment" ["address",...] )
  • sendtoaddress "KMD_address" amount ( "comment" "comment-to" subtractfeefromamount )
  • setaccount "KMD_address" "account" (deprecated)
  • setpubkey pubkey (unsupported due to wrong return type)
  • settxfee amount
  • signmessage "t-addr" "message"
Shielded (see API)
  • z_exportkey "zaddr"
  • z_exportviewingkey "zaddr" unsupported for sapling (https://github.com/zcash/zcash/issues/3060)
  • 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 ) (no output)
  • z_importviewingkey "vkey" ( rescan startHeight ) (no output)
  • z_importwallet "filename" (no output)
  • z_listaddresses ( includeWatchonly )
  • z_listoperationids
  • z_listreceivedbyaddress "address" ( minconf )
  • 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 deprecated
  • zcrawjoinsplit rawtx inputs outputs vpub_old vpub_new deprecated
  • zcrawkeygen deprecated
  • zcrawreceive zcsecretkey encryptednote deprecated
  • zcsamplejoinsplit deprecated
You can’t perform that action at this time.