Invalid private key

+1 vote

I am trying to sign transaction but I got an error and appreciate your support to know the issue here:

chain1: createrawsendfrom "1Ebo8Dos1rKGmZdyZ3Mhy2Dct8KzAPBYDxwJUU" '{"1DuDL9i8gK9AsoufuYWht3bVJAJGL5x3tEz5WT":{"dollar":2}}'                                                                                                                                                                                
{"method":"createrawsendfrom","params":["1Ebo8Dos1rKGmZdyZ3Mhy2Dct8KzAPBYDxwJUU",{"1DuDL9i8gK9AsoufuYWht3bVJAJGL5x3tEz5WT":{"dollar":2}}],"id":1,"chain_name":"chain1"}

0100000001273e245df3d0806fe511a7dd65141d739d5e84669fc88b2eecb4547577ddd8500000000000ffffffff0200000000000000003776a9145f729fa36835fa17be1caf7dab381c514d27313d88ac1c73706b719d5e84669fc88b2eecb4547577ddd85002000000000000007500000000000000003776a914649ff1e0665ab607c2f8a460b0bf15c74f0b0be688ac1c73706b719d5e84669fc88b2eecb4547577ddd85030000000000000007500000000


so the hex blob is generated but I have an error while signing:

chain1: signrawtransaction 0100000001273e245df3d0806fe511a7dd65141d739d5e84669fc88b2eecb4547577ddd8500000000000ffffffff0200000000000000003776a9145f729fa36835fa17be1caf7dab381c514d27313d88ac1c73706b719d5e84669fc88b2eecb4547577ddd85002000000000000007500000000000000003776a914649ff1e0665ab607c2f8a460b0bf15c74f0b0be688ac1c73706b719d5e84669fc88b2eecb4547577ddd85030000000000000007500000000 '[]' '["L5nEhhjBZtCMf6ekEMFcjiB2gqqm4bxobfwzTGzfjR115WNxKatW"]'
{"method":"signrawtransaction","params":["0100000001273e245df3d0806fe511a7dd65141d739d5e84669fc88b2eecb4547577ddd8500000000000ffffffff0200000000000000003776a9145f729fa36835fa17be1caf7dab381c514d27313d88ac1c73706b719d5e84669fc88b2eecb4547577ddd85002000000000000007500000000000000003776a914649ff1e0665ab607c2f8a460b0bf15c74f0b0be688ac1c73706b719d5e84669fc88b2eecb4547577ddd85030000000000000007500000000",[],["L5nEhhjBZtCMf6ekEMFcjiB2gqqm4bxobfwzTGzfjR115WNxKatW"]],"id":1,"chain_name":"chain1"}

error code: -5
error message:
Invalid private key

what is wrong about privkey? and be noted that I used address that generated from validateaddress  0274c09906a88376a85887bc0d3b466dde3998bbca7512fef90eae0484d4bb96ff to import to wallet.

asked Jul 2, 2018 by mina
Where did you get this private key from?
From online tool (using JS to generate (offline also))that generate public and private key

1 Answer

+1 vote
 
Best answer

If you generate a private key or address from a tool designed for bitcoin, they will not work on a MultiChain blockchain created with the default parameters. If you want your MultiChain blockchain to support bitcoin-compatible addressing, you need to change these parameters in params.dat to the values shown, before starting the chain:

address-pubkeyhash-version=00
address-scripthash-version=05
private-key-version=80
address-checksum-value=00000000

answered Jul 5, 2018 by MultiChain
selected Jul 5, 2018 by mina
I get the same error while using the mentioned configurations for params.dat and also using HD wallets. Appreciate your advice as below:
Using mcrpc python lib.

address1 = '12z51oYeUSVXK8NEEdmYDxY6HdBinCkpTN'
address2 = '127da59p99E8xDNcZ5VTmkKdnJnpT1cw89'

unsigned_tx = client.createrawsendfrom(address1, {address2: {'coin': 1}})
unsigned_tx
'0100000001b0c97186c7290f6771905a6934bbeb3c5dd873771623447d98c3bdf868d812120000000000ffffffff0200000000000000003776a9140c3926190feb3dd74fd51d0d6d21f5a65243bafb88ac1c73706b71e3ae1807ff12514de2238889a50e3d6b01000000000000007500000000000000003776a91415c32fa9fe7345893a0ad78a071cef7db06a04be88ac1c73706b71e3ae1807ff12514de2238889a50e3d6bf3010000000000007500000000'

privkey = 'xprv9s21ZrQH143K4BSSxN2KG2Jxo79d1w5StZu9fSebzW2nT13x3j3VdZJnUwfrTo4ayDd373WgA2XqYkgL7niCudG65fYsMLowkHm2MkxsJY2'

signed_tx = client.signrawtransaction(unsigned_tx, [], [privkey])
so I got an error as below:
raise RpcError(data['error'].get('message'))
mcrpc.exceptions.RpcError: Invalid private key
This doesn't look like a regular private key, but rather some extended one, probably related to the HD wallet.
Yes, It is extended one and related to the HD wallet. So how can I sign transaction using HD wallet ?
I'm afraid this question is a bit out of our scope here. You would need to understand more about the HD wallet's scheme and features to obtain from it a regular (private key, address) pair, then ensure that address has the appropriate permissions on the blockchain and send a transaction using one of its unspent outputs. MultiChain doesn't currently have any built-in HD support.
...