コード例 #1
0
 static byte[] addChecksum(byte[] input) {
   int inputLength = input.length;
   byte[] checksummed = new byte[inputLength + 4];
   System.arraycopy(input, 0, checksummed, 0, inputLength);
   byte[] checksum = Sha256Hash.hashTwice(input);
   System.arraycopy(checksum, 0, checksummed, inputLength, 4);
   return checksummed;
 }
コード例 #2
0
 // Adds this channel and optionally notifies the wallet of an update to this extension (used
 // during deserialize)
 private void putChannel(final StoredClientChannel channel, boolean updateWallet) {
   lock.lock();
   try {
     mapChannels.put(channel.id, channel);
     channelTimeoutHandler.schedule(
         new TimerTask() {
           @Override
           public void run() {
             TransactionBroadcaster announcePeerGroup = getAnnouncePeerGroup();
             removeChannel(channel);
             announcePeerGroup.broadcastTransaction(channel.contract);
             announcePeerGroup.broadcastTransaction(channel.refund);
           }
           // Add the difference between real time and Utils.now() so that test-cases can use a
           // mock clock.
         },
         new Date(
             channel.expiryTimeSeconds() * 1000
                 + (System.currentTimeMillis() - Utils.currentTimeMillis())));
   } finally {
     lock.unlock();
   }
   if (updateWallet) updatedChannel(channel);
 }
コード例 #3
0
 /**
  * Returns private key bytes, padded with zeros to 33 bytes.
  *
  * @throws java.lang.IllegalStateException if the private key bytes are missing.
  */
 public byte[] getPrivKeyBytes33() {
   byte[] bytes33 = new byte[33];
   byte[] priv = getPrivKeyBytes();
   System.arraycopy(priv, 0, bytes33, 33 - priv.length, priv.length);
   return bytes33;
 }
コード例 #4
0
 /** This should always be called before attempting to call sendPayment. */
 public boolean isExpired() {
   return paymentDetails.hasExpires()
       && System.currentTimeMillis() / 1000L > paymentDetails.getExpires();
 }