psbt: Use SIGHASH_DEFAULT when signing PSBTs #850

pull achow101 wants to merge 1 commits into bitcoin-core:master from achow101:gui-psbt-sighash-default changing 1 files +1 −1
  1. achow101 commented at 9:16 pm on January 6, 2025: member

    SIGHASH_DEFAULT should be used to indicate SIGHASH_DEFAULT for taproot inputs, and SIGHASH_ALL for all other input types. This avoids adding an unnecessary byte to the end of all Taproot signatures added to PSBTs signed in the GUI.

    See also bitcoin/bitcoin#22514

  2. gui, psbt: Use SIGHASH_DEFAULT when signing PSBTs
    SIGHASH_DEFAULT should be used to indicate SIGHASH_DEFAULT for taproot
    inputs, and SIGHASH_ALL for all other input types. This avoids adding an
    unnecessary byte to the end of all Taproot signatures added to PSBTs
    signed in the GUI.
    3e97ff9c5e
  3. DrahtBot commented at 9:16 pm on January 6, 2025: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK Sjors, pablomartin4btc, hebasto

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #832 (Improve user dialog when signing multisig psbts by mjdietzx)
    • #bitcoin/bitcoin/31622 (psbt: add non-default sighash types to PSBTs and unify sighash type match checking by achow101)
    • #bitcoin/bitcoin/29675 (wallet: Be able to receive and spend inputs involving MuSig2 aggregate keys by achow101)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  4. laanwj added the label Wallet on Jan 7, 2025
  5. luke-jr commented at 1:53 pm on January 8, 2025: member

    This avoids adding an unnecessary byte to the end of all Taproot signatures added to PSBTs signed in the GUI.

    Two bytes, isn’t it? For the PSBT_IN_SIGHASH keytype

  6. achow101 commented at 4:39 pm on January 8, 2025: member

    This avoids adding an unnecessary byte to the end of all Taproot signatures added to PSBTs signed in the GUI.

    Two bytes, isn’t it? For the PSBT_IN_SIGHASH keytype

    No, that field is not added. This is referring to the actual signature that will show up in the scriptWitness, and as appears in PSBT_IN_TAPROOT_*_SIG fields beforehand.

  7. Sjors commented at 11:05 am on January 16, 2025: member

    utACK 3e97ff9c5eaa3160426ba112930b047404c54c9e

    It would be useful for the FillPSBT doc in wallet.h to explain that passing SIGHASH_DEFAULT will use SIGHASH_ALL for pre-taproot inputs.

    You have to crawl all the way to MutableTransactionSignatureCreator::CreateSig to find this out:

    0// BASE/WITNESS_V0 signatures don't support explicit SIGHASH_DEFAULT, use SIGHASH_ALL instead.
    1const int hashtype = nHashType == SIGHASH_DEFAULT ? SIGHASH_ALL : nHashType;
    

    https://github.com/bitcoin/bitcoin/pull/31622/commits/e94bb4e5fc6dea67844a8495b948b679649b7b65 makes this problem go away though.


    Additional background: https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki#taproot-key-path-spending-signature-validation

    A Taproot signature is a 64-byte Schnorr signature, as defined in BIP340, with the sighash byte appended in the usual Bitcoin fashion. This sighash byte is optional. If omitted, the resulting signatures are 64 bytes, and a SIGHASH_DEFAULT mode is implied.

  8. pablomartin4btc commented at 7:37 pm on January 16, 2025: contributor

    utACK 3e97ff9c5eaa3160426ba112930b047404c54c9e

    I agree with @Sjors but is that not covered by doc at the /** Signature hash types/flags */ enum definition (src/script/interpreter.h)?

    https://github.com/bitcoin/bitcoin/commit/e94bb4e5fc6dea67844a8495b948b679649b7b65 makes this problem go away though.

    is that part of a PR?

  9. Sjors commented at 8:23 am on January 17, 2025: member

    @pablomartin4btc it’s part of #31622.

    The description in interpreter.h is ambiguous. It says “Taproot only”. It also says “equivalent to SIGHASH_ALL”, but doesn’t say that it gets converted (and obviously a constant can’t guarantee that actually happens).

  10. Theschorpioen approved
  11. DrahtBot added the label CI failed on Jan 26, 2025
  12. DrahtBot removed the label CI failed on Jan 31, 2025
  13. hebasto renamed this:
    gui, psbt: Use SIGHASH_DEFAULT when signing PSBTs
    psbt: Use SIGHASH_DEFAULT when signing PSBTs
    on Feb 2, 2025
  14. hebasto approved
  15. hebasto commented at 9:48 am on February 2, 2025: member
    ACK 3e97ff9c5eaa3160426ba112930b047404c54c9e, I have reviewed the code and it looks OK.
  16. hebasto merged this on Feb 2, 2025
  17. hebasto closed this on Feb 2, 2025


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/gui. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-12-18 09:20 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me