mirror of
https://github.com/aljazceru/nutshell.git
synced 2025-12-20 18:44:20 +01:00
[Wallet] Bugfix/enable-funding-multiple-mints (#210)
* Fix bug where no additional mints can be funded As soon as one mint is in the database, the new multimint selector only considers this mint, even if the `MINT_` environment variables point to a different one. This commit fixes it by explicitly adding the set mint URL to the selector. Additionally did some small cleanups. * Move mint adding to higher-level function * bypass selection at first time * use contextx, more explicit * remove whitespace --------- Co-authored-by: xphade <18196286+xphade@users.noreply.github.com>
This commit is contained in:
@@ -67,7 +67,7 @@ def cli(ctx: Context, host: str, walletname: str):
|
|||||||
ctx.obj["HOST"], os.path.join(settings.cashu_dir, walletname), name=walletname
|
ctx.obj["HOST"], os.path.join(settings.cashu_dir, walletname), name=walletname
|
||||||
)
|
)
|
||||||
ctx.obj["WALLET"] = wallet
|
ctx.obj["WALLET"] = wallet
|
||||||
asyncio.run(init_wallet(wallet))
|
asyncio.run(init_wallet(ctx.obj["WALLET"]))
|
||||||
|
|
||||||
# MUTLIMINT: Select a wallet
|
# MUTLIMINT: Select a wallet
|
||||||
# only if a command is one of a subset that needs to specify a mint host
|
# only if a command is one of a subset that needs to specify a mint host
|
||||||
@@ -75,7 +75,6 @@ def cli(ctx: Context, host: str, walletname: str):
|
|||||||
if ctx.invoked_subcommand not in ["send", "invoice", "pay"] or host:
|
if ctx.invoked_subcommand not in ["send", "invoice", "pay"] or host:
|
||||||
return
|
return
|
||||||
# else: we ask the user to select one
|
# else: we ask the user to select one
|
||||||
ctx.obj["WALLET"] = wallet # set a wallet for get_mint_wallet in the next step
|
|
||||||
ctx.obj["WALLET"] = asyncio.run(
|
ctx.obj["WALLET"] = asyncio.run(
|
||||||
get_mint_wallet(ctx)
|
get_mint_wallet(ctx)
|
||||||
) # select a specific wallet by CLI input
|
) # select a specific wallet by CLI input
|
||||||
|
|||||||
@@ -30,8 +30,10 @@ async def get_mint_wallet(ctx: Context):
|
|||||||
wallet: Wallet = ctx.obj["WALLET"]
|
wallet: Wallet = ctx.obj["WALLET"]
|
||||||
mint_balances = await wallet.balance_per_minturl()
|
mint_balances = await wallet.balance_per_minturl()
|
||||||
|
|
||||||
# if we have balances on more than one mint, we ask the user to select one
|
if ctx.obj["HOST"] not in mint_balances:
|
||||||
if len(mint_balances) > 1:
|
mint_url = wallet.url
|
||||||
|
elif len(mint_balances) > 1:
|
||||||
|
# if we have balances on more than one mint, we ask the user to select one
|
||||||
await print_mint_balances(wallet, show_mints=True)
|
await print_mint_balances(wallet, show_mints=True)
|
||||||
|
|
||||||
url_max = max(mint_balances, key=lambda v: mint_balances[v]["available"])
|
url_max = max(mint_balances, key=lambda v: mint_balances[v]["available"])
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ from ..core.settings import settings
|
|||||||
from ..nostr.nostr.client.client import NostrClient
|
from ..nostr.nostr.client.client import NostrClient
|
||||||
from ..nostr.nostr.event import Event
|
from ..nostr.nostr.event import Event
|
||||||
from ..nostr.nostr.key import PublicKey
|
from ..nostr.nostr.key import PublicKey
|
||||||
from .cli.cli_helpers import get_mint_wallet
|
|
||||||
from .crud import get_nostr_last_check_timestamp, set_nostr_last_check_timestamp
|
from .crud import get_nostr_last_check_timestamp, set_nostr_last_check_timestamp
|
||||||
from .helpers import receive
|
from .helpers import receive
|
||||||
from .wallet import Wallet
|
from .wallet import Wallet
|
||||||
|
|||||||
Reference in New Issue
Block a user