Skip to content

sign: Remove FillableSigningProvider - #35733

Open
achow101 wants to merge 7 commits into
bitcoin:masterfrom
achow101:rm-fillablesigningprovider
Open

achow101 wants to merge 7 commits into
bitcoin:masterfrom
achow101:rm-fillablesigningprovider

Conversation

@achow101

Copy link
Copy Markdown
Member

FillableSigningProvider was initially extracted from the wallet in order to produce the SigningProvider encapsulation system that we use today for the wallet and for providing key material to signing. It's primary user was the legacy wallet, but it was also being used as a convenience in a few other places. Since the legacy wallet is removed, there is no need to keep it around as a separate class. Instead, the things that it was doing can be inlined into LegacyDataSPKM where the functionality is actually being used to support migrating legacy wallets.

The remaining uses are tests and the bitcoin-tx tool, some of which were relying on the implicit addition of segwit scripts when adding a key. However, these can also use FlatSigningProvider with explicitly adding the segwit scripts when necessary, and have thusly been converted to do so.

@DrahtBot

DrahtBot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

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

External sites

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
Concept ACK vicjuma, rkrux
Approach ACK jeanpablojp

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #36897 (wallet, migration: Contain all legacy wallet and migration related things in its own subdirectory, namespace, and classes by achow101)
  • #36831 (test: split test_IsStandard into independent test cases by yuvicc)
  • #36794 (test: make script_combineSigs and spends_witness_prog cases independent by alexanderwiederin)
  • #36188 (crypto: plug hardware optimized SHA256 into libsecp256k1's context by furszy)
  • #34520 (refactor: Add [[nodiscard]] to functions returning bool+mutable ref by maflcko)

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.

LLM Linter (✨ experimental)

Possible typos and grammar issues:

  • src/wallet/scriptpubkeyman.cpp: redeemscripts → redeem scripts [misspelling]

2026-11-24 20:08:07

@DrahtBot

Copy link
Copy Markdown
Contributor

🚧 At least one of the CI tasks failed.
Task test ancestor commits: https://github.com/bitcoin/bitcoin/actions/runs/29456873744/job/87491882670
LLM reason (✨ experimental): CI failed because the build broke under clang with -Werror,-Wthread-safety-analysis (missing exclusive lock on cs_KeyStore in scriptpubkeyman.cpp).

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

@vicjuma vicjuma left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ACK for the bitcoin-tx changes. Will try to review the remaining parts

Comment thread src/bitcoin-tx.cpp
}
tempKeystore.AddKey(key);
CPubKey pubkey = key.GetPubKey();
tempKeystore.keys.emplace(pubkey.GetID(), key);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The key path works correctly. A helper function would maybe be handy same as the AddKey one but since we are only using it in a single place, I guess expanding it here may be fine.

bitcoin-tx testing

Creating unsigned transaction

ratedg@0xratedg:~/projects/contributions/bitcoin/build2/bin$ TX=$(./bitcoin-tx -regtest -create \
     in=7dc357e7ba70b0b503c9a12f4a293add0b1d230e08de3cad83e142737746c4b8:1 \
     outaddr=0.9:mmhnpJgEDuPxTmw6Nuu5Ms2xmP21n6XoCi)
ratedg@0xratedg:~/projects/contributions/bitcoin/build2/bin$

Signing the transaction

ratedg@0xratedg:~/projects/contributions/bitcoin/build2/bin$ TX=$(./bitcoin-tx -regtest "$TX" \
     set=prevtxs:"[{\"txid\":\"7dc357e7ba70b0b503c9a12f4a293add0b1d230e08de3cad83e142737746c4b8\",\"vout\":1,\"scriptPubKey\":\"76a91443dd6b08400c8e763c5e1b8520957e132cac817088ac\",\"amount\":1}]" \
     set=privatekeys:"[\"cNPgXXtoNEkhZd6txFEPQvWMF8gfvyG15JnYxgtrbQgiesHPwERA\"]" \
     sign=ALL)

Confirming

ratedg@0xratedg:~/projects/contributions/bitcoin/build2/bin$ ./bitcoin-cli -regtest testmempoolaccept "[\"$TX\"]" 0
[
  {
    "txid": "96aba7a976963a610c82d8fe5ba0f5da1837d64e875127fc74b3253c2de1b9d9",
    "wtxid": "96aba7a976963a610c82d8fe5ba0f5da1837d64e875127fc74b3253c2de1b9d9",
    "allowed": true,
    "vsize": 191,
    "fees": {
      "base": 0.10000000
    }
  }
]

The values used were generated from bitcoin 24.0 binary from the commands

Comment thread src/bitcoin-tx.cpp Outdated
UniValue v = prevOut["redeemScript"];
std::vector<unsigned char> rsData(ParseHexUV(v, "redeemScript"));
CScript redeemScript(rsData.begin(), rsData.end());
tempKeystore.AddCScript(redeemScript);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Following this function, the maximum script element size condition is being checked redeemScript.size() > MAX_SCRIPT_ELEMENT_SIZE

Comment thread src/bitcoin-tx.cpp
std::vector<unsigned char> rsData(ParseHexUV(v, "redeemScript"));
CScript redeemScript(rsData.begin(), rsData.end());
tempKeystore.AddCScript(redeemScript);
tempKeystore.scripts.emplace(CScriptID(redeemScript), redeemScript);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It was thoughtful to remove the check since pay-to-witness-script-hash doesn't share the same MAX_SCRIPT_ELEMENT_SIZE limit as the pay-to-script-hash.

The script path works correctly.

bitcoin-tx testing

Creating unsigned transaction

ratedg@0xratedg:~/projects/contributions/bitcoin/build2/bin$ TX=$(./bitcoin-tx -regtest -create \
  in=f4e3e878eefc814436f3cf27752bb1896934dcd8fa8663ffd8187e9358d0c03b:0 \
  outaddr=0.9:mwbmunN2ojMDLGWwZJuqPNX3dfyuvNqheF)
ratedg@0xratedg:~/projects/contributions/bitcoin/build2/bin$ 

Signing the transaction

ratedg@0xratedg:~/projects/contributions/bitcoin/build2/bin$ TX=$(./bitcoin-tx -regtest "$TX" \
  set=prevtxs:"[{\"txid\":\"f4e3e878eefc814436f3cf27752bb1896934dcd8fa8663ffd8187e9358d0c03b\",\"vout\":0,\"scriptPubKey\":\"a91417c74210b483bf6dd004660b05b356b6c3aa12dc87\",\"redeemScript\":\"522103804969501e96ed27704e3d82bef2b5ef04a53d80683ea1a4dbbb9d2e63b7e09921034c988b448e0fa6a1fcc09f33a20abf5ab0ca3e393fa717bb251493dd2819412752ae\",\"amount\":1.00000000}]" \
  set=privatekeys:"[\"cTzVvTMsbz75L9mF15FdM6AZWe22EXstSoQGhBGNMjYRjm28N7Yx\",\"cNc7X8u7KCubwor6rsuSMFdNCCEwK2qSkbHv5WFTPDWmBdRNWHgG\"]" \
  sign=ALL)

Confirming

ratedg@0xratedg:~/projects/contributions/bitcoin/build2/bin$ ./bitcoin-cli -regtest testmempoolaccept "[\"$TX\"]" 0
[
  {
    "txid": "6286887e90dfd4aebcbdec8d1949593ce46ed6b0d10a03e8f84db6fe7d52a914",
    "wtxid": "6286887e90dfd4aebcbdec8d1949593ce46ed6b0d10a03e8f84db6fe7d52a914",
    "allowed": true,
    "vsize": 302,
    "fees": {
      "base": 0.10000000
    }
  }
]

The values used were generated from bitcoin 24.0 binary from the commands

Comment thread src/bitcoin-tx.cpp
if (!registers.contains("privatekeys"))
throw std::runtime_error("privatekeys register variable must be set.");
FillableSigningProvider tempKeystore;
FlatSigningProvider tempKeystore;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

appropriate for the self-contained bitcoin-tx

Comment thread src/bitcoin-tx.cpp
}

const FillableSigningProvider& keystore = tempKeystore;
const FlatSigningProvider& keystore = tempKeystore;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

appropriate for the self-contained bitcoin-tx

@jeanpablojp jeanpablojp left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approach ACK

Built and ran the tests.

Comment thread src/bitcoin-tx.cpp Resolved
Comment thread src/test/fuzz/script_sign.cpp Resolved
@rkrux

rkrux commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Concept ACK 0396996 to containerise the codepath related to legacy wallets while discouraging usage of this seemingly outdated signing provider.

Instead of using FillableSigningProvider, use a FlatSigningProvider.
FillableSigningProvider is not a necessary part of the tests and
FlatSigningProvider is sufficient.
bitcoin-tx does not need to use FillableSigningProvider, it can use
FlatSigningProvider and inline ImplicitlyLearnRelatedKeyScripts.
The only real user of FillableSigningProvider is LegacyDataSPKM. Instead
of having it be a separate class which LegacyDataSPKM subclasses, move
the implementation directly into LegacyDataSPKM and have LegacyDataSPKM
be a subclass of SigningProvider.
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.

5 participants