Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion cashu/wallet/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ async def wrapper(*args, **kwargs):
)
@click.pass_context
@coro
async def cli(ctx: Context, host: str, walletname: str, unit: str, tests: bool, verbose: bool):
async def cli(
ctx: Context, host: str, walletname: str, unit: str, tests: bool, verbose: bool
):
if settings.debug:
configure_logger()
if settings.tor and not TorProxy().check_platform():
Expand Down Expand Up @@ -672,6 +674,13 @@ async def balance(ctx: Context, verbose):
help="Force swap token.",
type=bool,
)
@click.option(
"--lock-tags",
"-t",
default=None,
help="Comma-separated tags for locked tokens.",
type=str,
)
@click.pass_context
@coro
@init_auth_wallet
Expand All @@ -688,6 +697,7 @@ async def send_command(
offline: bool,
include_fees: bool,
force_swap: bool,
lock_tags: Optional[str] = None,
):
wallet: Wallet = ctx.obj["WALLET"]
amount = int(amount * 100) if wallet.unit in [Unit.usd, Unit.eur] else int(amount)
Expand All @@ -702,6 +712,7 @@ async def send_command(
include_fees=include_fees,
memo=memo,
force_swap=force_swap,
lock_tags=lock_tags,
)
else:
await send_nostr(wallet, amount=amount, pubkey=nostr, verbose=verbose, yes=yes)
Expand Down
15 changes: 15 additions & 0 deletions cashu/wallet/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from loguru import logger

from cashu.core.secret import Tags

from ..core.base import Token, TokenV3, TokenV4
from ..core.db import Database
from ..core.helpers import sum_proofs
Expand Down Expand Up @@ -121,6 +123,7 @@ async def send(
include_fees: bool = False,
memo: Optional[str] = None,
force_swap: bool = False,
lock_tags: Optional[str] = None,
):
"""
Prints token to send to stdout.
Expand All @@ -137,11 +140,23 @@ async def send(
logger.debug(
f"Adding a time lock of {settings.locktime_delta_seconds} seconds."
)
# parse tags
tags: Optional[Tags] = None
if lock_tags:
tags = Tags(
tags=[
[tag.split("=")[0], tag.split("=")[1]]
for tag in lock_tags.split(",")
]
)
else:
tags = None
secret_lock = await wallet.create_p2pk_lock(
lock.split(":")[1],
locktime_seconds=settings.locktime_delta_seconds,
sig_all=sigall,
n_sigs=1,
tags=tags,
)
logger.debug(f"Secret lock: {secret_lock}")
else:
Expand Down
5 changes: 2 additions & 3 deletions cashu/wallet/p2pk.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ async def create_p2pk_lock(
tags["locktime"] = str(
int((datetime.now() + timedelta(seconds=locktime_seconds)).timestamp())
)
tags["sigflag"] = (
SigFlags.SIG_ALL.value if sig_all else SigFlags.SIG_INPUTS.value
)
if sig_all:
tags["sigflag"] = SigFlags.SIG_ALL.value
if n_sigs > 1:
tags["n_sigs"] = str(n_sigs)
logger.debug(f"After tags: {tags}")
Expand Down