doc/offline-signing-tutorial.md writes the PSBT output using append (>>) instead of overwrite (>) in two spots:
- line 115 —
... | jq -r '.psbt' >> /path/to/funded_psbt.txt - line 173 —
... | jq -r .hex >> /path/to/final_psbt.txt
but every step after that just does $(cat ...) on these files, expecting only one line to be in there:
- lines 127, 133 —
decodepsbt $(cat /path/to/funded_psbt.txt),analyzepsbt $(cat ...) - lines 170-171 —
walletprocesspsbt $(cat /path/to/funded_psbt.txt) ... - line 180 —
sendrawtransaction $(cat /path/to/final_psbt.txt)
so if someone reruns the send step (say they typo'd the amount or just want to redo it) without deleting the file first, >> just adds another line instead of overwritting it. then unquoted $(cat file) splits that into two separate args, and evry RPC that reads it (decodepsbt, analyzepsbt, walletprocesspsbt, sendrawtransaction) throws a "too many arguments" error. kind of a bad spot to get stuck in, given this whole tutorial is about careful key handling.
tested the actual bash behavior to confirm this:
$ bash -c 'f=/tmp/t.txt; rm -f "$f"; echo a >> "$f"; echo b >> "$f"; foo(){ echo argc=$#; }; foo $(cat "$f")'
argc=2