1

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

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.