mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-01-31 15:22:16 +00:00
Payment channels: add wallet printouts of the contents of the extensions.
This commit is contained in:
parent
d3842cc0f4
commit
70590dac16
@ -201,6 +201,19 @@ public class StoredPaymentChannelClientStates implements WalletExtension {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
lock.lock();
|
||||
try {
|
||||
StringBuilder buf = new StringBuilder("Client payment channel states:\n");
|
||||
for (StoredClientChannel channel : mapChannels.values())
|
||||
buf.append(" ").append(channel).append("\n");
|
||||
return buf.toString();
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -227,4 +240,18 @@ class StoredClientChannel {
|
||||
this.refundFees = refundFees;
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final String newline = String.format("%n");
|
||||
return String.format("Stored client channel %s (%s)%n" +
|
||||
" Key: %s%n" +
|
||||
" Value to me: %d%n" +
|
||||
" Refund fees: %d%n" +
|
||||
" Contract: %s" +
|
||||
"Refund: %s",
|
||||
id, active ? "active" : "inactive", myKey, valueToMe, refundFees,
|
||||
contract.toString().replaceAll(newline, newline + " "),
|
||||
refund.toString().replaceAll(newline, newline + " "));
|
||||
}
|
||||
}
|
||||
|
@ -185,4 +185,18 @@ public class StoredPaymentChannelServerStates implements WalletExtension {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
lock.lock();
|
||||
try {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
for (StoredServerChannel stored : mapChannels.values()) {
|
||||
buf.append(stored);
|
||||
}
|
||||
return buf.toString();
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ package com.google.bitcoin.protocols.channels;
|
||||
import com.google.bitcoin.core.*;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.Date;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
@ -85,4 +86,18 @@ public class StoredServerChannel {
|
||||
checkArgument(wallet == state.wallet);
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized String toString() {
|
||||
final String newline = String.format("%n");
|
||||
return String.format("Stored server channel (%s)%n" +
|
||||
" Key: %s%n" +
|
||||
" Value to me: %d%n" +
|
||||
" Client output: %s%n" +
|
||||
" Refund unlock: %s (%d unix time)%n" +
|
||||
" Contract: %s%n",
|
||||
connectedHandler != null ? "connected" : "disconnected", myKey, bestValueToMe,
|
||||
clientOutput, new Date(refundTransactionUnlockTimeSecs * 1000), refundTransactionUnlockTimeSecs,
|
||||
contract.toString().replaceAll(newline, newline + " "));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user