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

Simple signer CLI #1203

Merged
merged 19 commits into from
Jan 14, 2020
Merged

Simple signer CLI #1203

merged 19 commits into from
Jan 14, 2020

Conversation

kantai
Copy link
Member

@kantai kantai commented Jan 2, 2020

This is a simple transaction generation and signer CLI.

For now, this only supports standard single-single transactions. We can expand the feature set later if we want it to be expanded (good multi-sig support would probably require some refactoring in the TransactionAuth, Transaction, and TransactionSigner structs, as well as breaking generation & signing into two different CLI methods).

$ ./target/debug/blockstack-cli -h
blockstack-cli (options) [method] [args...]

This CLI allows you to generate simple signed transactions for blockstack-core
to process.

This CLI has two methods:

  publish          used to generate and sign a contract publish transaction
  contract-call    used to generate and sign a contract-call transaction
  generate-sk      used to generate a secret key for transaction signing

For usage information on those methods, call `blockstack-cli [method] -h`

`blockstack-cli` accepts flag options as well:

   --testnet       instruct the transaction generator to use a testnet version byte instead of MAINNET (default)


$ ./target/debug/blockstack-cli generate-sk -h
USAGE:
 blockstack-cli (options) generate-sk

This method generates a secret key, outputting the hex encoding of the
secret key, the corresponding public key, and the corresponding P2PKH Stacks address.

$ ./target/debug/blockstack-cli publish -h
USAGE:
 blockstack-cli (options) publish [publisher-secret-key-hex] [fee-rate] [nonce] [contract-name] [file-name.clar]

The publish command generates and signs a contract publish transaction. If successful,
this command outputs the hex string encoding of the transaction to stdout, and exits with
code 0

$ ./target/debug/blockstack-cli contract-call -h
USAGE:
 blockstack-cli (options) contract-call [origin-secret-key-hex] [fee-rate] [nonce] [contract-publisher-address] [contract-name] [function-name] [args...]

The contract-call command generates and signs a contract-call transaction. If successful,
this command outputs the hex string encoding of the transaction to stdout, and exits with
code 0

Arguments are supplied in one of two ways: through script evaluation or via hex encoding
of the value serialization format. The method for supplying arguments is chosen by
prefacing each argument with a flag:

  -e  indicates the argument should be _evaluated_
  -x  indicates the argument is supplied as a hexstring of the value serialization

e.g.,

   blockstack-cli contract-call $secret_key SPJT598WY1RJN792HRKRHRQYFB7RJ5ZCG6J6GEZ4 10 0 foo-contract \
      transfer-fookens -e \'SPJT598WY1RJN792HRKRHRQYFB7RJ5ZCG6J6GEZ4 \
                       -e "(+ 1 2)" \
                       -x 0000000000000000000000000000000001 \
                       -x 050011deadbeef11ababffff11deadbeef11ababffff

Note that arguments supplied via the -x flag currently would want the JSON serialization scheme, but would change to the more compact serialization once #1199 merges.

@codecov
Copy link

codecov bot commented Jan 2, 2020

Codecov Report

❗ No coverage uploaded for pull request base (feature/testnet-runloop@8a06405). Click here to learn what that means.
The diff coverage is 24.26%.

Impacted file tree graph

@@                    Coverage Diff                     @@
##             feature/testnet-runloop    #1203   +/-   ##
==========================================================
  Coverage                           ?   82.61%           
==========================================================
  Files                              ?      149           
  Lines                              ?    40231           
  Branches                           ?        0           
==========================================================
  Hits                               ?    33237           
  Misses                             ?     6994           
  Partials                           ?        0
Impacted Files Coverage Δ
src/testnet/mod.rs 0% <ø> (ø)
src/chainstate/stacks/db/blocks.rs 88.98% <ø> (ø)
src/testnet/tenure.rs 0% <0%> (ø)
src/testnet/keychain.rs 0% <0%> (ø)
src/testnet/run_loop.rs 0% <0%> (ø)
src/testnet/node.rs 0% <0%> (ø)
src/testnet/burnchain.rs 0% <0%> (ø)
src/testnet/mem_pool.rs 0% <0%> (ø)
src/blockstack_cli.rs 80% <100%> (ø)
src/util/secp256k1.rs 84.58% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8a06405...6bdf72a. Read the comment docs.

This CLI allows you to generate simple signed transactions for blockstack-core
to process.

This CLI has two methods:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"three methods"


e.g.,

blockstack-cli contract-call $secret_key SPJT598WY1RJN792HRKRHRQYFB7RJ5ZCG6J6GEZ4 10 0 foo-contract \\
Copy link
Member

@jcnelson jcnelson Jan 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example doesn't match the usage.

transfer-fookens -e \\'SPJT598WY1RJN792HRKRHRQYFB7RJ5ZCG6J6GEZ4 \\
-e \"(+ 1 2)\" \\
-x 0000000000000000000000000000000001 \\
-x 050011deadbeef11ababffff11deadbeef11ababffff
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify, does -x indicate that a serialized Clarity value is being passed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Member

@jcnelson jcnelson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM @kantai! Just a few minor changes in the documentation, and it should be good to go. You might need to re-base off of develop first though.

@kantai kantai requested a review from lgalabru January 7, 2020 21:37
@kantai kantai self-assigned this Jan 7, 2020
Copy link
Contributor

@lgalabru lgalabru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used for testing #1202, looks good to me! Thanks @kantai

@kantai kantai merged commit 573b47a into feature/testnet-runloop Jan 14, 2020
@kantai kantai deleted the feature/signer-cli branch January 14, 2020 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants