diff --git a/app/gas-relayer/config/config.json b/app/gas-relayer/config/config.json index 3288d25..0e14159 100644 --- a/app/gas-relayer/config/config.json +++ b/app/gas-relayer/config/config.json @@ -6,7 +6,7 @@ }, "whisper": { - "privateKey": "0x1d8ef80c9933e20fa9720bf82f3ad481c6be9e44920932c008bb76655a211add", + "symKey": "0xd0d905c1c62b810b787141430417caf2b3f54cffadb395b7bb39fdeb8f17266b", "protocol": "ws", "host": "localhost", "port": 8546, diff --git a/app/gas-relayer/src/service.js b/app/gas-relayer/src/service.js index 46541ce..0389482 100644 --- a/app/gas-relayer/src/service.js +++ b/app/gas-relayer/src/service.js @@ -7,9 +7,10 @@ const erc20ABI = require('../abi/ERC20.json'); console.info("Starting...") +// TODO A node should call an API (probably from a status node) to register itself as a +// token gas relayer. + async function start(){ - - for(token in config.tokens){ if(config.tokens[token].pricePlugin !== undefined){ let PricePlugin = require(config.tokens[token].pricePlugin); @@ -71,25 +72,31 @@ const shhOptions = { }; let kId; - +let symKId; // Listening to whisper -web3.shh.addPrivateKey(config.whisper.privateKey) - .then((keyId) => { - shhOptions.privateKeyID = keyId; + +web3.shh.addSymKey(config.whisper.symKey) + .then(symKeyId => { + symKId = symKeyId; + return web3.shh.newKeyPair(); + }) + .then(keyId => { + shhOptions.symKeyId = symKId; + kId = keyId; - web3.shh.getPublicKey(keyId).then(pk => { - console.info(`Public Key: ${pk}`); - console.info("Topics Available:"); - config.topics = []; - for(let contractName in config.contracts) { - console.info("- %s: %s [%s]", config.contracts[contractName].name, contractName, Object.keys(config.contracts[contractName].allowedFunctions).join(', ')); - } - }); + console.info(`Sym Key: ${config.whisper.symKey}`); + console.info("Topics Available:"); + + config.topics = []; + for(let contractName in config.contracts) { + console.info("- %s: %s [%s]", config.contracts[contractName].name, contractName, Object.keys(config.contracts[contractName].allowedFunctions).join(', ')); + shhOptions.topics = [contractName]; + web3.shh.subscribe('messages', shhOptions, processMessages); + } console.info("Started."); console.info("Listening for messages...") - web3.shh.subscribe('messages', shhOptions, processMessages); }); diff --git a/app/gas-relayer/test/sendmsg.html b/app/gas-relayer/test/sendmsg.html index 2c703ce..e71f025 100644 --- a/app/gas-relayer/test/sendmsg.html +++ b/app/gas-relayer/test/sendmsg.html @@ -4,7 +4,7 @@ -