Skip to content
krumblez edited this page Apr 16, 2019 · 1 revision

Table of Contents

Overview

The "raw transaction API" gives developers or very sophisticated end-users low-level access to transaction creation and broadcast.

JSON-RPC API

listunspent [minconf=1] [maxconf=999999]

Returns an array of unspent transaction outputs in the wallet that have between minconf and maxconf (inclusive) confirmations. Each output is a 5-element object with keys: txid, output, scriptPubKey, amount, confirmations. txid is the hexadecimal transaction id, output is which output of that transaction, scriptPubKey is the hexadecimal-encoded CScript for that output, amount is the value of that output and confirmations is the transaction's depth in the chain.

lockunspent unlock? [{"txid":txid,"vout":n},...]

Temporarily lock (unlock=false) or unlock (unlock=true) specified transaction outputs. A locked transaction output will not be chosen by automatic coin selection, when spending bitcoins. Locks are stored in memory only. Nodes start with zero locked outputs, and the locked output list is always cleared (by virtue of process exit) when a node stops or fails.

listlockunspent

List all temporarily locked transaction outputs.

createrawtransaction [{"txid":txid,"vout":n},...] {address:amount,...}

Create a transaction spending given inputs (array of objects containing transaction outputs to spend), sending to given address(es). Returns the hex-encoded transaction in a string. Note that the transaction's inputs are not signed, and it is not stored in the wallet or transmitted to the network.

Also note that NO transaction validity checks are done; it is easy to create invalid transactions or transactions that will not be relayed/mined by the network because they contain insufficient fees.

decoderawtransaction

Returns JSON object with information about a serialized, hex-encoded transaction.

getrawtransaction [verbose=0]

If verbose=0, returns serialized, hex-encoded data for transaction txid. If verbose is non-zero, returns a JSON Object containing information about the transaction. Returns an error if is unknown.

signrawtransaction [{"txid":txid,"vout":n,"scriptPubKey":hex},...] [,...] [sighash="ALL"]

Sign as many inputs as possible for raw transaction (serialized, hex-encoded). The first argument may be several variations of the same transaction concatenated together; signatures from all of them will be combined together, along with signatures for keys in the local wallet. The optional second argument is an array of parent transaction outputs, so you can create a chain of raw transactions that depend on each other before sending them to the network. Third optional argument is an array of base58-encoded private keys that, if given, will be the only keys used to sign the transaction. The fourth optional argument is a string that specifies how the OP CHECKSIG is computed, and can be "ALL", "NONE", "SINGLE", "ALL|ANYONECANPAY", "NONE|ANYONECANPAY", or "SINGLE|ANYONECANPAY". Returns json object with keys:

  • hex : raw transaction with signature(s) (hex-encoded string)
  • complete : 1 if rawtx is completely signed, 0 if signatures are missing. If no private keys are given and the wallet is locked, requires that the wallet be unlocked with walletpassphrase first.

sendrawtransaction

Submits raw transaction (serialized, hex-encoded) to local node and network. Returns transaction id, or an error if the transaction is invalid for any reason.

Motivating use cases

Multisignature transactions

Funds are sitting in one or more multisignature transaction outputs, and it is time to gather signatures and spend them.

Assumption: you know the multisignature outputs' {txid, outputNumber, amount}.

  • Create a raw transaction to spend, using createrawtransaction.
  • Use signrawtransaction to add your signatures (after unlocking the wallet, if necessary).
  • Give the transaction to the other person(s) to sign.
  • You or they submit the transaction to the network using sendrawtransaction. You must be careful to include an appropriate transaction fee or the sendrawtransaction method is likely to fail (either immediately or, worse, the transaction will never confirm).

Debugging/testing

These lower-level routines will be useful for debugging and testing; listunspent gives a detailed list of the state of the wallet, and sendrawtx might be used to test double-spend-handling.

Input selection control

You want fine-grained control over exactly what coins in the wallet are spent.

  • Get a list of not-yet-spent outputs with listunspent
  • Create a transaction using createrawtransaction
  • Apply signatures using signrawtransaction
  • Submit it using sendrawtransaction Note that you are responsible for preventing accidental double-spends.

Control over payment of fees and/or transaction re-transmission

You want to specify, on a per-transaction basis, how much to pay in fees. Or you want to implement your own policy for how often transactions that are not immediately included in blocks are re-broadcast to the network.

  • Maintain a list of not-yet-spent, confirmed outputs with listunspent (refreshed every time a new block is found, using the -blocknotify feature).
  • Create a transaction with exactly the amount of fees you wish with createrawtransaction
  • Apply signatures using signrawtransaction
  • Submit it with sendrawtransaction
  • Re-submit it periodicially with sendrawtransaction if it does not get into a block.

Other, non-obvious use cases

Re-broadcast a transaction

If you want to re-broadcast a transaction right away, you can use the getrawtransaction and sendrawtransaction API calls to do that. As a bash shell-script one-liner it would be:

  • sendrawtransaction $(getrawtransaction $TXID) (note that Bitcoin-Qt/bitcoind automatically re-transmit wallet transactions periodically until they are accepted into a block).

Validate a transaction without broadcasting it

If you have a raw transaction and want to make sure all of its signatures are correct, you can use the signrawtransaction API call. Pass in the hex-encoded raw transaction, any inputs that bitcoind doesn't yet know about, and an empty array of private keys to use to sign the transaction. Passing an empty array of private keys will prevent signrawtransaction from doing any signing; if it returns "complete":1 then all of the existing signatures are valid and there are no signatures missing.

See Also

ION coin Qt and Daemon Info

Builds

HOW TO: Compile iond Daemon from source

HOW TO: Compile the ION QT wallet on Ubuntu

Snapcraft installs

Install ION client in a snap

Upgrade

HOW TO: Upgrade to ION 5.0

ION Masternodes

ION Masternode FAQ

HOW TO: ION 5.0 Masternode Quickstart Guide

HOW TO: Setup ION 5.0 remote Masternode with Ubuntu remote and local QT wallet(DASH-Rebase)

ION coincore QT wallet ELECTRON MINING

Mining ION coin ELECTRON tokens with Proof of Work

ionomy Sharenodes

ionomy Zendesk hosted Sharenodes and dedicated Masternodes FAQ

ION Chain Token System

Atomic Token Protocol (ATP) Overview

ION Token system Basic Operations

UseCases tokens Create-New-Token

UseCases tokens Send-tokens

UseCases tokens Token-balance

UseCases tokens View-token-information

Testing ION tokens on regtest

UseCases regtest Start-regtest

UseCases regtest Access Token Management Key

ION Token group management

UseCases tokens Key-rotation-with-token-authorities

Create and distribute the XDM token according to the IEO

UseCases tokens Create-Management-Tokens

UseCases tokens Drop-token-mint-capability

UseCases tokens Find-token-authorities

General FAQ

How to backup my wallet and its data

How to: backup ION coin blockchain database

HOW TO: Export Private Keys from ION QT

HOW TO: Import private key to ION 3.0 Wallet

How to generate an onion privacy address

Multisend

User-Documentation

Accounts-Explained

ION-coin-Data-Directory

Raw-Transactions

Running-ION

Gitian

Gitian Building

Gitian-building-create-VM-Debian

Gitian-building-create-Debian-VMware

Gitian-building-create-VM-Fedora

Gitian-building-setup-Gitian-Debian

Gitian-building-setup-Gitian-Debian-Google-Console

Gitian-building-setup-Gitian-Debian-Google-Console-Create-instance-template

Gitian-building-setup-Gitian-Debian-Google-Console-Create-VM-from-template

Gitian-building-setup-Gitian-Fedora

Zerocoin

HOW TO: Convert Zerocoin xION to ION

How to: Backup and restore xION Zerocoin private seed

Developer-Documentation

API-Calls-List

API-Reference-JSON-RPC

Weekly Play to Win ION coin mobile gaming tournaments

How do I get involved

ionomy extra info

XDM DarkMatter IEO

ionomy Support Help Centre

ionomy web links and info

ION coin Technical Whitepaper

ion coin Bounty Procedures

ionomy Bounty Information

ionomy ION current events

Clone this wiki locally