implement BITS + tests
This commit is contained in:
parent
ec859355c6
commit
727bf8524a
14 changed files with 213 additions and 79 deletions
|
|
@ -1,29 +1,32 @@
|
|||
'use strict';
|
||||
var bitcore = require('bitcore');
|
||||
|
||||
angular.module('copayApp.controllers').controller('SendController',
|
||||
function($scope, $rootScope, $window, $location, $timeout) {
|
||||
$scope.title = 'Send';
|
||||
$scope.loading = false;
|
||||
$scope.defaultFee = bitcore.TransactionBuilder.FEE_PER_1000B_SAT / bitcore.util.BIT;
|
||||
|
||||
// TODO this shouldnt be on a particular controller.
|
||||
// Detect mobile devices
|
||||
var isMobile = {
|
||||
Android: function() {
|
||||
return navigator.userAgent.match(/Android/i);
|
||||
return navigator.userAgent.match(/Android/i);
|
||||
},
|
||||
BlackBerry: function() {
|
||||
return navigator.userAgent.match(/BlackBerry/i);
|
||||
return navigator.userAgent.match(/BlackBerry/i);
|
||||
},
|
||||
iOS: function() {
|
||||
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
|
||||
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
|
||||
},
|
||||
Opera: function() {
|
||||
return navigator.userAgent.match(/Opera Mini/i);
|
||||
return navigator.userAgent.match(/Opera Mini/i);
|
||||
},
|
||||
Windows: function() {
|
||||
return navigator.userAgent.match(/IEMobile/i);
|
||||
return navigator.userAgent.match(/IEMobile/i);
|
||||
},
|
||||
any: function() {
|
||||
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
|
||||
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -32,27 +35,29 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
|
||||
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
|
||||
window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
|
||||
|
||||
$scope.isMobile = isMobile.any();
|
||||
$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'};
|
||||
$rootScope.$flashMessage = {
|
||||
message: 'You can not send a proposal transaction. Please, try again',
|
||||
type: 'error'
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.loading = true;
|
||||
|
||||
var address = form.address.$modelValue;
|
||||
var amount = (form.amount.$modelValue * 100000000).toFixed(); // satoshi to string
|
||||
var comment = form.comment.$modelValue;
|
||||
var amount = (form.amount.$modelValue * 100) | 0;
|
||||
|
||||
var w = $rootScope.wallet;
|
||||
w.createTx(address, amount, comment, function() {
|
||||
$scope.loading = false;
|
||||
$rootScope.$flashMessage = { message: 'The transaction proposal has been created', type: 'success'};
|
||||
$rootScope.$flashMessage = {
|
||||
message: 'The transaction proposal has been created',
|
||||
type: 'success'
|
||||
};
|
||||
$rootScope.$digest();
|
||||
});
|
||||
|
||||
|
|
@ -81,7 +86,11 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
reader.onload = (function(theFile) {
|
||||
return function(e) {
|
||||
var mpImg = new MegaPixImage(file);
|
||||
mpImg.render(canvas, { maxWidth: 200, maxHeight: 200, orientation: 6 });
|
||||
mpImg.render(canvas, {
|
||||
maxWidth: 200,
|
||||
maxHeight: 200,
|
||||
orientation: 6
|
||||
});
|
||||
|
||||
$timeout(function() {
|
||||
qrcode.width = canvas.width;
|
||||
|
|
@ -107,7 +116,7 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
|
||||
try {
|
||||
qrcode.decode();
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
//qrcodeError(e);
|
||||
}
|
||||
}
|
||||
|
|
@ -168,7 +177,9 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
canvas.height = 225;
|
||||
context.clearRect(0, 0, 300, 225);
|
||||
|
||||
navigator.getUserMedia({video: true}, _successCallback, _videoError);
|
||||
navigator.getUserMedia({
|
||||
video: true
|
||||
}, _successCallback, _videoError);
|
||||
}
|
||||
}, 500);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue