Add support for broadcasting a raw transaction
This commit is contained in:
parent
f47133cd4b
commit
f20550259f
@ -57,7 +57,9 @@
|
|||||||
</span>
|
</span>
|
||||||
|
|
||||||
[
|
[
|
||||||
<a href="/messages/verify">verify message</a>
|
<a href="/messages/verify" translate>verify message</a>
|
||||||
|
<span> · </span>
|
||||||
|
<a href="/tx/send" translate>broadcast transaction</a>
|
||||||
]
|
]
|
||||||
</div>
|
</div>
|
||||||
<a class="insight m10v pull-right" target="_blank" href="http://insight.is">insight <small>API v{{version}}</small></a>
|
<a class="insight m10v pull-right" target="_blank" href="http://insight.is">insight <small>API v{{version}}</small></a>
|
||||||
|
|||||||
2
public/js/main.min.js
vendored
2
public/js/main.min.js
vendored
File diff suppressed because one or more lines are too long
@ -11,6 +11,10 @@ angular.module('insight').config(function($routeProvider) {
|
|||||||
controller: 'BlocksController',
|
controller: 'BlocksController',
|
||||||
templateUrl: '/views/redirect.html'
|
templateUrl: '/views/redirect.html'
|
||||||
}).
|
}).
|
||||||
|
when('/tx/send', {
|
||||||
|
templateUrl: '/views/transaction_sendraw.html',
|
||||||
|
title: 'Broadcast Raw Transaction'
|
||||||
|
}).
|
||||||
when('/tx/:txId/:v_type?/:v_index?', {
|
when('/tx/:txId/:v_type?/:v_index?', {
|
||||||
templateUrl: '/views/transaction.html',
|
templateUrl: '/views/transaction.html',
|
||||||
title: 'Bitcoin Transaction '
|
title: 'Bitcoin Transaction '
|
||||||
|
|||||||
@ -170,3 +170,41 @@ function($scope, $rootScope, $routeParams, $location, Global, Transaction, Trans
|
|||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
angular.module('insight.transactions').controller('SendRawTransactionController',
|
||||||
|
function($scope, $http) {
|
||||||
|
$scope.transaction = '';
|
||||||
|
$scope.status = 'ready'; // ready|loading|sent|error
|
||||||
|
$scope.txid = '';
|
||||||
|
$scope.error = null;
|
||||||
|
|
||||||
|
$scope.formValid = function() {
|
||||||
|
return !!$scope.transaction;
|
||||||
|
};
|
||||||
|
$scope.send = function() {
|
||||||
|
var postData = {
|
||||||
|
rawtx: $scope.transaction
|
||||||
|
};
|
||||||
|
$scope.status = 'loading';
|
||||||
|
$http.post('/api/tx/send', postData)
|
||||||
|
.success(function(data, status, headers, config) {
|
||||||
|
if(typeof(data.txid) != 'string') {
|
||||||
|
// API returned 200 but the format is not known
|
||||||
|
$scope.status = 'error';
|
||||||
|
$scope.error = 'The transaction was sent but no transaction id was got back';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.status = 'sent';
|
||||||
|
$scope.txid = data.txid;
|
||||||
|
})
|
||||||
|
.error(function(data, status, headers, config) {
|
||||||
|
$scope.status = 'error';
|
||||||
|
if(data) {
|
||||||
|
$scope.error = data;
|
||||||
|
} else {
|
||||||
|
$scope.error = "No error message given (connection error?)"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|||||||
55
public/views/transaction_sendraw.html
Normal file
55
public/views/transaction_sendraw.html
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
<section data-ng-controller="SendRawTransactionController">
|
||||||
|
<div class="page-header">
|
||||||
|
<h1>
|
||||||
|
<span translate>Broadcast Raw Transaction</span>
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-12 col-md-8">
|
||||||
|
<form name="txForm" class="form-horizontal" role="form" novalidate>
|
||||||
|
<div class="form-group"
|
||||||
|
ng-class="{ 'has-error': txForm.rawData.$error.pattern }">
|
||||||
|
<label for="transaction-rawdata" class="col-sm-2 control-label" translate>
|
||||||
|
Raw transaction data
|
||||||
|
</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<textarea class="form-control" id="transaction-rawdata" name="rawData"
|
||||||
|
data-ng-model="transaction" data-ng-pattern="/^[0-9A-Fa-f]+$/"
|
||||||
|
rows="10" required></textarea>
|
||||||
|
<span class="help-block" ng-show="txForm.rawData.$error.pattern" translate>
|
||||||
|
Raw transaction data must be a valid hexadecimal string.
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-offset-2 col-sm-10">
|
||||||
|
<button class="btn btn-default" translate
|
||||||
|
data-ng-click="send()" data-ng-disabled="!txForm.$valid">
|
||||||
|
Send transaction
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<div class="row">
|
||||||
|
<div data-ng-hide="status == 'ready'"
|
||||||
|
class="col-sm-offset-2 col-sm-10">
|
||||||
|
<div ng-show="status == 'loading'" translate>
|
||||||
|
Loading...
|
||||||
|
</div>
|
||||||
|
<div ng-show="status == 'sent'" class="alert alert-success" translate>
|
||||||
|
Transaction succesfully broadcast.<br>Transaction id: {{txid}}
|
||||||
|
</div>
|
||||||
|
<div ng-show="status == 'error'" class="alert alert-warning" translate>
|
||||||
|
An error occured:<br>{{error}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-12 col-md-4 col-gray">
|
||||||
|
<p translate>
|
||||||
|
This form can be used to broadcast a raw transaction in hex format over
|
||||||
|
the Bitcoin network.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
Loading…
Reference in New Issue
Block a user