display the addresse in TXIn and optmize getAddress command

This commit is contained in:
Wei Yang 2017-10-19 22:28:49 +08:00
parent 01d18ce4d5
commit 5c88b24c2c
2 changed files with 7 additions and 4 deletions

View File

@ -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) {

View File

@ -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 {