Skip to content

Instantly share code, notes, and snippets.

@feulf
Created October 30, 2017 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save feulf/f0945fe6f77f3d0a77dffca6636dd267 to your computer and use it in GitHub Desktop.
Save feulf/f0945fe6f77f3d0a77dffca6636dd267 to your computer and use it in GitHub Desktop.
const OpenTimestamps = require('javascript-opentimestamps');
var fs = require('fs');
fs.readFile('bitcoin.pdf.ots', 'utf8', (err, contents) => {
const fileOts = Buffer.from(contents.toString('utf8'));
const detached = OpenTimestamps.DetachedTimestampFile.deserialize(fileOts);
const infoResult = OpenTimestamps.info(detached);
console.log(infoResult)
});
fs.readFile('hello-world.txt.ots', 'utf8', (err, ots) => {
const infoResult = OpenTimestamps.info(ots);
console.log(infoResult)
});
@feulf
Copy link
Author

feulf commented Oct 30, 2017

I'm using the javascript library at https://github.com/opentimestamps/javascript-opentimestamps.
I've tried the examples at README.md and the one in the examples/ folder:

  1. Example in examples/test.js:
$ node examples/test.js
STAMP
INFO
err=TypeError: Cannot read property '_HASHLIB_NAME' of undefined
(node:37926) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Invalid input
(node:37926) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
  1. Example running the code in this gist:
$ node info.js 
Unknown operation tag:  ef
/Users/federicoulfo/bauso/notarizza-function-docs-uploader/functions/node_modules/javascript-opentimestamps/src/timestamp.js:63
        const result = op.call(initialMsg);
                         ^

TypeError: Cannot read property 'call' of undefined
    at doTagOrAttestation (/Users/federicoulfo/bauso/notarizza-function-docs-uploader/functions/node_modules/javascript-opentimestamps/src/timestamp.js:63:26)
    at Function.deserialize (/Users/federicoulfo/bauso/notarizza-function-docs-uploader/functions/node_modules/javascript-opentimestamps/src/timestamp.js:77:5)
    at Function.deserialize (/Users/federicoulfo/bauso/notarizza-function-docs-uploader/functions/node_modules/javascript-opentimestamps/src/detached-timestamp-file.js:96:33)
    at fs.readFile (/Users/federicoulfo/bauso/notarizza-function-docs-uploader/functions/info.js:6:59)
    at tryToString (fs.js:449:3)
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:436:12)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment