pushkey
This module allows you to create and manage push keys. It can be accessed from the global variable pk.

register

1
pk.register(txObject, [signingKey | payloadOnly | [signingKey, payloadOnly]])
Copied!
Send a transaction to register a public key as a push key.

Parameters

  1. 1.
    txObject - Object: The transaction object
    • pubKey - String: (optional) A base58 encoded public key to be registered.
    • scopes - Array<String>: (optional) A list of repositories or namespaces where the push key can be used.
    • feeCap - String: (optional) The maximum amount of fee the key can spend from its creator's account.
    • nonce - Number|String : The signing account’s next nonce.
    • fee - String: The network fee to be paid by the signing account.
    • timestamp - String: (optional) The unix timestamp of the transaction.
    • sig - String : (optional) The transaction signature. If not provided, the transaction will be signed using the signingKey.
  2. 2.
    signingKey - String: (optional) The private key that will be used to sign the transaction.
  3. 3.
    payloadOnly - Boolean: (optional) When true, the transaction payload is returned instead of being sent to the network.

Returns

Object - The result object
  • hash - String: A 32 bytes transaction hash.
  • address - String: A bech32 encoded push key address.

Example

  • Create a transaction to register a public key on the network.
1
pk.register({
2
pubKey: "49G1iGk8fY7RQcJQ7LfQdThdyfaN8dKfxhGQSh8uuNaK35CgazZ",
3
fee: 1
4
}, user.getKey(accounts[0]))
Copied!

update

1
pk.update(txObject, [signingKey | payloadOnly | [signingKey, payloadOnly]])
Copied!
Send a transaction to update a previously registered public key.

Parameters

  1. 1.
    txObject - Object: The transaction object
    • id - String: The push key address.
    • addScopes - Array<String>: (optional) A list of repositories or namespaces where the push key can be used.
    • removeScopes - Array<Number>: (optional) Index of scopes to be removed.
    • feeCap - String: (optional) The maximum amount of fee the key can spend from its creator's account.
    • delete - Boolean: Indicates that the public key should be deleted.
    • nonce - Number|String : The signing account’s next nonce.
    • fee - String: The network fee to be paid by the signing account.
    • timestamp - String: (optional) The unix timestamp of the transaction.
    • sig - String : (optional) The transaction signature. If not provided, the transaction will be signed using the signingKey.
  2. 2.
    signingKey - String: (optional) The private key to use to sign the transaction.
  3. 3.
    payloadOnly - Boolean: (optional) When true, the transaction payload is returned instead of being sent to the network.

Returns

Object - The result object
  • hash - String: A 32 bytes transaction hash.

Example

  • Create a transaction to update a push key.
1
pk.update({
2
id:"pk1wfx7vp8qfyv98cctvamqwec5xjrj48tpkfwme7",
3
addScopes:"repos/",
4
removeScopes:[0],
5
fee: "0.01"
6
}, user.getKey(accounts[0]))
Copied!

unregister

1
pk.unregister(txObject, [signingKey | payloadOnly | [signingKey, payloadOnly]])
Copied!
Send a transaction to delete a public key.

Parameters

  1. 1.
    txObject - Object: The transaction object
    • id - String: The push key address.
    • nonce - Number|String : The signing account’s next nonce.
    • fee - String: The network fee to be paid by the signing account.
    • timestamp - String: (optional) The unix timestamp of the transaction.
    • sig - String : (optional) The transaction signature. If not provided, the transaction will be signed using the signingKey.
  2. 2.
    signingKey - String: (optional) The private key to use to sign the transaction.
  3. 3.
    payloadOnly - Boolean: (optional) When true, the transaction payload is returned instead of being sent to the network.

Returns

Object - The result object
  • hash - String: A 32 bytes transaction hash.

Example

  • Create a transaction to unregister a push key from the network.
1
pk.unregister({
2
id:"pk1wfx7vp8qfyv98cctvamqwec5xjrj48tpkfwme7",
3
fee: "0.01"
4
}, user.getKey(accounts[0]))
Copied!

get

1
pk.get(address, [height])
Copied!
Get a push key by its address.

Parameters

  1. 1.
    address - String: The push key address.
  2. 2.
    height - Number|String: (optional) The block height to query (Default: latest).

Returns

Object - The result object
  • hash - String: A 32 bytes transaction hash.

Example

JavaScript
Output
1
pk.get("pk1wfx7vp8qfyv98cctvamqwec5xjrj48tpkfwme7")
Copied!
1
{
2
"address": "os1wfx7vp8qfyv98cctvamqwec5xjrj48tpklxklh",
3
"feeCap": "0",
4
"feeUsed": "0",
5
"pubKey": [194,198,203,80,111,17,78,208,207,230,2,194,128,230,32,142,235,100,71,14,125,69,42,169,244,21,135,16,221,231,27,230]
6
}
Copied!

getByAddress

1
pk.getByAddress(address)
Copied!
Get a list of push keys belonging to an address.

Parameters

  1. 1.
    address - String: The push key address.

Returns

Array<Object> - The list of objects
  • address - String: The address of the push key owner.
  • feeCap - String: The maximum fee the push key is allowed to spend from the owner’s account.
  • feeUsed - String: The amount of Latinum spent on fees.
  • pubKey - Array<Number> - The public key

Example

JavaScript
Untitled
1
pk.get("pk1wfx7vp8qfyv98cctvamqwec5xjrj48tpkfwme7")
Copied!
1
{
2
"address": "os1wfx7vp8qfyv98cctvamqwec5xjrj48tpklxklh",
3
"feeCap": "0",
4
"feeUsed": "0",
5
"pubKey": [194,198,203,80,111,17,78,208,207,230,2,194,128,230,32,142,235,100,71,14,125,69,42,169,244,21,135,16,221,231,27,230]
6
}
Copied!

getAccountOfOwner

1
pk.getOwner(address, [height])
Copied!
Get the account that owns the given push key.

Parameters

  1. 1.
    address - String: The push key address.
  2. 2.
    height - Number|String: (optional) The block height to query (Default: latest).

Returns

Account

Example

JavaScript
Output
1
pk.getOwner("pk1wfx7vp8qfyv98cctvamqwec5xjrj48tpkfwme7")
Copied!
1
{
2
"balance": "4979.98",
3
"nonce": "19",
4
}
Copied!