Skip to content

Commit

Permalink
Properly account for Address.fromOutputScript raising an exception wh…
Browse files Browse the repository at this point in the history
…en it can't decode a script
  • Loading branch information
caedesvvv committed Oct 17, 2014
1 parent 5eb34b8 commit 379ba59
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 6 additions & 2 deletions js/model/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,14 @@ History.prototype.getTransferLabel = function(pocketImpact) {
* @private
*/
History.prototype.fillInput = function(transaction, data) {
var index = data[0],
var address,
index = data[0],
newRow = data[1],
txObj = Bitcoin.Transaction.fromHex(transaction);
var address = Bitcoin.Address.fromOutputScript(txObj.outs[index].script, Bitcoin.networks[this.identity.wallet.network]);
try {
address = Bitcoin.Address.fromOutputScript(txObj.outs[index].script, Bitcoin.networks[this.identity.wallet.network]);
} catch(e) {
}
if (address) {
newRow.address = address.toString();
this.update();
Expand Down
5 changes: 5 additions & 0 deletions js/model/tx.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,11 @@ Transaction.prototype.process = function(serializedTx, height) {

// Now parse inputs and outputs
tx.outs.forEach(function(txOut, i){
var outType = Bitcoin.scripts.classifyOutput(txOut.script, Bitcoin.networks[wallet.versions.network]);
// don't process output if not of the right type or has no value
if (!outType || outType === 'nulldata' || !txOut.value) {
return;
}
var address = Bitcoin.Address.fromOutputScript(txOut.script, Bitcoin.networks[wallet.versions.network]).toString();
var outputAddress = wallet.getWalletAddress(address);
// already exists
Expand Down

0 comments on commit 379ba59

Please sign in to comment.