Manually sign a raw transaction

+2 votes
Hi, i'm trying to create a node library that can handle addresses for a Multichain blockchain (node/browser wallet). Generating the addresses works, but now i also want to handle signing inside this library.

For this i only want the actual signing to happen inside the library, so the node can create the raw transaction but i don't want to give my private key to the node ... so signing the raw transaction should happen locally (in the library). Is there any documentation on how to sign a raw transaction? Where are the differences compared to signing a raw transaction for the bitcoin blockchain (because this also takes the network into account)?

kind regards,

asked Jun 1, 2016 by Daan

1 Answer

+1 vote
It works exactly the same as for bitcoin, and the transaction format is compatible. So whatever external process you would use to sign your transaction with a bitcoin private key can be used to sign a MultiChain transaction.

You should be aware however that MultiChain addresses can be a little different from bitcoin addresses, although you can easily make them fully compatible if you wish to. More information here:
answered Jun 1, 2016 by MultiChain
What is the format for the public and private keys passed into Daan's signTransaction function? In his sign.js example the key inputs were  Buffer.from('02fdcee0919d98a318fb34318ab6645420252eadf5cbfe09f5c4cc07d58f22c628', 'hex'), Buffer.from('825119fcc0c096916d192a8b62f69a78996cc3c7a73fe8665b74b7d7fe6d9a98', 'hex'));
How do you get the keys in that format?
Also, where does the sign function in Daan's address.js ( get the public and private keys? From the redeemScript? If so, how would you get the redeemScript from an already created transaction (created using createrawtransaction) How do you format it to pass into the function?
'It also has structure OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG <asset information> OP_DROP'
How do you format the asset information in this if you get it from decoderawtransaction?
Not sure what you mean with the format of the public and the private key

both are generated here:
this is based on:

The configuration of the blockchain can be found here:

The Public and private keys in the sign function are inside the Address object. As you can see here:
we are using issuer.sign ... and issuer contains his pub and priv key.

The redeem script is the scriptPubKey from the UTXO of the input, it is in this format:

But you can run the example .. there are docker files included. When you run it you can see exactly what is happening ...
when I try to run the example, I get this error:
{ [Error: getaddrinfo ENOTFOUND master.mcbitcoin.docker master.mcbitcoin.docker:80]
  code: 'ENOTFOUND',
  errno: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'master.mcbitcoin.docker',
  host: 'master.mcbitcoin.docker',
  port: 80 }
Is that a docker error? What should I do? Thanks.
got it to work, just connected it to my own chain. Thanks for all the help!
Could you write a function with input is hexdata (result of createrawsendfrom) and return signedtransaction