mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-13 02:35:52 +00:00
Payment channels: Better comments and logging.
This commit is contained in:
parent
273acbdccd
commit
38119b9355
@ -18,9 +18,9 @@ public class PaymentChannelCloseException extends Exception {
|
|||||||
/**
|
/**
|
||||||
* <p>The {@link com.google.bitcoin.protocols.channels.PaymentChannelClient#close()} method was called or the
|
* <p>The {@link com.google.bitcoin.protocols.channels.PaymentChannelClient#close()} method was called or the
|
||||||
* client sent a CLOSE message.</p>
|
* 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
|
* <p>As long as the server received the CLOSE message, this means that the channel is closing and the payment
|
||||||
* transaction (if any) was broadcast. If the client attempts to open a new connection, a new channel will have
|
* transaction (if any) will be broadcast. If the client attempts to open a new connection, a new channel will
|
||||||
* to be opened.</p>
|
* have to be opened.</p>
|
||||||
*/
|
*/
|
||||||
CLIENT_REQUESTED_CLOSE,
|
CLIENT_REQUESTED_CLOSE,
|
||||||
|
|
||||||
|
@ -380,6 +380,9 @@ public class PaymentChannelServerState {
|
|||||||
return closedFuture;
|
return closedFuture;
|
||||||
|
|
||||||
if (bestValueToMe.equals(BigInteger.ZERO)) {
|
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;
|
state = State.CLOSED;
|
||||||
closedFuture.set(this);
|
closedFuture.set(this);
|
||||||
return closedFuture;
|
return closedFuture;
|
||||||
@ -394,7 +397,8 @@ public class PaymentChannelServerState {
|
|||||||
throw new ValueOutOfRangeException("Unable to complete transaction - unable to pay required fee");
|
throw new ValueOutOfRangeException("Unable to complete transaction - unable to pay required fee");
|
||||||
feePaidForPayment = req.fee;
|
feePaidForPayment = req.fee;
|
||||||
if (feePaidForPayment.compareTo(bestValueToMe) >= 0)
|
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.
|
// Now really sign the multisig input.
|
||||||
signMultisigInput(tx, Transaction.SigHash.ALL, false);
|
signMultisigInput(tx, Transaction.SigHash.ALL, false);
|
||||||
// Some checks that shouldn't be necessary but it can't hurt to check.
|
// Some checks that shouldn't be necessary but it can't hurt to check.
|
||||||
|
@ -27,10 +27,9 @@ package paymentchannels;
|
|||||||
option java_package = "org.bitcoin.paymentchannel";
|
option java_package = "org.bitcoin.paymentchannel";
|
||||||
option java_outer_classname = "Protos";
|
option java_outer_classname = "Protos";
|
||||||
|
|
||||||
|
// This message is designed to be either sent raw over the network (e.g. length prefixed) or embedded inside another
|
||||||
// The connection should be a standard TLS connection and all messages sent over this socket are
|
// protocol that is being extended to support micropayments. In this file "primary" typically can be read as "client"
|
||||||
// serialized TwoWayChannelMessages prefixed with 2-byte size in big-endian (smaller than or
|
// and "secondary" as "server".
|
||||||
// equal to 32767 bytes in size)
|
|
||||||
message TwoWayChannelMessage {
|
message TwoWayChannelMessage {
|
||||||
enum MessageType {
|
enum MessageType {
|
||||||
CLIENT_VERSION = 1;
|
CLIENT_VERSION = 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user