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?
1 Answer
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
-
If I was to set the
-pubkeyprefix
and-secretprefix
to the same values as mainnet would that work? Commented Jun 25, 2020 at 20:32 -
1Hm are those actual command line parameters? I don't see those terms grepping the codebase. What do you mean?– pinheadCommented Jun 25, 2020 at 21:14
-
Oh, you are correct those are daemon options for Elements Project. With Elements you can set those params. Commented Jun 25, 2020 at 22:32
-
1I 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– pinheadCommented Jun 25, 2020 at 22:33
-
Ya, I have been using NBitcoin but it can't sign Elements transactions for some reason. Commented Jun 25, 2020 at 23:14