Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

Commit

Permalink
Fix crash that can occur when editing projects that have a P2SH targe…
Browse files Browse the repository at this point in the history
…t address
  • Loading branch information
mikehearn committed Dec 8, 2014
1 parent c9607a8 commit 04bc28f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions client/src/main/java/lighthouse/model/ProjectModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
import lighthouse.protocol.LHUtils;
import lighthouse.protocol.Project;
import lighthouse.wallet.PledgingWallet;
import org.bitcoinj.core.Address;
import org.bitcoinj.core.AddressFormatException;
import org.bitcoinj.core.Coin;
import org.bitcoinj.core.Transaction;
import org.bitcoinj.core.*;
import org.bitcoinj.script.Script;
import org.bitcoinj.script.ScriptBuilder;

Expand Down Expand Up @@ -76,9 +73,12 @@ public ProjectModel(LHProtos.ProjectDetails.Builder liveProto) {
proto.setPaymentUrl(LHUtils.makeServerPath(name, LHUtils.titleToUrlString(title.get())));
});

Address addr = project.getOutputs().get(0).getAddressFromP2PKHScript(project.getParams());
TransactionOutput output = project.getOutputs().get(0);
Address addr = output.getAddressFromP2PKHScript(project.getParams());
if (addr == null)
throw new IllegalArgumentException("Output type is not a pay to address: " + project.getOutputs().get(0));
addr = output.getAddressFromP2SH(project.getParams());
if (addr == null)
throw new IllegalArgumentException("Output type is not pay to address/p2sh: " + output);
address.set(addr.toString());
address.addListener(o -> {
try {
Expand Down

0 comments on commit 04bc28f

Please sign in to comment.