{"action":"created","issue":{"url":"https://api.github.com/repos/bitcoin/bitcoin/issues/7550","repository_url":"https://api.github.com/repos/bitcoin/bitcoin","labels_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/7550/labels{/name}","comments_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/7550/comments","events_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/7550/events","html_url":"https://github.com/bitcoin/bitcoin/pull/7550","id":134290837,"number":7550,"title":"rpc: Input-from-stdin mode for bitcoin-cli","user":{"login":"laanwj","id":126646,"avatar_url":"https://avatars.githubusercontent.com/u/126646?v=3","gravatar_id":"","url":"https://api.github.com/users/laanwj","html_url":"https://github.com/laanwj","followers_url":"https://api.github.com/users/laanwj/followers","following_url":"https://api.github.com/users/laanwj/following{/other_user}","gists_url":"https://api.github.com/users/laanwj/gists{/gist_id}","starred_url":"https://api.github.com/users/laanwj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laanwj/subscriptions","organizations_url":"https://api.github.com/users/laanwj/orgs","repos_url":"https://api.github.com/users/laanwj/repos","events_url":"https://api.github.com/users/laanwj/events{/privacy}","received_events_url":"https://api.github.com/users/laanwj/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/bitcoin/bitcoin/labels/RPC","name":"RPC","color":"0052cc"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-17T14:15:14Z","updated_at":"2016-02-17T16:30:32Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/7550","html_url":"https://github.com/bitcoin/bitcoin/pull/7550","diff_url":"https://github.com/bitcoin/bitcoin/pull/7550.diff","patch_url":"https://github.com/bitcoin/bitcoin/pull/7550.patch"},"body":"Implements #7442 by adding an option `-stdin` which reads additional arguments from standard in, one per line.\r\n\r\nFor example\r\n\r\n```bash\r\n$ echo -e \"mysecretcode\\n120\" | src/bitcoin-cli -stdin walletpassphrase\r\n$ echo -e \"walletpassphrase\\nmysecretcode\\n120\" | src/bitcoin-cli -stdin\r\n$ src/bitcoin-cli -stdin walletpassphrase\r\nmysecretcode\r\n120\r\n^D\r\n```\r\n\r\nThis is the simplest implementation and avoids escaping issues by using newline as separator instead of space, I first had another implementation: https://github.com/laanwj/bitcoin/commit/1f73b8e27b57c8561840cddc9f69a97475d06e85 that reuses `parseCommandLine` from the GUI debug console, but I think this is more useful in practice as most use of cli is probably script-driven.\r\n"},"comment":{"url":"https://api.github.com/repos/bitcoin/bitcoin/issues/comments/185284911","html_url":"https://github.com/bitcoin/bitcoin/pull/7550#issuecomment-185284911","issue_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/7550","id":185284911,"user":{"login":"paveljanik","id":6848764,"avatar_url":"https://avatars.githubusercontent.com/u/6848764?v=3","gravatar_id":"","url":"https://api.github.com/users/paveljanik","html_url":"https://github.com/paveljanik","followers_url":"https://api.github.com/users/paveljanik/followers","following_url":"https://api.github.com/users/paveljanik/following{/other_user}","gists_url":"https://api.github.com/users/paveljanik/gists{/gist_id}","starred_url":"https://api.github.com/users/paveljanik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paveljanik/subscriptions","organizations_url":"https://api.github.com/users/paveljanik/orgs","repos_url":"https://api.github.com/users/paveljanik/repos","events_url":"https://api.github.com/users/paveljanik/events{/privacy}","received_events_url":"https://api.github.com/users/paveljanik/received_events","type":"User","site_admin":false},"created_at":"2016-02-17T16:30:32Z","updated_at":"2016-02-17T16:30:32Z","body":"Brilliant idea!\r\n\r\nACK https://github.com/laanwj/bitcoin/commit/c97198db769954c4ad2b57eaf7e5335578badc00\r\n\r\n```shell\r\npavel$ echo -e \"getblockhash\\n0\" | bitcoin-7550/src/bitcoin-cli -stdin\r\n000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f\r\npavel$ \r\n```"}}