From e64581e4eb005536854d0516d78c4b9404484900 Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Thu, 13 Aug 2015 10:55:37 -0400 Subject: [PATCH] Update documentation with API changes for toJSON. --- docs/transaction.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/transaction.md b/docs/transaction.md index 321cce7..4432349 100644 --- a/docs/transaction.md +++ b/docs/transaction.md @@ -68,7 +68,7 @@ var multiSigTx = new Transaction() .change(address); var signature = multiSigTx.getSignatures(privateKey)[0]; -console.log(signature.toJSON()); +console.log(JSON.stringify(signature)); console.log(signature.toObject()); console.log(signature.signature.toString()); // Outputs a DER signature console.log(signature.sigtype); @@ -144,7 +144,7 @@ To remove all outputs, you can use `clearOutputs()`, which preserves change outp There are a series of methods used for serialization: * `toObject`: Returns a plain JavaScript object with no methods and enough information to fully restore the state of this transaction. Using other serialization methods (except for `toJSON`) will cause a some information to be lost. -* `toJSON`: Returns a string with a JSON-encoded version of the output for `toObject`. +* `toJSON`: Will be called when using `JSON.stringify` to return JSON-encoded string using the output from `toObject`. * `toString` or `uncheckedSerialize`: Returns an hexadecimal serialization of the transaction, in the [serialization format for bitcoin](https://bitcoin.org/en/developer-reference#raw-transaction-format). * `serialize`: Does a series of checks before serializing the transaction * `inspect`: Returns a string with some information about the transaction (currently a string formated as ``, that only shows the serialized value of the transaction.