Wallet

The operations related to the wallet are similar to those of Scrypta Core or Qt-Wallet. In general it is always possible to call the RPC functions of the wallet, even if not all calls are specified as endpoints.

Crypto.ts

The module responsible for all interfacing operations can be found in src / libs / Crypto.ts. This allows you to call any RPC function through the request method. There are several other methods that are called internally and can be analyzed directly. It is important to describe the request method as it is essential if you want to extend the IdaNode functionality.

request(method, params = [])

It allows to send any call to the wallet through the RPC protocol. The list of possible calls can be found here:

It is therefore possible, for example, to call the getnewaddress method directly through the request method:

import * as Crypto from '../libs/Crypto'
let wallet = new Crypto.Wallet
let address = await wallet.request('getnewaddress')

Note that externally this method is not reachable.

[POST] /init

This endpoint is used to initialize an address. In strictly blockchain terms this operation does not have a particular implication. An address exists because it is generated (the operation takes place offline) and does not require funds to carry out operations related to the signature.

However, it may be necessary to "initialize" it, or to make its existence known at a certain point in time, by sending funds. The amount of funds sent is decided upstream, within the .env file. In Scrypta's IdaNodes it amounts to 0.05 LYRA.

The call admits only the address field and will respond with the relative txid, if funds are actually sent. The operation could fail if there are not enough funds in the IdA Node to send the transaction. Here is an example of an answer:

{
"data": {
"dapp_address": "LY6BHLvjNbHCQxnpGgt6BvXhXjfX6Nk1X2",
"airdrop_tx": "d963d9d2d4862868ec3a1fa93beca49b4427a5fbb39722face624a06eabe6848"
},
"status": 200
}

Note: this call cannot be recalled more than once for IdA Node as an internal register is maintained.

[GET] /getnewaddress/:internal

It allows to generate a new address and returns the private key and the public key.

It is not recommended to use this function if IdA Node is public on the network. It would be more correct to generate offline or client-side addresses through the Scrypta Core library.

The internal parameter, which is optional, allows you to generate addresses within the IdA Node; that is, addresses that are saved in the wallet.dat (The Scrypta wallet file).

{
"address":"LXVTCseqosHJDD4BzU2Xb1XH6RPJQu7ZUq",
"private_key":"SpeJ9q3wDSDqsPYmMr5A1zUtgeFPkhDjHRcttN6PonAGhY4JazAK",
"pub_key":"03b635b83e1473a4b0cd91696926cfa69d1dec030b3e97213f52a45cbc976103a7",
"status":200
}

[POST] /send

It allows you to send funds directly from the IdaNode, specifying the following parameters:

  • from: the address that intends to send the funds

  • to: the address to you want to send the funds

  • amount: the amount you want to send

  • private_key: the private key of the address from which you intend to send the funds.

  • message: any optional text message that cannot exceed 80 Bytes and that is inserted as OP_RETURN within the transaction.

[POST] /sendrawtransaction

It allows you to send a previously set and signed raw transaction to the network.

[POST] /decoderawtransaction

It allows you to decode a raw transaction by converting it from hexadecimal to a JSON object.

[GET] /wallet/getinfo

Returns the wallet's response to the getinfo call. Contains synchronization information with the blockchain.

[GET] /wallet/masternodelist

Returns the response of the wallet to the calls masternode list, masternode count and masternode current thus allowing to analyze the current network.