-
-
Save feulf/824965174e315039210370fccbe799d8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function saveOts(otsFilename, buffer) { | |
| fs.exists(otsFilename, fileExist => { | |
| if (fileExist) { | |
| console.log('The timestamp proof \'' + otsFilename + '\' already exists'); | |
| } else { | |
| fs.writeFile(otsFilename, buffer, 'binary', err => { | |
| if (err) { | |
| return console.log(err); | |
| } | |
| console.log('The timestamp proof \'' + otsFilename + '\' has been created!'); | |
| }); | |
| } | |
| }); | |
| } | |
| const OpenTimestamps = require('javascript-opentimestamps'); | |
| var infoResult; | |
| const file = Buffer.from('5468652074696d657374616d70206f6e20746869732066696c6520697320696e636f6d706c6574652c20616e642063616e2062652075706772616465642e0a','hex'); | |
| const detached = OpenTimestamps.DetachedTimestampFile.fromBytes(new OpenTimestamps.Ops.OpSHA256(), file); | |
| const Context = require('./node_modules/javascript-opentimestamps/src/context.js'); // loading directly from node_modules... ew | |
| const ctx = new Context.StreamSerialization(); | |
| detached.serialize(ctx); | |
| var buffer = new Buffer(detached.getOutput()); | |
| var otsFilename = 'fed.ots'; | |
| saveOts(otsFilename, buffer); |
The problems were:
- #L24 ctx.getOutput() instead of detached.getOutput()
- No need to require the Context from a require, it is accessible with OpenTimestams.Context
- You are not calling the stamp function (which I suppose is the reason of the script)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
see https://gist.github.com/RCasatta/805091255747610a1d7d02d5c3bef1d2