RPC: Allow user to supply weight of external input #23187

issue instagibbs opened this issue on October 5, 2021
  1. instagibbs commented at 1:39 PM on October 5, 2021: member

    This would allow wallet operations like funding transactions with smart contract-based inputs such as LN, or any input the Core wallet doesn't know how to sign for.

    #17211 (comment)

  2. instagibbs added the label Feature on Oct 5, 2021
  3. achow101 commented at 6:51 PM on October 5, 2021: member

    The easiest way to do this is to add another field to the input object (in the inputs array) that specifies the input weight. However this is not possible to do with fundrawtransaction as it does not have an inputs array, but this would work for walletcreatefundedpsbt and send. Would it be reasonable to exclude fundrawtransaction from this particular feature?

  4. michaelfolkson commented at 6:08 PM on January 19, 2022: contributor

    Some additional clarification on this issue after the PR review club (and @achow101, @t-bast can correct me if this wrong!).

    any input the Core wallet doesn't know how to sign for

    It isn't that the Core wallet doesn't know how to sign for these inputs (there is a dummy signer if the Core wallet doesn't have the key(s) to spend it), it is that the Core wallet doesn't understand how to work out the weight of an external input and hence the required transaction fee. An example would be spending from a Lightning non-cooperative close or HTLC. The Core wallet would understand a Lightning cooperative close as that it is just spending from a 2-of-2 multisig which the Core understands (covered by descriptors). Any scripts not covered by descriptors (e.g. scripts covered by Miniscript or Lightning HTLCs that aren't covered by Miniscript) the Core wallet doesn't understand at the present time and needs the user to supply the weight of the external input.

  5. achow101 commented at 6:15 PM on January 19, 2022: member

    It isn't that the Core wallet doesn't know how to sign for these inputs (there is a dummy signer if the Core wallet doesn't have the key(s) to spend it), it is that the Core wallet doesn't understand how to work out the weight of an external input and hence the required transaction fee.

    "Doesn't know how to sign for" includes the case where solving data is missing. If the wallet is missing keys, it is also unable to determine the weight of an external input. Standard scripts still have solving data, and if they are unknown, the wallet will be unable to estimate their sizes.

  6. michaelfolkson commented at 6:28 PM on January 19, 2022: contributor

    Because ECDSA signatures (not Schnorr, they are fixed weight so you know the weight of a Schnorr signature beforehand) vary in weight so even for a standard script that only requires a single signature you don't know the weight of the signature if you don't have the key right?

  7. achow101 commented at 6:55 PM on January 19, 2022: member

    No. Signatures have a max size and the variation is only a one or two bytes, so it doesn't really matter. Keys and scripts are needed because they can vary. For P2PKH, the key may be either compressed or uncompressed. The spending size cannot be determined without knowing what the key is. For P2SH and P2WSH, obviously you need the script. P2WPKH could be computed without any solving data, but currently we do not. This behavior is at least consistent with the other output types.

  8. laanwj closed this on Jan 25, 2022

  9. DrahtBot locked this on Jan 25, 2023

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:14 UTC

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