Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
});
}
}
// Create transaction
let txObj = zencashjs.transaction.createRawTx(history, recipients, blockHeight, blockHash);
// Sign each history transcation
let index;
for (let i = 0; i < history.length; i++) {
index = fromAddresses.indexOf(belongToAddress[i]);
txObj = zencashjs.transaction.signTx(txObj, i, privateKeys[index], true);
}
// Convert it to hex string
const txHexString = zencashjs.transaction.serializeTx(txObj);
const txRespData = await apiPost(sendRawTxURL, {rawtx: txHexString});
finalMessage += `<small><a class="walletListItemDetails transactionExplorer monospace">${txRespData.txid}</a>`;
finalMessage += "</small><br>\n\n";
txFinished += 1;
if (txFinished === chunks.length) {
event.sender.send("send-finish", "ok", finalMessage);
}
}
}
catch(e) {
event.sender.send("send-finish", "error", e.message);
console.log(e);
}
});
// Refunding 'dust' (<54 satoshis will result in unconfirmed txs)
if (refundSatoshis > 60) {
recipients = recipients.concat({ address: senderAddress, satoshis: refundSatoshis })
}
}
// Create transaction
var txObj = zencashjs.transaction.createRawTx(history, recipients, blockHeight, blockHash)
// Sign each history transcation
for (var j = 0; j < history.length; j++) {
txObj = zencashjs.transaction.signTx(txObj, j, senderPrivateKey, true)
}
// Convert it to hex string
const txHexString = zencashjs.transaction.serializeTx(txObj)
// Post it to the api
axios.post(sendRawTxURL,
{
rawtx: txHexString
},
{
headers: {
'Content-Type': 'application/json'
}
})
.then((sendtxResp) => {
const txRespData = sendtxResp.data
this.setState({
progressValue: 100,
// Refund thresholdLimitInSatoshi amount to current address
if (thresholdLimitInSatoshi > 0) {
recipients = recipients.concat({
address: key,
satoshis: thresholdLimitInSatoshi
});
}
value.history.forEach(function(h) {
history = history.concat(h);
});
}
}
// Create transaction
let txObj = zencashjs.transaction.createRawTx(history, recipients, blockHeight, blockHash);
// Sign history/transaction with PKs
let j = 0;
for (let value of data.values()) {
if (value.id >= start) {
if (value.id === (start + nAddress)) {
break
}
for (let i = 0; i < value.history.length; i++) {
txObj = zencashjs.transaction.signTx(txObj, j, value.pk, true);
j += 1;
}
}
}
}
}
// Create transaction
let txObj = zencashjs.transaction.createRawTx(history, recipients, blockHeight, blockHash);
// Sign history/transaction with PKs
let j = 0;
for (let value of data.values()) {
if (value.id >= start) {
if (value.id === (start + nAddress)) {
break
}
for (let i = 0; i < value.history.length; i++) {
txObj = zencashjs.transaction.signTx(txObj, j, value.pk, true);
j += 1;
}
}
}
// Convert it to hex string
return zencashjs.transaction.serializeTx(txObj);
}
return
}
// If we don't have exact amount
// Refund remaining to current address
if (satoshisSoFar !== satoshisToSend + satoshisfeesToSend) {
var refundSatoshis = satoshisSoFar - satoshisToSend - satoshisfeesToSend
// Refunding 'dust' (<54 satoshis will result in unconfirmed txs)
if (refundSatoshis > 60) {
recipients = recipients.concat({ address: senderAddress, satoshis: refundSatoshis })
}
}
// Create transaction
var txObj = zencashjs.transaction.createRawTx(history, recipients, blockHeight, blockHash)
// Sign each history transcation
for (var j = 0; j < history.length; j++) {
txObj = zencashjs.transaction.signTx(txObj, j, senderPrivateKey, true)
}
// Convert it to hex string
const txHexString = zencashjs.transaction.serializeTx(txObj)
// Post it to the api
axios.post(sendRawTxURL,
{
rawtx: txHexString
},
{
headers: {
// If we don't have enough address - fail and tell it to the user
if (satoshisSoFar < amountInSatoshi + feeInSatoshi) {
let errStr = tr("wallet.tabWithdraw.messages.insufficientFundsSourceAddr", "Insufficient funds on source address!");
event.sender.send("send-finish", "error", errStr);
return;
}
// If we don't have exact amount - refund remaining to current address
if (satoshisSoFar !== (amountInSatoshi + feeInSatoshi)) {
let refundSatoshis = satoshisSoFar - amountInSatoshi - feeInSatoshi;
recipients = recipients.concat({address: fromAddress, satoshis: refundSatoshis});
}
// Create transaction
let txObj = zencashjs.transaction.createRawTx(history, recipients, blockHeight, blockHash);
// Sign each history transcation
for (let i = 0; i < history.length; i ++) {
txObj = zencashjs.transaction.signTx(txObj, i, privateKey, true);
}
// Convert it to hex string
const txHexString = zencashjs.transaction.serializeTx(txObj);
const txRespData = await apiPost(sendRawTxURL, {rawtx: txHexString});
// TODO redo this into garbage
let message = "TXid:\n\n<small>" + txRespData.txid + "</small><br><a class="\"walletListItemDetails" href="\"javascript:void(0)\"">Show Transaction in Explorer</a>";
event.sender.send("send-finish", "ok", message);
}
catch (e) {
event.sender.send("send-finish", "error", e.message);