[#FillableSigningProvider-mapScripts]
= xref:FillableSigningProvider.adoc[FillableSigningProvider]::mapScripts
:relfileprefix: ../
:mrdocs:

Map of script id to scripts known by the signing provider&period;

== Synopsis

Declared in `&lt;script&sol;signingprovider&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
&lsqb;&lsqb;guarded&lowbar;by(0x7f2e1c4fce28), guarded&lowbar;by(0x7f2e1825dbb8), guarded&lowbar;by(0x7f2e42e42c88), guarded&lowbar;by(0x7f2e28aff238), guarded&lowbar;by(0x7f2e33c27c28), guarded&lowbar;by(0x7f2e325890a8), guarded&lowbar;by(0x7f2e1b1449a8), guarded&lowbar;by(0x7f2e246ce008), guarded&lowbar;by(0x7f2e344481a8), guarded&lowbar;by(0x7f2e2a584768), guarded&lowbar;by(0x7f2e23074a98), guarded&lowbar;by(0x7f2e303a6a78), guarded&lowbar;by(0x7f2e188c0de8), guarded&lowbar;by(0x7f2e4333bc88), guarded&lowbar;by(0x7f2e151107b8), guarded&lowbar;by(0x7f2e09534e28), guarded&lowbar;by(0x7f2e258e7d68), guarded&lowbar;by(0x7f2e188ac418), guarded&lowbar;by(0x7f2e410a76d8), guarded&lowbar;by(0x7f2e241b2f28)&rsqb;&rsqb;
xref:FillableSigningProvider/ScriptMap.adoc[ScriptMap] mapScripts;
----

== Description

This map originally just held P2SH redeemScripts, and was used by wallet code to look up script ids referenced in &quot;OP&lowbar;HASH160 &lt;script id&gt; OP&lowbar;EQUAL&quot; P2SH outputs&period; Later in 605e8473a7d it was extended to hold P2WSH witnessScripts as well, and used to look up nested scripts referenced in &quot;OP&lowbar;0 &lt;script hash&gt;&quot; P2WSH outputs&period; Later in commits f4691ab3a9d and 248f3a76a82, it was extended once again to hold segwit &quot;OP&lowbar;0 &lt;key or script hash&gt;&quot; scriptPubKeys, in order to give the wallet a way to distinguish between segwit outputs that it generated addresses for and wanted to receive payments from, and segwit outputs that it never generated addresses for, but it could spend just because of having keys&period; (Before segwit activation it was also important to not treat segwit outputs to arbitrary wallet keys as payments, because these could be spent by anyone without even needing to sign with the keys&period;)

Some of the scripts stored in mapScripts are memory&hyphen;only and intentionally not saved to disk&period; Specifically, scripts added by ImplicitlyLearnRelatedKeyScripts(pubkey) calls are not written to disk so future wallet code can have flexibility to be more selective about what transaction outputs it recognizes as payments, instead of having to treat all outputs spending to keys it knows as payments&period; By contrast, mapScripts entries added by AddCScript(script), LearnRelatedScripts(pubkey, type), and LearnAllRelatedScripts(pubkey) calls are saved because they are all intentionally used to receive payments&period;

The FillableSigningProvider&colon;&colon;mapScripts script map should not be confused with the wallet&colon;&colon;LegacyDataSPKM&colon;&colon;setWatchOnly script set&period; The two collections can hold the same scripts, but they serve different purposes&period; The setWatchOnly script set is intended to expand the set of outputs the wallet considers payments&period; Every output with a script it contains is considered to belong to the wallet, regardless of whether the script is solvable or signable&period; By contrast, the scripts in mapScripts are only used for solving, and to restrict which outputs are considered payments by the wallet&period; An output with a script in mapScripts, unlike setWatchOnly, is not automatically considered to belong to the wallet if it can&apos;t be solved and signed for&period;


[.small]#Created with https://www.mrdocs.com[MrDocs]#
