Comparing version 0.0.37 to 0.0.38
@@ -20,2 +20,4 @@ import * as constants from "./lib/constants" | ||
import getSignature from "./lib/getSignature" | ||
import generateNewKeyPairFromHdKey from "./lib/generateNewKeyPairFromHdKey" | ||
import encryptTemplate from "./lib/encryptTemplate" | ||
@@ -41,3 +43,5 @@ export { | ||
getDataHash, | ||
getSignature | ||
getSignature, | ||
generateNewKeyPairFromHdKey, | ||
encryptTemplate | ||
} |
@@ -5,3 +5,3 @@ const bitcoin = require('bitcoinjs-lib') | ||
const createAndSendTransaction = async (decryptedSeedPhrase,password,amount,destAddress,our_wallet,nameId,nameValue) => { | ||
const createAndSendTransaction = async (decryptedSeedPhrase,password,amount,destAddress,our_wallet,nameId,nameValue,encryptedTemplateData) => { | ||
@@ -61,6 +61,7 @@ const hdKey = createHdKeyFromMnemonic(decryptedSeedPhrase,password) | ||
const txResponse = await sendToAddress(addressKeys, destAddress, changeAddress, amount, selectedInputs,nameId,nameValue) //chai.expect(addressesOfBob[0].address.substring(0,1)).to.not.be.uppercase | ||
const txResponse = await sendToAddress(addressKeys, destAddress, changeAddress, amount, selectedInputs,nameId,nameValue,encryptedTemplateData) //chai.expect(addressesOfBob[0].address.substring(0,1)).to.not.be.uppercase | ||
updateWalletWithUnconfirmedUtxos(txResponse,our_wallet) | ||
return txResponse | ||
} | ||
export default createAndSendTransaction |
@@ -16,6 +16,6 @@ import generateNameId from "./generateNameId"; | ||
*/ | ||
const createDoichainEntry = async (privateKey,validatorPublicKey, from,to,data) =>{ | ||
const nameId = await generateNameId(); | ||
const createDoichainEntry = (keyPair, validatorPublicKey, from, to, data) => { | ||
const nameId = generateNameId(); | ||
const message = to+from; //TODO why to+from and not from+to? | ||
const signature = getSignature(message, privateKey); | ||
const signature = getSignature(message, keyPair); | ||
let dataHash = ""; | ||
@@ -25,13 +25,11 @@ if(data) dataHash = getDataHash(data); | ||
const fromHostUrl = getUrl() | ||
return await encryptMessage(privateKey,validatorPublicKey,fromHostUrl).then((fromHostUrlEncrypted)=>{ | ||
const nameValue = JSON.stringify({ | ||
signature: signature, | ||
dataHash: dataHash, | ||
from: fromHostUrlEncrypted | ||
}); | ||
return {nameId:nameId,nameValue:nameValue} | ||
}) | ||
const fromHostUrlEncrypted = encryptMessage(keyPair._privateKey,validatorPublicKey,fromHostUrl) | ||
const nameValue = JSON.stringify({ | ||
signature: signature, | ||
dataHash: dataHash, | ||
from: fromHostUrlEncrypted | ||
}); | ||
return {nameId:nameId,nameValue:nameValue} | ||
} | ||
export default createDoichainEntry |
@@ -11,6 +11,9 @@ const bitcoin = require('bitcoinjs-lib') | ||
*/ | ||
const getSignature = (message,privateKey) => { | ||
const getSignature = (message,keyPair) => { | ||
try { | ||
const signature = Message(message).sign(new bitcore.PrivateKey.fromString(privateKey)); | ||
return signature; | ||
// const privateKey = keyPair.d.toBuffer(32) | ||
//var message = 'Hey this is Ranchi Mall' | ||
const signature = bitcoinMessage.sign(message, keyPair._privateKey, keyPair.compressed) | ||
console.log(signature.toString('base64')) | ||
return signature.toString('base64') | ||
} catch(exception) { | ||
@@ -17,0 +20,0 @@ throw {error:"Error during creating signature for doichain entry", exception: exception}; |
@@ -53,3 +53,3 @@ import settings from './settings' | ||
port: 443, | ||
host: "doichain-v0-0-9-88.doi.works" | ||
host: "doichain-v0-0-9-89.doi.works" | ||
} | ||
@@ -56,0 +56,0 @@ |
@@ -6,3 +6,3 @@ //import bitcoin from 'bitcoinjs-lib' | ||
export const sendToAddress = (keypair, destAddress, changeAddress, amount, inputsSelected, nameId, nameValue, network) => { | ||
export const sendToAddress = (keypair, destAddress, changeAddress, amount, inputsSelected, nameId, nameValue, encryptedTemplateData,network) => { | ||
@@ -75,3 +75,6 @@ let opCodesStackScript = undefined | ||
const txSignedSerialized = txb.build().toHex() | ||
return broadcastTransaction(null, txSignedSerialized, null, null, destAddress) | ||
if(!encryptedTemplateData) | ||
return broadcastTransaction(null, txSignedSerialized, null, null, destAddress) | ||
else | ||
return broadcastTransaction(nameId, txSignedSerialized, encryptedTemplateData, null, destAddress) | ||
} catch (e) { | ||
@@ -78,0 +81,0 @@ console.log('error broadcasting transaction', e) |
{ | ||
"name": "doichain", | ||
"version": "0.0.37", | ||
"version": "0.0.38", | ||
"description": "A js-Doichain library. The goal is to fully cover the Doichain protocol", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
187836
39
991