npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ultranotei-api

v4.1.0

Published

CJSI: UltraNoteI Javascript Interface - RPC/API

Downloads

25

Readme

UltraNoteI-API: Javascript/Node.js interface (RPC/API)

Javascript/Node.js interface to UltraNoteI cryptocurrency RPC/API.

There are three RPC servers built in to the three programs ultranoteid, ultranoteiwallet and walletd. They can each be started with the argument --help to display command line options.

ultranoteid

A node on the P2P network (daemon) with no wallet functions; console interactive. To launch:

$ ./ultranoteid

The default daemon RPC port is 43000 and the default P2P port is 42000.

walletd

A node on the P2P network (daemon) with wallet functions; console non-interactive. To launch, assuming that your my.wallet file is in the current directory:

$ ./walletd --container-file my.wallet --container-password PASSWD --local --bind-port 3333

The wallet functions RPC port is 3333. The default daemon P2P port is 42000. The default daemon RPC port is 43000. The --local option activates the daemon; otherwise, a remote daemon can be used.

ultranoteiwallet

A simple wallet; console interactive unless RPC server is running; requires access to a node daemon for full functionality. To launch, assuming that your my.wallet file is in the current directory:

$ ./ultranoteiwallet --rpc-bind-port 3333 --wallet-file my --password PASSWORD

The wallet functions RPC port is 3333. By default the wallet connects with the daemon on port 43000. It is possible to run several instances simultaneously using different wallets and ports.

Quick start for node.js

$ npm install ultranotei-api
$ ./ultranoteid # launch the network daemon
$ ./ultranoteiwallet --rpc-bind-port PORT --wallet-file my --password PASSWORD # launch the simple wallet

Create and run a test program.

$ node test.js

The test program could contain, for example, a payment via the simple wallet's RPC server

const XUNI = require('ultranotei-api')
const ccx = new XUNI({
  daemonHost: 'http://localhost', 
  walletHost: 'http://localhost', 
  daemonRpcPort: 43000,
  walletRpcPort: 3333
})

xuni.send([{
  address: 'xuni7Xd3NBbBiQNvv7vMLXmGMHyS8AVB6EhWoHo5EbGfR2Ki9pQnRTfEBt3YxYEVqpUCyJgvPjBYHp8N2yZwA7dqb4PjaGWuvs4',
  amount: 1234567
}])
.then((res) => { console.log(res) }) // display tx hash upon success
.catch((err) => { console.log(err) }) // display error message upon failure

API

const XUNI = require('ultranotei-api')
const xuni = new XUNI({
  daemonHost: <daemonHost>, 
  walletHost: <walletHost>,
  daemonRpcPort: <daemonRpcPort>,
  walletRpcPort: <walletRpcPort>,
  timeout: <timeout>
})

xuni.rpc returns a promise, where rpc is any of the methods below:

Wallet RPC (must provide walletRpcPort)

Get height (ultranoteiwallet)

xuni.height() // get last block height

Get balance (ultranoteiwallet)

xuni.balance() // get wallet balances

Get messages (ultranoteiwallet)

const opts = {
  firstTxId: FIRST_TX_ID, // (integer, optional), ex: 10
  txLimit: TX_LIMIT // maximum number of messages (integer, optional), ex: 10
}
xuni.messages(opts) // opts can be omitted

Get incoming payments (ultranoteiwallet)

const paymentId = PAYMENT_ID // (64-digit hex string, required), ex: '0ab1...3f4b'
xuni.payments(paymentId)

Get transfers (ultranoteiwallet)

xuni.transfers() // gets all transfers

Get number of unlocked outputs (ultranoteiwallet)

xuni.outputs() // gets outputs available as inputs for a new transaction

Reset wallet (ultranoteiwallet)

xuni.reset() // discard wallet cache and resync with block chain

Store wallet (ultranoteiwallet)

xuni.store() // save wallet cache to disk

Optimize wallet (ultranoteiwallet)

xuni.optimize() // combines many available outputs into a few by sending to self

Send transfers (ultranoteiwallet)

const transfers = [{ address: ADDRESS, amount: AMOUNT, message: MESSAGE }, ...] // ADDRESS = destination address (string, required), AMOUNT = raw XUNI (integer, required), MESSAGE = transfer message to be encrypted (string, optional)
const opts = {
  transfers: transfers, // (array, required), ex: [{ address: 'xuni7Xd...', amount: 1000, message: 'refund' }]
  fee: FEE, // (raw XUNI integer, optional, default is minimum required), ex: 10
  anonimity: MIX_IN, // input mix count (integer, optional, default 2), ex: 6
  paymentId: PAYMENT_ID, // (64-digit hex string, optional), ex: '0ab1...3f4b'
  unlockHeight: UNLOCK_HEIGHT // block height to unlock payment (integer, optional), ex: 12750
}
xuni.send(opts)

Reset or replace wallet (walletd)

const viewSecretKey = VIEW_SECRET_KEY // (64-digit hex string, optional), ex: '0ab1...3f4b'
xuni.resetOrReplace(viewSecretKey) // If no key, wallet is re-synced. If key, a new address is created from the key for a new wallet.

Get status (walletd)

xuni.status()

Get balance (walletd)

const address = ADDRESS // (string, required), ex: 'xuni7Xd...'
xuni.getBalance(address)

Create address (walletd)

xuni.createAddress()

Delete address (walletd)

const address = ADDRESS // (string, required), ex: 'xuni7Xd...'
xuni.deleteAddress(address)

Get addresses (walletd)

xuni.getAddresses()

Get view secret key (walletd)

xuni.getViewSecretKey()

Get spend keys (walletd)

const address = ADDRESS // (string, required), ex: 'xuni7Xd...'
xuni.getSpendKeys(address)

Get block hashes (walletd)

const firstBlockIndex = FIRST_BLOCK_INDEX // index of first block (integer, required), ex: 12750
const blockCount = BLOCK_COUNT // number of blocks to include (integer, required), ex: 30
xuni.getBlockHashes(firstBlockIndex, blockCount)

Get transaction (walletd)

const hash = HASH // (64-digit hex string, required), ex: '0ab1...3f4b'
xuni.getTransaction(hash) // get transaction details given hash

Get unconfirmed transactions (walletd)

const addresses = [ADDRESS1, ADDRESS2, ...] // ADDRESS = address string; address to include
xuni.getUnconfirmedTransactions(addresses) // addresses can be omitted

Get transactionHashes (walletd)

const opts = { // either blockHash or firstBlockIndex is required
  blockHash: BLOCK_HASH, // hash of first block (64-digit hex string, see comment above), ex: '0ab1...3f4b'
  firstBlockIndex: FIRST_BLOCK_INDEX, // index of first block (integer, see comment above), ex: 12750
  blockCount: BLOCK_COUNT, // number of blocks to include (integer, required), ex: 30
  addresses: [ADDRESS, ...], filter (array of address strings, optional), ex: ['xuni7Xd...']
  paymentId: PAYMENT_ID // filter (64-digit hex string, optional), ex: '0ab1...3f4b'
}
xuni.getTransactionHashes(opts)

Get transactions (walletd)

const opts = { // either blockHash or firstBlockIndex is required
  blockHash: BLOCK_HASH, // hash of first block (64-digit hex string, see comment above), ex: '0ab1...3f4b'
  firstBlockIndex: FIRST_BLOCK_INDEX, // index of first block (integer, see comment above), ex: 12750
  blockCount: BLOCK_COUNT, // number of blocks to include (integer, required), ex: 30
  addresses: [ADDRESS, ...], filter (array of address strings, optional), ex: ['xuni7Xd...']
  paymentId: PAYMENT_ID // filter (64-digit hex string, optional), ex: '0ab1...3f4b'
}
xuni.getTransactions(opts)

Send transaction (walletd)

const transfers = [{ address: ADDRESS, amount: AMOUNT, message: MESSAGE }, ...] // ADDRESS = destination address (string, required), AMOUNT = raw XUNI (integer, required), MESSAGE = transfer message to be encrypted (string, optional)
const addresses = [ADDRESS1, ADDRESS2, ...] // ADDRESS = source address string; address in wallet to take funds from
const opts = {
  transfers: transfers, // (array, required), ex: [{ address: 'xuni7Xd...', amount: 1000, message: 'tip' }]
  addresses: addresses, // (array, optional), ex: ['xuni7Xd...', 'xuni7Xe...']
  changeAddress: ADDRESS, // change return address (address string, optional if only one address in wallet or only one source address given), ex: 'xuni7Xd...'
  paymentId: PAYMENT_ID, // filter (64-digit hex string, optional), ex: '0ab1...3f4b'
  anonimity: MIX_IN, // input mix count (integer, optional, default 2), ex: 6
  fee: FEE, // (raw XUNI integer, optional, default is minimum required), ex: 10
  unlockHeight: UNLOCK_HEIGHT, // block height to unlock payment (integer, optional), ex: 12750
  extra: EXTRA // (variable length string, optional), ex: '123abc'
}
xuni.sendTransaction(opts)

Create delayed transaction (walletd)

const transfers = [{ address: ADDRESS, amount: AMOUNT, message: MESSAGE }, ...] // ADDRESS = destination address (string, required), AMOUNT = raw XUNI (integer, required), MESSAGE = transfer message to be encrypted (string, optional)
const addresses = [ADDRESS1, ADDRESS2, ...] // ADDRESS = source address string; address in wallet to take funds from
const opts = {
  transfers: transfers, // (array, required), ex: [{ address: 'xuni7Xd...', amount: 1000, message: 'tip' }]
  addresses: addresses, // (array, optional), ex: ['xuni7Xd...', 'xuni7Xe...']
  changeAddress: ADDRESS, // change return address (address string, optional if only one address in wallet or only one source address given), ex: 'xuni7Xd...'
  paymentId: PAYMENT_ID, // filter (64-digit hex string, optional), ex: '0ab1...3f4b'
  anonimity: MIX_IN, // input mix count (integer, optional, default 2), ex: 6
  fee: FEE, // (raw XUNI integer, optional, default is minimum required), ex: 10
  unlockHeight: UNLOCK_HEIGHT, // block height to unlock payment (integer, optional), ex: 12750
  extra: EXTRA // (variable length string, optional), ex: '123abc'
}
xuni.createDelayedTransaction(opts) // create but do not send transaction

Get delayed transaction hashes (walletd)

xuni.getDelayedTransactionHashes()

Delete delayed transaction (walletd)

const hash = HASH // (64-digit hex string, required), ex: '0ab1...3f4b'
xuni.deleteDelayedTransaction(hash)

Send delayed transaction (walletd)

const hash = HASH // (64-digit hex string, required), ex: '0ab1...3f4b'
xuni.sendDelayedTransaction(hash)

Get incoming messages from transaction extra field (walletd)

const extra = EXTRA // (hex string, required), ex: '0199...c3ca'
xuni.getMessagesFromExtra(extra)

Daemon RPC (must provide daemonRpcPort)

Get info

xuni.info() // get information about the block chain, including next block height

Get index

xuni.index() // get next block height

Get count

xuni.count() // get next block height

Get currency ID

xuni.currencyId()

Get block hash by height

const height = HEIGHT // (integer, required), ex: 12750
xuni.blockHashByHeight(height) // get block hash given height

Get block header by height

const height = HEIGHT // (integer, required), ex: 12750
xuni.blockHeaderByHeight(height) // get block header given height

Get block header by hash

const hash = HASH // (64-digit hex string, required), ex: '0ab1...3f4b'
xuni.blockHeaderByHash(hash) // get block header given hash

Get last block header

xuni.lastBlockHeader()

Get block

const hash = HASH // (64-digit hex string, required), ex: '0ab1...3f4b'
xuni.block(hash)

Get blocks

const height = HEIGHT // (integer, required), ex: 12750
xuni.blocks(height) // returns 31 blocks up to and including HEIGHT

Get block template

const address = ADDRESS // destination address (string, required), ex: 'xuni7Xd...'
const reserveSize = RESERVE_SIZE // bytes to reserve in block for work, etc. (integer < 256, optional, default 14), ex: 255
const opts = {
  address: address,
  reserveSize: reserveSize
}
xuni.blockTemplate(opts)

Submit block

const block = BLOCK // block blob (hex string, required), ex: '0300cb9eb...'
xuni.submitBlock(block)

Get transaction

const hash = HASH // (64-digit hex string, required), ex: '0ab1...3f4b'
xuni.transaction(hash)

Get transactions

const arr = [HASH1, HASH2, ...] // (array of 64-digit hex strings, required), ex: ['0ab1...3f4b']
xuni.transactions(arr)

Get transaction pool

xuni.transactionPool()

Send raw transaction

const transaction = TRANSACTION // transaction blob (hex string, required), ex: ''01d86301...'
xuni.sendRawTransaction(transaction)