PIP: PIP-0033 Title: DATA operation RPC implementation Type: Backend Impact: None Author: Benjamin Ansbach <[email protected]> Comments-URI: https://discord.gg/sJqcgtD (channel #pip-0033) Status: Draft Created: 2019-06-12
A description of the missing JSON-RPC methods related to DATA operations.
DATA Operations (optype = 10) were implemented in PascalCoin V4, but the node is missing the JSON-RPC methods to create and properly search for them. This PIP aims to describe the missing methods that need to be implemented to use this feature at it's full potential.
To make use of DATA operation the JSON-RPC API of PascalCoin needs to implement methods to..
find DATA operations based on it's unique properties.
The following sections describe implementation details of the JSON-RPC methods.
PascalCoin, at it's core, understands 2 types of encryption: AES, ECIES (sender or target pubkey)
With DATA operations we are able to split a long message into multiple operations (limited by the payload size of 255 bytes) and combine them later on.
DATA operations support
guid which is a unique value identifying a group of operations.data_sequence which identifies the position of a single operation in a group of operations (guid).The JSON-RPC API for DATA operations will support splitting large payloads (resulting payload >255 bytes) into multiple DATA operations where the guid of a DATA operation could (if not explicitly given) and the data_sequence will (if not given) be managed by the requested node.
The supported encryption methods will be applied before a split, meaning the payload will be encrypted and the encrypted value will be splitted. This will make single messages unusable as they cannot be decrypted with their accompanied operations grouped by guid, but saves valuable space.
From the known and established encryption methods we can say the following (255 bytes payload):
AESECIESWhen a JSON-RPC user wants to create a DATA operation, the following payload-related rules will apply:
operation[n].data_sequence = sequencesequence > 0
operation[n].amount will be set to 0operation[n].fee will be set to min fee (0.0001)last_n_operationoperation[n].payload to payload.slice(sequence * 255, 255)sequence++Errors that occur when creating one or more operations will be returned with the valid flag set to false, so users can re-send/re-sign them.
The following JSON-RPC methods are needed to make DATA operations available for everyone. A data type in [ and ] is optional, you can leave out the parameter in this case.
Executes a data operation.
Array<Operation> senddata({
UINT32 sender,
[UINT32 target = sender, ]
UINT16 data_type,
[UINT16 data_sequence = 0, ]
[GUID guid = GUID.new, ]
[PASCCURRENCY amount = 0, ]
[PASCCURRENCY fee = 0, ]
[HEXASTRING payload = '', ]
[String payload_method = 'none', ]
[String pwd = '']
})
sender UINT32
The sender of the operation. If the sender is null, the signer will be used.target [UINT32] (default = sender or signer)data_type UINT16 (default = 0)data_sequence [UINT16]guid [GUID]8-4-4-4-12 format. If null or not given, the node will generate a UUID V4 (random).amount [PASCCURRENCY] (defult = 0)
The amount to transfer to target, if not given or null the default value is 0.
fee [PASCCURRENCY] (default = 0)
The fee for the operation, if not given or null the default value is 0.
payload [HEXASTRING] (default = '')
The payload for the operation. If not given, the value is an empty string.
payload_method [String] (default = 'none')
The encryption method. Can either be none, dest, sender or aes.
pwd [String] (default = '')
The password when using payload_method=aes. Optional.
A array of all created operations.
Creates and signs a "DATA" operation for later use.
Array<Operation> signdata({
UINT32 signer,
[UINT32 sender = signer, ]
[UINT32 target = sender, ]
UINT16 data_type,
[UINT16 data_sequence = 0, ]
[GUID guid = GUID.new, ]
[PASCCURRENCY amount = 0, ]
[PASCCURRENCY fee = 0, ]
[HEXASTRING payload = '', ]
[String payload_method = 'none', ]
[String pwd = '']
})
rawoperations [HEXASTRING] (default = '')
In case this sign operation should be added to other signed operations, you'll need to provide the rawoperations HexaString of the previous signing request. If the parameter is not given, it will be set to '' (empty string).
signer UINT32sender [UINT32] (default = signer)target [UINT32] (default = sender or signer)data_type UINT16 (default = 0)data_sequence [UINT16]guid [GUID]8-4-4-4-12 format. If null or not given, the node will generate a UUID V4 (random).last_n_operation UINT32
Last value of n_operation of the signer (or sender or target)amount [PASCCURRENCY] (defult = 0)
The amount to transfer to target, if not given or null the default value is 0.fee [PASCCURRENCY] (default = 0)payload [HEXASTRING] (default = '')payload_method [String] (default = 'none')none, dest, sender or aes.pwd [String] (default = '')
The password when using payload_method aes. Can be left out or null.
The given rawoperations altered by the new operation(s).
This method will help to retrieve one or more DATA operations. DATA operations are special and will be heavily used, but the getaccountoperations method is already overloaded with parameters. Thats why we will introduce a new method that only searches for DATA operations.
Array<Operation> finddataoperations({
[UINT32 sender = null, ]
[UINT32 target = null, ]
[GUID guid = null, ]
[UINT16 data_type = null ,]
[UINT16 data_sequence = null ,]
[UINT32 start = 0 ,]
[UINT16 max = 100 ,]
})
sender [UINT32] (default = null)target [UINT32] (default = null)guid [GUID] (default = null)8-4-4-4-12 format. Optional.data_sequence [UINT16]data_type [UINT16]start [UINT32]max [UINT16]While all parameters are optional, the method cannot handle a call to the method without any parameter.
sender or target must be setdata_sequence is set, the guid must be provided.DATA operations play a key role in V5 and adoption, they can be implemented in V4 already but it makes most sense to make them available with the protocol update.
The changes are backwards compatible.
None.
UUID V4: https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_(random)
PascalCoin JSON RPC documentation: https://github.com/PascalCoin/PascalCoin/wiki/JSON-RPC-API