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AS,UACzB,OAAO,yBAAwB,EAAO,0CAIvC,GAAI,MAAM,EAAY,SAAS,WAC9B,OAAO,yBAAwB,EAAO,oDAGvC,IAAK,EAAY,SAAS,KACzB,OAAO,yBAAwB,EAAO,qCAGvC,IAAK,EAAY,SAAS,KACzB,OAAO,yBAAwB,EAAO,wCAEvC,IAAK,EAAY,SAAS,KAAK,MAC9B,OAAO,yBAAwB,EAAO,2CAEvC,IAAK,EAAY,SAAS,KAAK,YAC9B,OAAO,yBAAwB,EAAO,iDAEvC,IAAK,EAAY,SAAS,KAAK,KAC9B,OAAO,yBAAwB,EAAO,0CAIvC,GAA6C,iBAAlC,EAAY,SAAS,KAAK,KACpC,IACC,EAAY,SAAS,KAAK,KAAO,SAAS,EAAY,SAAS,KAAK,KACrE,CAAE,MAAM,GACP,OAAO,yBAAwB,EAAO,mDACvC,CAGD,OAAK,EAAY,SAAS,QAGrB,EAAY,SAAS,QAAQ,QAK7B,EAAY,SAAS,QAAQ,cAAlC,EACQ,yBAAwB,EAAO,wIAL/B,yBAAwB,EAAO,gDAH/B,yBAAwB,EAAO,0CAaxC,EAoDA,MAAM,aAAe,IACf,kBAAoB,IACpB,YAAc,KACd,UAAY,GAElB,OAAO,QAAU","file":"/npm/oip-npm@1.6.13/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/oip-npm@1.6.13/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","var florincoin = require('node-litecoin');\nvar request = require('request');\nvar jsonpatch = require('fast-json-patch');\nvar jsonpack = require('jsonpack/main');\nvar crypto = require('crypto');\nvar client;\n\nfunction OIP(args){\n\tthis.client = new florincoin.Client({\n\t\thost: args.host,\n\t\tport: args.port,\n\t\tuser: args.username || args.user, \n\t\tpass: args.password || args.pass\n\t});\n}\n\n// Accepts information in the following format: {\"name\": \"Test Publisher\", \"address\": \"FLO Address\"}\nOIP.prototype.signPublisher = function(args, callback){\n\t// Check if the callback is being passed in as args\n\tif (!args || typeof args === \"function\"){\n\t\tcallback = args;\n\t\tcallback(generateResponseMessage(false, 'You must submit information in the following format: {\"name\": \"Test Publisher\", \"address\": \"FLO Address\"}'));\n\t\treturn;\n\t}\n\n\tif (!args.name){\n\t\tcallback(generateResponseMessage(false, 'You must include the publisher address and the publisher name as arguments. {\"name\": \"Test Publisher\", \"address\": \"FLO Address\"}'))\n\t}\n\n\tif (!args.address){\n\t\tcallback(generateResponseMessage(false, 'You must include the publisher address and the publisher name as arguments. {\"name\": \"Test Publisher\", \"address\": \"FLO Address\"}'))\n\t}\n\n\t// http://api.alexandria.io/#sign-publisher-announcement-message\n\t// Publisher Name - Address - UNIX Timestamp\n\tvar toSign = args.name + \"-\" + args.address + \"-\" + Math.floor((new Date).getTime()/1000);\n\t\n\tsignMessage(args.address, toSign, function(data){\n\t\tcallback(data);\n\t});\n}\n\n// Accepts information in the following format: {\"name\": \"Test Publisher\", \"address\": \"FLO Address\"}\nOIP.prototype.signArtifact = function(args, callback){\n\t// Check if the callback is being passed in as args\n\tif (!args || typeof args === \"function\"){\n\t\tcallback = args;\n\t\tcallback(generateResponseMessage(false, 'You must submit information in the following format: {\"ipfs\": \"IPFS Location Hash\", \"address\": \"FLO Address\"}'));\n\t\treturn;\n\t}\n\n\tif (!args.ipfs){\n\t\tcallback(generateResponseMessage(false, 'You must include the publisher address and the publisher name as arguments. {\"ipfs\": \"IPFS Location Hash\", \"address\": \"FLO Address\"}'))\n\t}\n\n\tif (!args.address){\n\t\tcallback(generateResponseMessage(false, 'You must include the publisher address and the publisher name as arguments. {\"ipfs\": \"IPFS Location Hash\", \"address\": \"FLO Address\"}'))\n\t}\n\n\t// http://api.alexandria.io/#sign-publisher-announcement-message\n\t// IPFS Location Hash - Address - UNIX Timestamp\n\tvar toSign = args.ipfs + \"-\" + args.address + \"-\" + Math.floor((new Date).getTime()/1000);\n\t\n\tsignMessage(args.address, toSign, function(signature){\n\t\tcallback(signature);\n\t});\n}\n\n// Accepts information in the following format: {\"oip-publisher\":{\"name\":\"Publisher Name\",\"address\":\"FLO Address\",\"emailmd5\":\"\",\"bitmessage\":\"\"} }\nOIP.prototype.announcePublisher = function(args, callback){\n\tvar errorString = 'You must submit information in the following format: {\"oip-publisher\":{\"name\":\"Publisher Name\",\"address\":\"FLO Address\",\"emailmd5\":\"\",\"bitmessage\":\"\"} }';\n\t// Check if the callback is being passed in as args\n\tif (!args || typeof args === \"function\"){\n\t\tcallback = args;\n\t\tcallback(generateResponseMessage(false, errorString));\n\t\treturn;\n\t}\n\n\t// Validate that information is being submitted correctly.\n\tif (!args['oip-publisher']){\n\t\tcallback(generateResponseMessage(false, errorString))\n\t\treturn;\n\t}\n\n\tvar publisher = args['oip-publisher'];\n\n\tif (!publisher.name){\n\t\tcallback(generateResponseMessage(false, 'You must include the publisher name! ' + errorString));\n\t\treturn;\n\t}\n\n\tif (!publisher.address){\n\t\tcallback(generateResponseMessage(false, 'You must include the publisher address! ' + errorString));\n\t\treturn;\n\t}\n\n\n\n\t// http://api.alexandria.io/#sign-publisher-announcement-message\n\t// Publisher Name - Address - UNIX Timestamp\n\tvar toSign = args.name + \"-\" + args.address + \"-\" + Math.floor((new Date).getTime()/1000);\n\t\n\tsignMessage(args.address, toSign, function(signature){\n\t\tcallback(signature);\n\t});\n}\n\n// Accepts information in the format OIP-041\nOIP.prototype.publishArtifact = function(oipArtifact, callback){\n\t// Check if the callback is being passed in as args\n\tif (!oipArtifact || typeof oipArtifact === \"function\"){\n\t\tcallback = oipArtifact;\n\t\tcallback(generateResponseMessage(false, 'You must submit information in the OIP-041 format'));\n\t\treturn;\n\t}\n\t// Make sure we don't crash :)\n\tif (typeof oipArtifact == \"string\"){\n\t\t// Test to see if the artifact is valid JSON\n\t\ttry {\n\t\t\toipArtifact = JSON.parse(oipArtifact);\n\t\t} catch (e) {\n\t\t\tcallback(generateResponseMessage(false, \"Unable to parse JSON, please check your format and try again.\"));\n\t\t\treturn;\n\t\t}\n\t}\n\n\t// If the artifact verifies correctly it will contain no text, if it fails it will have an error.\n\tvar verify = this.verifyArtifact(oipArtifact);\n\t// Check if there is an error\n\tif (verify){\n\t\tcallback(verify);\n\t\treturn;\n\t}\n\n\tvar prunedArtifact = prune(oipArtifact);\n\n\tvar timestamp = Math.floor(Date.now() / 1000);\n\n\t// http://api.alexandria.io/#sign-publisher-announcement-message\n\t// IPFS - Address - UNIX Timestamp\n\tvar toSign = prunedArtifact[\"oip-041\"].artifact.storage.location + \"-\" + prunedArtifact[\"oip-041\"].artifact.publisher + \"-\" + timestamp;\n\n\tprunedArtifact[\"oip-041\"].artifact.timestamp = timestamp;\n\t\n\tvar oip = this;\n\t// Sign the message\n\toip.signMessage(prunedArtifact[\"oip-041\"].artifact.publisher, toSign, function(res){\n\t\tif (!res.success){\n\t\t\tcallback(res);\n\t\t\treturn;\n\t\t}\n\t\t// Attach signature\n\t\tprunedArtifact[\"oip-041\"].signature = res.message;\n\t\t// Above we remove the \"oip-041\" for ease of use, this adds it back in.\n\t\toip.sendToBlockChain(prunedArtifact, prunedArtifact[\"oip-041\"].artifact.publisher, function(response){\n\t\t\tcallback(response);\n\t\t})\n\t});\n}\n\nfunction prune(artifact) {\n\tvar clone = JSON.parse(JSON.stringify(artifact));\n\n\tpruneObject(clone);\n\n\treturn clone;\n\n\tfunction pruneObject(obj) {\n\t\tvar entries = Object.entries(obj);\n\n\t\tfor ([key, value] of entries) {\n\t\t\tif ('0' === value || 0 === value) delete obj[key];\n\t\t\tif ('object' === typeOf(value)) pruneObject(value);\n\t\t\tif ('array' === typeOf(value)) pruneArray(value);\n\t\t}\n\t}\n\n\tfunction pruneArray(array) {\n\t\tfor (var item of array) {\n\t\t\tif ('object' === typeOf(item)) pruneObject(item);\n\t\t}\n\t}\n\n\tfunction typeOf(obj) {\n\t  return {}.toString.call(obj).split(' ')[1].slice(0, -1).toLowerCase();\n\t}\n}\n\n// Accepts information in the format OIP-041-Artifact and OIP-041-Edit\nOIP.prototype.editArtifact = function(oipArtifact, callback){\n\t// Check if the callback is being passed in as args\n\tif (!oipArtifact || typeof oipArtifact === \"function\"){\n\t\tcallback = oipArtifact;\n\t\tcallback(generateResponseMessage(false, 'You must submit information in the OIP-041 format'));\n\t\treturn;\n\t}\n\t// Make sure we don't crash :)\n\tif (typeof oipArtifact == \"string\"){\n\t\t// Test to see if the artifact is valid JSON\n\t\ttry {\n\t\t\toipArtifact = JSON.parse(oipArtifact);\n\t\t} catch (e) {\n\t\t\tcallback(generateResponseMessage(false, \"Unable to parse JSON, please check your format and try again.\" + e));\n\t\t\treturn;\n\t\t}\n\t}\n\t// Check if it is an edit or artifact format.\n\tif (oipArtifact['oip-041'].edit){\n\t\t// IPFS - Address - UNIX Timestamp\n\t\tvar toSign = oipArtifact.artifact.storage.location + \"-\" + oipArtifact.artifact.publisher + \"-\" + oipArtifact.artifact.timestamp;\n\t\t\n\t\t// Sign the message\n\t\toip.signMessage(oipArtifact.artifact.publisher, toSign, function(res){\n\t\t\tif (!res.success){\n\t\t\t\tcallback(res);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Attach signature\n\t\t\toipArtifact.signature = res.message;\n\t\t\t// Above we remove the \"oip-041\" for ease of use, this adds it back in.\n\t\t\tvar reformattedOIP = { \"oip-041\": oipArtifact }\n\t\t\toip.sendToBlockChain(reformattedOIP, oipArtifact.artifact.publisher, function(response){\n\t\t\t\tcallback(response);\n\t\t\t\treturn;\n\t\t\t})\n\t\t});\n\t}\n\t// If the artifact verifies correctly it will contain no text, if it fails it will have an error.\n\tvar verify = this.verifyArtifact(oipArtifact);\n\t// Check if there is an error\n\tif (verify){\n\t\tcallback(verify);\n\t\treturn;\n\t}\n\n\tif (!oipArtifact['oip-041'].artifact.txid){\n\t\treturn generateResponseMessage(false, \"artifact.txid is a required field when editting! Please submit the TXID of the artifact you wish to edit.\");\n\t}\n\n\tvar oip = this;\n\t// Get the original artifact\n\toip.getArtifact(oipArtifact['oip-041'].artifact.txid, function(response){\n\t\tif (typeof response == \"string\"){\n\t\t\t// Test to see if the artifact is valid JSON\n\t\t\ttry {\n\t\t\t\tresponse = JSON.parse(response);\n\t\t\t} catch (e) {\n\t\t\t\tconsole.log(response);\n\t\t\t\tcallback(generateResponseMessage(false, \"Unable to parse JSON, please check your format and try again.\" + e));\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// Check if response is successful\n\t\tif (!response.success){\n\t\t\tcallback(response);\n\t\t\treturn;\n\t\t}\n\n\t\tvar oldArtifact = response.message;\n\t\t//console.log(JSON.stringify(oldArtifact));\n\n\t\t// Check if the TX is OIP-041, only supports edits for that currently\n\t\tif (!response.message['oip-041']){\n\t\t\tcallback(generateResponseMessage(false, \"Unable to edit artifacts that are not OIP-041\"));\n\t\t\treturn;\n\t\t}\n\n\t\t// Remove the txid, we don't want to publish that\n\t\tvar oldTX = oipArtifact['oip-041'].artifact.txid;\n\t\tdelete oipArtifact['oip-041'].artifact.txid;\n\t\t// LibraryD adds a lot of info we do not want to republish, delete all of those from the results.\n\t\tdelete response.message['oip-041'].artifact.info.ExtraInfoString;\n\t\tdelete response.message['oip-041'].edit;\n\t\tdelete response.message['oip-041'].transferArtifact;\n\t\tdelete response.message.tags;\n\t\tdelete response.message.timestamp;\n\t\tdelete response.message.title;\n\t\tdelete response.message.type;\n\t\tdelete response.message.tags;\n\t\tdelete response.message.year;\n\t\tdelete response.message.publisher;\n\t\tdelete response.message.block;\n\n\t\t//console.log(JSON.stringify(response.message));\n\n\t\t// Get the edit format\n\t\tvar oipEdit = oip.generateEditDiff(response.message, oipArtifact, oldTX);\n\n\t\tif (!oipEdit.success){\n\t\t\tcallback(oipEdit);\n\t\t\treturn;\n\t\t}\n\n\t\toipEdit = oipEdit.message;\n\n\t\t// Generate the MD5 Hash \n\t\tvar patchHash = JSON.stringify(oipEdit);\n\t\tpatchHash = crypto.createHash('md5').update(patchHash).digest(\"hex\");\n\n\t\t//console.log(patchHash);\n\n\t\tvar timestamp = Math.floor(Date.now() / 1000);\n\t\t// http://api.alexandria.io/#sign-publisher-announcement-message\n\t\t// Old TXID - MD5 Hash of Patch - UNIX Timestamp\n\t\tvar toSign = oldTX + \"-\" + patchHash + \"-\" + timestamp;\n\n\t\toipArtifact['oip-041'].artifact.timestamp = timestamp;\n\t\t\n\t\t//console.log(toSign);\n\t\t//console.log(oipEdit);\n\t\t// Sign the message\n\t\toip.signMessage(oipArtifact['oip-041'].artifact.publisher, toSign, function(res){\n\t\t\tif (!res.success){\n\t\t\t\tcallback(res);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Attach signature\n\t\t\toipEdit['oip-041'].signature = res.message;\n\t\t\toip.sendToBlockChain(oipEdit, oipArtifact['oip-041'].artifact.publisher, function(response){\n\t\t\t\tcallback(response);\n\t\t\t})\n\t\t});\n\t})\n}\n\nOIP.prototype.deactivateArtifact = function(txid, title, callback){\n\tif (!callback){\n\t\t// Check if they submitted the callback as the title\n\t\tif (typeof title == \"function\"){\n\t\t\tcallback = title;\n\t\t\tcallback(generateResponseMessage(false, 'You must submit a title!'));\n\t\t\treturn;\n\t\t}\n\t\treturn;\n\t}\n\n\t// Check if we have a txid\n\tif (!txid){\n\t\tcallback(generateResponseMessage(false, \"You must submit a txid!\"));\n\t\treturn;\n\t}\n\n\t// Check txid length, make sure it is 64\n\tif (txid.length != 64){\n\t\tcallback(generateResponseMessage(false, \"You must submit a valid txid!\"));\n\t\treturn;\n\t}\n\n\tif (!title){\n\t\tcallback(generateResponseMessage(false, \"You must submit a title!\"));\n\t\treturn;\n\t}\n\n\tvar oip = this;\n\toip.getArtifact(txid, function(response){\n\t\tif (typeof response == \"string\"){\n\t\t\t// Test to see if the artifact is valid JSON\n\t\t\ttry {\n\t\t\t\tresponse = JSON.parse(response);\n\t\t\t} catch (e) {\n\t\t\t\tcallback(generateResponseMessage(false, \"Artifact is not valid JSON\"));\n\t\t\t}\n\t\t}\n\n\t\t// Check if response is successful\n\t\tif (!response.success){\n\t\t\tcallback(response);\n\t\t\treturn;\n\t\t}\n\n\t\tvar oldArtifact = response.message;\n\n\t\t// Check if title matches.\n\t\tif (oldArtifact[\"oip-041\"].artifact.info.title == title){\n\t\t\tvar timestamp = Math.floor(Date.now() / 1000);\n\t\t\tvar toSign = oldArtifact.txid + \"-\" + oldArtifact['oip-041'].artifact.publisher + \"-\" + timestamp;\n\n\t\t\t// Sign the message\n\t\t\toip.signMessage(oldArtifact[\"oip-041\"].artifact.publisher, toSign, function(res){\n\t\t\t\tif (!res.success){\n\t\t\t\t\tcallback(res);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Attach signature\n\t\t\t\tvar oipDeactivate = {\n\t\t\t\t\t\"oip-041\": {\n\t\t\t\t\t\t\"deactivateArtifact\": {\n\t\t\t\t\t\t\t\"txid\": oldArtifact.txid,\n\t\t\t\t\t\t\t\"timestamp\": timestamp\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"signature\": res.message\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\toip.sendToBlockChain(oipDeactivate, oldArtifact[\"oip-041\"].artifact.publisher, function(response){\n\t\t\t\t\tcallback(response);\n\t\t\t\t})\n\t\t\t})\n\t\t} else {\n\t\t\tcallback(generateResponseMessage(false, \"The title does not match! Aborting deactivation!\"));\n\t\t}\n\t});\n}\n\nOIP.prototype.transferArtifact = function(txid, origOwner, newOwner, callback){\n\tif (!callback){\n\t\t// Check if they submitted the callback as the title\n\t\tif (typeof newOwner == \"function\"){\n\t\t\tcallback = newOwner;\n\t\t\tcallback(generateResponseMessage('You must submit a new owner!'));\n\t\t\treturn;\n\t\t}\n\t\treturn;\n\t}\n\n\t// Check if we have a txid\n\tif (!txid){\n\t\tcallback(generateResponseMessage(false, \"You must submit a txid!\"));\n\t\treturn;\n\t}\n\n\t// Check txid length, make sure it is 64\n\tif (txid.length != 64){\n\t\tcallback(generateResponseMessage(false, \"You must submit a valid txid!\"));\n\t\treturn;\n\t}\n\n\tif (!origOwner){\n\t\tcallback(generateResponseMessage(false, \"You must submit the original owner!\"));\n\t\treturn;\n\t}\n\n\tif (!newOwner){\n\t\tcallback(generateResponseMessage(false, \"You must submit the new owner!\"));\n\t\treturn;\n\t}\n\n\tvar oip = this;\n\t\n\tvar timestamp = Math.floor(Date.now() / 1000);\n\tvar toSign = txid + \"-\" + origOwner + \"-\" + newOwner + \"-\" + timestamp;\n\n\t// Sign the message\n\toip.signMessage(origOwner, toSign, function(res){\n\t\tif (!res.success){\n\t\t\tcallback(res);\n\t\t\treturn;\n\t\t}\n\t\t// Attach signature\n\t\tvar oipTransfer = {\n\t\t\t\"oip-041\": {\n\t\t\t\t\"transferArtifact\": {\n\t\t\t\t\t\"txid\": txid,\n\t\t\t\t\t\"to\": newOwner,\n\t\t\t\t\t\"from\": origOwner,\n\t\t\t\t\t\"timestamp\": timestamp\n\t\t\t\t},\n\t\t\t\t\"signature\": res.message\n\t\t\t}\n\t\t}\n\n\t\toip.sendToBlockChain(oipTransfer, origOwner, function(response){\n\t\t\tcallback(response);\n\t\t})\n\t})\n}\n\nOIP.prototype.signMessage = function(address, toSign, callback){\n\ttry {\n\t\tthis.client.signMessage(address, toSign, function(err, signature) {\n\t\t\tif (err){\n\t\t\t\tcallback(generateResponseMessage(false, \"Error signing message: \" + err));\n\t\t\t\tconsole.log(generateResponseMessage(false, \"Error signing message: \" + err));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Return the signature\n\t\t\tcallback(generateResponseMessage(true, signature));\n\t\t});\n\t} catch (e) {\n\t\tcallback(generateResponseMessage(false, \"Error signing publisher message: \" + e));\n\t\tconsole.log(generateResponseMessage(false, \"Error signing publisher message: \" + e));\n\t}\n}\n\n// callback is (errorString, txIDs Array)\nOIP.prototype.multiPart = function(txComment, address, callback) {\n\tvar txIDs = [];\n\n\tvar multiPartPrefix = \"oip-mp(\";\n\n\tvar chop = this.chopString(txComment);\n\n\tvar part = 0;\n\tvar max = chop.length - 1;\n\n\t// the first reference tx id is always 64 zeros\n\tvar reference = new Array(65).join(\"0\");\n\tvar shortRef = shortenReference(reference);\n\n\tvar data = chop[part];\n\tvar preImage = part.toString() + \"-\" + max.toString() + \"-\" + address + \"-\" + \"-\" + data;\n\n\tvar oip = this;\n\n\toip.signMessage(address, preImage, function(response){\n\t\tif (!response.success){\n\t\t\tcallback(response);\n\t\t\treturn;\n\t\t}\n\n\t\tvar txComment = makeTxComment(multiPartPrefix, [part, max, address, shortRef, response.message], data);\n\n\t\toip.client.sendToAddress(address, SEND_AMOUNT, \"\", \"\", txComment, function(err, txid) {\n\t\t\tif (err){\n\t\t\t\tcallback(generateResponseMessage(false, \"Unable to send funds to address: \" + err))\n\t\t\t\tconsole.log(err);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t\n\t\t\ttxIDs[txIDs.length] = txid;\n\t\t\treference = txid;\n\n\t\t\toip.publishPart(chop, max, 0, reference, address, SEND_AMOUNT, multiPartPrefix, function(response){\n\t\t\t\tcallback(response);\n\t\t\t})\n\t\t});\n\t})\n}\n\nvar txIDs = [];\nOIP.prototype.publishPart = function(chopPieces, numberOfPieces, lastPiecesCompleted, reference, address, amount, multiPartPrefix, callback){\n\tif (lastPiecesCompleted == 0)\n\t\ttxIDs.push(reference);\n\n\tvar shortRef = shortenReference(reference);\n\t// Increment the number of completed pieces\n\tvar part = lastPiecesCompleted + 1;\n\n\t// Chop the next section of data to sign\n\tvar data = chopPieces[part];\n\tvar preImage = part.toString() + \"-\" + numberOfPieces.toString() + \"-\" + address + \"-\" + shortRef + \"-\" + data;\n\n\t// Generate signature\n\tvar oip = this;\n\toip.signMessage(address, preImage, function(res){\n\t\tif (!res.success){\n\t\t\tcallback(res)\n\t\t\tconsole.log(res);\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tvar multiPart = makeTxComment(multiPartPrefix, [part, numberOfPieces, address, shortRef, res.message], data);\n\n\t\toip.client.sendToAddress(address, SEND_AMOUNT, \"\", \"\", multiPart, function(err, txid) {\n\t\t\tif (err){\n\t\t\t\tcallback(generateResponseMessage(false, \"Unable to send funds to address: \" + err))\n\t\t\t\tconsole.log(err);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Store the txid from the just sent transaction.\n\t\t\ttxIDs[txIDs.length] = txid;\n\n\t\t\t// Check if we are done with publishing\n\t\t\tif (part < numberOfPieces){\n\t\t\t\t// Recurse back in.\n\t\t\t\toip.publishPart(chopPieces, numberOfPieces, part, reference, address, amount, multiPartPrefix, callback);\n\t\t\t} else {\n\t\t\t\t// We are done! Callback time.\n\t\t\t\tcallback(generateResponseMessage(true, txIDs));\n\t\t\t\t// Clear out the txIDs\n\t\t\t\ttxIDs = [];\n\t\t\t}\n\t\t});\n\t});\n}\n\nfunction makeTxComment(prefix, parts, data) {\n\tvar parts = parts.map((part, index) => index > 0 && parseInt(part) === 0 ? '' : part.toString());\n\tvar txComment = prefix + parts.join(',') + '):' + data;\n\n\treturn txComment;\n}\n\nfunction shortenReference(ref) {\n\treturn ref.substring(0, 10);\n}\n\nOIP.prototype.chopString = function(input) {\n\tinput = input.toString();\n\n\tvar chunks = [];\n\twhile (input.length > CHOP_MAX_LEN) {\n\t\tchunks[chunks.length] = input.slice(0, CHOP_MAX_LEN);\n\t\tinput = input.slice(CHOP_MAX_LEN);\n\t}\n\tchunks[chunks.length] = input;\n\n\treturn chunks;\n};\n\nOIP.prototype.sendToBlockChain = function(txComment, address, callback){\n\t// Make sure that it is a string and not JSON object.\n\tif (typeof txComment != \"string\"){\n\t\t// We are a JSON object, test if we accidently have a status message instead of just oip\n\t\tif (txComment.success){\n\t\t\ttxComment = txComment.message;\n\t\t}\n\t\t// If JSON object then convert to string.\n\t\ttxComment = UTF8SafeJsonEncode(txComment);\n\t} else {\n\t\t// It is a string, convert to JSON, strip message out, then convert back to a string\n\t\ttxComment = JSON.parse(txComment);\n\n\t\tif (txComment.success){\n\t\t\ttxComment = txComment.message;\n\t\t}\n\t\t// If JSON object then convert to string.\n\t\ttxComment = UTF8SafeJsonEncode(txComment);\n\t}\n\t// Check comment length.\n\tif (txComment.length > (CHOP_MAX_LEN * 10)) {\n\t\tcallback(generateResponseMessage(false, \"txComment is too large to fit within 10 multipart transactions. Try making it smaller!\"));\n\t}\n\telse if (txComment.length > TXCOMMENT_MAX_LEN) {\n\t\tthis.multiPart(txComment, address, callback);\n\t}\n\telse {\n\t\tthis.client.sendToAddress(address, SEND_AMOUNT, \"\", \"\", txComment, function(err, txid) {\n\t\t\tif (err){\n\t\t\t\tcallback(generateResponseMessage(false, \"Unable to send funds to address: \" + err))\n\t\t\t\tconsole.log(err);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcallback(generateResponseMessage(true, [txid]));\n\t\t});\n\t}\n}\n\nOIP.prototype.generateEditDiff = function(originalArtifact, updatedArtifact, origTXID){\n\tif (!originalArtifact || !updatedArtifact)\n\t\treturn generateResponseMessage(false, \"You are missing either the original artifact or the updated artifact\");\n\t// Check if the original artifact is actually just the transaction ID for the original artifact\n\tif (originalArtifact.length == TX_LENGTH)\n\t\treturn generateResponseMessage(false, \"You just submit the original artifact JSON, not the TXID. You can get the Artifact JSON by using the getArtifact function.\");\n\n\tvar oaVerify = this.verifyArtifact(originalArtifact);\n\tvar uaVerify = this.verifyArtifact(updatedArtifact);\n\n\tif (oaVerify || uaVerify){\n\t\tif (oaVerify){\n\t\t\treturn oaVerify;\n\t\t}\n\t\tif (uaVerify){\n\t\t\treturn uaVerify;\n\t\t}\n\t}\n\n\t//console.log(JSON.stringify(originalArtifact));\n\t//console.log(JSON.stringify(updatedArtifact));\n\n\t// http://stackoverflow.com/a/8432188/1232109\n\tvar result = jsonpatch.compare(originalArtifact, updatedArtifact);\n\n\t//console.log(result);\n\t//console.log(jsonpack.pack(result));\n\n\t//console.log(JSON.stringify(originalArtifact, true, 4));\n\t//console.log(JSON.stringify(updatedArtifact, true, 4));\n\t//console.log(JSON.stringify(squashPatch(result), true, 4));\n\n\tvar squashed = squashPatch(result);\n\t//console.log(JSON.stringify(squashed));\n\tvar packed = jsonpack.pack(squashed);\n\t//console.log(jsonpack.pack(squashed));\n\n\tvar oip041Edit = {\n\t    \"oip-041\":{\n\t        \"editArtifact\":{\n\t            \"txid\": origTXID,\n\t            \"timestamp\":updatedArtifact['oip-041'].artifact.timestamp,\n\t            \"patch\": squashed\n\t        }\n\t    }\n\t}\n\n\treturn JSON.parse('{\"success\": true, \"message\": ' + JSON.stringify(oip041Edit) + '}');\n}\n\nOIP.prototype.getArtifact = function(txid, callback){\n\tvar baseURL = 'https://api.alexandria.io/alexandria/v2/search';\n\tvar options = {\n\t\tmethod: 'POST',\n\t\theaders: {},\n\t\turl: baseURL,\n\t\tbody: JSON.stringify({\n\t\t\t'protocol': 'media',\n\t\t\t'search-on': 'txid',\n\t\t\t'search-for': txid\n\t\t})\n\t};\n\n\ttry {\n\t\trequest(options, function (error, response, body) {\n\t\t\tif (!error && response.statusCode == 200) {\n\t\t\t\t// Grab the result we want.\n\t\t\t\t//console.log(body);\n\t\t\t\tvar artifacts = JSON.parse(body);\n\n\t\t\t\t//console.log(artifacts.response);\n\t\t\t\tif (!artifacts.response || artifacts.response.length == 0 || typeof artifacts.response[0] == \"undefined\"){\n\t\t\t\t\tcallback(generateResponseMessage(false, \"No artifacts found from your search of TXID \"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tvar artifact = artifacts.response[0];\n\t\t\t\tvar str = JSON.stringify(artifact);\n\n\t\t\t\tif (artifacts.status == \"success\"){\n\t\t\t\t\t// We return the message differently here as it hates returning JSON inside JSON for some reason...\n\t\t\t\t\tcallback('{\"success\": true, \"message\": ' + str + '}');\n\t\t\t\t} else {\n\t\t\t\t\tcallback(generateResponseMessage(false, \"Artifact could not be found.\"))\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcallback(generateResponseMessage(false, \"Request failed with status: \" + response.statusCode + \", with error: \" + error));\n\t\t\t}\n\t\t});\n\t} catch (e) {\n\t\t// The request failed for some reason, catch to not crash the program.\n\t\tcallback(generateResponseMessage(false, \"POST Request crashed, stack: \" + e));\n\t}\n}\n\nOIP.prototype.verifyArtifact = function(oipArtifact){\n\tif (!oipArtifact || typeof oipArtifact === \"function\"){\n\t\treturn generateResponseMessage(false, 'You must submit information in the OIP-041 format');\n\t}\n\n\tif (typeof oipArtifact == \"string\"){\n\t\t// Test to see if the artifact is valid JSON\n\t\ttry {\n\t\t\toipArtifact = JSON.parse(oipArtifact);\n\t\t} catch (e) {\n\t\t\treturn generateResponseMessage(false, \"Artifact is not valid JSON\");\n\t\t}\n\t}\n\n\t// Test that the artifact has all required fields.\n\t// Test \"oip-041\" wrapping/version number\n\tif (!oipArtifact[\"oip-041\"]){\n\t\treturn generateResponseMessage(false, \"Artifact is not contained in 'oip-041' or is using an unsupported oip schema version.\");\n\t}\n\n\toipArtifact = oipArtifact[\"oip-041\"];\n\t// Test required fields\n\tif (!oipArtifact.artifact){\n\t\treturn generateResponseMessage(false, \"You must submit artifact JSON inside oip-041!\");\n\t}\n\tif (!oipArtifact.artifact.publisher){\n\t\treturn generateResponseMessage(false, \"artifact.publisher is a required field\");\n\t}\n\tif (!oipArtifact.artifact.timestamp){\n\t\treturn generateResponseMessage(false, \"artifact.timestamp is a required field\");\n\t}\n\n\t// Validate timestamp is a number\n\tif (isNaN(oipArtifact.artifact.timestamp)){\n\t\treturn generateResponseMessage(false, \"artifact.timestamp must be submitted as a number\");\n\t}\n\n\tif (!oipArtifact.artifact.type){\n\t\treturn generateResponseMessage(false, \"artifact.type is a required field\");\n\t}\n\n\tif (!oipArtifact.artifact.info){\n\t\treturn generateResponseMessage(false, \"artifact.info is a required fieldset\");\n\t}\n\tif (!oipArtifact.artifact.info.title){\n\t\treturn generateResponseMessage(false, \"artifact.info.title is a required field\");\n\t}\n\tif (!oipArtifact.artifact.info.description){\n\t\treturn generateResponseMessage(false, \"artifact.info.description is a required field\");\n\t}\n\tif (!oipArtifact.artifact.info.year){\n\t\treturn generateResponseMessage(false, \"artifact.info.year is a required field\");\n\t}\n\n\t// Validate year is a number\n\tif (typeof oipArtifact.artifact.info.year == \"string\"){\n\t\ttry {\n\t\t\toipArtifact.artifact.info.year = parseInt(oipArtifact.artifact.info.year);\n\t\t} catch(e){\n\t\t\treturn generateResponseMessage(false, \"artifact.info.year must be submitted as a number\");\n\t\t}\n\t}\n\n\tif (!oipArtifact.artifact.storage){\n\t\treturn generateResponseMessage(false, \"artifact.storage is a required fieldset\");\n\t}\n\tif (!oipArtifact.artifact.storage.network){\n\t\treturn generateResponseMessage(false, \"artifact.storage.network is a required field\");\n\t}\n\n\t// Currently the storage location is a required field. This however can be \"hidden\" using LibraryD so that you can serve the IPFS file location via an API (for example, that detects payments)\n\tif (!oipArtifact.artifact.storage.location){\n\t\treturn generateResponseMessage(false, \"artifact.storage.location is a required field (Talk with Alexandria if you need to hide this field from being published in LibraryD)\");\n\t}\n\n\t// Default return nothing.\n\treturn;\n}\n\nfunction squashPatch(patch){\n\tvar squashed = {\n\t\t\"add\": [],\n\t\t\"replace\": [],\n\t\t\"remove\": []\n\t}\n\tfor (var i = 0; i < patch.length; i++) {\n\t\t// Store the operation\n\t\tvar operation = patch[i].op;\n\t\t// Remove operation key from squashed patch\n\t\tdelete patch[i].op;\n\t\t// Edit the path to be shorter, unless it is the signature.\n\t\tpatch[i].path = patch[i].path.replace(\"/oip-041/artifact\", \"\");\n\t\t// Check what the operation is, and move it to the right place\n\t\tif (operation == \"add\")\n\t\t\tsquashed.add.push(patch[i]);\n\t\telse if (operation == \"replace\")\n\t\t\tsquashed.replace.push(patch[i]);\n\t\telse if (operation == \"remove\")\n\t\t\tsquashed.remove.push(patch[i]);\n\t}\n\treturn squashed;\n}\n\nfunction generateResponseMessage(success, message) {\n\ttry {\n\t\tvar response = {success: ''+success};\n\t\tif (success) {\n\t\t\tresponse.message = ''+message;\n\t\t} else {\n\t\t\tresponse.error = ''+message;\n\t\t}\n\t\treturn response;\n\t} catch(e) {\n\t\tconsole.log(e.message);\n\t\tconsole.log(success);\n\t\tconsole.log(message);\n\t\treturn '{\"success\": false, \"error\": \"Error generating response message\"}';\n\t}\n}\n\nfunction UTF8SafeJsonEncode(s, emit_unicode) {\n   var json = JSON.stringify(s);\n   return emit_unicode ? json : json.replace(/[\\u007f-\\uffff]/g,\n\t  function(c) { \n\t\treturn '\\\\u'+('0000'+c.charCodeAt(0).toString(16)).slice(-4);\n\t  }\n   );\n}\n\nconst CHOP_MAX_LEN = 270;\nconst TXCOMMENT_MAX_LEN = 528;\nconst SEND_AMOUNT = 0.0001;\nconst TX_LENGTH = 64;\n\nmodule.exports = OIP;\n"]}