<p>the parameters to create the address are different from the bitcoin ones and elements may also have blinders, TL DR, use rust-elements for instance.</p>

CC BY-SA 4.0
2022-05-04T19:19:36.980Z
2022-05-04T19:19:36.980Z
T. Rossi
<p>I'm building a script and have it's hex representation, then I convert it to a pubkey and address, which results in something like: 3NqNAUBEWarVjKerLcCnPrTGbaQ4QFcAfr or 2N7aFmKeUXbTSowccnkzJ44BZj8HFqLUUdm (when I set testnet parameters)</p>
<p>in elements when I try to build a transaction with <code>createrawtransaction</code> to put some coin to that address I get:</p>
<p><code>Invalid prefix for Base58-encoded address</code></p>
<p>I've tried to build a descriptor with sh() and import it but that won't work because custom scripts are not supported.</p>
<p>Is it possible to use P2SH in elements? How do you generate the address from the script hex (it looks like it's different from bitcoin)?</p>
<p>PS: the script is built with python bitcoinlib like this</p>
<pre><code>redeemScript = CScript([winner_key, OP_CHECKSIG, OP_IFDUP, OP_NOTIF, cashback_key, OP_CHECKSIGVERIFY, blocks_b, OP_CHECKSEQUENCEVERIFY, OP_ENDIF ])
</code></pre>
<p>where keys are hex representation of bytes, blocks_b is an int represented in bytes.hex(), I'm not really sure this is working, but I think there is something I'm missing on how to generate the address first.</p>

<p2sh><python-bitcoinlib><elements>
p2sh addresses in elements
T. Rossi
# p2sh addresses in elements

(Asked by: username_0 on 2022-04-15)

I'm building a script and have it's hex representation, then I convert it to a pubkey and address, which results in something like: 3NqNAUBEWarVjKerLcCnPrTGbaQ4QFcAfr or 2N7aFmKeUXbTSowccnkzJ44BZj8HFqLUUdm (when I set testnet parameters)

in elements when I try to build a transaction with `createrawtransaction` to put some coin to that address I get:

`Invalid prefix for Base58-encoded address`

I've tried to build a descriptor with sh() and import it but that won't work because custom scripts are not supported.

Is it possible to use P2SH in elements? How do you generate the address from the script hex (it looks like it's different from bitcoin)?

PS: the script is built with python bitcoinlib like this

```
redeemScript = CScript([winner_key, OP_CHECKSIG, OP_IFDUP, OP_NOTIF, cashback_key, OP_CHECKSIGVERIFY, blocks_b, OP_CHECKSEQUENCEVERIFY, OP_ENDIF ])

```

where keys are hex representation of bytes, blocks\_b is an int represented in bytes.hex(), I'm not really sure this is working, but I think there is something I'm missing on how to generate the address first.

**Tags:** p2sh, python-bitcoinlib, elements


---

## 1 answers

### Answer by username_0 on 2022-05-04. Score: 0 | Accepted answer

the parameters to create the address are different from the bitcoin ones and elements may also have blinders, TL DR, use rust-elements for instance.


---

