paper wallet in advanced options
This commit is contained in:
parent
21de0baf74
commit
0b1df04a82
7 changed files with 269 additions and 56 deletions
82
src/js/controllers/paperWallet.js
Normal file
82
src/js/controllers/paperWallet.js
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
angular.module('copayApp.controllers').controller('paperWalletController',
|
||||
function($scope, $http, profileService, addressService) {
|
||||
|
||||
self = this;
|
||||
var fc = profileService.focusedClient;
|
||||
var rawTx;
|
||||
|
||||
self.onQrCodeScanned = function(data) {
|
||||
$scope.privateKey = data;
|
||||
console.log(data);
|
||||
}
|
||||
|
||||
self.createTx = function(privateKey, passphrase) {
|
||||
console.log("entro");
|
||||
console.log(privateKey);
|
||||
console.log(passphrase);
|
||||
if (!privateKey) self.error = "Enter privateKey or scann for one";
|
||||
this.getRawTx(privateKey, passphrase, function(err, rawTx, utxos) {
|
||||
console.log(utxos);
|
||||
console.log("creada");
|
||||
if (err) self.error = err.toString();
|
||||
else {
|
||||
self.balance = (utxos / 1e8).toFixed(8);
|
||||
rawTx = rawTx;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
self.getRawTx = function(privateKey, passphrase, cb) {
|
||||
if (privateKey.charAt(0) == 6) {
|
||||
fc.decryptBIP38PrivateKey(privateKey, passphrase, null, function(err, privateKey) {
|
||||
if (err) return cb(err);
|
||||
|
||||
fc.getBalanceFromPrivateKey(privateKey, function(err, utxos) {
|
||||
if (err) return cb(err);
|
||||
|
||||
addressService.getAddress(fc.credentials.walletId, true, function(err, destinationAddress) {
|
||||
if (err) return cb(err);
|
||||
|
||||
fc.buildTxFromPrivateKey(privateKey, destinationAddress, null, function(err, tx) {
|
||||
if (err) return cb(err);
|
||||
console.log(tx.serialize());
|
||||
return cb(null, tx.serialize(), utxos);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
fc.getBalanceFromPrivateKey(privateKey, function(err, utxos) {
|
||||
if (err) return cb(err)
|
||||
|
||||
addressService.getAddress(fc.credentials.walletId, true, function(err, destinationAddress) {
|
||||
if (err) return cb(err);
|
||||
|
||||
fc.buildTxFromPrivateKey(privateKey, destinationAddress, null, function(err, tx) {
|
||||
if (err) return cb(err);
|
||||
console.log(tx.serialize());
|
||||
return cb(null, tx.serialize(), utxos);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
self.transaction = function() {
|
||||
|
||||
self.doTransaction(rawTx).then(function(response) {
|
||||
console.log(response); //mostrar pantalla de sent successfully
|
||||
},
|
||||
function(err) {
|
||||
self.error = err;
|
||||
console.log(err); //mostrar mensaje de error en la pantalla
|
||||
});
|
||||
};
|
||||
|
||||
self.doTransaction = function(rawTx) {
|
||||
return $http.post('https://insight.bitpay.com/api/tx/send', {
|
||||
rawtx: rawTx
|
||||
});
|
||||
};
|
||||
|
||||
});
|
||||
|
|
@ -2,4 +2,5 @@
|
|||
|
||||
angular.module('copayApp.controllers').controller('preferencesAdvancedController',
|
||||
function($scope) {
|
||||
});
|
||||
|
||||
});
|
||||
117
src/js/routes.js
117
src/js/routes.js
|
|
@ -44,7 +44,7 @@ angular
|
|||
v = JSON.stringify(v);
|
||||
}
|
||||
// Trim output in mobile
|
||||
if ( window.cordova ) {
|
||||
if (window.cordova) {
|
||||
v = v.toString();
|
||||
if (v.length > 1000) {
|
||||
v = v.substr(0, 997) + '...';
|
||||
|
|
@ -85,7 +85,7 @@ angular
|
|||
}
|
||||
});
|
||||
|
||||
$stateProvider
|
||||
$stateProvider
|
||||
.state('translators', {
|
||||
url: '/translators',
|
||||
walletShouldBeComplete: true,
|
||||
|
|
@ -275,27 +275,27 @@ angular
|
|||
})
|
||||
|
||||
.state('preferencesGlidera', {
|
||||
url: '/preferencesGlidera',
|
||||
walletShouldBeComplete: true,
|
||||
needProfile: true,
|
||||
views: {
|
||||
'main': {
|
||||
templateUrl: 'views/preferencesGlidera.html'
|
||||
},
|
||||
}
|
||||
})
|
||||
url: '/preferencesGlidera',
|
||||
walletShouldBeComplete: true,
|
||||
needProfile: true,
|
||||
views: {
|
||||
'main': {
|
||||
templateUrl: 'views/preferencesGlidera.html'
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
.state('preferencesAdvanced', {
|
||||
url: '/preferencesAdvanced',
|
||||
templateUrl: 'views/preferencesAdvanced.html',
|
||||
walletShouldBeComplete: true,
|
||||
needProfile: true,
|
||||
views: {
|
||||
'main': {
|
||||
templateUrl: 'views/preferencesAdvanced.html'
|
||||
},
|
||||
}
|
||||
})
|
||||
url: '/preferencesAdvanced',
|
||||
templateUrl: 'views/preferencesAdvanced.html',
|
||||
walletShouldBeComplete: true,
|
||||
needProfile: true,
|
||||
views: {
|
||||
'main': {
|
||||
templateUrl: 'views/preferencesAdvanced.html'
|
||||
},
|
||||
}
|
||||
})
|
||||
.state('preferencesColor', {
|
||||
url: '/preferencesColor',
|
||||
templateUrl: 'views/preferencesColor.html',
|
||||
|
|
@ -309,16 +309,16 @@ angular
|
|||
})
|
||||
|
||||
.state('preferencesAltCurrency', {
|
||||
url: '/preferencesAltCurrency',
|
||||
templateUrl: 'views/preferencesAltCurrency.html',
|
||||
walletShouldBeComplete: true,
|
||||
needProfile: true,
|
||||
views: {
|
||||
'main': {
|
||||
templateUrl: 'views/preferencesAltCurrency.html'
|
||||
},
|
||||
}
|
||||
})
|
||||
url: '/preferencesAltCurrency',
|
||||
templateUrl: 'views/preferencesAltCurrency.html',
|
||||
walletShouldBeComplete: true,
|
||||
needProfile: true,
|
||||
views: {
|
||||
'main': {
|
||||
templateUrl: 'views/preferencesAltCurrency.html'
|
||||
},
|
||||
}
|
||||
})
|
||||
.state('preferencesAlias', {
|
||||
url: '/preferencesAlias',
|
||||
templateUrl: 'views/preferencesAlias.html',
|
||||
|
|
@ -376,18 +376,18 @@ angular
|
|||
},
|
||||
}
|
||||
})
|
||||
|
||||
.state('about', {
|
||||
url: '/about',
|
||||
templateUrl: 'views/preferencesAbout.html',
|
||||
walletShouldBeComplete: true,
|
||||
needProfile: true,
|
||||
views: {
|
||||
'main': {
|
||||
templateUrl: 'views/preferencesAbout.html'
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
.state('about', {
|
||||
url: '/about',
|
||||
templateUrl: 'views/preferencesAbout.html',
|
||||
walletShouldBeComplete: true,
|
||||
needProfile: true,
|
||||
views: {
|
||||
'main': {
|
||||
templateUrl: 'views/preferencesAbout.html'
|
||||
},
|
||||
}
|
||||
})
|
||||
.state('logs', {
|
||||
url: '/logs',
|
||||
templateUrl: 'views/preferencesLogs.html',
|
||||
|
|
@ -410,6 +410,17 @@ angular
|
|||
},
|
||||
}
|
||||
})
|
||||
.state('paperWallet', {
|
||||
url: '/paperWallet',
|
||||
templateUrl: 'views/paperWallet.html',
|
||||
walletShouldBeComplete: true,
|
||||
needProfile: true,
|
||||
views: {
|
||||
'main': {
|
||||
templateUrl: 'views/paperWallet.html'
|
||||
},
|
||||
}
|
||||
})
|
||||
.state('backup', {
|
||||
url: '/backup',
|
||||
templateUrl: 'views/backup.html',
|
||||
|
|
@ -435,14 +446,14 @@ angular
|
|||
})
|
||||
|
||||
.state('add', {
|
||||
url: '/add',
|
||||
needProfile: true,
|
||||
views: {
|
||||
'main': {
|
||||
templateUrl: 'views/add.html'
|
||||
},
|
||||
}
|
||||
})
|
||||
url: '/add',
|
||||
needProfile: true,
|
||||
views: {
|
||||
'main': {
|
||||
templateUrl: 'views/add.html'
|
||||
},
|
||||
}
|
||||
})
|
||||
.state('cordova', {
|
||||
url: '/cordova/:status/:isHome',
|
||||
views: {
|
||||
|
|
@ -450,7 +461,7 @@ angular
|
|||
controller: function($rootScope, $state, $stateParams, $timeout, go, isCordova) {
|
||||
switch ($stateParams.status) {
|
||||
case 'resume':
|
||||
$rootScope.$emit('Local/Resume');
|
||||
$rootScope.$emit('Local/Resume');
|
||||
break;
|
||||
case 'backbutton':
|
||||
if (isCordova && $stateParams.isHome == 'true' && !$rootScope.modalOpened) {
|
||||
|
|
@ -534,4 +545,4 @@ angular
|
|||
}, 50);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue