fix issue where empty broadcast did not handle the error response appropriately

This commit is contained in:
Wowee0 2019-08-27 11:17:08 -05:00
parent 1f3b878d63
commit e18b634c4e

View file

@ -1363,10 +1363,7 @@ $(document).ready(function() {
url: "https://api.blockcypher.com/v1/"+network+"/main/txs/push", url: "https://api.blockcypher.com/v1/"+network+"/main/txs/push",
data: JSON.stringify({"tx":$("#rawTransaction").val()}), data: JSON.stringify({"tx":$("#rawTransaction").val()}),
error: function(data) { error: function(data) {
var obj = $.parseJSON(data.responseText); var r = 'Failed to broadcast: error code=' + data.status.toString() + ' ' + data.statusText;
var r = ' ';
r += (obj.error) ? obj.error : '';
r = (r!='') ? r : ' Failed to broadcast'; // build response
$("#rawTransactionStatus").addClass('alert-danger').removeClass('alert-success').removeClass("hidden").html(r).prepend('<span class="glyphicon glyphicon-exclamation-sign"></span>'); $("#rawTransactionStatus").addClass('alert-danger').removeClass('alert-success').removeClass("hidden").html(r).prepend('<span class="glyphicon glyphicon-exclamation-sign"></span>');
}, },
success: function(data) { success: function(data) {
@ -1393,10 +1390,7 @@ $(document).ready(function() {
data: {"data":$("#rawTransaction").val()}, data: {"data":$("#rawTransaction").val()},
dataType: "json", dataType: "json",
error: function(data) { error: function(data) {
var obj = $.parseJSON(data.responseText); var r = 'Failed to broadcast: error code=' + data.status.toString() + ' ' + data.statusText;
var r = ' ';
r += (obj.data.tx_hex) ? ' '+obj.data.tx_hex : '';
r = (r!='') ? r : ' Failed to broadcast'; // build response
$("#rawTransactionStatus").addClass('alert-danger').removeClass('alert-success').removeClass("hidden").html(r).prepend('<span class="glyphicon glyphicon-exclamation-sign"></span>'); $("#rawTransactionStatus").addClass('alert-danger').removeClass('alert-success').removeClass("hidden").html(r).prepend('<span class="glyphicon glyphicon-exclamation-sign"></span>');
// console.error(JSON.stringify(data, null, 4)); // console.error(JSON.stringify(data, null, 4));
}, },