mirror of
https://github.com/aljazceru/ark.git
synced 2026-02-03 02:24:40 +01:00
* Import stubs * send and balance cmd implementations * ListVtxos & faucet * main.go: add faucetCommand * fix after review * send: continue if no forfeits included in current round * remove cov in noah/Makefile * fancy printJSON * remove rpc_url --------- Co-authored-by: altafan <18440657+altafan@users.noreply.github.com>
31 lines
491 B
Go
31 lines
491 B
Go
package main
|
|
|
|
import (
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
var balanceCommand = cli.Command{
|
|
Name: "balance",
|
|
Usage: "Print balance of the Noah wallet",
|
|
Action: balanceAction,
|
|
}
|
|
|
|
func balanceAction(ctx *cli.Context) error {
|
|
client, close, err := getArkClient(ctx)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer close()
|
|
|
|
vtxos, err := getVtxos(ctx, client)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
balance := computeBalance(vtxos)
|
|
|
|
return printJSON(map[string]interface{}{
|
|
"balance": balance,
|
|
})
|
|
}
|