bb8
bb8 copied to clipboard
Allow JSON input via STDIN
Allow STDIN to supply the JSON input to bb8
cat someFileWithChangeTrustOp.js | bb8 change-trust --
Also allow the command to come from the JSON itself:
{
"bb8_cmd":{
"command":"change-trust",
"data":{
"source_account":"GACCT",
"asset_code":"COMP",
"asset_issuer":"GISSUER"
}
} | bb8 --
this part
Allow STDIN to supply the JSON input to bb8
is supported:
$ cat tx.json
{
"source_account": "GBDGNIE6H7RSFIXLID6XO3GHUPPCX5BBJ7JJBRXKB6DBS5B2VSEUWOG6",
"name": "answer to the ultimate question",
"value": "42"
}
$ cat tx.json | xargs -0 bb manage-data
AAAAAEZmoJ4/4yKi60D9d2zHo94r9CFP0pDG6g+GGXQ6rIlLAAAAZABt1SYAAAAGAAAAAAAAAAAAAAABAAAAAAAAAAoAAAAfYW5zd2VyIHRvIHRoZSB1bHRpbWF0ZSBxdWVzdGlvbgAAAAABAAAAAjQyAAAAAAAAAAAAAA==
not sure about the Windows syntax for it though, but it should work on Windows with power shell / bash / binutils
as to passing a command in JSON as well, need to think about it more, since this is most likely a different mode all together, since it is no longer "$ bb command args" where args could be in JSON, but rather "$ bb command-and-agrs" that come from JSON, which now also might need to support its own composition.
Agreed, perhaps
cat file.json | bb8 from-data -0
where from-data means the JSON data is something like the form:
{ "exec_flags": [], "command": "bb8-command", "command_flags": [...], "data": { ... } }
And instead of solely relying on xargs or the pipeline to make chaining work, what about modifying a transaction file one command at a time?
set STELLAR_ACCOUNT=GMYACCOUNT
REM empty-transaction sets source-account and sequence number in file init_account.xdr
bb8 --txn_file init_account.xdr empty-transaction
bb8 gen-keys --newaccount #creates newaccount.key and newacccount.pub
bb8 --txn_file init_account.xdr create-account --keyfile newaccount.pub --amount 10
REM 'type' is the windows version of 'cat' though not nearly as cool
type change-trust.json | bb8 --txn_file init_account.xdr change-trust -0 --op_source_account newaccount.pub
type add-signer.json | bb8 --txn_file init_account.xdr add-singer -0 --op_source_account newaccount.pub
type zero-master-key.json | bb8 --txn_file init_account.xdr set-options --op_source_account newaccount.pub
REM lastly sign the transaction to complete the init_account.xdr file, ready to submit
bb8 --txn_file init_account.xdr sign my_signing_key.key newaccount.key