From d2023b053f59faa232fda13886f301131e92398b Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Wed, 7 Oct 2015 14:37:24 -0300 Subject: [PATCH] Revert "improve transaction method" --- src/js/controllers/paperWallet.js | 42 +++++++++++++++++-------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/src/js/controllers/paperWallet.js b/src/js/controllers/paperWallet.js index dcf53758d..e7aacf700 100644 --- a/src/js/controllers/paperWallet.js +++ b/src/js/controllers/paperWallet.js @@ -51,31 +51,35 @@ angular.module('copayApp.controllers').controller('paperWalletController', fc.decryptBIP38PrivateKey(privateKey, passphrase, null, function(err, privateKey) { if (err) return cb(err); - self.getRawTxFromPrivateKey(privateKey, function(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); + return cb(null, tx.serialize(), utxos); + }); + }); }); }); - } else - self.getRawTxFromPrivateKey(privateKey, function(err) { - if (err) return cb(err); + } 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); + return cb(null, tx.serialize(), utxos); + }); + }); }); + } }; - self.getRawTxFromPrivateKey = function(privateKey, cb) { - 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); - return cb(null, tx.serialize(), utxos); - }); - }); - }); - } - self.transaction = function() { self.error = null; self.sending = true;