Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (self.opts.debug) {
vm.on('step', function (data) {
console.log(data.opcode.name)
})
}
// create tx
var txParams = payload.params[0]
// console.log('params:', payload.params)
const normalizedTxParams = {
to: txParams.to ? ethUtil.addHexPrefix(txParams.to) : undefined,
from: txParams.from ? ethUtil.addHexPrefix(txParams.from) : undefined,
value: txParams.value ? ethUtil.addHexPrefix(txParams.value) : undefined,
data: txParams.data ? ethUtil.addHexPrefix(txParams.data) : undefined,
gasLimit: txParams.gas ? ethUtil.addHexPrefix(txParams.gas) : block.header.gasLimit,
gasPrice: txParams.gasPrice ? ethUtil.addHexPrefix(txParams.gasPrice) : undefined,
nonce: txParams.nonce ? ethUtil.addHexPrefix(txParams.nonce) : undefined,
}
var tx = new FakeTransaction(normalizedTxParams)
tx._from = normalizedTxParams.from || '0x0000000000000000000000000000000000000000'
vm.runTx({
tx: tx,
block: block,
skipNonce: true,
skipBalance: true
}, function(err, results) {
if (err) return cb(err)
if (results.error != null) {
return cb(new Error("VM error: " + results.error))
}
enableHomestead: true
})
if (self.opts.debug) {
vm.on('step', function (data) {
console.log(data.opcode.name)
})
}
// create tx
var txParams = payload.params[0]
// console.log('params:', payload.params)
const normalizedTxParams = {
to: txParams.to ? ethUtil.addHexPrefix(txParams.to) : undefined,
from: txParams.from ? ethUtil.addHexPrefix(txParams.from) : undefined,
value: txParams.value ? ethUtil.addHexPrefix(txParams.value) : undefined,
data: txParams.data ? ethUtil.addHexPrefix(txParams.data) : undefined,
gasLimit: txParams.gas ? ethUtil.addHexPrefix(txParams.gas) : block.header.gasLimit,
gasPrice: txParams.gasPrice ? ethUtil.addHexPrefix(txParams.gasPrice) : undefined,
nonce: txParams.nonce ? ethUtil.addHexPrefix(txParams.nonce) : undefined,
}
var tx = new FakeTransaction(normalizedTxParams)
tx._from = normalizedTxParams.from || '0x0000000000000000000000000000000000000000'
vm.runTx({
tx: tx,
block: block,
skipNonce: true,
skipBalance: true
}, function(err, results) {
if (err) return cb(err)
async createTransactionsFromUTXO() {
this.utxos = await getAllUtxosWithKeys();
this.alltransactions = [];
for (let i in this.utxos) {
let utxo = this.utxos[i];
let blockNumber = parseInt(i.split('_')[1]);
try {
let txData = {
prev_hash: utxo.getHash().toString('hex'),
prev_block: blockNumber,
token_id: utxo.token_id.toString(),
new_owner: this.nextAddressGen.next(utxo.new_owner).value
};
let txDataForRlp = [ethUtil.addHexPrefix(txData.prev_hash), txData.prev_block, ethUtil.toBuffer(txData.token_id), txData.new_owner];
let txRlpEncoded = ethUtil.hashPersonalMessage(ethUtil.sha3(RLP.encode(txDataForRlp)));
if (utxo.new_owner instanceof Buffer)
utxo.new_owner = ethUtil.addHexPrefix(utxo.new_owner.toString('hex')).toLowerCase();
let signature = ethUtil.ecsign(txRlpEncoded, prkeys[utxo.new_owner]);
txData.signature = ethUtil.toRpcSig(signature.v, signature.r, signature.s).toString("hex");
let createdTx = createSignedTransaction(txData);
this.alltransactions.push(createdTx);
} catch (e) {
console.log(e);
}
}
console.log('TXcount - ', this.alltransactions.length);
)
updateSendAmount(maxAmount)
}
metricsEvent({
eventOpts: {
category: 'Activation',
action: 'userCloses',
name: 'closeCustomizeGas',
},
pageOpts: {
section: 'customizeGasModal',
component: 'customizeGasSaveButton',
},
customVariables: {
gasPriceChange: (new BigNumber(ethUtil.addHexPrefix(gasPrice))).minus(new BigNumber(ethUtil.addHexPrefix(originalState.gasPrice))).toString(10),
gasLimitChange: (new BigNumber(ethUtil.addHexPrefix(gasLimit))).minus(new BigNumber(ethUtil.addHexPrefix(originalState.gasLimit))).toString(10),
},
})
setGasPrice(ethUtil.addHexPrefix(gasPrice))
setGasLimit(ethUtil.addHexPrefix(gasLimit))
setGasTotal(ethUtil.addHexPrefix(gasTotal))
updateSendErrors({ insufficientFunds: false })
hideModal()
}
export function signMessageWithPrivKeyV2(privKey: Buffer, msg: string): string {
const hash = hashPersonalMessage(toBuffer(msg));
const signed = ecsign(hash, privKey);
const combined = Buffer.concat([
Buffer.from(signed.r),
Buffer.from(signed.s),
Buffer.from([signed.v])
]);
const combinedHex = combined.toString('hex');
return addHexPrefix(combinedHex);
}
serializeSignature(signatureString) {
const signature = stripHexPrefix(signatureString);
let r = ethUtil.addHexPrefix(signature.substring(0,64));
let s = ethUtil.addHexPrefix(signature.substring(64,128));
let v = ethUtil.addHexPrefix(signature.substring(128,130));
r = ethUtil.toBuffer(r);
s = ethUtil.toBuffer(s);
v = ethUtil.bufferToInt(ethUtil.toBuffer(v));
if (v < 27) {
v = v + 27;
}
v = ethUtil.toBuffer(v);
this.r = r;
this.v = v;
this.s = s;
}
function sendRawTransaction(data, callback) {
var tx = new Transaction(data);
_debugLog(
'[Transaction] sending raw data from [' +
utils.addHexPrefix(tx.from.toString('hex')) +
'] to [' +
utils.addHexPrefix(tx.to.toString('hex')) +
']'
);
_vm.blockchain.getHead(function(err, block) {
var timeNowInSeconds = Math.floor(Date.now() / 1000);
var nextBlock = new Block();
nextBlock.header.number = blockNumber() + 1;
nextBlock.header.difficulty = block.header.difficulty;
nextBlock.header.parentHash = block.hash();
nextBlock.header.timestamp = new Buffer(
_pad(timeNowInSeconds.toString(16)),
'hex'
);
nextBlock.transactions.push(tx);
var transactionHash = utils.bufferToHex(tx.hash());
async function withdraw(web3, amount) {
const ethbetInstance = await contractService.getDeployedInstance(web3, "Ethbet");
let results = await ethbetInstance.withdraw(amount, { from: web3.eth.defaultAccount, gas: 100000 });
if (ethUtil.addHexPrefix(results.receipt.status.toString()) !== "0x1") {
throw new Error("Contract execution failed")
}
return results;
}
const updateCustomGasPrice = newPrice => dispatch(setCustomGasPrice(addHexPrefix(newPrice)))