From 5c88b24c2c3fb6021abf366295e2372540ba4e07 Mon Sep 17 00:00:00 2001 From: Wei Yang Date: Thu, 19 Oct 2017 22:28:49 +0800 Subject: [PATCH] display the addresse in TXIn and optmize getAddress command --- cli_explore.go | 6 ++---- transaction.go | 5 +++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cli_explore.go b/cli_explore.go index b5ddb4c..d221321 100644 --- a/cli_explore.go +++ b/cli_explore.go @@ -17,14 +17,12 @@ func (cli *CLI) getAddress(pubKey string) { pubKeyHash := HashPubKey(public) versionedPayload := append([]byte{version}, pubKeyHash...) - checksum := checksum(versionedPayload) + fullPayload := append(versionedPayload, checksum(versionedPayload)...) - fullPayload := append(versionedPayload, checksum...) - address := Base58Encode(fullPayload) fmt.Println() fmt.Printf("PubKey : %s\n", pubKey) fmt.Printf("PubKeyHash : %x\n", pubKeyHash) - fmt.Printf("Address : %s\n", address) + fmt.Printf("Address : %s\n", Base58Encode(fullPayload)) } func (cli *CLI) getPubKeyHash(address string) { diff --git a/transaction.go b/transaction.go index c06c23e..f3fc097 100644 --- a/transaction.go +++ b/transaction.go @@ -94,11 +94,16 @@ func (tx Transaction) String() string { for i, input := range tx.Vin { + pubKeyHash := HashPubKey(input.PubKey) + versionedPayload := append([]byte{version}, pubKeyHash...) + fullPayload := append(versionedPayload, checksum(versionedPayload)...) + lines = append(lines, fmt.Sprintf(" Input %d:", i)) lines = append(lines, fmt.Sprintf(" TXID: %x", input.Txid)) lines = append(lines, fmt.Sprintf(" Out: %d", input.Vout)) lines = append(lines, fmt.Sprintf(" Signature: %x", input.Signature)) lines = append(lines, fmt.Sprintf(" PubKey: %x", input.PubKey)) + lines = append(lines, fmt.Sprintf(" Addr : %s", Base58Encode(fullPayload))) } for i, output := range tx.Vout {