Select Git revision
Hans Moog
authored and
GitHub
committed
* Feat: started adding new logic to the wallet package * Feat: intermediary commit * Feat: added Outputs to wallet * Feat: started implementing SendFunds * Feat: added AddressManager + refactored code * Feat: tx gets constructed * Feat: txs get sent now * Feat: fixed bug after merge * Fix: fixed faucet * Fix: fix double spend tool * Fix: refactored broken tests * Fix: fixed additional tests * Fix: fixed some integration tests * Fix: fixed some issues * Fix: fixed further bugs in integration tests * Fix: fixed some bugs *Make WaitToKillTimeInSeconds a parameter * Set default ParaWaitToKill to 60 seconds * Fix bug * Feat: added an output manager * Fix: fixed bug * Feat: added new features to the wallet * Feat: added missing comments * Feat: updated some stuff * Feat: started to implement a cli wallet * Feat: added new features to cli wallet * Feat: added more features to cli wallet * Feat: MOAR FEATURES * Feat: finished wallet * Fix: fixed bug due to refactor * Fix: fixed bugs * Refactor: removed comments from private methods * do not ignore client lib * move wallet inside of the client dir * do not ignore client in docker build * go fmt yourself * Feat: added config to wallet * Feat: exe creates default config upon first launch * Feat: updated gitignore * Feat: refactored some code * Feat: added ERROR to all "non-fatal" error messages * Feat: removed error prefix from call and moved to func * Feat: indented error message * Feat: make commands look like params in useage print * Feat: reordered commands and params * Feat: fixed bug with colored coins creation * Fix: fixed missing unit tests * Feat: added message to sendfunds * Feat: added message for faucet POW call * Feat: intermediary commit * Fix: Enable server-status to get server information * Fix: Fix dependency cycle * Fix: Fix unit test errors * Fix: Fix integration test * Fix: Fix consensus integration test * Fix: fix * Refactor: Reorganize the wallet files to make it cleaner * Fix: Fix * Add script for building cli-wallet binaries Co-authored-by: Hans Moog <hm@mkjc.net> Co-authored-by:
capossele <angelocapossele@gmail.com> Co-authored-by:
Wolfgang Welz <welzwo@gmail.com> Co-authored-by:
jkrvivian <jkrvivian@gmail.com>
balance.go 1.32 KiB
package main
import (
"flag"
"fmt"
"os"
"text/tabwriter"
"github.com/iotaledger/goshimmer/client/wallet"
)
func execBalanceCommand(command *flag.FlagSet, cliWallet *wallet.Wallet) {
err := command.Parse(os.Args[2:])
if err != nil {
panic(err)
}
confirmedBalance, pendingBalance, err := cliWallet.Balance()
if err != nil {
printUsage(nil, err.Error())
}
// initialize tab writer
w := new(tabwriter.Writer)
w.Init(os.Stdout, 0, 8, 2, '\t', 0)
defer w.Flush()
// print header
fmt.Println()
_, _ = fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", "STATUS", "BALANCE", "COLOR", "TOKEN NAME")
_, _ = fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", "------", "---------------", "--------------------------------------------", "-------------------------")
// print empty if no balances founds
if len(confirmedBalance) == 0 && len(pendingBalance) == 0 {
_, _ = fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", "<EMPTY>", "<EMPTY>", "<EMPTY>", "<EMPTY>")
return
}
// print balances
for color, amount := range confirmedBalance {
_, _ = fmt.Fprintf(w, "%s\t%d %s\t%s\t%s\n", "[ OK ]", amount, cliWallet.AssetRegistry().Symbol(color), color.String(), cliWallet.AssetRegistry().Name(color))
}
for color, amount := range pendingBalance {
_, _ = fmt.Fprintf(w, "%s\t%d\t%s\t%s\n", "[PEND]", amount, color.String(), cliWallet.AssetRegistry().Name(color))
}
}