Skip to content

Commit

Permalink
docs: create commonTransactionParameters to hold parameters that ar…
Browse files Browse the repository at this point in the history
…e common between all transaction types (#209)

Signed-off-by: Rob Walworth <[email protected]>
  • Loading branch information
rwalworth authored May 29, 2024
1 parent a090187 commit df50d5c
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 28 deletions.
35 changes: 35 additions & 0 deletions test-specifications/commonTransactionParameters.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Common Transaction Parameters

There are common parameters that can be set for all Hedera transaction types. This document specifies a common JSON object that should be added to all transactions that encapsulates these common parameters.

## Transaction Parameter Object Definition

| Parameter Name | Type | Required/Optional | Description/Notes |
|--------------------------|--------------|-------------------|----------------------------------------------------------------------------------|
| transactionId | string | optional | |
| maxTransactionFee | int64 | optional | Units of tinybars |
| validTransactionDuration | int64 | optional | Units of seconds |
| memo | string | optional | |
| regenerateTransactionId | bool | optional | |
| signers | list<string> | optional | List of DER-encoded hex strings of all additional private keys required to sign. |

## Example Usage

If the `createAccount` method were to contain this object and name it `"commonTransactionParams"`, its usage would look like:

```json
{
"jsonrpc": "2.0",
"id": 99232,
"method": "createAccount",
"params": {
"key": "302a300506032b6570032100e9a0f9c81b3a2bb81a4af5fe05657aa849a3b9b0705da1fb52f331f42cf4b496",
"receiverSignatureRequired": true,
"commonTransactionParams": {
"signers": [
"302e020100300506032b65700422042031f8eb3e77a04ebe599c51570976053009e619414f26bdd39676a5d3b2782a1d"
]
}
}
}
```
65 changes: 37 additions & 28 deletions test-specifications/crypto-service/accountCreateTransaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ https://docs.hedera.com/hedera/sdks-and-apis/rest-api

### Input Parameters

| Parameter Name | Type | Required/Optional | Description/Notes |
|---------------------------|--------|-------------------|---------------------------------------------------------------------------------------------------------------------------------------------|
| key | string | optional | DER-encoded hex string representation for private or public keys. Keylists and threshold keys are the hex of the serialized protobuf bytes. |
| initialBalance | int64 | optional | Units of tinybars |
| receiverSignatureRequired | bool | optional | |
| autoRenewPeriod | int64 | optional | Units of seconds |
| memo | string | optional | |
| maxAutoTokenAssociations | int32 | optional | |
| stakedAccountId | string | optional | |
| stakedNodeId | int64 | optional | |
| declineStakingReward | bool | optional | |
| alias | string | optional | Hex string representation of the keccak-256 hash of an ECDSAsecp256k1 public key type. |
| signerKey | string | optional | DER-encoded hex string representation of an additional private key required to sign. |
| Parameter Name | Type | Required/Optional | Description/Notes |
|---------------------------|--------------------------------------------------|-------------------|---------------------------------------------------------------------------------------------------------------------------------------------|
| key | string | optional | DER-encoded hex string representation for private or public keys. Keylists and threshold keys are the hex of the serialized protobuf bytes. |
| initialBalance | int64 | optional | Units of tinybars |
| receiverSignatureRequired | bool | optional | |
| autoRenewPeriod | int64 | optional | Units of seconds |
| memo | string | optional | |
| maxAutoTokenAssociations | int32 | optional | |
| stakedAccountId | string | optional | |
| stakedNodeId | int64 | optional | |
| declineStakingReward | bool | optional | |
| alias | string | optional | Hex string representation of the keccak-256 hash of an ECDSAsecp256k1 public key type. |
| commonTransactionParams | [json object](../commonTransactionParameters.md) | optional | |

### Output Parameters

Expand Down Expand Up @@ -136,11 +136,11 @@ https://docs.hedera.com/hedera/sdks-and-apis/rest-api

- If true, this account's key must sign any transaction depositing into this account (in addition to all withdrawals).

| Test no | Name | Input | Expected response | Implemented (Y/N) |
|---------|--------------------------------------------------------------------------------------------|----------------------------------------------------------|--------------------------------------------------------------------------------------|-------------------|
| 1 | Creates an account that requires a receiving signature | key=<VALID_PRIVATE_KEY>, receiverSignatureRequired=true | The account creation succeeds and the account requires a receiving signature. | N |
| 2 | Creates an account that doesn't require a receiving signature | key=<VALID_PRIVATE_KEY>, receiverSignatureRequired=false | The account creation succeeds and the account doesn't require a receiving signature. | N |
| 3 | Creates an account that requires a receiving signature but isn't signed by the account key | key=<VALID_PUBLIC_KEY>, receiverSignatureRequired=true | The account creation fails with an INVALID_SIGNATURE response code from the network. | N |
| Test no | Name | Input | Expected response | Implemented (Y/N) |
|---------|--------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------|-------------------|
| 1 | Creates an account that requires a receiving signature | key=<VALID_PUBLIC_KEY>, receiverSignatureRequired=true, commonTransactionParams.signers=[<ASSOCIATED_PRIVATE_KEY>] | The account creation succeeds and the account requires a receiving signature. | N |
| 2 | Creates an account that doesn't require a receiving signature | key=<VALID_KEY>, receiverSignatureRequired=false | The account creation succeeds and the account doesn't require a receiving signature. | N |
| 3 | Creates an account that requires a receiving signature but isn't signed by the account key | key=<VALID_KEY>, receiverSignatureRequired=true | The account creation fails with an INVALID_SIGNATURE response code from the network. | N |

#### JSON Request Example

Expand All @@ -150,8 +150,13 @@ https://docs.hedera.com/hedera/sdks-and-apis/rest-api
"id": 99232,
"method": "createAccount",
"params": {
"key": "302e020100300506032b65700422042031f8eb3e77a04ebe599c51570976053009e619414f26bdd39676a5d3b2782a1d",
"receiverSignatureRequired": true
"key": "302a300506032b6570032100e9a0f9c81b3a2bb81a4af5fe05657aa849a3b9b0705da1fb52f331f42cf4b496",
"receiverSignatureRequired": true,
"commonTransactionParams": {
"signers": [
"302e020100300506032b65700422042031f8eb3e77a04ebe599c51570976053009e619414f26bdd39676a5d3b2782a1d"
]
}
}
}
```
Expand Down Expand Up @@ -351,14 +356,14 @@ https://docs.hedera.com/hedera/sdks-and-apis/rest-api
}
```

### **Decline rewards:**
### **Decline Reward:**

- If true, the account declines receiving a staking reward.

| Test no | Name | Input | Expected response | Implemented (Y/N) |
|---------|---------------------------------------------------------|----------------------------------------------|--------------------------------------------------------------------------------|-------------------|
| 1 | Creates an account that declines staking rewards | key=<VALID_KEY>, declineStakingRewards=true | The account creation succeeds and the account declines staking rewards. | N |
| 1 | Creates an account that doesn't decline staking rewards | key=<VALID_KEY>, declineStakingRewards=false | The account creation succeeds and the account doesn't decline staking rewards. | N |
| 2 | Creates an account that doesn't decline staking rewards | key=<VALID_KEY>, declineStakingRewards=false | The account creation succeeds and the account doesn't decline staking rewards. | N |

#### JSON Request Example

Expand Down Expand Up @@ -391,11 +396,11 @@ https://docs.hedera.com/hedera/sdks-and-apis/rest-api

- The bytes to be used as the account's alias. The bytes must be formatted as the calculated last 20 bytes of the keccak-256 hash of an ECDSA primitive key.

| Test no | Name | Input | Expected response | Implemented (Y/N) |
|---------|-------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------|-------------------|
| 1 | Creates an account with the keccak-256 hash of an ECDSAsecp256k1 public key | key=<VALID_KEY>, alias=<LAST_20_BYTES_ECDSA_SECP256K1_PUBLIC_KEY_KECCAK_256_HASH>, signerKey=<CORRESPONDING_ECDSA_SECP256K1_PRIVATE_KEY> | The account creation succeeds and the account has the keccak-256 hash of the ECDSAsecp256k1 public key as its alias. | N |
| 2 | Creates an account with the keccak-256 hash of an ECDSAsecp256k1 public key without a signature | key=<VALID_KEY>, alias=<LAST_20_BYTES_ECDSA_SECP256K1_PUBLIC_KEY_KECCAK_256_HASH> | The account creation fails with an INVALID_SIGNATURE response code from the network. | N |
| 3 | Creates an account with an invalid alias | key=<VALID_KEY>, alias=<INVALID_ALIAS> | The account creation fails with an INVALID_ALIAS_KEY response code from the network. | N |
| Test no | Name | Input | Expected response | Implemented (Y/N) |
|---------|-------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------|-------------------|
| 1 | Creates an account with the keccak-256 hash of an ECDSAsecp256k1 public key | key=<VALID_KEY>, alias=<LAST_20_BYTES_ECDSA_SECP256K1_PUBLIC_KEY_KECCAK_256_HASH>, commonTransactionParams.signers=[<CORRESPONDING_ECDSA_SECP256K1_PRIVATE_KEY>] | The account creation succeeds and the account has the keccak-256 hash of the ECDSAsecp256k1 public key as its alias. | N |
| 2 | Creates an account with the keccak-256 hash of an ECDSAsecp256k1 public key without a signature | key=<VALID_KEY>, alias=<LAST_20_BYTES_ECDSA_SECP256K1_PUBLIC_KEY_KECCAK_256_HASH> | The account creation fails with an INVALID_SIGNATURE response code from the network. | N |
| 3 | Creates an account with an invalid alias | key=<VALID_KEY>, alias=<INVALID_ALIAS> | The account creation fails with an INVALID_ALIAS_KEY response code from the network. | N |

#### JSON Request Example

Expand All @@ -407,7 +412,11 @@ https://docs.hedera.com/hedera/sdks-and-apis/rest-api
"params": {
"key": "302e020100300506032b65700422042031f8eb3e77a04ebe599c51570976053009e619414f26bdd39676a5d3b2782a1d",
"alias": "990a3f6573669cc6266c00983dc24359bd4b223b",
"signerKey": "30540201010420c5f9d140822511e581228feb2bde5a9706ee4c4377822e7cf4755fec529f0bcfa00706052b8104000aa124032200038064ccfe93ce1492ada790da7204edd8e3fd004ee68e4fae7641e00db20527c5"
"commonTransactionParams": {
"signers": [
"30540201010420c5f9d140822511e581228feb2bde5a9706ee4c4377822e7cf4755fec529f0bcfa00706052b8104000aa124032200038064ccfe93ce1492ada790da7204edd8e3fd004ee68e4fae7641e00db20527c5"
]
}
}
}
```
Expand Down

0 comments on commit df50d5c

Please sign in to comment.