diff --git a/cli_printchain.go b/cli_printchain.go index 4c2e865..cd5c7a0 100644 --- a/cli_printchain.go +++ b/cli_printchain.go @@ -14,14 +14,14 @@ func (cli *CLI) printChain() { for { block := bci.Next() - fmt.Printf("Prev. hash: %x\n", block.PrevBlockHash) - fmt.Printf("Hash: %x\n", block.Hash) + fmt.Printf("============ Block %x ============\n", block.Hash) + fmt.Printf("Prev. block: %x\n", block.PrevBlockHash) pow := NewProofOfWork(block) - fmt.Printf("PoW: %s\n", strconv.FormatBool(pow.Validate())) + fmt.Printf("PoW: %s\n\n", strconv.FormatBool(pow.Validate())) for _, tx := range block.Transactions { fmt.Println(tx) } - fmt.Println() + fmt.Printf("\n\n") if len(block.PrevBlockHash) == 0 { break diff --git a/transaction.go b/transaction.go index 598c65f..7f035a8 100644 --- a/transaction.go +++ b/transaction.go @@ -89,21 +89,21 @@ func (tx *Transaction) Sign(privKey ecdsa.PrivateKey, prevTXs map[string]Transac func (tx Transaction) String() string { var lines []string - lines = append(lines, fmt.Sprintf("Transaction %x:", tx.ID)) + lines = append(lines, fmt.Sprintf("--- Transaction %x:", tx.ID)) for i, input := range tx.Vin { - 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(" 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)) } for i, output := range tx.Vout { - lines = append(lines, fmt.Sprintf(" Output %d:", i)) - lines = append(lines, fmt.Sprintf(" Value: %d", output.Value)) - lines = append(lines, fmt.Sprintf(" Script: %x", output.PubKeyHash)) + lines = append(lines, fmt.Sprintf(" Output %d:", i)) + lines = append(lines, fmt.Sprintf(" Value: %d", output.Value)) + lines = append(lines, fmt.Sprintf(" Script: %x", output.PubKeyHash)) } return strings.Join(lines, "\n")