0.5.6 • Published 2 years ago

stealthjs-lib v0.5.6

Weekly downloads
2
License
MIT
Repository
-
Last release
2 years ago

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

ParamType
methodstring
paramsArray.<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.

ParamTypeDefault
nRequirednumber
keysArray.<string>
accountstring""

backupwallet(destination) ⇒ Promise.<Object>

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

ParamType
destinationstring

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

ParamType
txIdstring
vOutnumber
amountnumber

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.

ParamTypeDescription
transactionsArray.<object>{"txid":txid,"vOut":n},...
addressesobject{address:amount,...}

decoderawtransaction(hex) ⇒ Promise.<Object>

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

ParamType
hexstring

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

Kind: global function

ParamTypeDescription
txIdstringtransaction ID of the input
vOutnumberprevout index of the input
aliasaliasnon-case sensitive staker alias

dumpprivkey(XSTAddress) ⇒ Promise.<Object>

Reveals the private key corresponding to .

ParamType
XSTAddressstring

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

ParamType
txIdstring
vOutnumber
aliasstring

encryptwallet(passphrase) ⇒ Promise.<Object>

Encrypts the wallet with

ParamType
passphrasestring

exitreplay() ⇒ Promise.<Object>

Manually exits registry replay (testnet only).

getaccount(XSTAddress) ⇒ Promise.<Object>

Returns the account associated with the given address.

ParamType
XSTAddressstring

getaccountaddress(account) ⇒ Promise.<Object>

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

ParamType
accountstring

getaddressbalance(address) ⇒ Promise.<Object>

Returns the balance of .

ParamType
addressstring

getaddressesbyaccount(account) ⇒ Promise.<Object>

Returns the list of addresses for the given account.

ParamType
accountstring

getaddressinfo(address) ⇒ Promise.<Object>

Returns info about .

ParamType
addressstring

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)

ParamTypeDefault
addressstring
startnumber1
maxnumber100

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).

ParamTypeDefault
addressstring
startnumber1
maxnumber100

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).

ParamTypeDefault
addressstring
startnumber1
maxnumber100

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.

ParamTypeDefault
accountstring
minConfnumber1

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.

ParamTypeDefault
hashstring
txInfobooleanfalse

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

Returns details of a block with given block-number.

ParamTypeDefault
numberstring
txInfobooleanfalse

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 .

ParamType
indexnumber

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

Total block interval for the window in seconds

ParamType
periodnumber
windowSizenumber
windowSpacingnumber

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

RMSD of the block intervals for the window in seconds

ParamType
periodstring
windowSizestring
windowSpacingstring

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

RMSD of the block intervals for the window in seconds

ParamType
periodstring
windowSizestring
windowSpacingstring

getblockschedule(blocks) ⇒ Promise.<Object>

Returns details of Stealthnodes in the block schedule

ParamType
blocksstring

getcheckpoint() ⇒ Promise.<Object>

Show info of synchronized checkpoint.

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

Returns key and address information about the child.

ParamType
extendedKeystring
childnumber
networkBytestring

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.

ParamType
extendedKeystring

gethourlymissed(hours) ⇒ Promise.<Object>

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

ParamType
hoursnumber

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.

ParamType
accountstring

getnewestblockbeforetime(time) ⇒ Promise.<Object>

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

ParamType
timenumber

getnewpubkey(account) ⇒ Promise.<Object>

Returns new public key for coinbase generation.

ParamType
accountstring

getnewstealthaddress(label) ⇒ Promise.<Object>

Returns a new StealthAddress for receiving payments anonymously.

ParamType
labelstring

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".

ParamType
periodnumber
windowSizenumber
windowSpacingnumber

getqposbalance(pubKey) ⇒ Promise.<Object>

Returns qPoS balance owned by

ParamType
pubKeystring

getqposinfo(height) ⇒ Promise.<Object>

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

ParamType
heightnumber

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 .

ParamTypeDefault
txIdstring
verbosenumber0

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

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

ParamTypeDefault
accountstring
minConfnumber1

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

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

ParamTypeDefault
XSTAddressstring
minConfnumber1

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.

ParamTypeDefault
blocksnumber

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

Returns the number of addresses with balances greater than minimum.

ParamTypeDefault
startnumber0
maxnumber10

getrichlistsize(minimum) ⇒ Promise.<Object>

Returns the number of addresses with balances greater than minimum.

ParamTypeDefault
minimumnumber0

getstakersbyid(disqualified) ⇒ Promise.<Object>

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

ParamTypeDefault
disqualifiedboolfalse

getstakerid(alias) ⇒ Promise.<Object>

Returns the id of the staker registered with .

ParamType
aliasstring

getstakerinfo(alias) ⇒ Promise.<Object>

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

ParamType
aliasstring

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.

ParamType
stakersnumber

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.

ParamType
nTargetstring

gettransaction(txId) ⇒ Promise.<Object>

Get detailed information about

ParamType
txIdstring

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

Number of transactions in each window

ParamType
periodnumber
windowSizenumber
windowSpacingnumber

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

Amount of xst transferred in each window

ParamType
periodnumber
windowSizenumber
windowSpacingnumber

help(command) ⇒ Promise.<Object>

List commands, or get help for a command.

ParamType
commandstring

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

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

ParamType
XSTPrivateKeystring
labelstring

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

Import an owned StealthAddresses.

ParamType
scanSecretstring
spendSecretstring
labelstring

keypoolrefill(newSize) ⇒ Promise.<Object>

Fills the keypool.

ParamType
newSizestring

listaccounts(minConf) ⇒ Promise.<Object>

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

ParamTypeDefault
minConfnumber1

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
ParamTypeDefaultDescription
minConfnumber1minimum number of confirmations before payments are included
includeEmptybooleanfalsewhether 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
ParamTypeDefaultDescription
minConfnumber1minimum number of confirmations before payments are included
includeEmptybooleanfalsewhether 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

ParamTypeDefault
blockHashstring
targetConfirmationsnumber0

liststealthaddresses(showSecrets) ⇒ Promise.<Object>

List owned StealthAddresses.

ParamType
showSecretsstring

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

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

ParamTypeDefault
accountstring
countnumber10
fromnumber0

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}

ParamTypeDefaultDescription
minConfnumber1
maxConfnumber9999999
txOutsArray.<string>"address",...

makekeypair(prefix) ⇒ Promise.<Object>

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

ParamType
prefixstring

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

Move from one account in your wallet to another.

ParamTypeDefault
fromAccountstring
toAccountstring
amountnumber
minConfnumber1
commentstring""

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

Kind: global function

ParamTypeDescription
txIdstring
vOutnumber
aliasstring
ownerstring
amountnumberis is the amount to pay If the amount is not specified it will be calculated automatically
delegatestringand controller are compressed pubkeys If delegate and controller are not specified then they are taken from owner.
controllerstring
payoutnumberis 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.

ParamTypeDefault
reserveboolean
amountnumber0

scanforalltxns(fromHeight) ⇒ Promise.<Object>

Scan blockchain for owned transactions.

ParamTypeDefault
fromHeightnumber0

scanforstealthtxns(fromHeight) ⇒ Promise.<Object>

Scan blockchain for owned stealth transactions.

ParamTypeDefault
fromHeightnumber0

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

Kind: global function

ParamTypeDescription
messagestringalert text message
privateKeystringhex string of alert master private key
minVerstringminimum applicable internal client version
maxVerstringmaximum applicable internal client version
prioritystringinteger priority number
idstringalert id (id=0 canels all alerts except id=1 alerts)
cancelUpTostringcancels all alert id's up to this number

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

Kind: global function

ParamTypeDefaultDescription
fromAccountstring
toXSTAddressstring
amountnumberreal and is rounded to the nearest 0.000001
minConfnumber1
commentstring""
commentTostring""

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

Kind: global function

ParamTypeDefaultDescription
fromAccountstring
addressAmountobject{address: amount,...} amounts are double-precision floating point numbers
minConfnumber1
commentstring""

sendrawtransaction(hex) ⇒ Promise.<Object>

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

ParamType
hexstring

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

Kind: global function

ParamTypeDefaultDescription
XSTAddressstring
amountnumberreal and is rounded to the nearest 0.000001
commentstring""
commentTostring""

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

Kind: global function

ParamTypeDefaultDescription
addressstring
amountnumberreal and is rounded to the nearest 0.000001
narrationstring""
commentstring""
commentTostring""

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

Sets the account associated with the given address.

ParamType
XSTAddressstring
accountstring

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

Kind: global function

ParamTypeDescription
txIdstringtransaction ID of the input
vOutnumberprevout index of the input
aliasstringnon-case sensitive staker alias
controllerstringcompressed pubkey

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

Kind: global function

ParamTypeDescription
txIdstringtransaction ID of the input
vOutnumberprevout index of the input
aliasstringon-case sensitive staker alias
delegatestringcompressed pubkey
payoutstringfraction of block rewards to pay to the delegate in millipercent

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

Kind: global function

ParamTypeDescription
txIdstringtransaction ID of the input
vOutnumberprevout index of the input
aliasstringon-case sensitive staker alias
keystringmetadata key
valuenumbermetadata value

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

Kind: global function

ParamTypeDescription
txIdstringtransaction ID of the input
vOutnumberprevout index of the input
aliasstringon-case sensitive staker alias
ownerstringowners compressed pubkey

settxfee(amount) ⇒ Promise.<Object>

Kind: global function

ParamTypeDescription
amountnumberis 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

ParamType
XSTAddressstring
messagestring

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

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

ParamTypeDefault
hexstring
transactionsArray.<object>
privateKeysArray.<string>
signHashTypesstring"\"ALL\""

stop(detach) ⇒ Promise.<Object>

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

ParamType
detachboolean

validateaddress(XSTAddress) ⇒ Promise.<Object>

Return information about .

ParamType
XSTAddressstring

validatepubkey(XSTPubKey) ⇒ Promise.<Object>

Return information about .

ParamType
XSTPubKeystring

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

Verify a signed message

ParamType
XSTAddressstring
signaturestring
messagestring

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

Verify a signed message

ParamType
pagenubmer
perPagenubmer
orderingboolean
0.5.6

2 years ago

0.5.3

3 years ago

0.5.2

3 years ago

0.5.1

3 years ago

0.4.0

4 years ago

0.3.0

4 years ago

0.2.9

4 years ago

0.2.8

4 years ago

0.2.7

4 years ago

0.2.6

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.1

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.0

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago