Masternodes#

class defichain.node.Masternodes(node)#
createmasternode(ownerAddress: str, operatorAddress: str | None = None, inputs: [{}] = [], timelock: str | None = None) str#

Creates (and submits to local node and network) a masternode creation transaction with given owner and operator addresses, spending the given inputs.. The last optional argument (may be empty array) is an array of specific UTXOs to spend.

Parameters:
  • ownerAddress (str) – (required) Any valid address for keeping collateral amount (any P2PKH or P2WKH address) - used as owner key

  • operatorAddress – (optional) Optional (== ownerAddress) masternode operator auth address (P2PKH only, unique)

  • inputs (json array) – (optional) Inputs

  • timelock (str) – (optional) Defaults to no timelock period so masternode can be resigned once active. To set a timelock period specify either FIVEYEARTIMELOCK or TENYEARTIMELOCK to create a masternode that cannot be resigned for five or ten years and will have 1.5x or 2.0 the staking power respectively. Be aware that this means that you cannot spend the collateral used to create a masternode for whatever period is specified.

Returns:

“hash” (string) – The hex-encoded hash of broadcasted transaction

Example:
>>> node.masternodes.createmasternode("ownerAddress", "operatorAddress")
getactivemasternodecount(blockCount: int = 20160) int#

Return number of unique masternodes in the last specified number of blocks

Parameters:

blockCount (int) – (optional) The number of blocks to check for unique masternodes

Returns:

n (numeric) – Number of unique masternodes seen

Example:
>>> node.masternodes.getactivemasternodecount()
getanchorteams(blockHeight: int | None = None) {}#

Returns the auth and confirm anchor masternode teams at current or specified height

Parameters:

blockHeight (int) – (optional) The height of block which contain tx

Returns:

{“auth”:[Address,…],”confirm”:[Address,…]} (json) – Two sets of masternode operator addresses

Example:
>>> node.masternodes.getanchorteams()
getmasternode(mn_id: str) {}#

Returns information about specified masternode

Parameters:

mn_id (str) – (required) Masternode’s id

Returns:

{id:{…}} (json) – Json object with masternode information

Example:
>>> node.masternodes.getmasternode("095d2bfb5d05ba73fa96502df85aca818ee79810b9ababa71a9dc97e2c360100")
getmasternodeblocks(id: str | None = None, ownerAddress: str | None = None, operatorAddress: str | None = None, depth: int | None = None) {}#

Returns blocks generated by the specified masternode

Needs one of the three identifier: id, ownerAddress, operatorAddress

Parameters:
  • id (str) – (optional) Masternode’s id

  • ownerAddress (str) – (optional) Masternode owner address

  • operatorAddress (str) – (optional) Masternode operator address

  • depth (int) – (optional) Maximum depth, from the genesis block is the default

Returns:

{…} (json) – Json object with block hash and height information

Example:
>>> node.masternodes.getmasternodeblocks(id="095d2bfb5d05ba73fa96502df85aca818ee79810b9ababa71a9dc97e2c360100")
listanchors() []#

List anchors (if any)

Returns:

[…] (array) – Returns array of anchors

Example:
>>> node.masternodes.listanchors()
listmasternodes(start: str | None = None, including_start: bool | None = None, limit: int = 1000000, verbose: bool = True) {}#

Returns information about specified masternodes (or all, if list of ids is empty).

Parameters:
  • start (str) – (optional) Optional first key to iterate from, in lexicographical order. Typically, it’s set to last ID from previous request

  • including_start (bool) – (optional) If true, then iterate including starting position. False by default

  • limit (int) – (optional) Maximum number of orders to return, 1000000 by default

  • verbose (bool) – (optional) Flag for verbose list (default = true), otherwise only ids are listed

Returns:

{id:{…},…} (json) – Json object with masternodes information

Example:
>>> node.masternodes.listmasternodes()
resignmasternode(mn_id: str, inputs: [{}] = None) str#

Creates (and submits to local node and network) a transaction resigning your masternode. Collateral will be unlocked after 2016 blocks.

The last optional argument (may be empty array) is an array of specific UTXOs to spend. One of UTXO’s must belong to the MN’s owner (collateral) address

Parameters:
  • mn_id (str) – (required) The Masternode’s ID

  • inputs (json array) – (optional) Inputs

Returns:

“hash” (string) – The hex-encoded hash of broadcasted transaction

Example:
>>> node.masternodes.resignmasternode("095d2bfb5d05ba73fa96502df85aca818ee79810b9ababa71a9dc97e2c360100")
updatemasternode(mn_id: str, values: {} = None, inputs: [{}] = None) str#

Creates (and submits to local node and network) a masternode update transaction which update the masternode operator addresses, spending the given inputs..

The last optional argument (may be empty array) is an array of specific UTXOs to spend.

Requires wallet passphrase to be set with walletpassphrase call.

Parameters:
  • mn_id (str) – (required) The Masternode’s ID

  • values (json) –

    (required)

    {
        "ownerAddress": "str",       (string) The new masternode owner address, requires masternode collateral fee (P2PKH or P2WPKH)
        "operatorAddress": "str",    (string) The new masternode operator address (P2PKH or P2WPKH)
        "rewardAddress": "str",      (string) Masternode`s new reward address, empty "" to remove reward address.
    }
    

  • inputs (json array) – Inputs

Returns:

“hash” (string) – The hex-encoded hash of broadcasted transaction

Example:
>>> node.masternodes.updatemasternode("mn_id", {"rewardAddress": "rewardAddress"})