Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
wan: '0x67f3de547c7f3bc77095686a9e7fe49397e59cdf', // WMKR
},
from: '0x026a6301477c59ab17d11cade5fd00e5c8c6fa90',
to: '0x017ab346a4bb19f46c99bf19b6592828435540b0',
value: '2242000000000000',
storeman: {
wan: '0x06daa9379cbe241a84a65b217a11b38fe3b4b063',
eth: '0x41623962c5d44565de623d53eb677e0f300467d2',
},
redeemKey,
};
// Get Ethereum private keys
const ethDatadir = '/home/user/.ethereum/testnet/';
const ethKeyObject = keythereum.importFromFile(opts.from, ethDatadir);
const ethPrivateKey = keythereum.recover('mypassword', ethKeyObject);
// Get Wanchain private keys
const wanDatadir = '/home/user/.wanchain/testnet/';
const wanKeyObject = keythereum.importFromFile(opts.to, wanDatadir);
const wanPrivateKey = keythereum.recover('mypassword', wanKeyObject);
// Do inbound MKR to WMKR transaction
Promise.resolve([])
.then(sendApprove)
.then(sendLock)
.then(confirmLock)
.then(sendRedeem)
.then(confirmRedeem)
.catch(err => {
console.log(err);
});
// Define the transaction opts
const opts = {
from: '0x017ab346a4bb19f46c99bf19b6592828435540b0',
to: '0x026a6301477c59ab17d11cade5fd00e5c8c6fa90',
value: '1210000000000000000',
storeman: {
wan: '0x06daa9379cbe241a84a65b217a11b38fe3b4b063',
eth: '0x41623962c5d44565de623d53eb677e0f300467d2',
},
redeemKey,
};
// Get Ethereum private keys
const ethDatadir = '/home/user/.ethereum/testnet/';
const ethKeyObject = keythereum.importFromFile(opts.to, ethDatadir);
const ethPrivateKey = keythereum.recover('mypassword', ethKeyObject);
// Get Wanchain private keys
const wanDatadir = '/home/user/.wanchain/testnet/';
const wanKeyObject = keythereum.importFromFile(opts.from, wanDatadir);
const wanPrivateKey = keythereum.recover('mypassword', wanKeyObject);
// Do outbound WETH to ETH transaction
Promise.resolve([])
.then(sendLock)
.then(confirmLock)
.then(sendRedeem)
.then(confirmRedeem)
.catch(err => {
console.log('Error:', err);
});
},
// Generate a new redeemKey
redeemKey: wanx.newRedeemKey('sha256'),
// private key of to address
wif: 'cNggJXP2mMNSHA1r9CRd1sv65uykZNyeH8wkH3ZPZVUL1nLfTxRM',
};
// Total miner fee for redeem (in satoshis)
const minerFee = '2000';
// Get Wanchain private keys
const wanDatadir = '/home/user/.wanchain/testnet/';
const wanKeyObject = keythereum.importFromFile(opts.from, wanDatadir);
const wanPrivateKey = keythereum.recover('mypassword', wanKeyObject);
// Do outbound WBTC to BTC transaction
Promise.resolve([])
.then(sendLock)
.then(confirmLock)
.then(redeemBitcoin)
.catch(err => {
console.log('Error:', err);
});
async function sendLock() {
console.log('Starting btc outbound lock', opts);
// Get the outbound fee
const fee = await cctx.getOutboundFee(opts);
// Define the transaction opts
const opts = {
from: '0x026a6301477c59ab17d11cade5fd00e5c8c6fa90',
to: '0x017ab346a4bb19f46c99bf19b6592828435540b0',
value: '1210000000000000000',
storeman: {
wan: '0x06daa9379cbe241a84a65b217a11b38fe3b4b063',
eth: '0x41623962c5d44565de623d53eb677e0f300467d2',
},
redeemKey,
};
// Get Ethereum private keys
const ethDatadir = '/home/user/.ethereum/testnet/';
const ethKeyObject = keythereum.importFromFile(opts.from, ethDatadir);
const ethPrivateKey = keythereum.recover('mypassword', ethKeyObject);
// Do inbound ETH to WETH lock transaction
Promise.resolve([])
.then(sendLock)
.then(confirmLock)
.catch(err => {
console.log('Error:', err);
});
async function sendLock() {
console.log('Starting eth inbound lock', opts);
// Get the raw lock tx
const lockTx = cctx.buildLockTx(opts);
to: '0x017ab346a4bb19f46c99bf19b6592828435540b0',
value: '1210000000000000000',
storeman: {
wan: '0x06daa9379cbe241a84a65b217a11b38fe3b4b063',
eth: '0x41623962c5d44565de623d53eb677e0f300467d2',
},
redeemKey: {
x: '4d5569480ddd42fb1a8ddd641a36f384913480e621dacd038f234131f69b9b9d',
xHash: '2cb53e1ae99fb341bf674076f9bcc2f4e170b08354fe74eb3bb9e7c325f584f0',
},
};
// Get Wanchain private keys
const wanDatadir = '/home/user/.wanchain/testnet/';
const wanKeyObject = keythereum.importFromFile(opts.to, wanDatadir);
const wanPrivateKey = keythereum.recover('mypassword', wanKeyObject);
// Do inbound ETH to WETH redeem transaction
Promise.resolve([])
.then(sendRedeem)
.then(confirmRedeem)
.catch(err => {
console.log('Error:', err);
});
async function sendRedeem() {
console.log('Starting eth inbound redeem', opts);
// Get the raw redeem tx
const redeemTx = cctx.buildRedeemTx(opts);
console.log("Inside Add to SC");
const user = await User.findOne({ email: email });
let currPubKey;
if (user.pubKey == "" || user.pubKey == undefined) {
// user's account is not created create on.
currPubKey = createKeystore(user.email);
} else {
currPubKey = user.pubKey;
}
console.log(`Current public Key: ${currPubKey}`);
console.log(`User Key: ${user.pubKey}`)
const keyObj = keythereum.importFromFile(
coinbase_acnt,
process.env.DEF_KEY_PATH
);
const privateKey = keythereum.recover(process.env.DEF_ACCOUNT_PWD, keyObj);
const count = await web3.eth.getTransactionCount(coinbase_acnt).catch(err => {
console.error(err);
throw err;
});
var rawTransaction = {
from: coinbase_acnt,
gasPrice: web3.utils.toHex(20 * 1e9),
gasLimit: web3.utils.toHex(210000),
to: process.env.CONTRACT_ADDR,
value: "0x0",
data: contract.methods
.addCertificate(
currPubKey,
examData.courseName,
examData.userName,
examData.timestamp,
const EthereumTx = require('ethereumjs-tx');
const keythereum = require('keythereum');
const WebSocket = require('isomorphic-ws');
const ws = new WebSocket('ws://localhost:31337/transactions');
const DATADIR = '/home/user/.ethereum/priv_testnet';
const ADDRESS = '34e583cf9c1789c3141538eec77d9f0b8f7e89f2';
const PASSWORD = 'password';
const enc_key = keythereum.importFromFile(ADDRESS, DATADIR);
const key = keythereum.recover(PASSWORD, enc_key);
ws.onmessage = msg => {
// Should do verification of parameters / user confirmation?
console.log(msg.data);
const {id, data} = JSON.parse(msg.data);
const {chainId} = data;
console.log(data);
const tx = new EthereumTx(data);
tx.sign(key);
console.log({'id': id, 'chainId': chainId, 'data': tx.serialize().toString('hex')});
ws.send(JSON.stringify({'id': id, 'chainId': chainId, 'data': tx.serialize().toString('hex')}));
};
storeman: {
wan: '0x9ebf2acd509e0d5f9653e755f26d9a3ddce3977c',
btc: '0x83e5ca256c9ffd0ae019f98e4371e67ef5026d2d',
},
// Generate a new redeemKey
redeemKey: wanx.newRedeemKey('sha256'),
// lockTime is optional
// lockTime: moment().add(8, 'h').unix(),
};
// Get Wanchain private keys
const wanDatadir = '/home/user/.wanchain/testnet/';
const wanKeyObject = keythereum.importFromFile(opts.to, wanDatadir);
const wanPrivateKey = keythereum.recover('mypassword', wanKeyObject);
// Do inbound BTC to WBTC transaction
Promise.resolve([]).then(() => {
console.log('Starting btc inbound lock', opts);
// Create new P2SH lock address
const contract = cctx.buildHashTimeLockContract(opts);
console.log('Created new BTC contract', contract);
// Add the lockTime to opts
opts.lockTime = contract.lockTime;
// Convert BTC amount from satoshis to bitcoin
const sendAmount = (new BigNumber(opts.value)).div(100000000).toString();
to: '0x017ab346a4bb19f46c99bf19b6592828435540b0',
value: '1210000000000000000',
storeman: {
wan: '0x06daa9379cbe241a84a65b217a11b38fe3b4b063',
eth: '0x41623962c5d44565de623d53eb677e0f300467d2',
},
redeemKey: {
x: '4d5569480ddd42fb1a8ddd641a36f384913480e621dacd038f234131f69b9b9d',
xHash: '2cb53e1ae99fb341bf674076f9bcc2f4e170b08354fe74eb3bb9e7c325f584f0',
},
};
// Get Wanchain private keys
const ethDatadir = '/home/user/.ethereum/testnet/';
const ethKeyObject = keythereum.importFromFile(opts.to, ethDatadir);
const ethPrivateKey = keythereum.recover('mypassword', ethKeyObject);
// Do outbound redeem transaction
Promise.resolve([]).then(() => {
console.log('Starting eth outbound redeem', opts);
// Get the tx count to determine next nonce
return web3eth.eth.getTransactionCount(opts.to);
}).then(txCount => {
// Get the raw redeem tx
const redeemTx = cctx.buildRedeemTx(opts);
redeemTx.nonce = web3eth.utils.toHex(txCount);
// Sign and send the tx
getKeystore(function (err, data) {
if (err) cb(err, null);
else {
var keystore = JSON.parse(data)
try {
var privateKey = keythereum.recover(password, keystore);
cb(null, privateKey);
// setTimeout(function () { cb(null, privateKey) }, 2000);
}
catch (err) {
cb({ message: lang[language].KeyPassMatch }, null);
}
}
})
}