20 lines
380 B
Go
20 lines
380 B
Go
|
package main
|
||
|
|
||
|
import "fmt"
|
||
|
|
||
|
func (cli *CLI) getBalance(address string) {
|
||
|
bc := NewBlockchain(address)
|
||
|
defer bc.db.Close()
|
||
|
|
||
|
balance := 0
|
||
|
pubKeyHash := Base58Decode([]byte(address))
|
||
|
pubKeyHash = pubKeyHash[1 : len(pubKeyHash)-4]
|
||
|
UTXOs := bc.FindUTXO(pubKeyHash)
|
||
|
|
||
|
for _, out := range UTXOs {
|
||
|
balance += out.Value
|
||
|
}
|
||
|
|
||
|
fmt.Printf("Balance of '%s': %d\n", address, balance)
|
||
|
}
|