with p2pkh, one can generate all addresses (keys) given the seed and I believe that's what wallets do when checking balance of an account (check all those keys)
But with p2sh (pay to script hash), one needs to remember/store the script and provide it when spending, otherwise bad luck. Is that right?
If so, do wallets support remembering these scripts, or how do people do that?
there are a few components to it: you need to know the type of script you used to create the address, you need to know the keys and policies involved in the script, and you need to use a wallet that can build the script and sign transactions for it.
take a 2-of-3 p2sh multisig for example. if you created this script with electrum, you went through a process to set up the multisig. electrum has a gui that walks you through the process, it asks you what the signing policy is and what the xpubs of the signers are, and from that it can create the wallet, derive all of the addresses, and build txs to sign. so in the case of this multisig wallet you need to know that it's 2-of-3, p2sh, and the specific 3 xpubs used. with this information you should be able to recreate the wallet in any application that supports creating p2sh multisig wallets.
for more advanced scripts, you might need to know/backup more information related to the spending conditions. and if you lose that information, then you lose access to your funds.
reply
Great explanation. Thank you!
reply
Yes you do. Normally these are able to be generated deterministicly so you just need the parameters (xpubs) and then the software can handle the rest
reply