<p>It seems like there should be a standard for this; surprised I can't find anything. Something analogous to <a href="https://en.bitcoin.it/wiki/Wallet_import_format" rel="nofollow noreferrer">WIF</a> but for P2SH. Perhaps WIF could be modified to adopt a new version byte to signify P2SH and then just have the redeem script appended to the end of the key (similar to how 0x01 is appended to signify the WIF key corresponds to a compressed pubkey).</p>

CC BY-SA 4.0
2023-02-14T16:16:45.590Z
Arguably, that exists now: output descriptors (BIP380 and its follow-ups).
Pieter Wuille
CC BY-SA 4.0
2023-02-14T16:21:13.123Z
I see BIP380 is a draft however since it deals with a wallet-side application, does that mean it could be implemented already?
Poseidon
CC BY-SA 4.0
2023-02-14T16:21:47.430Z
It's implemented in a number of software projects already (including Bitcoin Core, see https://github.com/bitcoin/bitcoin/blob/v24.0.1/doc/descriptors.md). The 'status' of BIPs often doesn't mean much.
Pieter Wuille
CC BY-SA 4.0
2023-02-14T16:09:38.580Z
2023-02-14T16:09:38.580Z
jason
<p>In the context of multsig scripts, the sender should be the one actually including the M of N multsig script in the transaction. But because many senders willing to send to a multsig script would bear the high transaction costs due to increase in transaction size, we use P2SH of a script.</p>
<p>So, what the network doing is that it is shifting the cost from the sender to the multsig owners(recipient).</p>
<p>The receiver should present the redeem script(multisig script) to spend the UTXO later.</p>
<p>Now about forgetting the redeem script, because the P2SH is a hash..the script cannot be recovered back if forgotten and the bitcoin is forever locked inside the unspendable UTXO. Atleast in the case of multsig scripts, the receiver willing to spend that UTXO would just need the public keys satisfying the constraint and their signatures.</p>
<p><strong>Losing the redeem script will lock away the bitcoins in the UTXO forever</strong></p>
<p>The <code>addmultsigaddress</code> method in the Bitcoin Core RPC stores the redeem script in the core wallet for multsig functionality. Many other wallet implementations might store the redeem script based on their goals of implementation.</p>

CC BY-SA 4.0
2021-10-11T13:30:32.467Z
2021-10-11T13:30:32.467Z
Pranay Reddy
<p>Imagine that I wrote a redeem script. I calculated the related P2SH address, and sent some bitcoins to that address. In order to spend that bitcoins, I need to remember two things:</p>

<ol>
<li>The private keys that are needed by the redeem script. </li>
<li>The redeem script itself.</li>
</ol>

<p>Using the bitcoind RPC interface I can store in my wallet P2PKH addresses and their related private keys. I would like to store also the P2SH address and related redeem script: it would be nice to have an RPC method that parses the script string, stores the script in the wallet and returns the P2SH address.</p>

<p>Is it possible? What if I forget the redeem script that is necessary to spend bitcoins from a P2SH? Am I missing something? Is it true that it's useful to store redeem scripts in the wallet and not only with private keys?</p>

<wallet><script><p2sh>
How can I store a redeem script in my wallet?
Giuseppe Galano
# How can I store a redeem script in my wallet?

(Asked by: username_0 on 2016-10-04)

Imagine that I wrote a redeem script. I calculated the related P2SH address, and sent some bitcoins to that address. In order to spend that bitcoins, I need to remember two things:

1. The private keys that are needed by the redeem script.
2. The redeem script itself.

Using the bitcoind RPC interface I can store in my wallet P2PKH addresses and their related private keys. I would like to store also the P2SH address and related redeem script: it would be nice to have an RPC method that parses the script string, stores the script in the wallet and returns the P2SH address.

Is it possible? What if I forget the redeem script that is necessary to spend bitcoins from a P2SH? Am I missing something? Is it true that it's useful to store redeem scripts in the wallet and not only with private keys?

**Tags:** wallet, script, p2sh


---

## 2 answers

### Answer by username_1 on 2023-02-14. Score: 1

It seems like there should be a standard for this; surprised I can't find anything. Something analogous to [WIF](https://en.bitcoin.it/wiki/Wallet_import_format) but for P2SH. Perhaps WIF could be modified to adopt a new version byte to signify P2SH and then just have the redeem script appended to the end of the key (similar to how 0x01 is appended to signify the WIF key corresponds to a compressed pubkey).

> **Comments:**
> **username_2**: Arguably, that exists now: output descriptors (BIP380 and its follow-ups).  
> **username_3**: I see BIP380 is a draft however since it deals with a wallet-side application, does that mean it could be implemented already?  
> **username_2**: It's implemented in a number of software projects already (including Bitcoin Core, see https://github.com/bitcoin/bitcoin/blob/v24.0.1/doc/descriptors.md). The 'status' of BIPs often doesn't mean much.  

---

### Answer by username_4 on 2021-10-11. Score: 1

In the context of multsig scripts, the sender should be the one actually including the M of N multsig script in the transaction. But because many senders willing to send to a multsig script would bear the high transaction costs due to increase in transaction size, we use P2SH of a script.

So, what the network doing is that it is shifting the cost from the sender to the multsig owners(recipient).

The receiver should present the redeem script(multisig script) to spend the UTXO later.

Now about forgetting the redeem script, because the P2SH is a hash..the script cannot be recovered back if forgotten and the bitcoin is forever locked inside the unspendable UTXO. Atleast in the case of multsig scripts, the receiver willing to spend that UTXO would just need the public keys satisfying the constraint and their signatures.

**Losing the redeem script will lock away the bitcoins in the UTXO forever**

The `addmultsigaddress` method in the Bitcoin Core RPC stores the redeem script in the core wallet for multsig functionality. Many other wallet implementations might store the redeem script based on their goals of implementation.


---

