Skip to content

Explicit change #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
4 changes: 4 additions & 0 deletions green_cli/param_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ def convert(self, value, param, ctx):
# level. gdk only allows one addressee with send all
ctx.params['details']['send_all'] = True
value = 0
elif value == "change":
# Explicit change output
ctx.params['details']['addressees'][-1]['is_change'] = True
value = 0
else:
value = self.value2sat(value)

Expand Down
12 changes: 7 additions & 5 deletions green_cli/tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ def __exit__(self, type, value, traceback):
if self.recreate:
self._tx = _create_tx(self._tx)
self._tx = _save_tx(self._tx)
if self._tx['error']:
click.echo(f"ERROR: {self._tx['error']}", err=True)
return False

@tx.command()
Expand Down Expand Up @@ -167,9 +169,9 @@ def outputs(ctx, session, **options):
if ctx.invoked_subcommand:
return

tx = _load_tx(allow_errors=True)
for output in tx['transaction_outputs']:
_print_tx_output(options, output)
with Tx(allow_errors=True) as tx:
for output in tx['transaction_outputs']:
_print_tx_output(options, output)

@outputs.command(name='add')
@click.argument('address', type=Address(), expose_value=False)
Expand Down Expand Up @@ -217,8 +219,8 @@ def _filter_utxos(utxo_filter, utxos):
if address and address == utxo.get('address', None):
selected.append(utxo)
continue
if txhash == '*' or txhash == utxo['txhash']:
if not pt_idx or pt_idx == '*' or int(pt_idx) == utxo['pt_idx']:
if txhash == '*' or txhash == 'all' or txhash == utxo['txhash']:
if not pt_idx or pt_idx == 'all' or pt_idx == '*' or int(pt_idx) == utxo['pt_idx']:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: comparing in the same order would read better, or perhaps a utility function _is_all could be used.

selected.append(utxo)
return selected

Expand Down