|
|
|
@ -61,10 +61,10 @@ function createSignedTransaction(bitcoreLib, privateKeyString, sourceAddress, de
|
|
|
|
|
* Create a UTXO.
|
|
|
|
|
*
|
|
|
|
|
* @param {type} sourceAddress Sender's wallet address
|
|
|
|
|
* @param {type} txHash From UXTO (unspent output)
|
|
|
|
|
* @param {type} txOutputIndex From UXTO (unspent output)
|
|
|
|
|
* @param {type} script From UXTO (unspent output)
|
|
|
|
|
* @param {type} inputSatoshis From UXTO (unspent output)
|
|
|
|
|
* @param {type} txHash From UTXO (unspent output)
|
|
|
|
|
* @param {type} txOutputIndex From UTXO (unspent output)
|
|
|
|
|
* @param {type} script From UTXO (unspent output)
|
|
|
|
|
* @param {type} inputSatoshis From UTXO (unspent output)
|
|
|
|
|
* @returns {createUtxo.utxo}
|
|
|
|
|
*/
|
|
|
|
|
function createUtxo(sourceAddress, txHash, txOutputIndex, script, inputSatoshis) {
|
|
|
|
@ -81,17 +81,17 @@ function createUtxo(sourceAddress, txHash, txOutputIndex, script, inputSatoshis)
|
|
|
|
|
/**
|
|
|
|
|
* Get unspent outputs for a wallet address.
|
|
|
|
|
* @param {string} walletaddress
|
|
|
|
|
* @param {function} successCallback Passes object with {uxtos: [{txHash,txOutputIndex,script,value}], currency: "DOGE", label: "Dogecoin"}
|
|
|
|
|
* @param {function} successCallback Passes object with {utxos: [{txHash,txOutputIndex,script,value}], currency: "DOGE", label: "Dogecoin"}
|
|
|
|
|
* @param {function} errorCallback Passes string error message suitable for display
|
|
|
|
|
* @returns {undefined}
|
|
|
|
|
*/
|
|
|
|
|
function getUXTOData(walletaddress, successCallback, errorCallback) {
|
|
|
|
|
apirequest(SETTINGS.apis.getuxto, {
|
|
|
|
|
function getUTXOData(walletaddress, successCallback, errorCallback) {
|
|
|
|
|
apirequest(SETTINGS.apis.getutxo, {
|
|
|
|
|
walletaddress: walletaddress
|
|
|
|
|
}, function (resp) {
|
|
|
|
|
if (resp.status == "OK") {
|
|
|
|
|
successCallback({
|
|
|
|
|
uxtos: resp.unspent_outputs,
|
|
|
|
|
utxos: resp.unspent_outputs,
|
|
|
|
|
currency: resp.currency,
|
|
|
|
|
label: resp.label
|
|
|
|
|
});
|
|
|
|
@ -103,26 +103,26 @@ function getUXTOData(walletaddress, successCallback, errorCallback) {
|
|
|
|
|
var error = $.parseJSON(errorData.responseText);
|
|
|
|
|
if (error && typeof error.msg != 'undefined') {
|
|
|
|
|
errorCallback(resp.msg);
|
|
|
|
|
sendErrorReport("Crypto", "Couldn't get UXTO data", error.msg);
|
|
|
|
|
sendErrorReport("Crypto", "Couldn't get UTXO data", error.msg);
|
|
|
|
|
} else {
|
|
|
|
|
errorCallback("There's a server or network problem. Check your Internet connection or try again later. Your funds are safe.");
|
|
|
|
|
sendErrorReport("Crypto", "Couldn't get UXTO data", "Server/network problem: " + xhr.status + ": " + xhr.statusText);
|
|
|
|
|
sendErrorReport("Crypto", "Couldn't get UTXO data", "Server/network problem: " + xhr.status + ": " + xhr.statusText);
|
|
|
|
|
}
|
|
|
|
|
} catch (ex) {
|
|
|
|
|
errorCallback("There's a server or network problem. Check your Internet connection or try again later. Your funds are safe.");
|
|
|
|
|
sendErrorReport("Crypto", "Couldn't get UXTO data", "Server/network problem: " + xhr.status + ": " + xhr.statusText);
|
|
|
|
|
sendErrorReport("Crypto", "Couldn't get UTXO data", "Server/network problem: " + xhr.status + ": " + xhr.statusText);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function sendCoins(privatekey, fromaddress, toaddress, amount) {
|
|
|
|
|
var progressdialog = app.dialog.progress("Querying blockchain...", 25);
|
|
|
|
|
getUXTOData(fromaddress, function (success) {
|
|
|
|
|
getUTXOData(fromaddress, function (success) {
|
|
|
|
|
progressdialog.setProgress(50);
|
|
|
|
|
progressdialog.setText("Creating transaction...");
|
|
|
|
|
if (success.uxtos.length == 0) {
|
|
|
|
|
if (success.utxos.length == 0) {
|
|
|
|
|
app.dialog.close();
|
|
|
|
|
app.dialog.alert("Your wallet has no available funds (ZERO_LENGTH_UXTO).", "Error");
|
|
|
|
|
app.dialog.alert("Your wallet has no available funds (ZERO_LENGTH_UTXO).", "Error");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var utxos = [];
|
|
|
|
|