diff --git a/lib/services/bitcoind.js b/lib/services/bitcoind.js index f865cf57a..fab662205 100644 --- a/lib/services/bitcoind.js +++ b/lib/services/bitcoind.js @@ -192,7 +192,8 @@ Bitcoin.prototype.getAPIMethods = function() { ['nftProtocolOwnerOf', this, this.nftProtocolOwnerOf, 1], ['nftProtocolGetByTxid', this, this.nftProtocolGetByTxid, 1], ['nftProtocolGet', this, this.nftProtocolGet, 1], - ['nftProtocolList', this, this.nftProtocolList, 4] + ['nftProtocolList', this, this.nftProtocolList, 4], + ['nftProtocolRegister', this, this.nftProtocolRegister, 9] ]; return methods; }; @@ -2377,6 +2378,42 @@ Bitcoin.prototype.nftProtocolList = function(count, skipFromTip, height, regTxOn }); }; +/** + * Will register a new NFT protocol. + * @param {String} protocolId - NFT protocol ID. + * @param {String} protocolName - NFT protocol name. + * @param {String} ownerAddress - NFT protocol owner address. + * @param {Number} regSign - NFT reg-sign. + * @param {String} metadataMimeType - MIME type describing metadata content type. + * @param {String} metadataSchemaUri - URI to schema (json/xml/binary) describing metadata format. + * @param {Boolean} isTransferable - Defines if this NF token type can be transferred. + * @param {Boolean} isMetadataEmbedded - Defines if metadata is embedded or contains a URI. + * @param {Boolean} maxMetadataSize - Defines maximum metadata length for the NFT. + * @param {Function} callback + */ +Bitcoin.prototype.nftProtocolRegister = function(protocolId, protocolName, ownerAddress, regSign, metadataMimeType, metadataSchemaUri, isTransferable, isMetadataEmbedded, maxMetadataSize, callback) { + var self = this; + + if (regSign === undefined) regSign = 2; + if (metadataMimeType === undefined) metadataMimeType = "text/plain"; + if (metadataSchemaUri === undefined) metadataSchemaUri = ''; + if (isTransferable === undefined) isTransferable = true; + if (isMetadataEmbedded === undefined) isMetadataEmbedded = false; + if (maxMetadataSize === undefined) maxMetadataSize = 255; + + regSign = regSign.toString(); + isTransferable = isTransferable.toString(); + isMetadataEmbedded = isMetadataEmbedded.toString(); + maxMetadataSize = maxMetadataSize.toString(); + + this.client.nfToken("register", protocolId, protocolName, ownerAddress, regSign, metadataMimeType, metadataSchemaUri, isTransferable, isMetadataEmbedded, maxMetadataSize, function(err, response) { + if (err) { + return callback(self._wrapRPCError(err)); + } + callback(null, response.result); + }); +}; + /** * Called by Node to stop the service. * @param {Function} callback diff --git a/package.json b/package.json index fbd7301ea..ee8894d70 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "bitcore-node-crown", "description": "Full node with extended capabilities using Bitcore and Crown Core", "author": "Crown Developers ", - "version": "0.4.14", + "version": "0.4.15", "publishConfig": { "tag": "next" },