2014-03-26 09:18:42 -03:00
|
|
|
'use strict';
|
|
|
|
|
|
2014-03-28 14:08:14 -04:00
|
|
|
angular.module('copay.send').controller('SendController',
|
2014-04-18 19:08:01 -03:00
|
|
|
function($scope, $rootScope, $location) {
|
2014-03-26 09:18:42 -03:00
|
|
|
$scope.title = 'Send';
|
2014-04-24 22:43:19 -03:00
|
|
|
$scope.loading = false;
|
2014-03-31 12:48:35 -03:00
|
|
|
|
2014-04-19 04:55:32 -03:00
|
|
|
$scope.unitIds = ['BTC','mBTC'];
|
|
|
|
|
$scope.selectedUnit = $scope.unitIds[0];
|
|
|
|
|
|
|
|
|
|
$scope.submitForm = function(form) {
|
|
|
|
|
if (form.$invalid) {
|
|
|
|
|
$rootScope.flashMessage = { message: 'You can not send a proposal transaction. Please, try again', type: 'error'};
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-24 22:43:19 -03:00
|
|
|
$scope.loading = true;
|
|
|
|
|
|
2014-04-19 04:55:32 -03:00
|
|
|
var address = form.address.$modelValue;
|
|
|
|
|
var amount = (form.amount.$modelValue * 100000000).toString(); // satoshi to string
|
|
|
|
|
|
|
|
|
|
var w = $rootScope.wallet;
|
|
|
|
|
w.createTx( address, amount,function() {
|
2014-04-23 02:01:54 -03:00
|
|
|
|
2014-04-24 22:43:19 -03:00
|
|
|
$scope.loading = false;
|
2014-04-23 02:01:54 -03:00
|
|
|
$rootScope.flashMessage = { message: 'The transaction proposal has been created', type: 'success'};
|
2014-04-19 04:55:32 -03:00
|
|
|
$rootScope.$digest();
|
|
|
|
|
});
|
2014-04-24 22:43:19 -03:00
|
|
|
|
|
|
|
|
// reset fields
|
|
|
|
|
$scope.address = null;
|
|
|
|
|
$scope.amount = null;
|
|
|
|
|
form.address.$pristine = true;
|
|
|
|
|
form.amount.$pristine = true;
|
|
|
|
|
|
|
|
|
|
};
|
2014-03-26 09:18:42 -03:00
|
|
|
});
|