cmd: fix get-txn when fetching from txn pool

when looking at a transaction that's still in the pool, outputindices[@]
is empty

Signed-off-by: Ciro S. Costa <utxobr@protonmail.com>
This commit is contained in:
Ciro S. Costa 2021-07-20 18:50:45 -04:00
parent dd302892fd
commit 2b2bf3eba6

View file

@ -144,13 +144,19 @@ func (c *getTransactionCommand) prettyOutputs(
table.AddRow("Outputs")
table.AddRow()
table.AddRow("", "STEALTH ADDR", "AMOUNT", "AMOUNT IDX")
fmt.Println("indices", txn.OutputIndices)
for idx, vout := range txnDetails.Vout {
amount := "?"
if vout.Amount != 0 {
amount = strconv.Itoa(vout.Amount)
}
table.AddRow(idx, vout.Target.Key, amount, txn.OutputIndices[idx])
var outIdx interface{} = "?"
if len(txn.OutputIndices) != 0 {
outIdx = txn.OutputIndices[idx]
}
table.AddRow(idx, vout.Target.Key, amount, outIdx)
}
fmt.Println(table)