mirror of
https://github.com/aljazceru/nutshell.git
synced 2025-12-22 19:34:18 +01:00
show clean balance
This commit is contained in:
@@ -160,9 +160,17 @@ async def pay(ctx, invoice: str, yes: bool):
|
|||||||
|
|
||||||
|
|
||||||
@cli.command("balance", help="Balance.")
|
@cli.command("balance", help="Balance.")
|
||||||
|
@click.option(
|
||||||
|
"--verbose",
|
||||||
|
"-v",
|
||||||
|
default=False,
|
||||||
|
is_flag=True,
|
||||||
|
help="Show pending tokens as well.",
|
||||||
|
type=bool,
|
||||||
|
)
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
@coro
|
@coro
|
||||||
async def balance(ctx):
|
async def balance(ctx, verbose):
|
||||||
wallet: Wallet = ctx.obj["WALLET"]
|
wallet: Wallet = ctx.obj["WALLET"]
|
||||||
keyset_balances = wallet.balance_per_keyset()
|
keyset_balances = wallet.balance_per_keyset()
|
||||||
if len(keyset_balances) > 1:
|
if len(keyset_balances) > 1:
|
||||||
@@ -173,9 +181,12 @@ async def balance(ctx):
|
|||||||
f"Keyset: {k or 'undefined'} Balance: {v['balance']} sat (available: {v['available']} sat)"
|
f"Keyset: {k or 'undefined'} Balance: {v['balance']} sat (available: {v['available']} sat)"
|
||||||
)
|
)
|
||||||
print("")
|
print("")
|
||||||
print(
|
if verbose:
|
||||||
f"Balance: {wallet.balance} sat (available: {wallet.available_balance} sat in {len([p for p in wallet.proofs if not p.reserved])} tokens)"
|
print(
|
||||||
)
|
f"Balance: {wallet.balance} sat (available: {wallet.available_balance} sat in {len([p for p in wallet.proofs if not p.reserved])} tokens)"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
print(f"Balance: {wallet.available_balance} sat")
|
||||||
|
|
||||||
|
|
||||||
@cli.command("send", help="Send coins.")
|
@cli.command("send", help="Send coins.")
|
||||||
|
|||||||
@@ -552,9 +552,10 @@ class Wallet(LedgerAPI):
|
|||||||
return sum_proofs([p for p in self.proofs if not p.reserved])
|
return sum_proofs([p for p in self.proofs if not p.reserved])
|
||||||
|
|
||||||
def status(self):
|
def status(self):
|
||||||
print(
|
# print(
|
||||||
f"Balance: {self.balance} sat (available: {self.available_balance} sat in {len([p for p in self.proofs if not p.reserved])} tokens)"
|
# f"Balance: {self.balance} sat (available: {self.available_balance} sat in {len([p for p in self.proofs if not p.reserved])} tokens)"
|
||||||
)
|
# )
|
||||||
|
print(f"Balance: {self.available_balance} sat")
|
||||||
|
|
||||||
def balance_per_keyset(self):
|
def balance_per_keyset(self):
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user