3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-07 14:54:15 +00:00

Payment channels: Better comments and logging.

This commit is contained in:
Mike Hearn 2013-09-05 12:42:33 +02:00
parent 273acbdccd
commit 38119b9355
3 changed files with 12 additions and 9 deletions

View File

@ -18,9 +18,9 @@ public class PaymentChannelCloseException extends Exception {
/**
* <p>The {@link com.google.bitcoin.protocols.channels.PaymentChannelClient#close()} method was called or the
* client sent a CLOSE message.</p>
* <p>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.</p>
* <p>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.</p>
*/
CLIENT_REQUESTED_CLOSE,

View File

@ -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.

View File

@ -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
}
}