On this page

latest contributor to this doc

Last Edit:

@gcharang

nSPV

nSPV enhances the normal "Simple Payment Verification" (SPV) technology available for a Smart Chain. To learn more about regular SPV technology, read this entry on the Bitcoin wiki.

nSPV leverages the dPoW security mechanism of the Komodo Platform to enable secure and scalable super-lite "SPV" clients. An nSPV client network utilizes a smaller amount of computation and storage resources compared to a normal SPV network. For all Smart Chains that enable nSPV, full nodes on the network can serve the necessary data to nSPV nodes for the latter to have full wallet functionality.

All Komodo-compatible Smart Chains, including the KMD main chain, can utilize this technology.

More details are available in the blog posts here and here.

This document is intended for using the nSPV features through the komodod and komodo-cli

There is an alternate implementation called libnspv that is standalone and works as a full wallet for Komodo and any Smart Chain that has dPoW enabled.

To use the following methods, the daemon must be started with the command line parameter: -nSPV=1. The parameter instructs the daemon to act as a nSPV client.

The following RPC calls interact with the komodod software, and are made available through the komodo-cli software.

nspv_broadcast hex

Use this method to broadcast the hex value returned by the nspv_spend method.

NameTypeDescription
hex(string)the transaction in hex format

NameTypeDescription
result(string)whether the command was successful
expected(string)the expected transaction id
broadcast(string)the broadcasted transaction id
retcode(number)the return code

0: no error

-1,-2,-3: failure

-200x: mostly OK, some of the inputs may not be notarized
type(string)the type of the broadcast
lastpeer(string)the last known peer

Command:

curl --data-binary '{"jsonrpc": "2.0", "id":"curltest", "method": "broadcast", "params": ["0400008085202f890155c894ada147bf184bb7dff790ca429e6860775d3bb471dc0f69a28f080977e0010000006a47304402206774ff903a8a4b73bcd5a79fe5c744f34d2263160cd8877c198c2228c66a8a42022063e1d2d6403c395e3472a6a509f01cbff0b90e3413bc6f7bc492649302a4a64001210217a6aa6c0fe017f9e469c3c00de5b3aa164ca410e632d1c04169fd7040e20e06ffffffff0200e1f505000000001976a9144726f2838fc4d6ac66615e10604e18926e9b556e88ac48f804060000000023210217a6aa6c0fe017f9e469c3c00de5b3aa164ca410e632d1c04169fd7040e20e06ace77e395d000000000000000000000000000000"] }' -H 'content-type: text/plain;' http://127.0.0.1:$port/

nspv_getinfo [hdrheight]

Use this method to get the general information on the state of the blockchain at the moment.

NameTypeDescription
hdrheight(number, optional)supplies the height of the block for which the header data is required

NameTypeDescription
result(string)whether the command was successful
nSPV(string)the mode of nSPV
address(string)the address corresponding to the wifkey
pubkey(string)the pubkey corresponding to the wifkey
wifexpires(string)the time in seconds till the login expires
height(number)the current height of the blockchain
chaintip(string)the blockhash of the last block
notarization(json)a json containing the notarization details
notarized_height(number)the height of the latest block that has been notarized
notarized_blockhash(string)the blockhash of the latest block that has been notarized
notarization_txid(string)the id of the transaction in which the notarization data is included in the chain being dPoW'ed
notarization_txidheight(number)the height of the block in which the notarization transaction is included
notarization_desttxid(string)the id of the transaction in which the notarization data is included in the chain acting as the data store
header(string)a json containing the details of the header (of the current block by default / block of height specified by hdrheight if it is specified)
height(number)the height of the block that has been queried
blockhash(string)the blockhash of the block that has been queried
hashPrevBlock(string)the blockhash of the block before the block that has been queried
hashMerkleRoot(string)the merkleroot of the block that has been queried
nTime(number)a timestamp recording when this block was created
nBits(number)the calculated difficulty target being used for this block
protocolversion(string)the version of the client; helps the nspv client disconnect from nodes that are out of date
lastpeer(string)the last known peer

Command:

curl --user $rpcuser:$rpcpassword --data-binary '{"jsonrpc": "2.0", "id":"curltest", "method": "nspv_getinfo", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:$rpcport/

nspv_hdrsproof prevheight nextheight

This method scans backwards from the prevheight until the process encounters a notarization transaction, then forward from nextheight until the process encounters another notarization transaction.

Then the process finds the notarized blocks corresponding to these two notarization transactions.

Then the process returns all the block headers between these two notarized blocks.

Now that both ends of this segment of blocks are notarized blocks, all block headers in this segment can be validated to see if they link back to each other.

NameTypeDescription
prevheight(number)the block number from which headers are required
nextheight(number)the block number to which headers are required

NameTypeDescription
result(string)whether the command was successful
prevht(string)the height of the first notarized block below the height prevheight
nextht(string)the height of the first notarized block above the height nextheight
prevtxid(string)the id of the transaction that contains the notarization data of the block of height prevht
prevtxidht(string)the height of the block in which the transaction with id prevtxid is present
prevtxlen(string)the length of the transaction with id prevtxid
nexttxid(string)the id of the transaction that contains the notarization data of the block of height nextht
nexttxidht(string)the height of the block in which the transaction with id nexttxid is present
nexttxlen(string)the length of the transaction with id nexttxid
numhdrs(string)the number of headers being returned
headers(string)a json containing the details of the header (of the current block by default / block of height specified by hdrheight if it is specified)
height(number)the height of the block that has been queried
blockhash(string)the blockhash of the block that has been queried
hashPrevBlock(string)the blockhash of the block before the block that has been queried
hashMerkleRoot(string)the merkleroot of the block that has been queried
nTime(number)a timestamp recording when this block was created
nBits(number)the calculated difficulty target being used for this block
lastpeer(string)the last known peer

Command:

curl --data-binary '{"jsonrpc": "2.0", "id":"curltest", "method": "hdrsproof", "params": [1456692, 1456694 ] }' -H 'content-type: text/plain;' http://127.0.0.1:$port/

nspv_listtransactions [address [isCC [skipcount [filter]]]]

This method returns a list of transactions for an address.

NameTypeDescription
address(string, optional)the address for which transactions are to be listed; if not specified, the current active address is used
isCC(number, optional)only return transactions that are related to Antara modules
skipcount(number, optional)skips the specified number of transactions starting from the oldest; always returns the latest transaction
filter(number, optional)(in development)

NameTypeDescription
result(string)whether the command was successful
txids(array of jsons)an array containing jsons that describe the transactions
height(number)the height of the block in which the transaction was included
txid(string)the id of the transaction
value(number)the amount of coins in the vin/vout (inputs and outputs)
vin/vout(number)the index of vin/vout in the transaction
address(string)the address for which the transactions are being returned
isCC(number)whether the address belongs to an Antara module
height(number)the height of the blockchain when this response was returned
numtxids(number)number of vouts/vins being returned
skipcount(number)the number of transactions that have been skipped, starting from the oldest transaction
filter(number)(in development)
lastpeer(string)the last known peer

Command:

curl --data-binary '{"jsonrpc": "2.0", "id":"curltest", "method": "listtransactions", "params": ["RFmQiF4Zbzxchv9AG6dw6ZaX8PbrA8FXAb"] }' -H 'content-type: text/plain;' http://127.0.0.1:$port/

nspv_listunspent [address [isCC [skipcount [filter]]]]

Use this method to retrieve all the unspent outputs belonging to an address.

NameTypeDescription
address(string, optional)the address for which transactions are to be listed; if not specified, the current active address is used
isCC(number, optional)only return transactions that are related to Antara modules
skipcount(number, optional)skips the specified number of transactions starting from the oldest; always returns the latest transaction
filter(number, optional)(in development)

NameTypeDescription
result(string)whether the command was successful
utxos(array of jsons)an array containing jsons that describe the outputs
height(number)the height of the block in which the output was created
txid(string)the id of the transaction in which the output is present
vout(number)the index of the vout (output) in the transaction
value(number)the amount of coins in the vout (output)
rewards(number)the amount of active user rewards claimable by the output
address(string)the address for which the transactions are being returned
isCC(number)whether the address belongs to an Antara module
height(number)the height of the blockchain when this response was returned
numutxos(number)number of vouts(outputs) being returned
balance(number)the total balance available for the address
rewards(number)the total rewards claimable by the address
skipcount(number)the number of utoxs that have been skipped; from the oldest
filter(number)(in development)
lastpeer(string)the last known peer

Command:

curl --data-binary '{"jsonrpc": "2.0", "id":"curltest", "method": "listunspent", "params": ["RFmQiF4Zbzxchv9AG6dw6ZaX8PbrA8FXAb"] }' -H 'content-type: text/plain;' http://127.0.0.1:$port/

nspv_login wif

Use this method to login to an address using its wifkey.

NameTypeDescription
wif(string)the wifkey (wallet import format of the privatekey)

NameTypeDescription
result(string)whether the command was successful
status(string)the time till the expiry of the login
address(string)the address corresponding to the wifkey
pubkey(string)the pubkey corresponding to the wifkey
wifprefix(number)the prefix of the wifkey (indicates the netwok the wifkey is to be used on)
compressed(boolean)indicates whether the wifkey is compressed

Command:

curl --data-binary '{"jsonrpc": "2.0", "id":"curltest", "method": "login", "params": ["Uxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"] }' -H 'content-type: text/plain;' http://127.0.0.1:$port/

nspv_logout

Use this method to logout of the currently logged in address.

NameTypeDescription
(none)

NameTypeDescription
result(string)whether the command succeeded

Command:

curl --data-binary '{"jsonrpc": "2.0", "id":"curltest", "method": "logout", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:$port/

nspv_mempool address isCC memfunc [txid vout evalcode ccfunc]]]

This method returns the current transactions in the mempool. The various parameters can be used to filter the transactions.

NameTypeDescription
address(string,optional)if the transactions should belong to the address
isCC(number,optional)if the transactions should belong to any Antara module
memfunc(number,optional)TBD
txid(string,optional)TBD
vout(number,optional)TBD
evalcode(number,optional)TBD
ccfunc(number,optional)TBD

NameTypeDescription
result(string)whether the command was successful
txids(array of strings)the ids of the transactions in the mempool
address(string)the address that was used to filter the mempool
isCC(number)if the transactions returned belong to an Antara Module
height(number)the height of the blockchain when this response was returned
numtxids(number)the number of transaction ids that are being returned
txid(string)TBD
vout(number)TBD
memfunc(number)TBD
type(string)the type of the filter apploed to the mempool
lastpeer(string)the last known peer

Command:

curl --data-binary '{"jsonrpc": "2.0", "id":"curltest", "method": "mempool", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:$port/

nspv_notarizations height

This method returns the notarization data for a given height.

NameTypeDescription
height(number)the height at which notarization data is required

NameTypeDescription
result(string)whether the command was successful
prev(json)the details of the previous notarization
notarized_height(number)the height of the latest block that has been notarized
notarized_blockhash(string)the blockhash of the latest block that has been notarized
notarization_txid(string)the id of the transaction in which the notarization data is included in the chain being dPoW'ed
notarization_txidheight(number)the height of the block in which the notarization transaction is included
notarization_desttxid(string)the id of the transaction in which the notarization data is included in the chain acting as the data store
next(json)the details of the next notarization
lastpeer(string)the last known peer

Command:

curl --data-binary '{"jsonrpc": "2.0", "id":"curltest", "method": "notarizations", "params": [145677] }' -H 'content-type: text/plain;' http://127.0.0.1:$port/

nspv_spend address amount

This method can be used to spend some coins from the currently loggedin address to any other address.

NameTypeDescription
address(string)the address of the recipient
amount(number)the amount to be sent

NameTypeDescription
rewards(string)the rewards being claimed by this spend transaction
validated(string)
tx(json)a json containing details of the transaction
nVersion(number)version of the komodo daemon
vin(array of jsons)the inputs being consumed by the transaction
txid(string)the id of the transaction whose input is being spent
vout(number)the output number in the above transaction
scriptSig(string)the redeem script that satisfies the scriptPubkey of the above output
sequenceid(number)the sequence number that has been set
vout(array of jsons)the outputs being created by the transaction
value(string)the value in the output
scriptPubKey(string)the locking script placed on the above value
nLockTime(number)the locktime that has been set
nExpiryHeight(number)the block height after which the transaction will be removed from the mempool if it has not been mined
valueBalance(number)
result(string)whether the command succeeded
hex(string)the transaction in hex format; it should be broadcast to the network using the nspv_broadcast method
retcodes(number)the return codes; given an indication on the success or failure in the creation of the transaction
lastpeer(string)the last known peer

Command:

curl --data-binary '{"jsonrpc": "2.0", "id":"curltest", "method": "spend", "params": ["RFmQiF4Zbzxchv9AG6dw6ZaX8PbrA8FXAb",1 ] }' -H 'content-type: text/plain;' http://127.0.0.1:$port/

nspv_spentinfo txid vout

This method returns the spent info of the output specified by the arguments.

NameTypeDescription
txid(string)the id of the transaction whose spent info is required
vout(number)the vout number in the above transaction whose spent info is required

NameTypeDescription
result(string)whether the command succeeded
txid(string)the id of the transaction whose spent info is returned
vout(string)the vout number in the above transaction whose spent info is required
spentheight(string)the block height at which the output has been spent
spenttxid(string)the id of the transaction that spent this output
spentvini(string)the input number of this output in the transaction that spent it
spenttxlen(string)the length of the transaction that spent this output
spenttxprooflen(string)the length of proof of the transaction that spent this output
lastpeer(string)the last known peer

Command:

curl --data-binary '{"jsonrpc": "2.0", "id":"curltest", "method": "spentinfo", "params": ["e07709088fa2690fdc71b43b5d7760689e42ca90f7dfb74b18bf47a1ad94c855",1 ] }' -H 'content-type: text/plain;' http://127.0.0.1:$port/

nspv_txproof txid vout [height]

This method is an internal function to be used by the nspv_listtransactions method

NameTypeDescription
txid(string)the id of the transaction whose proof is requested
vout(number)the number of the output in the above transaction
height(number,optional)

NameTypeDescription
txid(string)the id of the transaction whose proof is returned
height(string)the height at which the proof of the transaction is returned
txlen(string)the length of the transaction
txprooflen(string)the length of the proof for the transaction
lastpeer(string)the last known peer

Command:

curl --user $rpcuser:$rpcpassword --data-binary '{"jsonrpc": "2.0", "id":"curltest", "method": "nspv_txproof", "params": ["ae234c7f47bcb5adbe7c5c5661051865be0ce61422328de90fe5a3f8fa8b7c60", "4322"] }' -H 'content-type: text/plain;' http://127.0.0.1:$rpcport/