CLI tool for signing transactions

Motivation:

  1. Signing transactions offline
  2. Creating meaningful and reproducible code for DEMOs and presentations. Also there is an idea to create something like Jupiter Notebook for such cases
  3. Other usages?

Capabilities:

  1. Creating an account by seed and nonce
  2. Signing transactions: for a given unsigned transaction in JSON it returns a signed JSON representation
  3. Verifying transactions in JSON

Requirements:

  1. Working with Windows, Linux and macOS
  2. Providing a seed or private key by a console prompt or file
  3. Zero dependencies
  4. bash-completions

Specifying a secret:

waves-cli --secret=[seed|pk] # "seed" by default
          --secret-from=file:///path/to/secret # by default a secret is provided by prompt
          --secret-format=[bin|base58] # defaults: "bin" for files, "base58" for prompt.

--secret-format=bin is denied for prompt.

Creating an account:

waves-cli --create-account
          --nonce=[number] # 0 by default

Prints (after prompt):

{
  "privateKey": "Base58-encoded private key",
  "publicKey": "Base58-encoded public key"
}

Signing a transfer transaction:

Example of transaction.json:

{
  "type": 4,
  "version": 1,
  "sender": "Base58-encoded address of sender",
  "senderPublicKey": "Base58-encoded public key of sender",
  "fee": 100000,
  "timestamp": 1527505909911,
  "recipient": "Base58-encoded address of recipient",
  "assetId": null,
  "amount": 1699900000,
  "feeAsset": null,
  "attachment": "Base58-encoded string"
}

Here:

  • An order of fields doesn’t matter;
  • Optional fields are “version”, “sender”, “senderPublicKey”, “timestamp”, “attachment”;
  • The default “version” is 1;
  • The default “timestamp” is now;
  • The default “attachment” is “” (an empty string);
  • If “sender” and “senderPublicKey” are specified, they are validated against the secret;

Signing:

waves-cli --sign-tx
          --tx-from=file:///path/to/transaction.json # by default a JSON will be parsed from STDIN

Example of output:

{
  "type": 4,
  "id": "Base58-encoded id of transaction",
  "sender": "Base58-encoded address of sender",
  "senderPublicKey": "Base58-encoded public key of sender",
  "fee": 100000,
  "timestamp": 1527505909911,
  "signature": "Base58-encoded signature",
  "recipient": "Base58-encoded address of recipient",
  "assetId": null,
  "amount": 1699900000,
  "feeAsset": null,
  "attachment": "",
  "height": 1018524
}
1 Like

Sounds cool.
However will many people use it when they can use pywaves?

I dunno :slight_smile: But this tool also will be helpful for client libraries. The fastest way to deal with cryptography is to run this tool in a fork and parse its response. At least for prototypes. Not all languages have good FFI to C