Transactions

From Nxtwiki
Jump to: navigation, search

Broadcast Transaction

Broadcast a transaction to the network. POST only.

Request:

  • requestType is broadcastTransaction
  • transactionBytes is the bytecode of a signed transaction (optional)
  • transactionJSON is the transaction object (optional if transactionBytes provided)
  • prunableAttachmentJSON is the attachment object embedded in transactionJSON containing a prunable message (required if transactionJSON not provided because transactionBytes never includes prunable data)

Response:

  • requestProcessingTime (N) is the API request processing time (in millisec)
  • fullHash (S) is the full hash of the signed transaction
  • transaction (S) is the transaction ID

Broadcast Transaction Example

http://localhost:7876/nxt?
  requestType=broadcastTransaction&
  transactionBytes=001046aac6013c0057fb6f3a958e320bb49c4e81b4c2cf28b9f25d086c143...
{
 "requestProcessingTime": 4,
 "fullHash": "3a304584f20cf3d2cbbdd9698ff9a166427005ab98fbe9ca4ad6253651ee81f1",
 "transaction": "15200507403046301754"
}


Calculate Full Hash

Calculate the full hash of a transaction.

Request:

  • requestType is calculateFullHash
  • unsignedTransactionJSON is the unsigned transaction JSON object (optional)
  • unsignedTransactionBytes are the unsigned bytes of a transaction (optional if unsignedTransactionJSON is provided)
  • signatureHash is a SHA-256 hash of the transaction signature

Response:

  • requestProcessingTime (N) is the API request processing time (in millisec)
  • fullHash (S) is the full hash of the signed transaction

Calculate Full Hash Example

http://localhost:7876/nxt?
  requestType=calculateFullHash&
  unsignedTransactionBytes=001046aac6013c0057fb6f3a958e320bb49c4e81b4c2cf28b9f2...&
  signatureHash=b35eae7d2f01639810d37694138aa0a86fbbf8a9bf58c2be4f2a5b8f0f30b3f7
{
 "requestProcessingTime": 1,
 "fullHash": "3a304584f20cf3d2cbbdd9698ff9a166427005ab98fbe9ca4ad6253651ee81f1"
}


Get Expected Transactions

Returns the non-phased unconfirmed transactions expected to be included in the next block (only), plus the phased transactions scheduled to finish in that block (whether approved or not).

Request:

  • requestType is getExpectedTransactions
  • account is one account ID (optional)
  • account is one account ID (optional)

  • requireBlock is the block ID of a block that must be present in the blockchain during execution (optional)
  • requireLastBlock is the block ID of a block that must be last in the blockchain during execution (optional)

Response:

  • expectedTransactions (A) is an array of expected transactions (refer to Get Transaction for details)
  • requestProcessingTime (N) is the API request processing time (in millisec)

Get Expected Transactions Example

http://localhost:7876/nxt?
  requestType=getExpectedTransactions&
  account=NXT-X5A4-FTMJ-J97M-F3ANH
{
 "expectedTransactions": [
 {
   "senderPublicKey": "aaf2ffc347dae1442f218c17ff9ae1e917ab32af0af779360737f6faf7a4023e",
   "signature": "58720e3cb6cd4a9ad1dcb0bede55952e624b02a125aa0ac5934d7312cf87660147b495...",
   "feeNQT": "100000000",
   "type": 2,
   "fullHash": "79df9c85bc30f4a72c5d1899ce57b6533f321e1412f433fc3975cd4142a3c781",
   "version": 1,
   "phased": false,
   "ecBlockId": "17663518922057624367",
   "signatureHash": "687701be20bfb0935b3165ae31c08b685a173be660a9720ed0319ec17cc646eb",
   "attachment": {
    "quantityQNT": "5",
    "priceNQT": "908000000",
    "asset": "8122396658538927693",
    "version.BidOrderPlacement": 1
   },
   "senderRS": "NXT-X5A4-FTMJ-J97M-F3ANH",
   "subtype": 3,
   "amountNQT": "0",
   "sender": "15551212561974070530",
   "ecBlockHeight": 820879,
   "deadline": 1440,
   "transaction": "12102351684905000825",
   "timestamp": 80248727,
   "height": 2147483647
  }
 ],
 "requestProcessingTime": 1
}


Get Referencing Transactions

Gets the transactions referencing a given transaction id.

Request:

  • requestType is getReferencingTransactions
  • transaction is one transaction ID
  • firstIndex is a zero-based index to the first block ID to retrieve (optional)
  • lastIndex is a zero-based index to the last block ID to retrieve (optional)
  • requireBlock is the block ID of a block that must be present in the blockchain during execution (optional)
  • requireLastBlock is the block ID of a block that must be last in the blockchain during execution (optional)

Response:

  • transactions (A) is an array of transactions (refer to Get Transaction for details)
  • requestProcessingTime (N) is the API request processing time (in millisec)

Get Referencing Transactions Example

http://localhost:7876/nxt?
  requestType=getReferencingTransactions&
  transaction=9132239833429154693
{
 "requestProcessingTime": 1,
 "transactions": [
  {
   "senderPublicKey": "36bb17bc15678804a95ed895d524bb361aa5dfc4e78a800901aefff783f48010",
   "signature": "f39849eee16cd534f86915e22bd41d91fd6e965278242c957422196454deb705aa4...",
   "feeNQT": "100000000",
   "transactionIndex": 0,
   "type": 1,
   "confirmations": 216565,
   "fullHash": "c96b60bafc581891be88eae695f773677fe3cf7322cc149831d70de046041ea7",
   "version": 1,
   "phased": false,
   "ecBlockId": "1861841686166492176",
   "referencedTransactionFullHash": "859b376bbe3bbc7ebd5520d0d3fd20256f921e4c6bc3e...",
   "signatureHash": "0ed3aaabc682d4b5242b69930c0f659b62776b92bc2eecc40e37c895c5260eb4",
   "attachment": {
    "version.Message": 1,
    "messageIsText": true,
    "message": "],\"type\":\"payment\",\"oracles\":[{\"name\":\"nayru\"}]}",
    "version.ArbitraryMessage": 0
   },
   "senderRS": "NXT-DRGK-5CLR-35AZ-84R5R",
   "subtype": 0,
   "amountNQT": "0",
   "sender": "7750380612824194513",
   "ecBlockHeight": 614622,
   "block": "13844289828761736561",
   "blockTimestamp": 67496993,
   "deadline": 1440,
   "transaction": "10455204377422490569",
   "timestamp": 67496806,
   "height": 614629
  }
 ]
}


Get Transaction

Get a transaction object given a transaction ID.

Request:

  • requestType is getTransaction
  • transaction is the transaction ID (optional)
  • fullHash is the full hash of the transaction (optional if transaction ID is provided)
  • includePhasingResult is true to retrieve execution status of each phased transaction (optional)
  • requireBlock is the block ID of a block that must be present in the blockchain during execution (optional)
  • requireLastBlock is the block ID of a block that must be last in the blockchain during execution (optional)

Response:

  • sender (S) is the account ID of the sender
  • senderRS (S) is the Reed-Solomon address of the sender
  • feeNQT (S) is the fee (in NQT) of the transaction
  • amountNQT (S) is the amount (in NQT) of the transaction
  • transactionIndex (N) is a zero-based index giving the order of the transaction in its block
  • timestamp (N) is the time (in seconds since the genesis block) of the transaction
  • referencedTransactionFullHash (S) is the full hash of a transaction referenced by this one, omitted if no previous transaction is referenced
  • confirmations (N) is the number of transaction confirmations
  • subtype (N) is the transaction subtype (refer to Get Constants for a current list of subtypes)
  • block (S) is the ID of the block containing the transaction
  • blockTimestamp (N) is the timestamp (in seconds since the genesis block) of the block
  • height (N) is the height of the block in the blockchain
  • senderPublicKey (S) is the public key of the sending account for the transaction
  • type (N) is the transaction type (refer to Get Constants for a current list of types)
  • deadline (N) is the deadline (in minutes) for the transaction to be confirmed
  • signature (S) is the digital signature of the transaction
  • recipient (S) is the account number of the recipient, if applicable
  • recipientRS (S) is the Reed-Solomon address of the recipient, if applicable
  • fullHash (S) is the full hash of the signed transaction
  • signatureHash (S) is a SHA-256 hash of the transaction signature
  • approved (B) is a boolean indicating if the transaction is approved (only included when includePhasingResult is true and the transaction is phased)
  • result (S) is a string containing the result of the transaction (only included when includePhasingResult is true and the transaction is phased)
  • executionHeight (N) is the height the transaction was executed (only included when includePhasingResult is true and the transaction is phased)
  • transaction (S) is the transaction ID
  • version (N) is the transaction version number
  • phased (B) is true if the transaction is phased, false otherwise
  • ecBlockId (N) is the economic clustering block ID
  • ecBlockHeight (N) is the economic clustering block height
  • attachment (O) is an object containing any additional data needed for the transaction, if applicable
  • lastBlock (S) is the last block ID on the blockchain (applies if requireBlock is provided but not requireLastBlock)
  • requestProcessingTime (N) is the API request processing time (in millisec)

Note: The block, blockTimestamp and confirmations fields are omitted for unconfirmed transactions. Double-spending transactions are not retrieved.

Get Transaction Example

http://localhost:7876/nxt?
  requestType=getTransaction&
  transaction=15200507403046301754
{
 "senderPublicKey": "57fb6f3a958e320bb49c4e81b4c2cf28b9f25d086c143b473beec228f79ff93c",
 "signature": "5f0378b7390ff5a815eadd1354de533eef682f139362b153576e2207320a6...",
 "feeNQT": "100000000",
 "transactionIndex": 2,
 "requestProcessingTime": 2842,
 "type": 0,
 "confirmations": 849,
 "fullHash": "3a304584f20cf3d2cbbdd9698ff9a166427005ab98fbe9ca4ad6253651ee81f1",
 "version": 1,
 "ecBlockId": "17321329645912574173",
 "signatureHash": "b35eae7d2f01639810d37694138aa0a86fbbf8a9bf58c2be4f2a5b8f0f30b3f7",
 "senderRS": "NXT-L6FM-89WK-VK8P-FCRBB",
 "subtype": 0,
 "amountNQT": "100000000",
 "sender": "15323192282528158131",
 "recipientRS": "NXT-4VNQ-RWZC-4WWQ-GVM8S",
 "recipient": "17013046603665206934",
 "ecBlockHeight": 275727,
 "block": "8455642159445842600",
 "blockTimestamp": 29797208,
 "deadline": 60,
 "transaction": "15200507403046301754",
 "timestamp": 29796934,
 "height": 275730
}


Get Transaction Bytes

Get the bytecode of a transaction.

Request:

  • requestType is getTransactionBytes
  • transaction is a transaction ID
  • requireBlock is the block ID of a block that must be present in the blockchain during execution (optional)
  • requireLastBlock is the block ID of a block that must be last in the blockchain during execution (optional)

Response:

  • confirmations (N) is the number of transaction confirmations
  • transactionBytes (S) are the bytes contained in the transaction
  • unsignedTransactionBytes (S) are the unsigned bytes contained in the transaction
  • prunableAttachmentJSON (O) is the prunable attachment JSON object, if applicable, because transactionBytes never includes prunable data
  • lastBlock (S) is the last block ID on the blockchain (applies if requireBlock is provided but not requireLastBlock)
  • requestProcessingTime (N) is the API request processing time (in millisec)

Get Transaction Bytes Example

http://localhost:7876/nxt?
  requestType=getTransactionBytes&
  transaction=15200507403046301754
{
 "unsignedTransactionBytes": "001046aac6013c0057fb6f3a958e320bb49c4e81b4c2cf28b9f25d086c143b473...",
 "requestProcessingTime": 66,
 "confirmations": 1019,
 "transactionBytes": "001046aac6013c0057fb6f3a958e320bb49c4e81b4c2cf28b9f25d086c143b473..."
}


Parse Transaction

Get a transaction object given a (signed or unsigned) transaction bytecode, or re-parse a transaction object. Verify the signature.

Request:

  • requestType is parseTransaction
  • transactionBytes is the signed or unsigned bytecode of the transaction (optional)
  • transactionJSON is the transaction object (optional if transactionBytes is included)
  • requireBlock is the block ID of a block that must be present in the blockchain during execution (optional)
  • requireLastBlock is the block ID of a block that must be last in the blockchain during execution (optional)

Response: Refer to Get Transaction for additional fields.

  • verify (B) is true if the signature is verified, false otherwise

Parse Transaction Example

http://localhost:7876/nxt?
  requestType=parseTransaction&
  transactionBytes=001046aac6013c0057fb6f3a958e320bb49c4e81b4c2cf28b9f25d086c143...
{
 "senderPublicKey": "57fb6f3a958e320bb49c4e81b4c2cf28b9f25d086c143b473beec228f79ff93c",
 "signature": "5f0378b7390ff5a815eadd1354de533eef682f139362b153576e2207320a6...",
 "feeNQT": "100000000",
 "requestProcessingTime": 2,
 "type": 0,
 "fullHash": "3a304584f20cf3d2cbbdd9698ff9a166427005ab98fbe9ca4ad6253651ee81f1",
 "version": 1,
 "ecBlockId": "17321329645912574173",
 "signatureHash": "b35eae7d2f01639810d37694138aa0a86fbbf8a9bf58c2be4f2a5b8f0f30b3f7",
 "senderRS": "NXT-L6FM-89WK-VK8P-FCRBB",
 "subtype": 0,
 "amountNQT": "100000000",
 "sender": "15323192282528158131",
 "recipientRS": "NXT-4VNQ-RWZC-4WWQ-GVM8S",
 "recipient": "17013046603665206934",
 "ecBlockHeight": 275727,
 "verify": true,
 "deadline": 60,
 "transaction": "15200507403046301754",
 "timestamp": 29796934,
 "height": 2147483647
}


Retrieve Pruned Transaction

Force retrieval of the prunable data for a given transaction, even if past the configured nxt.maxPrunableLifetime.

Request:

  • requestType is retrievePrunedTransaction
  • transaction is transaction ID

Response: Refer to Get Transaction for fields.

Retrieve Pruned Transaction Example

http://localhost:7876/nxt?
  requestType=retrievePrunedTransaction&
  transaction=9343032000583494722
{
 "senderPublicKey": "7c94b068c95edcaf6ad588cda8784c7c27421ac334be092a6b487885f40f4f0c",
 "signature": "a4b4b7829b90ae0aa6c6654d364d23b335c64383bacc0e518b5aa1f2746de706121d308ae11244bf0933eddaed170c958bb9520700d63a7ed9ab30eb766717ca",
 "feeNQT": "320000000",
 "transactionIndex": 0,
 "requestProcessingTime": 0,
 "type": 6,
 "confirmations": 41543,
 "fullHash": "42ece25f1a1ea9815a7e6856635c323810efd2a38686bd57b7241fce28841da0",
 "version": 1,
 "phased": false,
 "ecBlockId": "11517076094591827523",
 "signatureHash": "5202c62fafb4b990313f03cf8882c2bad73c7888790794bb8c46a186abfc34ca",
 "attachment": {
  "filename": "7dba799bc6d4439191f89a88a9e50dad.jpg",
  "data": "ffd8ffe000104a46494600010100000100010000ffdb00430003050805050404050a07070...",
  "name": "Darkwing Duck",
  "channel": "Darkwing Duck",
  "description": "Darkwing Duck",
  "type": "image/jpeg",
  "version.TaggedDataUpload": 1,
  "isText": false,
  "hash": "5fb2f476f2556d15e4d419c6ff10bdbd05a7c5284242eba67c4de1adaee185a2",
  "tags": "Darkwing Duck"
 },
 "senderRS": "NXT-K8HZ-VMMS-ZX8E-EY5JR",
 "subtype": 0,
 "amountNQT": "0",
 "sender": "14681874272470211071",
 "ecBlockHeight": 788531,
 "block": "17859315470736709713",
 "blockTimestamp": 78307385,
 "deadline": 1440,
 "transaction": "9343032000583494722",
 "timestamp": 78307322,
 "height": 788546
}


Send Transaction

It broadcasts a transaction to the network without validating it, without re-broadcasting it and without adding it locally as unconfirmed transaction. Specially intended for roaming or light clients to send transactions to remote peers. POST only.

Request:

  • requestType is sendTransaction
  • transactionBytes is the bytecode of a signed transaction (optional)
  • transactionJSON is the transaction object (optional if transactionBytes provided)
  • prunableAttachmentJSON is the attachment object embedded in transactionJSON containing a prunable message (required if transactionJSON not provided because transactionBytes never includes prunable data)
  • adminPassword is a string with the admin password (optional)

Response:

  • requestProcessingTime (N) is the API request processing time (in millisec)
  • fullHash (S) is the full hash of the signed transaction
  • transaction (S) is the transaction ID

Send Transaction Example

http://localhost:7876/nxt?
  requestType=sendTransaction&
  transactionBytes=00109e61b606a0052bdd59320496b133052f58c82e8...
{
 "requestProcessingTime": 2,
 "fullHash": "799ad836f9c65e2985978123f145130b867bab9a86f6fdabae8e8c8f25c087dc",
 "transaction": "2981038777035168377"
}


Sign Transaction

Calculates the full hash, signature hash, and transaction ID of an unsigned transaction.

Request:

  • requestType is signTransaction
  • unsignedTransactionJSON is the transactionJSON field of the transaction, without a signature subfield
  • unsignedTransactionBytes is the unsignedTransactionBytes field of the transaction (optional, if unsignedTransactionJSON provided)
  • prunableAttachmentJSON is a prunable attachment JSON object, if applicable, because unsignedTransactionBytes never includes prunable data (optional if the transaction has already been broadcast and the prunable message can still be retrieved from the database)
  • secretPhrase is the secret passphrase of the signing account
  • validate is false to skip validation of the transaction bytes being signed (useful on nodes where the full blockchain is not downloaded)
  • requireBlock is the block ID of a block that must be present in the blockchain during execution (optional)
  • requireLastBlock is the block ID of a block that must be last in the blockchain during execution (optional)

Response:

  • signatureHash (S) is a SHA-256 hash of the transaction signature, used in escrow transactions
  • verify (B) is true the signature is verified, false if not
  • transactionJSON (O) is the signed transaction JSON object
  • transactionBytes (S) are the signed transaction bytes
  • fullHash (S) is the full hash of the signed transaction
  • prunableAttachmentJSON (O) is the prunable attachment JSON object, if applicable, because transactionBytes never includes prunable data
  • transaction (S) is the transaction ID, derived from the fullHash
  • lastBlock (S) is the last block ID on the blockchain (applies if requireBlock is provided but not requireLastBlock)
  • requestProcessingTime (N) is the API request processing time (in millisec)

Sign Transaction Example

http://localhost:7876/nxt?
  requestType=signTransaction&
  unsignedTransactionBytes=00100cfb3c03a00510f09c34f225d425306e5be55a494690...&
  secretPhrase=SecretPhrase
{
 "signatureHash": "3f4830bf28f105d5075f5e084c36e4582a156e713abfe0bc6ee51cbf8b20f2d2",
 "transactionJSON": {
  "senderPublicKey": "10f09c34f225d425306e5be55a4946908156072afbead4d574a512d7e086ef5c",
  "signature": "24513e93029688100c5a04183ffddc49812fd7a137a15fb3a2545aa9a2bcb5004a3...",
  "feeNQT": "100000000",
  "type": 0,
  "fullHash": "c34af8f1509e3be79c4562e24125ff2a8f026871fdd1a0366ad315bf8fab76b9",
  "version": 1,
  "phased": false,
  "ecBlockId": "15869644242181198665",
  "signatureHash": "3f4830bf28f105d5075f5e084c36e4582a156e713abfe0bc6ee51cbf8b20f2d2",
  "attachment": {
   "version.OrdinaryPayment": 0
  },
  "senderRS": "NXT-4VDY-LNVT-LMAY-FMCKA",
  "subtype": 0,
  "amountNQT": "1000000000",
  "sender": "15295723609781267838",
  "recipientRS": "NXT-BMUV-8QQR-47VK-CR7F3",
  "recipient": "11580081983047651163",
  "ecBlockHeight": 382777,
  "deadline": 1440,
  "transaction": "16662085316881435331",
  "timestamp": 54328076,
  "height": 2147483647
 },
 "verify": true,
 "requestProcessingTime": 5,
 "transactionBytes": "00100cfb3c03a00510f09c34f225d425306e5be55a4946908156072afbead4...",
 "fullHash": "c34af8f1509e3be79c4562e24125ff2a8f026871fdd1a0366ad315bf8fab76b9",
 "transaction": "16662085316881435331"
}