Forging

From Nxtwiki
Jump to: navigation, search

Start / Stop / Get Forging

Start or stop forging with an account, or check to see if an account is forging. POST only.

Request:

  • requestType is either startForging, stopForging or getForging
  • secretPhrase is the secret passphrase of the account (optional for stopForging and getForging if password protected like the Debug Operations)

Response:

  • deadline (N) is the estimated time (in seconds since the last block) until the account will forge a block (startForging and getForging only)
  • hitTime (N) is the estimated time (in seconds since the genesis block) when the account will forge a block (startForging and getForging only)
  • remaining (N) is the deadline less the elapsed time since the last block (getForging only)
  • foundAndStopped (B) is true if forging was stopped, false if forging was already stopped (stopForging only)
  • account (S) is the account number (getForging only)
  • accountRS (S) is the Reed-Solomon address of the account (getForging only)
  • requestProcessingTime (N) is the API request processing time (in millisec)

Note: A getForging request returns errorCode 5 if the account is not forging. If the account has a zero effectiveBalance, forging can be started but deadline, remainingTime and hitTime will be set to zero.

Start / Stop / Get Forging Example

http://localhost:7876/nxt?
  requestType=startForging&
  secretPhrase=IWontTellYou
{
 "requestProcessingTime": 1,
 "deadline": 0,
 "hitTime": 0
}


Get Forging

Refer to Start / Stop / Get Forging.

Start Forging

Refer to Start / Stop / Get Forging.

Stop Forging

Refer to Start / Stop / Get Forging.

Lease Balance

Lease the entire guaranteed balance of NXT to another account, after 1440 confirmations. POST only.

Request: Refer to Create Transaction Request for common parameters.

  • requestType is leaseBalance
  • period is the lease period (in number of blocks, 1440 minimum)
  • recipient is the lessee (recipient) account
  • recipientPublicKey is the public key of the lessee (recipient) account (optional, enhances security of a new account)

Response: Refer to Create Transaction Response.

Lease Balance Example

http://localhost:7876/nxt?
  requestType=leaseBalance&
  period=1440&
  recipient=NXT-4VNQ-RWZC-4WWQ-GVM8S&
  secretPhrase=IWontTellYou&
  feeNQT=100000000&
  deadline=60
{
 "signatureHash": "462590bb85b615ddd34d59a1ffdc452a9baee2088044c1b9eb44298e49158f35",
 "unsignedTransactionBytes": "04107977ce013c0057fb6f3a958e320bb49c4e81b4c2cf28b9f25d086c143b473b...",
 "transactionJSON": {
  "senderPublicKey": "57fb6f3a958e320bb49c4e81b4c2cf28b9f25d086c143b473beec228f79ff93c",
  "signature": "4a89702535246fd55bfc4b4691dc4266daa3100e00cdf0caaed57a5ad750da075a...",
  "feeNQT": "100000000",
  "type": 4,
  "fullHash": "251bcd86057c09bb2d055bbeeb9b67ccae861f75d4aada21b3b79a13db9712e1",
  "version": 1,
  "ecBlockId": "6565389899781382679",
  "signatureHash": "462590bb85b615ddd34d59a1ffdc452a9baee2088044c1b9eb44298e49158f35",
  "attachment": {
   "version.EffectiveBalanceLeasing": 1,
   "period": 1440
  },
  "senderRS": "NXT-L6FM-89WK-VK8P-FCRBB",
  "subtype": 0,
  "amountNQT": "0",
  "sender": "15323192282528158131",
  "recipientRS": "NXT-4VNQ-RWZC-4WWQ-GVM8S",
  "recipient": "17013046603665206934",
  "ecBlockHeight": 280672,
  "deadline": 60,
  "transaction": "13477439723061189413",
  "timestamp": 30308217,
  "height": 2147483647
 },
 "broadcasted": true,
 "requestProcessingTime": 7340,
 "transactionBytes": "04107977ce013c0057fb6f3a958e320bb49c4e81b4c2cf28b9f25d086c143b473b...",
 "fullHash": "251bcd86057c09bb2d055bbeeb9b67ccae861f75d4aada21b3b79a13db9712e1",
 "transaction": "13477439723061189413"
}


Get Next Block Generators

Returns the next block generators ordered by hit time. The list of currently active forgers is first initialized using the block generators with at least 2 blocks generated within the previous 10,000 blocks, excluding accounts without a public key. The list is updated as new blocks are processed. The results are not 100% correct since previously active generators may no longer be running and new generators won't be known until they generate a block.

Request:

  • requestType is getNextBlockGenerators
  • limit (N) is the number of next block generators to display.

Response:

  • activeCount (N) is the number of active forging accounts
  • lastBlock (S) is the last block ID on the blockchain
  • generators (A) is an array containing the number of next block generators requested
    • effectiveBalanceNXT (N) is the balance (in NXT) of the account available for forging: the unleased guaranteedBalance of this account plus the leased guaranteedBalance of all lessors to this account
    • accountRS (S) is the Reed-Solomon address of the account
    • deadline (N) is the estimated time (in seconds since the last block) until the account will forge a block
    • account (S) is the account number
    • hitTime (N) is the estimated time (in seconds since the genesis block) when the account will forge a block
  • requestProcessingTime (N) is the API request processing time (in millisec)
  • timestamp (N) is the timestamp (in seconds since the genesis block) when the request was executed
  • height (N) is the height of the blockchain

Get Next Block Generators Example

http://localhost:7876/nxt?
  requestType=getNextBlockGenerators&
  limit=3
{
 "activeCount": 216,
 "lastBlock": "10153073870267066931",
 "generators": [
  {
   "effectiveBalanceNXT": 5400786,
   "accountRS": "NXT-8HNT-4ZTF-ZXH3-7RU38",
   "deadline": 4,
   "account": "5982846390354787993",
   "hitTime": 112224054
  },
  {
   "effectiveBalanceNXT": 4061204,
   "accountRS": "NXT-HLNR-4HDK-HQUJ-37545",
   "deadline": 35,
   "account": "1263370831364868759",
   "hitTime": 112224085
  },
  {
   "effectiveBalanceNXT": 8847921,
   "accountRS": "NXT-ZEKG-CHYB-N8AR-4TQ3U",
   "deadline": 52,
   "account": "3244519536310858286",
   "hitTime": 112224102
  }
  ],
 "requestProcessingTime": 1,
 "timestamp": 112224050,
 "height": 1351776
}