Trace a wallet-visible Orchard spend back to its creating action
A Zcash wallet knows private relationships that a public transaction parser cannot recover. For an Orchard spend it can report the action that created the spent note.
Read the wallet's decrypted spend records
Set TXID to an in-wallet transaction. action indexes the spending action, whereas txidPrev and actionPrev locate the earlier transaction and action. Keep both sides when reconstructing the wallet's private ledger.
zcash-cli z_viewtransaction "$TXID" | jq '.spends[] | select(.pool == "orchard") | {action, txidPrev, actionPrev, valueZat}'
Distinguish note identity from transaction identity
Several actions can occur in one transaction. Using only the previous transaction ID as a key can merge different notes. Scope the index by pool because Sapling uses a different output index. The returned relationships reflect this wallet's visibility and should not be published as public-chain metadata.