From ba1196a96241cea3de052f8baf3101d2281b1c54 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Sun, 27 Oct 2024 09:37:34 -0300 Subject: [PATCH] File.Human() option to print partial results. --- ots.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ots.go b/ots.go index ab2ac14..cf26bce 100644 --- a/ots.go +++ b/ots.go @@ -149,20 +149,26 @@ func (ts File) GetBitcoinAttestedSequences() []Sequence { return results } -func (ts File) Human() string { +func (ts File) Human(withPartials bool) string { strs := make([]string, 0, 100) strs = append(strs, fmt.Sprintf("file digest: %x", ts.Digest)) strs = append(strs, fmt.Sprintf("hashed with: sha256")) strs = append(strs, "instruction sequences:") for _, seq := range ts.Sequences { + curr := ts.Digest strs = append(strs, "~>") + strs = append(strs, " start "+hex.EncodeToString(curr)) for _, inst := range seq { line := " " if inst.Operation != nil { line += inst.Operation.Name + curr = inst.Operation.Apply(curr, inst.Argument) if inst.Operation.Binary { line += " " + hex.EncodeToString(inst.Argument) } + if withPartials { + line += " = " + hex.EncodeToString(curr) + } } else if inst.Attestation != nil { line += inst.Attestation.Human() } else {