Serializing fully signed multisig transaction with toObject changes hash
When I have a fully signed Transaction object (2-of-3 signatures provided) and then inflate it to a JSON object through var json = JSON.stringify(tx.toObject()), it seems the hash of the transaction changes.
When I then do:
var tx2 = new bitcore.Transaction(JSON.parse(json)); , it gives this error:
throw new errors.InvalidState(message);
Invalid state: Hash in object does not match transaction hash
If I try to broadcast the transaction through Insight before inflating it to JSON, it works perfectly fine. But when I convert that exact transaction through JSON and then back I get the error above.
Serializing the fully-signed transaction like tx.serialize() and then creating a new transaction from that value also works as it should. So it just related to toObject() it seems.
Error is thrown from bitcore-lib/lib/util/preconditions.js:9
Let me know if I can provide any additional information.