How to use the zencashjs.transaction function in zencashjs

To help you get started, we’ve selected a few zencashjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ZencashOfficial / arizen / app / main.js View on Github external
});
                }
            }

            // 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 href="javascript:void(0)" onclick="openUrl('${settings.explorerUrl}/tx/${txRespData.txid}')" class="walletListItemDetails transactionExplorer monospace" target="_blank">${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);
    }
});
github ZencashOfficial / zencash-mobile / src / containers / SendPage.js View on Github external
// 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,
github ZencashOfficial / arizen / app / main.js View on Github external
// 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;
            }
        }
    }
github ZencashOfficial / arizen / app / main.js View on Github external
}
    }

    // 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);
}
github ZencashOfficial / zencash-mobile / src / containers / SendPage.js View on Github external
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: {
github ZencashOfficial / arizen / app / main.js View on Github external
// 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 href=\"javascript:void(0)\" onclick=\"openUrl('" + settings.explorerUrl + "/tx/" + txRespData.txid +"')\" class=\"walletListItemDetails transactionExplorer\" target=\"_blank\">Show Transaction in Explorer</a>";
        event.sender.send("send-finish", "ok", message);
    }
    catch (e) {
        event.sender.send("send-finish", "error", e.message);

zencashjs

Dead easy to use Horizen JavaScript based library

MIT
Latest version published 8 months ago

Package Health Score

59 / 100
Full package analysis