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?
Can a regtest bitcoind node use SignRawTransactionWithKey + prevtxs for a mainnet raw transaction?
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);
If I was to set the
-secretprefixto the same values as mainnet would that work? 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?– pinheadJun 25, 2020 at 21:14
Oh, you are correct those are daemon options for Elements Project. With Elements you can set those params. 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– pinheadJun 25, 2020 at 22:33
Ya, I have been using NBitcoin but it can't sign Elements transactions for some reason. Jun 25, 2020 at 23:14