/** * <p>Closes the given channel using {@link ServerConnectionEventHandler#closeChannel()} and * {@link PaymentChannelV1ServerState#close()} to notify any connected client of channel closure and to complete and * broadcast the latest payment transaction.</p> * * <p>Removes the given channel from this set of {@link StoredServerChannel}s and notifies the wallet of a change to * this wallet extension.</p> */ public void closeChannel(StoredServerChannel channel) { lock.lock(); try { if (mapChannels.remove(channel.contract.getHash()) == null) return; } finally { lock.unlock(); } synchronized (channel) { channel.closeConnectedHandler(); try { TransactionBroadcaster broadcaster = getBroadcaster(); channel.getOrCreateState(wallet, broadcaster).close(); } catch (InsufficientMoneyException e) { log.error("Exception when closing channel", e); } catch (VerificationException e) { log.error("Exception when closing channel", e); } channel.state = null; } updatedChannel(channel); }
/** * <p>Closes the given channel using {@link ServerConnectionEventHandler#closeChannel()} and * {@link PaymentChannelV1ServerState#close()} to notify any connected client of channel closure and to complete and * broadcast the latest payment transaction.</p> * * <p>Removes the given channel from this set of {@link StoredServerChannel}s and notifies the wallet of a change to * this wallet extension.</p> */ public void closeChannel(StoredServerChannel channel) { lock.lock(); try { if (mapChannels.remove(channel.contract.getHash()) == null) return; } finally { lock.unlock(); } synchronized (channel) { channel.closeConnectedHandler(); try { TransactionBroadcaster broadcaster = getBroadcaster(); channel.getOrCreateState(wallet, broadcaster).close(); } catch (InsufficientMoneyException e) { log.error("Exception when closing channel", e); } catch (VerificationException e) { log.error("Exception when closing channel", e); } channel.state = null; } updatedChannel(channel); }
/** * <p>Closes the given channel using {@link ServerConnectionEventHandler#closeChannel()} and * {@link PaymentChannelV1ServerState#close()} to notify any connected client of channel closure and to complete and * broadcast the latest payment transaction.</p> * * <p>Removes the given channel from this set of {@link StoredServerChannel}s and notifies the wallet of a change to * this wallet extension.</p> */ public void closeChannel(StoredServerChannel channel) { lock.lock(); try { if (mapChannels.remove(channel.contract.getHash()) == null) return; } finally { lock.unlock(); } synchronized (channel) { channel.closeConnectedHandler(); try { TransactionBroadcaster broadcaster = getBroadcaster(); channel.getOrCreateState(wallet, broadcaster).close(); } catch (InsufficientMoneyException e) { log.error("Exception when closing channel", e); } catch (VerificationException e) { log.error("Exception when closing channel", e); } channel.state = null; } updatedChannel(channel); }
/** * <p>Closes the given channel using {@link ServerConnectionEventHandler#closeChannel()} and * {@link PaymentChannelV1ServerState#close()} to notify any connected client of channel closure and to complete and * broadcast the latest payment transaction.</p> * * <p>Removes the given channel from this set of {@link StoredServerChannel}s and notifies the wallet of a change to * this wallet extension.</p> */ public void closeChannel(StoredServerChannel channel) { lock.lock(); try { if (mapChannels.remove(channel.contract.getHash()) == null) return; } finally { lock.unlock(); } synchronized (channel) { channel.closeConnectedHandler(); try { TransactionBroadcaster broadcaster = getBroadcaster(); channel.getOrCreateState(wallet, broadcaster).close(); } catch (InsufficientMoneyException e) { log.error("Exception when closing channel", e); } catch (VerificationException e) { log.error("Exception when closing channel", e); } channel.state = null; } updatedChannel(channel); }
@Override public void channelOpen(Sha256Hash channelId) { log.info("Channel open for {}: {}.", clientAddress, channelId); // Try to get the state object from the stored state set in our wallet PaymentChannelServerState state = null; try { StoredPaymentChannelServerStates storedStates = (StoredPaymentChannelServerStates) appKit.wallet().getExtensions().get(StoredPaymentChannelServerStates.class.getName()); state = storedStates.getChannel(channelId).getOrCreateState(appKit.wallet(), appKit.peerGroup()); } catch (VerificationException e) { // This indicates corrupted data, and since the channel was just opened, cannot happen throw new RuntimeException(e); } log.info(" with a maximum value of {}, expiring at UNIX timestamp {}.", // The channel's maximum value is the value of the multisig contract which locks in some // amount of money to the channel state.getContract().getOutput(0).getValue(), // The channel expires at some offset from when the client's refund transaction becomes // spendable. state.getExpiryTime() + StoredPaymentChannelServerStates.CHANNEL_EXPIRE_OFFSET); }
state = storedServerChannel.getOrCreateState(wallet, broadcaster); step = InitStep.CHANNEL_OPEN; conn.sendToClient(Protos.TwoWayChannelMessage.newBuilder()
state = storedServerChannel.getOrCreateState(wallet, broadcaster); step = InitStep.CHANNEL_OPEN; conn.sendToClient(Protos.TwoWayChannelMessage.newBuilder()
state = storedServerChannel.getOrCreateState(wallet, broadcaster); step = InitStep.CHANNEL_OPEN; conn.sendToClient(Protos.TwoWayChannelMessage.newBuilder()
state = storedServerChannel.getOrCreateState(wallet, broadcaster); step = InitStep.CHANNEL_OPEN; conn.sendToClient(Protos.TwoWayChannelMessage.newBuilder()
PaymentChannelServerState serverState = storedServerChannel.getOrCreateState(serverWallet, mockBroadcaster);