paper wallet in advanced options
This commit is contained in:
parent
21de0baf74
commit
0b1df04a82
7 changed files with 269 additions and 56 deletions
|
|
@ -8,7 +8,7 @@
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"angular": "1.4.6",
|
"angular": "1.4.6",
|
||||||
"angular-bitcore-wallet-client": "0.4.4",
|
"angular-bitcore-wallet-client": "0.6.4",
|
||||||
"angular-foundation": "0.7.0",
|
"angular-foundation": "0.7.0",
|
||||||
"angular-gettext": "2.1.0",
|
"angular-gettext": "2.1.0",
|
||||||
"angular-moment": "0.10.1",
|
"angular-moment": "0.10.1",
|
||||||
|
|
@ -23,4 +23,4 @@
|
||||||
"ng-lodash": "0.2.3",
|
"ng-lodash": "0.2.3",
|
||||||
"qrcode-decoder-js": "*"
|
"qrcode-decoder-js": "*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
73
public/views/modals/paperWallet.html
Normal file
73
public/views/modals/paperWallet.html
Normal file
|
|
@ -0,0 +1,73 @@
|
||||||
|
<nav class="tab-bar">
|
||||||
|
<section class="left-small">
|
||||||
|
<a ng-click="cancel()" class="p10">
|
||||||
|
<span class="text-close" translate>Close</span>
|
||||||
|
</a>
|
||||||
|
</section>
|
||||||
|
<section class="middle tab-bar-section">
|
||||||
|
<h1 class="title ellipsis" ng-style="{'color':color}" translate>
|
||||||
|
Paper wallet amount
|
||||||
|
</h1>
|
||||||
|
</section>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div class="modal-content fix-modals-touch">
|
||||||
|
<h4 class="title m0" translate>Details</h4>
|
||||||
|
<ul class="no-bullet size-14 m0">
|
||||||
|
<li class="line-b p10 oh">
|
||||||
|
<span class="text-gray" translate>Address</span>:
|
||||||
|
<span class="right">
|
||||||
|
<span class="text-gray enable_text_select">{{addr}}</span>
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
<li class="line-b p10 oh">
|
||||||
|
<span class="text-gray" translate>Amount</span>:
|
||||||
|
<span class="right">
|
||||||
|
{{customizedAmountUnit}}
|
||||||
|
<span class="label gray radius">{{customizedAlternativeUnit}}</span>
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div ng-show="!customizedAmountBtc" class="row m20t">
|
||||||
|
<div class="large-12 large-centered columns">
|
||||||
|
<form name="amountForm" ng-submit="submitForm(amountForm)" novalidate>
|
||||||
|
<div class="right" ng-hide="amountForm.amount.$pristine && !amountForm.amount.$modelValue ">
|
||||||
|
<span class="has-error right size-12" ng-if="amountForm.amount.$invalid">
|
||||||
|
<i class="icon-close-circle size-14"></i>
|
||||||
|
<span clas="vm" translate>Not valid</span>
|
||||||
|
</span>
|
||||||
|
<small class="text-primary right" ng-if="!amountForm.amount.$invalid">
|
||||||
|
<i class="icon-checkmark-circle size-14"></i>
|
||||||
|
</small>
|
||||||
|
</div>
|
||||||
|
<div ng-if="!showAlternative">
|
||||||
|
<label for="amount">
|
||||||
|
<span translate>Amount</span>
|
||||||
|
</label>
|
||||||
|
<div class="input">
|
||||||
|
<input type="number" id="amount" name="amount" ng-attr-placeholder="{{'Amount'|translate}}"
|
||||||
|
ng-model="_customAmount" valid-amount required autocomplete="off">
|
||||||
|
<input type="number" id="alternative" name="alternative" ng-model="_customAlternative" style="display:none">
|
||||||
|
<a class="postfix" ng-click="toggleAlternative()">{{unitName}}</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div ng-if="showAlternative">
|
||||||
|
<label for="alternative"><span translate>Amount in</span> {{ alternativeName }}
|
||||||
|
</label>
|
||||||
|
<div class="input">
|
||||||
|
<input type="number" id="alternative" name="alternative" ng-attr-placeholder="{{'Amount'|translate}}"
|
||||||
|
ng-model="_customAlternative" required autocomplete="off" required>
|
||||||
|
<input type="number" id="amount" name="amount" ng-model="_customAmount" style="display:none">
|
||||||
|
<a class="postfix" ng-click="toggleAlternative()"> {{ alternativeIsoCode }}</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="button black round expand" ng-disabled="amountForm.$invalid" ng-style="{'background-color':color}" translate>
|
||||||
|
Generate QR Code
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="extra-margin-bottom"></div>
|
||||||
|
</div>
|
||||||
41
public/views/paperWallet.html
Normal file
41
public/views/paperWallet.html
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
<div
|
||||||
|
class="topbar-container"
|
||||||
|
ng-include="'views/includes/topbar.html'"
|
||||||
|
ng-init="titleSection='Scan Paper Wallet'; goBackToState = 'preferencesAdvanced';">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="content p20v" ng-controller="paperWalletController as paperWallet">
|
||||||
|
<div class="row">
|
||||||
|
<div class="large-12 medium-12 columns">
|
||||||
|
<div class="text-warning size-14 m20b" ng-show="paperWallet.error">
|
||||||
|
<i class="fi-alert size-12"></i>
|
||||||
|
<span translate>{{paperWallet.error}}</span>
|
||||||
|
</div>
|
||||||
|
<div ng-show="!paperWallet.balance" class="input">
|
||||||
|
<label for="privateKey"><span>Paper Wallet Private Key</span></label>
|
||||||
|
<input type="text" placeholder="Paste your paper wallet private key here" ng-model="privateKey" id="privateKey">
|
||||||
|
<div class="qr-scanner-input">
|
||||||
|
<qr-scanner on-scan="paperWallet.onQrCodeScanned(data)"></qr-scanner>
|
||||||
|
</div>
|
||||||
|
<label for="passphrase">
|
||||||
|
<span>Passphrase (if you have one): </span>
|
||||||
|
</label>
|
||||||
|
<input id="passphrase" type="password" name="passphrase" placeholder="Passphrase" ng-model="passphrase">
|
||||||
|
</div>
|
||||||
|
<div ng-show="paperWallet.balance">
|
||||||
|
<label for="totalBalance">
|
||||||
|
<h2 translate>Total Amount to be recived: {{paperWallet.balance}} BTC</h2>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="large-12 medium-12 columns" ng-show="paperWallet.balance">
|
||||||
|
<button ng-style="{'background-color':index.backgroundColor}" class="button black round expand" ng-click="paperWallet.transaction()" translate>Accept</button>
|
||||||
|
</div>
|
||||||
|
<div class="large-12 medium-12 columns" ng-show="!paperWallet.balance" >
|
||||||
|
<button ng-style="{'background-color':index.backgroundColor}" class="button black round expand" ng-click="paperWallet.createTx(privateKey, passphrase)" translate>Create transaction</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="extra-margin-bottom"></div>
|
||||||
|
|
@ -16,6 +16,11 @@
|
||||||
<li class="line-b p20" ng-click="index.retryScan(); $root.go('walletHome'); ">
|
<li class="line-b p20" ng-click="index.retryScan(); $root.go('walletHome'); ">
|
||||||
<span translate>Scan addresses for funds</span>
|
<span translate>Scan addresses for funds</span>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
<li class="line-b p20" ng-click="$root.go('paperWallet')">
|
||||||
|
<i class="icon-arrow-right3 size-24 right text-gray"></i>
|
||||||
|
<span translate>Scan Paper Wallet</span>
|
||||||
|
</li>
|
||||||
|
|
||||||
<li class="line-b p20" ng-click="$root.go('export')">
|
<li class="line-b p20" ng-click="$root.go('export')">
|
||||||
<i class="icon-arrow-right3 size-24 right text-gray"></i>
|
<i class="icon-arrow-right3 size-24 right text-gray"></i>
|
||||||
|
|
|
||||||
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',
|
angular.module('copayApp.controllers').controller('preferencesAdvancedController',
|
||||||
function($scope) {
|
function($scope) {
|
||||||
});
|
|
||||||
|
});
|
||||||
117
src/js/routes.js
117
src/js/routes.js
|
|
@ -44,7 +44,7 @@ angular
|
||||||
v = JSON.stringify(v);
|
v = JSON.stringify(v);
|
||||||
}
|
}
|
||||||
// Trim output in mobile
|
// Trim output in mobile
|
||||||
if ( window.cordova ) {
|
if (window.cordova) {
|
||||||
v = v.toString();
|
v = v.toString();
|
||||||
if (v.length > 1000) {
|
if (v.length > 1000) {
|
||||||
v = v.substr(0, 997) + '...';
|
v = v.substr(0, 997) + '...';
|
||||||
|
|
@ -85,7 +85,7 @@ angular
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$stateProvider
|
$stateProvider
|
||||||
.state('translators', {
|
.state('translators', {
|
||||||
url: '/translators',
|
url: '/translators',
|
||||||
walletShouldBeComplete: true,
|
walletShouldBeComplete: true,
|
||||||
|
|
@ -275,27 +275,27 @@ angular
|
||||||
})
|
})
|
||||||
|
|
||||||
.state('preferencesGlidera', {
|
.state('preferencesGlidera', {
|
||||||
url: '/preferencesGlidera',
|
url: '/preferencesGlidera',
|
||||||
walletShouldBeComplete: true,
|
walletShouldBeComplete: true,
|
||||||
needProfile: true,
|
needProfile: true,
|
||||||
views: {
|
views: {
|
||||||
'main': {
|
'main': {
|
||||||
templateUrl: 'views/preferencesGlidera.html'
|
templateUrl: 'views/preferencesGlidera.html'
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
.state('preferencesAdvanced', {
|
.state('preferencesAdvanced', {
|
||||||
url: '/preferencesAdvanced',
|
url: '/preferencesAdvanced',
|
||||||
templateUrl: 'views/preferencesAdvanced.html',
|
templateUrl: 'views/preferencesAdvanced.html',
|
||||||
walletShouldBeComplete: true,
|
walletShouldBeComplete: true,
|
||||||
needProfile: true,
|
needProfile: true,
|
||||||
views: {
|
views: {
|
||||||
'main': {
|
'main': {
|
||||||
templateUrl: 'views/preferencesAdvanced.html'
|
templateUrl: 'views/preferencesAdvanced.html'
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.state('preferencesColor', {
|
.state('preferencesColor', {
|
||||||
url: '/preferencesColor',
|
url: '/preferencesColor',
|
||||||
templateUrl: 'views/preferencesColor.html',
|
templateUrl: 'views/preferencesColor.html',
|
||||||
|
|
@ -309,16 +309,16 @@ angular
|
||||||
})
|
})
|
||||||
|
|
||||||
.state('preferencesAltCurrency', {
|
.state('preferencesAltCurrency', {
|
||||||
url: '/preferencesAltCurrency',
|
url: '/preferencesAltCurrency',
|
||||||
templateUrl: 'views/preferencesAltCurrency.html',
|
templateUrl: 'views/preferencesAltCurrency.html',
|
||||||
walletShouldBeComplete: true,
|
walletShouldBeComplete: true,
|
||||||
needProfile: true,
|
needProfile: true,
|
||||||
views: {
|
views: {
|
||||||
'main': {
|
'main': {
|
||||||
templateUrl: 'views/preferencesAltCurrency.html'
|
templateUrl: 'views/preferencesAltCurrency.html'
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.state('preferencesAlias', {
|
.state('preferencesAlias', {
|
||||||
url: '/preferencesAlias',
|
url: '/preferencesAlias',
|
||||||
templateUrl: 'views/preferencesAlias.html',
|
templateUrl: 'views/preferencesAlias.html',
|
||||||
|
|
@ -376,18 +376,18 @@ angular
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
.state('about', {
|
.state('about', {
|
||||||
url: '/about',
|
url: '/about',
|
||||||
templateUrl: 'views/preferencesAbout.html',
|
templateUrl: 'views/preferencesAbout.html',
|
||||||
walletShouldBeComplete: true,
|
walletShouldBeComplete: true,
|
||||||
needProfile: true,
|
needProfile: true,
|
||||||
views: {
|
views: {
|
||||||
'main': {
|
'main': {
|
||||||
templateUrl: 'views/preferencesAbout.html'
|
templateUrl: 'views/preferencesAbout.html'
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.state('logs', {
|
.state('logs', {
|
||||||
url: '/logs',
|
url: '/logs',
|
||||||
templateUrl: 'views/preferencesLogs.html',
|
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', {
|
.state('backup', {
|
||||||
url: '/backup',
|
url: '/backup',
|
||||||
templateUrl: 'views/backup.html',
|
templateUrl: 'views/backup.html',
|
||||||
|
|
@ -435,14 +446,14 @@ angular
|
||||||
})
|
})
|
||||||
|
|
||||||
.state('add', {
|
.state('add', {
|
||||||
url: '/add',
|
url: '/add',
|
||||||
needProfile: true,
|
needProfile: true,
|
||||||
views: {
|
views: {
|
||||||
'main': {
|
'main': {
|
||||||
templateUrl: 'views/add.html'
|
templateUrl: 'views/add.html'
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.state('cordova', {
|
.state('cordova', {
|
||||||
url: '/cordova/:status/:isHome',
|
url: '/cordova/:status/:isHome',
|
||||||
views: {
|
views: {
|
||||||
|
|
@ -450,7 +461,7 @@ angular
|
||||||
controller: function($rootScope, $state, $stateParams, $timeout, go, isCordova) {
|
controller: function($rootScope, $state, $stateParams, $timeout, go, isCordova) {
|
||||||
switch ($stateParams.status) {
|
switch ($stateParams.status) {
|
||||||
case 'resume':
|
case 'resume':
|
||||||
$rootScope.$emit('Local/Resume');
|
$rootScope.$emit('Local/Resume');
|
||||||
break;
|
break;
|
||||||
case 'backbutton':
|
case 'backbutton':
|
||||||
if (isCordova && $stateParams.isHome == 'true' && !$rootScope.modalOpened) {
|
if (isCordova && $stateParams.isHome == 'true' && !$rootScope.modalOpened) {
|
||||||
|
|
@ -534,4 +545,4 @@ angular
|
||||||
}, 50);
|
}, 50);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
Loading…
Add table
Add a link
Reference in a new issue