Skip to content
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

bitcoin: display account name when sending to self #1360

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

benma
Copy link
Collaborator

@benma benma commented Jan 30, 2025

Before, we did this only when sending to the same account. This commit extends this to work when sending to an address of a different account of the same keystore.

The bitcoin transaction script_configs field is used for inputs and change outputs. We add a similar list, output_script_configs, which allows to attach script configs of different accounts to outputs, with output_script_config_index to reference them in the output.

To ensure backwards compatibility, output_script_config_index is added as a new field, which takes precedence over
script_config_index when set.

The output script configs are validated, but since one can send to any address of the same keystore, the output script config validation allows any combination of script configs, unlike the input script configs. To not duplicate lots of code, a few refactors are done:

  • validate_script_configs is now used for generic validation and is used to validate the output script configs as well as the input script configs
  • validate_input_script_configs performs additional validation as before (can't mix multisig and single sig inputs, can't mix inputs from different accounts, etc).
  • the multisig/policy name is stored in ValidatedScriptConfig, so we don't have to fetch it twice

The Python lib version was downgraded from 8.0.0 to 7.0.0, it seems it
was bumped before in error - the previous release tag and release is 6.3.0.

Before, we did this only when sending to the same account. This commit
extends this to work when sending to an address of a *different*
account of the same keystore.

The bitcoin transaction script_configs field is used for inputs and
change outputs. We add a similar list, `output_script_configs`, which
allows to attach script configs of different accounts to outputs, with
`output_script_config_index` to reference them in the output.

To ensure backwards compatibility, `output_script_config_index` is
added as a new field, which takes precedence over
`script_config_index` when set.

The output script configs are validated, but since one can send to any
address of the same keystore, the output script config validation
allows any combination of script configs, unlike the input script
configs. To not duplicate lots of code, a few refactors are done:

- validate_script_configs is now used for generic validation and is
used to validate the output script configs as well as the input script
configs
- validate_input_script_configs performs additional validation as
before (can't mix multisig and single sig inputs, can't mix inputs
from different accounts, etc).
- the multisig/policy name is stored in ValidatedScriptConfig, so we
don't have to fetch it twice

The Python lib version was downgraded from 8.0.0 to 7.0.0, it seems it
was bumped before in error - the previous release tag and release is 6.3.0.
// from BTCSignInitRequest. This enables verification that an output belongs to the same keystore,
// even if it is from a different account than we spend from, allowing us to display this info to
// the user.
optional uint32 output_script_config_index = 9;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Wondering it this should just be optional BTCScriptConfigWithKeypath output_script_config instead of a reference into a vector, to simplify the code and API of client libraries.

The script_configs vector for inputs/changes is there so

  • we can validate that multisig/singlesig inputs are not mixed and that different accounts are not mixed, and
  • that we can confirm multisig details at the beginning of a transaction
  • and to have a speedup to not repeat validation for each input

All that is not necessary for the output script infos, and the validation performance is not so important there as the user is anyway manually confirming the output 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant