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

Support using stdin as a input argument (shell pipe) #287

Closed
yangby-cryptape opened this issue May 22, 2020 · 2 comments
Closed

Support using stdin as a input argument (shell pipe) #287

yangby-cryptape opened this issue May 22, 2020 · 2 comments
Labels
good first issue Good for newcomers stale

Comments

@yangby-cryptape
Copy link
Collaborator

Now, a lot of sub-commands of ckb-cli require exporting data into files before pass them into next sub-commands.

In current, I have to write code like this:

ckb-cli tx init --tx-file "${ckb_tmp_txfile}"

echo "${privkey}" > "${privkey_file}"
ckb-tx sign-inputs --tx-file "${ckb_tmp_txfile}" \
    --privkey-path "${privkey_file}" \
    --add-signatures
rm "${privkey_file}"

cat "${ckb_tmp_txfile}" \
    | jq -r ".transaction.outputs[0].lock.code_hash = \"0x${lock_code_hash}\"" \
    | jq -r ".transaction.outputs[0].lock.hash_type = \"data\"" \
    | jq -r ".transaction.outputs[0].lock.args = \"0x\"" \
    | jq -r ".transaction.outputs[0].type = null" \
    | jq -r ".transaction.outputs_data[0] = \"0x\"" \
    > "${ckb_tmp_txfile}.tmp"
mv "${ckb_tmp_txfile}.tmp" "${ckb_tmp_txfile}"
ckb-cli tx send --tx-file "${ckb_tmp_txfile}" --skip-check
rm "${ckb_tmp_txfile}"

But, if ckb-cli support using stdin as a input argument, all temporary files are unnecessary.

For example, if - means stdin, the above code can be rewrite like this:

ckb-cli tx init --tx-file - \
    | ckb-tx sign-inputs --tx-file - --privkey "${privkey}" --add-signatures \
    | jq -r ".transaction.outputs[0].lock.code_hash = \"0x${lock_code_hash}\"" \
    | jq -r ".transaction.outputs[0].lock.hash_type = \"data\"" \
    | jq -r ".transaction.outputs[0].lock.args = \"0x\"" \
    | jq -r ".transaction.outputs[0].type = null" \
    | jq -r ".transaction.outputs_data[0] = \"0x\"" \
    | ckb-cli tx send --tx-file - --skip-check
Copy link

github-actions bot commented Aug 1, 2024

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the stale label Aug 1, 2024
Copy link

github-actions bot commented Aug 7, 2024

This issue was closed because it has been stalled for 5 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers stale
Projects
None yet
Development

No branches or pull requests

2 participants