refactor(tui): describe non-to-key outputs in explorer
Some checks are pending
Security Scan / security (push) Waiting to run
Test / Test (push) Waiting to run

Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
Virgil 2026-04-04 22:31:10 +00:00
parent bb941ebcc5
commit bdbefa7d4a

View file

@ -328,7 +328,7 @@ func (m *ExplorerModel) viewTxDetail() string {
if targetKey, ok := v.SpendKey(); ok {
b.WriteString(fmt.Sprintf(" [%d] bare amount=%d key=%x\n", i, v.Amount, targetKey[:4]))
} else {
b.WriteString(fmt.Sprintf(" [%d] bare amount=%d target=%T\n", i, v.Amount, v.Target))
b.WriteString(fmt.Sprintf(" [%d] bare amount=%d %s\n", i, v.Amount, describeTxOutTarget(v.Target)))
}
case types.TxOutputZarcanum:
b.WriteString(fmt.Sprintf(" [%d] zarcanum stealth=%x\n", i, v.StealthAddress[:4]))
@ -341,6 +341,22 @@ func (m *ExplorerModel) viewTxDetail() string {
return b.String()
}
// describeTxOutTarget renders a human-readable summary for non-to-key outputs.
func describeTxOutTarget(target types.TxOutTarget) string {
switch t := target.(type) {
case types.TxOutMultisig:
return fmt.Sprintf("multisig minimum_sigs=%d keys=%d", t.MinimumSigs, len(t.Keys))
case types.TxOutHTLC:
return fmt.Sprintf("htlc expiration=%d flags=%d redeem=%x refund=%x", t.Expiration, t.Flags, t.PKRedeem[:4], t.PKRefund[:4])
case types.TxOutToKey:
return fmt.Sprintf("to_key key=%x mix_attr=%d", t.Key[:4], t.MixAttr)
case nil:
return "target=<nil>"
default:
return fmt.Sprintf("target=%T", t)
}
}
// loadBlocks refreshes the block list from the chain store.
// Blocks are listed from newest (top) to oldest.
func (m *ExplorerModel) loadBlocks() {