Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate and broadcast messages with multiple signatures via CLI #2204

Closed
7 tasks done
alessio opened this issue Aug 31, 2018 · 7 comments
Closed
7 tasks done

Generate and broadcast messages with multiple signatures via CLI #2204

alessio opened this issue Aug 31, 2018 · 7 comments
Assignees

Comments

@alessio
Copy link
Contributor

alessio commented Aug 31, 2018

Summary

We want to allow users to generate and broadcast transactions via command line that require multiple signatures.

This epic aims to capture the ongoing work on related issues:

Problem Definition

As a gaiacli user
I want to generated and append my signature to unsigned/signed transactions
So that I can broadcast the transactions at a later stage.

Proposal

A proposed workflow follows:

1. Offline Tx generation

The user should start by generating a transaction, e.g.:

$ gaiacli --chain-id=test-chain-pa0XWJ \
    send --amount=10steak \
    --to=cosmos15yttnqfpxrwg7fsxhepyrsy7nasz5u8y6hnc8m
    --from=foo --gas=0 \
    --generate-only > exampleTx.json
estimated gas = 3189
$ jq . exampleTx.json 
{
  "type": "auth/StdTx",
  "value": {
    "msg": [
      {
        "type": "cosmos-sdk/Send",
        "value": {
          "inputs": [
            {
              "address": "cosmos1f5sa4fpcnz9dc30z9xfmx5tmz2rq69cyj5hl3p",
              "coins": [
                {
                  "denom": "steak",
                  "amount": "10"
                }
              ]
            }
          ],
          "outputs": [
            {
              "address": "cosmos15yttnqfpxrwg7fsxhepyrsy7nasz5u8y6hnc8m",
              "coins": [
                {
                  "denom": "steak",
                  "amount": "10"
                }
              ]
            }
          ]
        }
      }
    ],
    "fee": {
      "amount": [
        {
          "denom": "",
          "amount": "0"
        }
      ],
      "gas": "3189"
    },
    "signatures": null,
    "memo": ""
  }
}

2. Offline Tx signing

A new command sign is developed to allow users to sign transactions offline:

$ gaiacli --chain-id=test-chain-pa0XWJ sign exampleTx.json --name=foo > signedTx.json
Password to sign with 'foo':
$ jq . signedTx.json 
{
  "type": "auth/StdTx",
  "value": {
    "msg": [
      {
        "type": "cosmos-sdk/Send",
        "value": {
          "inputs": [
            {
              "address": "cosmos1f5sa4fpcnz9dc30z9xfmx5tmz2rq69cyj5hl3p",
              "coins": [
                {
                  "denom": "steak",
                  "amount": "10"
                }
              ]
            }
          ],
          "outputs": [
            {
              "address": "cosmos15yttnqfpxrwg7fsxhepyrsy7nasz5u8y6hnc8m",
              "coins": [
                {
                  "denom": "steak",
                  "amount": "10"
                }
              ]
            }
          ]
        }
      }
    ],
    "fee": {
      "amount": [
        {
          "denom": "",
          "amount": "0"
        }
      ],
      "gas": "3189"
    },
    "signatures": [
      {
        "pub_key": {
          "type": "tendermint/PubKeySecp256k1",
          "value": "A4ukQascVz+7WxXIRm4hQ3+ndC8tabznOZmtJMKIx8fn"
        },
        "signature": "MEUCIQDDBazT4r4iTOJWQeQIL+eeaj5i0iuMPUMYk1AgZsaEGgIgeQgcGibjnXx6Mnrg6V1ySOwMGJNoRljZhZUgTX0DKDs=",
        "account_number": "0",
        "sequence": "2"
      }
    ],
    "memo": ""
  }
}

The sign command aims to support multiple signatures, e.g.:

$ gaiacli --chain-id=test-chain-pa0XWJ sign signedTx.json --name=bar | jq .
Password to sign with 'bar':
{
  "type": "auth/StdTx",
  "value": {
    "msg": [
      {
        "type": "cosmos-sdk/Send",
        "value": {
          "inputs": [
            {
              "address": "cosmos1f5sa4fpcnz9dc30z9xfmx5tmz2rq69cyj5hl3p",
              "coins": [
                {
                  "denom": "steak",
                  "amount": "10"
                }
              ]
            }
          ],
          "outputs": [
            {
              "address": "cosmos15yttnqfpxrwg7fsxhepyrsy7nasz5u8y6hnc8m",
              "coins": [
                {
                  "denom": "steak",
                  "amount": "10"
                }
              ]
            }
          ]
        }
      }
    ],
    "fee": {
      "amount": [
        {
          "denom": "",
          "amount": "0"
        }
      ],
      "gas": "3189"
    },
    "signatures": [
      {
        "pub_key": {
          "type": "tendermint/PubKeySecp256k1",
          "value": "A4ukQascVz+7WxXIRm4hQ3+ndC8tabznOZmtJMKIx8fn"
        },
        "signature": "MEUCIQDDBazT4r4iTOJWQeQIL+eeaj5i0iuMPUMYk1AgZsaEGgIgeQgcGibjnXx6Mnrg6V1ySOwMGJNoRljZhZUgTX0DKDs=",
        "account_number": "0",
        "sequence": "2"
      },
      {
        "pub_key": {
          "type": "tendermint/PubKeySecp256k1",
          "value": "A540gCzZ7y4XkJQaLmGQVncIoXphcXUWhksZMxYXCc9A"
        },
        "signature": "MEQCICj1Qqg3p3+RUzpHKZ4a+fpDCnSOIAo9+tlPWYSHXwPyAiABFiip5ytCcqjC32z8q02eWw+Q5RmzojxnLk6lfvj91A==",
        "account_number": "2",
        "sequence": "0"
      }
    ],
    "memo": ""
  }
}

3. Broadcasting of offline-generated transactions

The signed transaction could ultimately be broadcast by passing it as an argument to the submit command:

$ gaiacli submit signedTx.json
estimated gas = 3189
Committed at block 781 (tx hash: 4EC62A011124660E52CCBD0395C65EC24391FE2A, response: {Code:0 Data:[] Log:Msg 0:  Info: GasWanted:3189 GasUsed:3189 Tags:[{Key:[115 101 110 100 101 114] Value:[99 111 115 109 111 115 49 102 53 115 97 52 102 112 99 110 122 57 100 99 51 48 122 57 120 102 109 120 53 116 109 122 50 114 113 54 57 99 121 106 53 104 108 51 112]} {Key:[114 101 99 105 112 105 101 110 116] Value:[99 111 115 109 111 115 49 53 121 116 116 110 113 102 112 120 114 119 103 55 102 115 120 104 101 112 121 114 115 121 55 110 97 115 122 53 117 56 121 54 104 110 99 56 109]}] XXX_NoUnkeyedLiteral:{} XXX_unrecognized:[] XXX_sizecache:0})

For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned

/cc @jackzampolin @ebuchman @ValarDragon

@alessio
Copy link
Contributor Author

alessio commented Sep 3, 2018

/cc @cwgoes

@cwgoes
Copy link
Contributor

cwgoes commented Sep 3, 2018

Thanks for the summary. Suggestions:

  1. Rename submit to broadcast for consistency with our terminology elsewhere.
  2. Consider adding another CLI command to inspect a transaction JSON, attempt to decode it, and determine which further signatures (if any) are required.

@alessio
Copy link
Contributor Author

alessio commented Sep 3, 2018

  1. Rename submit to broadcast for consistency with our terminology elsewhere.

Fine for me.

  1. Consider adding another CLI command to inspect a transaction JSON, attempt to decode it, and determine which further signatures (if any) are required.

Seconded.

@alessio
Copy link
Contributor Author

alessio commented Sep 4, 2018

@cwgoes re:

Consider adding another CLI command to inspect a transaction JSON, attempt to decode it, and determine which further signatures (if any) are required.

Please have a look at bd6a75d

@jackzampolin
Copy link
Member

This all looks like exactly what we want here. Excited to use this feature!

@cwgoes
Copy link
Contributor

cwgoes commented Sep 4, 2018

Please have a look at bd6a75d

Good but maybe we can print both at the same time, a bit simpler & I don't think we need separate commands.

@alessio alessio self-assigned this Sep 5, 2018
@alessio
Copy link
Contributor Author

alessio commented Sep 8, 2018

This features set has now hit develop, see relevant issues for more information. Hence closing.

@alessio alessio closed this as completed Sep 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants