diff --git a/core/src/main/java/com/google/bitcoin/protocols/channels/PaymentChannelClientState.java b/core/src/main/java/com/google/bitcoin/protocols/channels/PaymentChannelClientState.java index dd5b3c5e..9dae4c6f 100644 --- a/core/src/main/java/com/google/bitcoin/protocols/channels/PaymentChannelClientState.java +++ b/core/src/main/java/com/google/bitcoin/protocols/channels/PaymentChannelClientState.java @@ -23,7 +23,6 @@ import com.google.bitcoin.script.ScriptBuilder; import com.google.bitcoin.utils.Threading; import com.google.bitcoin.wallet.AllowUnconfirmedCoinSelector; import com.google.common.annotations.VisibleForTesting; -import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -326,7 +325,7 @@ public class PaymentChannelClientState { TransactionSignature ourSignature = refundTx.calculateSignature(0, myKey, multisigScript, Transaction.SigHash.ALL, false); // Insert the signatures. - Script scriptSig = ScriptBuilder.createMultiSigInputScript(ImmutableList.of(ourSignature, theirSig)); + Script scriptSig = ScriptBuilder.createMultiSigInputScript(ourSignature, theirSig); log.info("Refund scriptSig: {}", scriptSig); log.info("Multi-sig contract scriptPubKey: {}", multisigScript); TransactionInput refundInput = refundTx.getInput(0); diff --git a/core/src/main/java/com/google/bitcoin/protocols/channels/PaymentChannelServerState.java b/core/src/main/java/com/google/bitcoin/protocols/channels/PaymentChannelServerState.java index df1996e2..a1272201 100644 --- a/core/src/main/java/com/google/bitcoin/protocols/channels/PaymentChannelServerState.java +++ b/core/src/main/java/com/google/bitcoin/protocols/channels/PaymentChannelServerState.java @@ -32,7 +32,6 @@ import org.slf4j.LoggerFactory; import javax.annotation.Nullable; import java.math.BigInteger; import java.util.Arrays; -import java.util.Collections; import static com.google.common.base.Preconditions.*; @@ -394,9 +393,13 @@ public class PaymentChannelServerState { try { Wallet.SendRequest req = makeUnsignedChannelContract(bestValueToMe); tx = req.tx; - // Provide a BS signature so that completeTx wont freak out about unsigned inputs. + // Provide a throwaway signature so that completeTx won't complain out about unsigned inputs it doesn't + // know how to sign. Note that this signature does actually have to be valid, so we can't use a dummy + // signature to save time, because otherwise completeTx will try to re-sign it to make it valid and then + // die. We could probably add features to the SendRequest API to make this a bit more efficient. signMultisigInput(tx, Transaction.SigHash.NONE, true); - if (!wallet.completeTx(req)) // Let wallet handle adding additional inputs/fee as necessary. + // Let wallet handle adding additional inputs/fee as necessary. + if (!wallet.completeTx(req)) throw new ValueOutOfRangeException("Unable to complete transaction - unable to pay required fee"); feePaidForPayment = req.fee; log.info("Calculated fee is {}", feePaidForPayment);