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:
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.
A proposed workflow follows:
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": ""
}
}
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": ""
}
}
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})
/cc @jackzampolin @ebuchman @ValarDragon
/cc @cwgoes
Thanks for the summary. Suggestions:
submit to broadcast for consistency with our terminology elsewhere.
- Rename submit to broadcast for consistency with our terminology elsewhere.
Fine for me.
- Consider adding another CLI command to inspect a transaction JSON, attempt to decode it, and determine which further signatures (if any) are required.
Seconded.
@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 https://github.com/cosmos/cosmos-sdk/pull/2216/commits/bd6a75d600c59aacc6e73e67837105683966da39
This all looks like exactly what we want here. Excited to use this feature!
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.
This features set has now hit develop, see relevant issues for more information. Hence closing.