diff --git a/core/src/main/java/com/google/bitcoin/protocols/channels/PaymentChannelCloseException.java b/core/src/main/java/com/google/bitcoin/protocols/channels/PaymentChannelCloseException.java index ec479ea4..8a4a526b 100644 --- a/core/src/main/java/com/google/bitcoin/protocols/channels/PaymentChannelCloseException.java +++ b/core/src/main/java/com/google/bitcoin/protocols/channels/PaymentChannelCloseException.java @@ -18,9 +18,9 @@ public class PaymentChannelCloseException extends Exception { /** *

The {@link com.google.bitcoin.protocols.channels.PaymentChannelClient#close()} method was called or the * client sent a CLOSE message.

- *

As long as the server received the CLOSE message, this means that the channel was closed and the payment - * transaction (if any) was broadcast. If the client attempts to open a new connection, a new channel will have - * to be opened.

+ *

As long as the server received the CLOSE message, this means that the channel is closing and the payment + * transaction (if any) will be broadcast. If the client attempts to open a new connection, a new channel will + * have to be opened.

*/ CLIENT_REQUESTED_CLOSE, 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 ac9e2bc9..28eafb85 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 @@ -380,6 +380,9 @@ public class PaymentChannelServerState { return closedFuture; if (bestValueToMe.equals(BigInteger.ZERO)) { + // TODO: This is bogus. We shouldn't allow the client to get into this state (where they open and close + // a channel without sending us any money). We should either send an error at this point, or require + // the submission of an initial zero-valued payment during the open phase. state = State.CLOSED; closedFuture.set(this); return closedFuture; @@ -394,7 +397,8 @@ public class PaymentChannelServerState { throw new ValueOutOfRangeException("Unable to complete transaction - unable to pay required fee"); feePaidForPayment = req.fee; if (feePaidForPayment.compareTo(bestValueToMe) >= 0) - throw new ValueOutOfRangeException("Had to pay more in fees than the channel was worth"); + throw new ValueOutOfRangeException(String.format("Had to pay more in fees (%s) than the channel was worth (%s)", + feePaidForPayment, bestValueToMe)); // Now really sign the multisig input. signMultisigInput(tx, Transaction.SigHash.ALL, false); // Some checks that shouldn't be necessary but it can't hurt to check. diff --git a/core/src/paymentchannel.proto b/core/src/paymentchannel.proto index 4cccd087..9dc621b7 100644 --- a/core/src/paymentchannel.proto +++ b/core/src/paymentchannel.proto @@ -27,10 +27,9 @@ package paymentchannels; option java_package = "org.bitcoin.paymentchannel"; option java_outer_classname = "Protos"; - -// The connection should be a standard TLS connection and all messages sent over this socket are -// serialized TwoWayChannelMessages prefixed with 2-byte size in big-endian (smaller than or -// equal to 32767 bytes in size) +// This message is designed to be either sent raw over the network (e.g. length prefixed) or embedded inside another +// protocol that is being extended to support micropayments. In this file "primary" typically can be read as "client" +// and "secondary" as "server". message TwoWayChannelMessage { enum MessageType { CLIENT_VERSION = 1; @@ -208,4 +207,4 @@ message Error { }; optional ErrorCode code = 1 [default=OTHER]; optional string explanation = 2; // NOT SAFE FOR HTML WITHOUT ESCAPING -} \ No newline at end of file +}