stealthjs-lib

0.5.6 • Public • Published

Stealth (ticker symbol XST) Javascript SDK

This is a Javascript SDK library for querying Stealth RPC daemon.

Install:

npm install --save stealthjs-lib

Stealth features:

  • 5 second block
  • Fee-less transactions
  • Cryptographic private transactions
  • Massive blockchain scalability
  • On-Chain governance
  • Supports smart contracts, Blockchain Oracles and side chains

Learn more about Stealth, the fastest private digital currency at the official website https://stealth.org/

Usage

const Stealth = require('stealthjs-lib');

const client = new Stealth({
  host: "localhost", // Host for the RPC daemon
  port: 46502, // Port for the RPC daemon
  username: "rpcclientusername", // Username for RPC daemon
  password: "rpcclientpassword", // Password for RPC daemon
  jsonRpc: "2.0", // JSON rpc version
  debug: false, // Turns on logging of the request and response
});

await client.help();

API definition

request(method, params) ⇒ Promise.<object>

Make request to any of the RPC functions directly

Param Type
method string
params Array.<any>

addmultisigaddress(nRequired, keys, [account]) ⇒ Promise.<Object>

Add a n-required-to-sign multi-signature address to the wallet each key is an XST address or hex-encoded public key If [account] is specified, assign address to [account].

Param Type Default
nRequired number
keys Array.<string>
[account] string ""

backupwallet(destination) ⇒ Promise.<Object>

Safely copies wallet.dat to destination, which can be a directory or a path with filename.

Param Type
destination string

checkwallet() ⇒ Promise.<Object>

Check wallet for integrity.

claimqposbalance(txId, vOut, amount) ⇒ Promise.<Object>

claimqposbalance is the transaction ID of the input is the prevout index of the input is the amount to claim Amount is real and rounded to the nearest 0.000001. Claim plus change is returned to claimant hashed pubkey

Param Type
txId string
vOut number
amount number

clearwallettransactions() ⇒ Promise.<Object>

delete all transactions from wallet - reload with scanforalltxns Warning: Backup your wallet first!

createrawtransaction(transactions, addresses) ⇒ Promise.<Object>

createrawtransaction [{"txid":txid,"vout":n},...] {address:amount,...} Create a transaction spending given inputs (array of objects containing transaction id and output number), sending to given address(es). Returns hex-encoded raw transaction. Note that the transaction's inputs are not signed, and it is not stored in the wallet or transmitted to the network.

Param Type Description
transactions Array.<object> [{"txid":txid,"vOut":n},...]
addresses object {address:amount,...}

decoderawtransaction(hex) ⇒ Promise.<Object>

Return a JSON object representing the serialized, hex-encoded transaction.

Param Type
hex string

disablestaker(txId, vOut, alias) ⇒ Promise.<Object>

Kind: global function

Param Type Description
txId string transaction ID of the input
vOut number prevout index of the input
alias alias non-case sensitive staker alias

dumpprivkey(XSTAddress) ⇒ Promise.<Object>

Reveals the private key corresponding to .

Param Type
XSTAddress string

enablestaker(txId, vOut, alias) ⇒ Promise.<Object>

enablestaker is the transaction ID of the input is the prevout index of the input is a non-case sensitive staker alias

Param Type
txId string
vOut number
alias string

encryptwallet(passphrase) ⇒ Promise.<Object>

Encrypts the wallet with

Param Type
passphrase string

exitreplay() ⇒ Promise.<Object>

Manually exits registry replay (testnet only).

getaccount(XSTAddress) ⇒ Promise.<Object>

Returns the account associated with the given address.

Param Type
XSTAddress string

getaccountaddress(account) ⇒ Promise.<Object>

Returns the current XST address for receiving payments to this account.

Param Type
account string

getaddressbalance(address) ⇒ Promise.<Object>

Returns the balance of

.
Param Type
address string

getaddressesbyaccount(account) ⇒ Promise.<Object>

Returns the list of addresses for the given account.

Param Type
account string

getaddressinfo(address) ⇒ Promise.<Object>

Returns info about

.
Param Type
address string

getaddressinouts(address, [start], [max]) ⇒ Promise.<Object>

Returns [max] inputs + outputs of

beginning with [start] For example, if [start]=101 and [max]=100 means to return the second 100 in-outs (if possible). [start] is the nth in-out (default: 1) [max] is the max in-outs to return (default: 100)
Param Type Default
address string
[start] number 1
[max] number 100

getaddressinputs(address, [start], [max]) ⇒ Promise.<Object>

Returns [max] inputs of

beginning with [start] For example, if [start]=101 and [max]=100 means to return the second 100 inputs (if possible).
Param Type Default
address string
[start] number 1
[max] number 100

getaddressoutputs(address, [start], [max]) ⇒ Promise.<Object>

Returns [max] outputs of

beginning with [start] For example, if [start]=101 and [max]=100 means to return the second 100 outputs (if possible).
Param Type Default
address string
[start] number 1
[max] number 100

getadjustedtime() ⇒ Promise.<Object>

Returns the Stealth network adjusted time.

getbalance(account, [minConf]) ⇒ Promise.<Object>

If [account] is not specified, returns the server's total available balance. If [account] is specified, returns the balance in the account.

Param Type Default
account string
[minConf] number 1

getbestblockhash() ⇒ Promise.<Object>

Returns the hash of the best block in the longest block chain.

getblock(hash, [txInfo]) ⇒ Promise.<Object>

Returns data needed to construct a block to work on:

  • "version" : block version
  • "previousblockhash" : hash of current highest block
  • "transactions" : contents of non-coinbase transactions that should be included in the next block
  • "coinbaseaux" : data that should be included in coinbase
  • "coinbasevalue" : maximum allowable input to coinbase transaction, including the generation award and transaction fees
  • "target" : hash target
  • "mintime" : minimum timestamp appropriate for next block
  • "curtime" : current timestamp
  • "mutable" : list of ways the block template may be changed
  • "noncerange" : range of valid nonces
  • "sigoplimit" : limit of sigops in blocks
  • "sizelimit" : limit of block size
  • "bits" : compressed target of next block
  • "height" : height of the next block

See https://en.bitcoin.it/wiki/BIP_0022 for full specification.

Param Type Default
hash string
[txInfo] boolean false

getblockbynumber(number, [txInfo]) ⇒ Promise.<Object>

Returns details of a block with given block-number.

Param Type Default
number string
[txInfo] boolean false

getblockcount() ⇒ Promise.<Object>

Returns the number of blocks in the longest block chain

getblockhash(index) ⇒ Promise.<Object>

Returns hash of block in best-block-chain at .

Param Type
index number

getblockinterval(period, windowSize, windowSpacing) ⇒ Promise.<Object>

Total block interval for the window in seconds

Param Type
period number
windowSize number
windowSpacing number

getblockintervalmean(period, windowSize, windowSpacing) ⇒ Promise.<Object>

RMSD of the block intervals for the window in seconds

Param Type
period string
windowSize string
windowSpacing string

getblockintervalrmsd(period, windowSize, windowSpacing) ⇒ Promise.<Object>

RMSD of the block intervals for the window in seconds

Param Type
period string
windowSize string
windowSpacing string

getblockschedule(blocks) ⇒ Promise.<Object>

Returns details of Stealthnodes in the block schedule

Param Type
blocks string

getcheckpoint() ⇒ Promise.<Object>

Show info of synchronized checkpoint.

getchildkey(extendedKey, child, [networkByte]) ⇒ Promise.<Object>

Returns key and address information about the child.

Param Type
extendedKey string
child number
[networkByte] string

getconnectioncount() ⇒ Promise.<Object>

Returns the number of connections to other nodes.

getdifficulty() ⇒ Promise.<Object>

Returns the difficulty as a multiple of the minimum difficulty.

gethashespersec() ⇒ Promise.<Object>

Returns a recent hashes per second performance measurement while generating.

gethdaccount(extendedKey) ⇒ Promise.<Object>

Returns all transactions for the hdaccount.

Param Type
extendedKey string

gethourlymissed(hours) ⇒ Promise.<Object>

Returns an object with an array of numbers that represent number of missed blocks in the last .

Param Type
hours number

getinfo() ⇒ Promise.<Object>

Returns an object containing various state info.

getmininginfo() ⇒ Promise.<Object>

Returns an object containing mining-related information.

getnewaddress([account]) ⇒ Promise.<Object>

Returns a new XST address for receiving payments. If [account] is specified (recommended), it is added to the address book so payments received with the address will be credited to [account].

Param Type
[account] string

getnewestblockbeforetime(time) ⇒ Promise.<Object>

Returns the hash of the newest block that has a time stamp earlier than is a unix epoch (seconds)

Param Type
time number

getnewpubkey([account]) ⇒ Promise.<Object>

Returns new public key for coinbase generation.

Param Type
[account] string

getnewstealthaddress([label]) ⇒ Promise.<Object>

Returns a new StealthAddress for receiving payments anonymously.

Param Type
[label] string

getpeerinfo() ⇒ Promise.<Object>

Returns data about each connected network node.

getpicopowermean(period, windowSize, windowSpacing) ⇒ Promise.<Object>

Returns an object with attributes: window_start: starting time of each window, number_blocks: number of blocks in each window, pico_power_mean: mean expressed in units of 1e-12 power".

Param Type
period number
windowSize number
windowSpacing number

getqposbalance(pubKey) ⇒ Promise.<Object>

Returns qPoS balance owned by

Param Type
pubKey string

getqposinfo([height]) ⇒ Promise.<Object>

Returns exhaustive qPoS information Optional [height] will get info as of that height (expensive)

Param Type
[height] number

getrawmempool() ⇒ Promise.<Object>

Returns all transaction ids in memory pool.

getrawtransaction(txId, [verbose]) ⇒ Promise.<Object>

If verbose=0, returns a string that is serialized, hex-encoded data for . If verbose is non-zero, returns an Object with information about .

Param Type Default
txId string
[verbose] number 0

getreceivedbyaccount(account, [minConf]) ⇒ Promise.<Object>

Returns the total amount received by addresses with in transactions with at least [minconf] confirmations.

Param Type Default
account string
[minConf] number 1

getreceivedbyaddress(XSTAddress, [minConf]) ⇒ Promise.<Object>

Returns the total amount received by in transactions with at least [minconf] confirmations.

Param Type Default
XSTAddress string
[minConf] number 1

getrecentqueue(blocks) ⇒ Promise.<Object>

is the number of blocks to look back. Returns a 1, 0 array, where 1 is hit and 0 is miss. The array is ordered chronologically.

Param Type Default
blocks number

getrichlist([start], [max]) ⇒ Promise.<Object>

Returns the number of addresses with balances greater than [minimum].

Param Type Default
[start] number 0
[max] number 10

getrichlistsize([minimum]) ⇒ Promise.<Object>

Returns the number of addresses with balances greater than [minimum].

Param Type Default
[minimum] number 0

getstakersbyid([disqualified]) ⇒ Promise.<Object>

Returns details of StealthNodes by ascending id. Optional [disqualified=false] includes disqualified stakers if true.

Param Type Default
[disqualified] bool false

getstakerid(alias) ⇒ Promise.<Object>

Returns the id of the staker registered with .

Param Type
alias string

getstakerinfo(alias) ⇒ Promise.<Object>

Returns exhaustive information about the qPoS registry. is a non-case sensitive staker alias.

Param Type
alias string

getstakerprice() ⇒ Promise.<Object>

Returns the current staker price.

getstakerpriceinfo() ⇒ Promise.<Object>

Returns staker price history and ROI information. is the number of stakers for which to calculate prices.

Param Type
stakers number

getstakersbyweight() ⇒ Promise.<Object>

Returns details of Stealthnodes in descending weight.

getstakersummary() ⇒ Promise.<Object>

Returns a summary of the state and activity of Stealthnodes.

getsubsidy([nTarget]) ⇒ Promise.<Object>

Returns proof-of-work subsidy value for the specified value of target.

Param Type
[nTarget] string

gettransaction(txId) ⇒ Promise.<Object>

Get detailed information about

Param Type
txId string

gettxvolume(period, windowSize, windowSpacing) ⇒ Promise.<Object>

Number of transactions in each window

Param Type
period number
windowSize number
windowSpacing number

getxstvolume(period, windowSize, windowSpacing) ⇒ Promise.<Object>

Amount of xst transferred in each window

Param Type
period number
windowSize number
windowSpacing number

help(command) ⇒ Promise.<Object>

List commands, or get help for a command.

Param Type
command string

importprivkey(XSTPrivateKey, [label]) ⇒ Promise.<Object>

Adds a private key (as returned by dumpprivkey) to your wallet.

Param Type
XSTPrivateKey string
[label] string

importstealthaddress(scanSecret, spendSecret, [label]) ⇒ Promise.<Object>

Import an owned StealthAddresses.

Param Type
scanSecret string
spendSecret string
[label] string

keypoolrefill([newSize]) ⇒ Promise.<Object>

Fills the keypool.

Param Type
[newSize] string

listaccounts([minConf]) ⇒ Promise.<Object>

Returns Object that has account names as keys, account balances as values.

Param Type Default
[minConf] number 1

listaddressgroupings() ⇒ Promise.<Object>

Lists groups of addresses which have had their common ownership made public by common use as inputs or as the resulting change in past transactions

listreceivedbyaccount([minConf], [includeEmpty]) ⇒ Promise.<Object>

Returns an array of objects containing:

  • "account" : the account of the receiving addresses
  • "amount" : total amount received by addresses with this account
  • "confirmations" : number of confirmations of the most recent transaction included
Param Type Default Description
[minConf] number 1 minimum number of confirmations before payments are included
[includeEmpty] boolean false whether to include addresses that haven't received any payments

listreceivedbyaddress([minConf], [includeEmpty]) ⇒ Promise.<Object>

Returns an array of objects containing:

  • "address" : receiving address
  • "account" : the account of the receiving address
  • "amount" : total amount received by the address
  • "confirmations" : number of confirmations of the most recent transaction included
Param Type Default Description
[minConf] number 1 minimum number of confirmations before payments are included
[includeEmpty] boolean false whether to include addresses that haven't received any payments

listsinceblock([blockHash], [targetConfirmations]) ⇒ Promise.<Object>

Get all transactions in blocks since block [blockHash], or all transactions if omitted

Param Type Default
[blockHash] string
[targetConfirmations] number 0

liststealthaddresses(showSecrets) ⇒ Promise.<Object>

List owned StealthAddresses.

Param Type
showSecrets string

listtransactions(account, count, from) ⇒ Promise.<Object>

Returns up to [count] most recent transactions skipping the first [from] transactions for account [account].

Param Type Default
account string
count number 10
from number 0

listunspent([minConf], [maxConf], [txOuts]) ⇒ Promise.<Object>

Returns array of unspent transaction outputs with between minConf and maxConf (inclusive) confirmations. Optionally filtered to only include txOuts paid to specified addresses. Results are an array of Objects, each of which has: {txId, vOut, scriptPubKey, amount, confirmations}

Param Type Default Description
[minConf] number 1
[maxConf] number 9999999
[txOuts] Array.<string> ["address",...]

makekeypair([prefix]) ⇒ Promise.<Object>

Make a public/private key pair. [prefix] is optional preferred prefix for the public key.

Param Type
[prefix] string

move(fromAccount, toAccount, amount, [minConf], [comment]) ⇒ Promise.<Object>

Move from one account in your wallet to another.

Param Type Default
fromAccount string
toAccount string
amount number
[minConf] number 1
[comment] string ""

purchasestaker(txId, vOut, alias, owner, [amount], [delegate], [controller], [payout]) ⇒ Promise.<Object>

Kind: global function

Param Type Description
txId string
vOut number
alias string
owner string
[amount] number is is the amount to pay If the amount is not specified it will be calculated automatically
[delegate] string and [controller] are compressed pubkeys If delegate and controller are not specified then they are taken from owner.
[controller] string
[payout] number is in percentage, and is rounded to the nearest thousandths of a percent Either just the owner key or all 3 keys plus the payout must be specified.

repairwallet() ⇒ Promise.<Object>

Repair wallet if checkwallet reports any problem.

resendtx() ⇒ Promise.<Object>

Re-send unconfirmed transactions.

reservebalance([reserve], [amount]) ⇒ Promise.<Object>

Set reserve amount not participating in network protection. If no parameters provided current setting is printed.

Param Type Default
[reserve] boolean
[amount] number 0

scanforalltxns([fromHeight]) ⇒ Promise.<Object>

Scan blockchain for owned transactions.

Param Type Default
[fromHeight] number 0

scanforstealthtxns([fromHeight]) ⇒ Promise.<Object>

Scan blockchain for owned stealth transactions.

Param Type Default
[fromHeight] number 0

sendalert(message, privateKey, minVer, maxVer, priority, id, [cancelUpTo]) ⇒ Promise.<Object>

Kind: global function

Param Type Description
message string alert text message
privateKey string hex string of alert master private key
minVer string minimum applicable internal client version
maxVer string maximum applicable internal client version
priority string integer priority number
id string alert id (id=0 canels all alerts except id=1 alerts)
[cancelUpTo] string cancels all alert id's up to this number

sendfrom(fromAccount, toXSTAddress, amount, [minConf], [comment], [commentTo]) ⇒ Promise.<Object>

Kind: global function

Param Type Default Description
fromAccount string
toXSTAddress string
amount number real and is rounded to the nearest 0.000001
[minConf] number 1
[comment] string ""
[commentTo] string ""

sendmany(fromAccount, addressAmount, [minConf], [comment]) ⇒ Promise.<Object>

Kind: global function

Param Type Default Description
fromAccount string
addressAmount object {address: amount,...} amounts are double-precision floating point numbers
[minConf] number 1
[comment] string ""

sendrawtransaction(hex) ⇒ Promise.<Object>

Submits raw transaction (serialized, hex-encoded) to local node and network.

Param Type
hex string

sendtoaddress(XSTAddress, amount, [comment], [commentTo]) ⇒ Promise.<Object>

Kind: global function

Param Type Default Description
XSTAddress string
amount number real and is rounded to the nearest 0.000001
[comment] string ""
[commentTo] string ""

sendtostealthaddress(address, amount, [narration], [comment], [commentTo]) ⇒ Promise.<Object>

Kind: global function

Param Type Default Description
address string
amount number real and is rounded to the nearest 0.000001
[narration] string ""
[comment] string ""
[commentTo] string ""

setaccount(XSTAddress, account) ⇒ Promise.<Object>

Sets the account associated with the given address.

Param Type
XSTAddress string
account string

setstakercontroller(txId, vOut, alias, controller) ⇒ Promise.<Object>

Kind: global function

Param Type Description
txId string transaction ID of the input
vOut number prevout index of the input
alias string non-case sensitive staker alias
controller string compressed pubkey

setstakerdelegate(txId, vOut, alias, delegate, payout) ⇒ Promise.<Object>

Kind: global function

Param Type Description
txId string transaction ID of the input
vOut number prevout index of the input
alias string on-case sensitive staker alias
delegate string compressed pubkey
payout string fraction of block rewards to pay to the delegate in millipercent

setstakermeta(txId, vOut, alias, key, value) ⇒ Promise.<Object>

Kind: global function

Param Type Description
txId string transaction ID of the input
vOut number prevout index of the input
alias string on-case sensitive staker alias
key string metadata key
value number metadata value

setstakerowner(txId, vOut, alias, owner) ⇒ Promise.<Object>

Kind: global function

Param Type Description
txId string transaction ID of the input
vOut number prevout index of the input
alias string on-case sensitive staker alias
owner string owners compressed pubkey

settxfee(amount) ⇒ Promise.<Object>

Kind: global function

Param Type Description
amount number is a real and is rounded to the nearest 0.01

signmessage(XSTAddress, message) ⇒ Promise.<Object>

Sign a message with the private key of an address

Param Type
XSTAddress string
message string

signrawtransaction(hex, transactions, privateKeys, [signHashTypes]) ⇒ Promise.<Object>

Sign inputs for raw transaction (serialized, hex-encoded).

Param Type Default
hex string
transactions Array.<object>
privateKeys Array.<string>
[signHashTypes] string "&quot;ALL&quot;"

stop(detach) ⇒ Promise.<Object>

Stop StalthCoin server (and possibly override the detachdb config value).

Param Type
detach boolean

validateaddress(XSTAddress) ⇒ Promise.<Object>

Return information about .

Param Type
XSTAddress string

validatepubkey(XSTPubKey) ⇒ Promise.<Object>

Return information about .

Param Type
XSTPubKey string

verifymessage(XSTAddress, signature, message) ⇒ Promise.<Object>

Verify a signed message

Param Type
XSTAddress string
signature string
message string

getcharacterspg(page, perPage, ordering) ⇒ Promise.<Object>

Verify a signed message

Param Type
page nubmer
perPage nubmer
ordering boolean

Package Sidebar

Install

npm i stealthjs-lib

Weekly Downloads

0

Version

0.5.6

License

MIT

Unpacked Size

86.2 kB

Total Files

11

Last publish

Collaborators

  • dekadentno
  • riimak
  • tibor.hudik
  • aussieboi
  • kpetrovic
  • thudik