Merge pull request #3274 from javierbitpay/fix/paperWallet-getTx
improve transaction method
This commit is contained in:
commit
90967e9652
1 changed files with 17 additions and 21 deletions
|
|
@ -51,35 +51,31 @@ angular.module('copayApp.controllers').controller('paperWalletController',
|
||||||
fc.decryptBIP38PrivateKey(privateKey, passphrase, null, function(err, privateKey) {
|
fc.decryptBIP38PrivateKey(privateKey, passphrase, null, function(err, privateKey) {
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
|
|
||||||
fc.getBalanceFromPrivateKey(privateKey, function(err, utxos) {
|
self.getRawTxFromPrivateKey(privateKey, function(err) {
|
||||||
if (err) return cb(err);
|
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 {
|
} else
|
||||||
fc.getBalanceFromPrivateKey(privateKey, function(err, utxos) {
|
self.getRawTxFromPrivateKey(privateKey, function(err) {
|
||||||
if (err) return cb(err)
|
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.transaction = function() {
|
||||||
self.error = null;
|
self.error = null;
|
||||||
self.sending = true;
|
self.sending = true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue