fine tuning

This commit is contained in:
Peter D. Gray 2024-06-06 12:21:04 -04:00
parent a9fb98fd93
commit cad2722d14
No known key found for this signature in database
GPG Key ID: A2DCD558C2BE5D7C
2 changed files with 27 additions and 25 deletions

View File

@ -116,15 +116,15 @@ Usage: ckcc sign [OPTIONS] PSBT_IN [PSBT_OUT]
Approve a spending transaction by signing it on Coldcard
Options:
-f, --finalize Show final signed transaction, ready for transmission
-z, --visualize Show text of Coldcard's interpretation of the transaction
(does not create transaction, no interaction needed)
-p, --pushtx TEXT Broadcast transaction via provided PushTx URL. Requires
--finalize flag. Shortcut options: coldcard, mempool
-s, --signed Include a signature over visualization text
-x, --hex Write out (signed) PSBT in hexidecimal
-6, --base64 Write out (signed) PSBT encoded in base64
--help Show this message and exit.
-f, --finalize Show final signed transaction, ready for transmission
-z, --visualize Show text of Coldcard's interpretation of the transaction
(does not create transaction, no interaction needed)
-p, --pushtx URL Broadcast transaction via provided PushTx URL. Shortcut
options: coldcard, mempool
-s, --signed Include a signature over visualization text
-x, --hex Write out (signed) PSBT in hexidecimal
-6, --base64 Write out (signed) PSBT encoded in base64
--help Show this message and exit.
% (... acquire PSBT file for what you want to do ...)
@ -158,4 +158,4 @@ Commands:
enroll Enroll miniscript wallet
get Get registered miniscript wallet by name.
ls List registered miniscript wallet names.
```
```

View File

@ -483,7 +483,7 @@ def wait_and_download(dev, req, fn):
@click.argument('psbt_out', type=click.File('wb'), required=False)
@click.option('--finalize', '-f', is_flag=True, help='Show final signed transaction, ready for transmission')
@click.option('--visualize', '-z', is_flag=True, help='Show text of Coldcard\'s interpretation of the transaction (does not create transaction, no interaction needed)')
@click.option('--pushtx', '-p', default=None, help='Broadcast transaction via provided PushTx URL. Forces --finalize flag. Shortcut options: coldcard, mempool')
@click.option('--pushtx', '-p', default=None, help='Broadcast transaction via provided PushTx URL. Shortcut options: coldcard, mempool', metavar="URL")
@click.option('--signed', '-s', is_flag=True, help='Include a signature over visualization text')
@click.option('--hex', '-x', 'hex_mode', is_flag=True, help="Write out (signed) PSBT in hexidecimal")
@click.option('--base64', '-6', 'b64_mode', is_flag=True, help="Write out (signed) PSBT encoded in base64")
@ -513,6 +513,7 @@ def sign_transaction(psbt_in, psbt_out=None, pushtx=None, b64_mode=False, hex_mo
if pushtx:
finalize = True
visualize = signed = False
flags = 0x0
if visualize or signed:
@ -540,19 +541,6 @@ def sign_transaction(psbt_in, psbt_out=None, pushtx=None, b64_mode=False, hex_mo
else:
click.echo(result, nl=False)
else:
if finalize and pushtx:
pushtx_url = {
"coldcard": "https://coldcard.com/pushtx#",
"mempool": "https://mempool.space/pushtx#"
}.get(pushtx, pushtx)
chain = dev.send_recv(CCProtocolPacker.block_chain())
try:
url = txn_to_pushtx_url(result, pushtx_url, sha=sha, chain=chain)
click.launch(url)
except Exception as e:
click.echo(f"ERROR: {e}", err=True)
return
# save it
if hex_mode:
result = b2a_hex(result)
@ -561,9 +549,23 @@ def sign_transaction(psbt_in, psbt_out=None, pushtx=None, b64_mode=False, hex_mo
if psbt_out:
psbt_out.write(result)
else:
elif not pushtx:
click.echo(result)
if pushtx:
pushtx_url = {
"coldcard": "https://coldcard.com/pushtx#",
"mempool": "https://mempool.space/pushtx#"
}.get(pushtx, pushtx)
chain = dev.send_recv(CCProtocolPacker.block_chain())
try:
url = txn_to_pushtx_url(result, pushtx_url, sha=sha, chain=chain)
click.launch(url)
except Exception as e:
click.echo(f"ERROR: {e}", err=True)
@main.command('backup')
@click.option('--outdir', '-d',