<p>No, you will get an <code>Invalid private key</code> error. Note that if you use a correct-network private key but it is the wrong key to sign the input you provide you get a different error: <code>Unable to sign input, invalid stack size (possibly missing key)</code></p>
<p>The base58 prefix is checked against a constant value that is different for each network (main, regtest, etc)</p>
<pre><code>const std::vector&lt;unsigned char&gt;&amp; privkey_prefix =
    Params().Base58Prefix(CChainParams::SECRET_KEY);
</code></pre>
<p><a href="https://github.com/bitcoin/bitcoin/blob/master/src/key_io.cpp#L132-L148" rel="nofollow noreferrer">https://github.com/bitcoin/bitcoin/blob/master/src/key_io.cpp#L132-L148</a></p>

CC BY-SA 4.0
2020-06-25T20:32:00.353Z
If I was to set the `-pubkeyprefix` and `-secretprefix` to the same values as mainnet would that work?
Harmalarm
CC BY-SA 4.0
2020-06-25T21:14:03.983Z
Hm are those actual command line parameters? I don't see those terms grepping the codebase. What do you mean?
pinhead
CC BY-SA 4.0
2020-06-25T22:32:39.363Z
Oh, you are correct those are daemon options for Elements Project. With Elements you can set those params.
Harmalarm
CC BY-SA 4.0
2020-06-25T22:33:35.410Z
I see. Cool. Ya know, you don't need a full node to sign a TX if you have all that data. There's libraries and toolkits written in other languages etc that might suit you better
pinhead
CC BY-SA 4.0
2020-06-25T23:14:41.727Z
Ya, I have been using NBitcoin but it can't sign Elements transactions for some reason.
Harmalarm
CC BY-SA 4.0
2020-06-25T17:51:58.690Z
2020-06-25T18:01:52.540Z
2020-06-25T18:01:52.540Z
pinhead
<p>I want to know if a regtest nnode can sign a raw mainnet transaction with the signrawtransactionwithkey rpc provided that I pass the correct keys and prevtxs as the regtest node will not be aware of them?</p>

<development><signrawtransaction>
Can a regtest bitcoind node use SignRawTransactionWithKey + prevtxs for a mainnet raw transaction?
Harmalarm
# Can a regtest bitcoind node use SignRawTransactionWithKey + prevtxs for a mainnet raw transaction?

(Asked by: username_0 on 2020-06-24)

I want to know if a regtest nnode can sign a raw mainnet transaction with the signrawtransactionwithkey rpc provided that I pass the correct keys and prevtxs as the regtest node will not be aware of them?

**Tags:** development, signrawtransaction


---

## 1 answers

### Answer by username_1 on 2020-06-25. Score: 1

No, you will get an `Invalid private key` error. Note that if you use a correct-network private key but it is the wrong key to sign the input you provide you get a different error: `Unable to sign input, invalid stack size (possibly missing key)`

The base58 prefix is checked against a constant value that is different for each network (main, regtest, etc)

```
const std::vector<unsigned char>& privkey_prefix =
    Params().Base58Prefix(CChainParams::SECRET_KEY);

```

<https://github.com/bitcoin/bitcoin/blob/master/src/key_io.cpp#L132-L148>

> **Comments:**
> **username_0**: If I was to set the `-pubkeyprefix` and `-secretprefix` to the same values as mainnet would that work?  
> **username_1**: Hm are those actual command line parameters? I don't see those terms grepping the codebase. What do you mean?  
> **username_0**: Oh, you are correct those are daemon options for Elements Project. With Elements you can set those params.  
> **username_1**: I see. Cool. Ya know, you don't need a full node to sign a TX if you have all that data. There's libraries and toolkits written in other languages etc that might suit you better  
> **username_0**: Ya, I have been using NBitcoin but it can't sign Elements transactions for some reason.  

---

