mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-14 11:15:51 +00:00
Migrate fully qualified names to using imports.
This commit is contained in:
parent
9e16d5fdeb
commit
4bbb7be059
@ -44,7 +44,7 @@ import static com.google.common.base.Preconditions.*;
|
||||
* <p>An AbstractBlockChain implementation must be connected to a {@link BlockStore} implementation. The chain object
|
||||
* by itself doesn't store any data, that's delegated to the store. Which store you use is a decision best made by
|
||||
* reading the getting started guide, but briefly, fully validating block chains need fully validating stores. In
|
||||
* the lightweight SPV mode, a {@link org.bitcoinj.store.SPVBlockStore} is the right choice.</p>
|
||||
* the lightweight SPV mode, a {@link SPVBlockStore} is the right choice.</p>
|
||||
*
|
||||
* <p>This class implements an abstract class which makes it simple to create a BlockChain that does/doesn't do full
|
||||
* verification. It verifies headers and is implements most of what is required to implement SPV mode, but
|
||||
@ -53,7 +53,7 @@ import static com.google.common.base.Preconditions.*;
|
||||
* <p>There are two subclasses of AbstractBlockChain that are useful: {@link BlockChain}, which is the simplest
|
||||
* class and implements <i>simplified payment verification</i>. This is a lightweight and efficient mode that does
|
||||
* not verify the contents of blocks, just their headers. A {@link FullPrunedBlockChain} paired with a
|
||||
* {@link org.bitcoinj.store.H2FullPrunedBlockStore} implements full verification, which is equivalent to
|
||||
* {@link H2FullPrunedBlockStore} implements full verification, which is equivalent to
|
||||
* Bitcoin Core. To learn more about the alternative security models, please consult the articles on the
|
||||
* website.</p>
|
||||
*
|
||||
|
@ -212,7 +212,7 @@ public class Block extends Message {
|
||||
* the system it was 50 coins per block, in late 2012 it went to 25 coins per block, and so on. The size of
|
||||
* a coinbase transaction is inflation plus fees.</p>
|
||||
*
|
||||
* <p>The half-life is controlled by {@link org.bitcoinj.core.NetworkParameters#getSubsidyDecreaseBlockCount()}.
|
||||
* <p>The half-life is controlled by {@link NetworkParameters#getSubsidyDecreaseBlockCount()}.
|
||||
* </p>
|
||||
*/
|
||||
public Coin getBlockInflation(int height) {
|
||||
@ -815,7 +815,7 @@ public class Block extends Message {
|
||||
* Returns the difficulty of the proof of work that this block should meet encoded <b>in compact form</b>. The {@link
|
||||
* BlockChain} verifies that this is not too easy by looking at the length of the chain when the block is added.
|
||||
* To find the actual value the hash should be compared against, use
|
||||
* {@link org.bitcoinj.core.Block#getDifficultyTargetAsInteger()}. Note that this is <b>not</b> the same as
|
||||
* {@link Block#getDifficultyTargetAsInteger()}. Note that this is <b>not</b> the same as
|
||||
* the difficulty value reported by the Bitcoin "getdifficulty" RPC that you may see on various block explorers.
|
||||
* That number is the result of applying a formula to the underlying difficulty to normalize the minimum to 1.
|
||||
* Calculating the difficulty that way is currently unsupported.
|
||||
|
@ -21,8 +21,12 @@ import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
import org.bitcoinj.store.BlockStore;
|
||||
import org.bitcoinj.store.BlockStoreException;
|
||||
import org.bitcoinj.store.MemoryBlockStore;
|
||||
import org.bitcoinj.store.SPVBlockStore;
|
||||
import org.bitcoinj.wallet.Wallet;
|
||||
import org.bitcoinj.wallet.WalletExtension;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -40,10 +44,10 @@ public class BlockChain extends AbstractBlockChain {
|
||||
/**
|
||||
* <p>Constructs a BlockChain connected to the given wallet and store. To obtain a {@link Wallet} you can construct
|
||||
* one from scratch, or you can deserialize a saved wallet from disk using
|
||||
* {@link Wallet#loadFromFile(java.io.File, WalletExtension...)}</p>
|
||||
* {@link Wallet#loadFromFile(File, WalletExtension...)}</p>
|
||||
*
|
||||
* <p>For the store, you should use {@link org.bitcoinj.store.SPVBlockStore} or you could also try a
|
||||
* {@link org.bitcoinj.store.MemoryBlockStore} if you want to hold all headers in RAM and don't care about
|
||||
* <p>For the store, you should use {@link SPVBlockStore} or you could also try a
|
||||
* {@link MemoryBlockStore} if you want to hold all headers in RAM and don't care about
|
||||
* disk serialization (this is rare).</p>
|
||||
*/
|
||||
public BlockChain(Context context, Wallet wallet, BlockStore blockStore) throws BlockStoreException {
|
||||
|
@ -105,7 +105,7 @@ public class BloomFilter extends Message {
|
||||
* It should be a random value, however secureness of the random value is of no great consequence.</p>
|
||||
*
|
||||
* <p>updateFlag is used to control filter behaviour on the server (remote node) side when it encounters a hit.
|
||||
* See {@link org.bitcoinj.core.BloomFilter.BloomUpdate} for a brief description of each mode. The purpose
|
||||
* See {@link BloomFilter.BloomUpdate} for a brief description of each mode. The purpose
|
||||
* of this flag is to reduce network round-tripping and avoid over-dirtying the filter for the most common
|
||||
* wallet configurations.</p>
|
||||
*/
|
||||
@ -270,7 +270,7 @@ public class BloomFilter extends Message {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this filter will match anything. See {@link org.bitcoinj.core.BloomFilter#setMatchAll()}
|
||||
* Returns true if this filter will match anything. See {@link BloomFilter#setMatchAll()}
|
||||
* for when this can be a useful thing to do.
|
||||
*/
|
||||
public synchronized boolean matchesAll() {
|
||||
|
@ -24,6 +24,7 @@ import com.google.common.hash.Hasher;
|
||||
import com.google.common.hash.Hashing;
|
||||
import com.google.common.io.BaseEncoding;
|
||||
|
||||
import org.bitcoinj.store.SPVBlockStore;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -55,7 +56,7 @@ import static com.google.common.base.Preconditions.*;
|
||||
* </ol>
|
||||
*
|
||||
* <p>Checkpoints are used by the SPV {@link BlockChain} to initialize fresh
|
||||
* {@link org.bitcoinj.store.SPVBlockStore}s. They are not used by fully validating mode, which instead has a
|
||||
* {@link SPVBlockStore}s. They are not used by fully validating mode, which instead has a
|
||||
* different concept of checkpoints that are used to hard-code the validity of blocks that violate BIP30 (duplicate
|
||||
* coinbase transactions). Those "checkpoints" can be found in NetworkParameters.</p>
|
||||
*
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
package org.bitcoinj.core;
|
||||
|
||||
import org.bitcoinj.utils.ContextPropagatingThreadFactory;
|
||||
import org.bitcoinj.wallet.SendRequest;
|
||||
import org.slf4j.*;
|
||||
|
||||
@ -119,7 +120,7 @@ public class Context {
|
||||
}
|
||||
|
||||
/**
|
||||
* Require that new threads use {@link #propagate(Context)} or {@link org.bitcoinj.utils.ContextPropagatingThreadFactory},
|
||||
* Require that new threads use {@link #propagate(Context)} or {@link ContextPropagatingThreadFactory},
|
||||
* rather than using a heuristic for the desired context.
|
||||
*/
|
||||
public static void enableStrictMode() {
|
||||
@ -145,7 +146,7 @@ public class Context {
|
||||
* Sets the given context as the current thread context. You should use this if you create your own threads that
|
||||
* want to create core BitcoinJ objects. Generally, if a class can accept a Context in its constructor and might
|
||||
* be used (even indirectly) by a thread, you will want to call this first. Your task may be simplified by using
|
||||
* a {@link org.bitcoinj.utils.ContextPropagatingThreadFactory}.
|
||||
* a {@link ContextPropagatingThreadFactory}.
|
||||
*/
|
||||
public static void propagate(Context context) {
|
||||
slot.set(checkNotNull(context));
|
||||
@ -162,7 +163,7 @@ public class Context {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link org.bitcoinj.core.NetworkParameters} specified when this context was (auto) created. The
|
||||
* Returns the {@link NetworkParameters} specified when this context was (auto) created. The
|
||||
* network parameters defines various hard coded constants for a specific instance of a Bitcoin network, such as
|
||||
* main net, testnet, etc.
|
||||
*/
|
||||
|
@ -624,7 +624,7 @@ public class ECKey implements EncryptableItem {
|
||||
|
||||
/**
|
||||
* Signs the given hash and returns the R and S components as BigIntegers. In the Bitcoin protocol, they are
|
||||
* usually encoded using ASN.1 format, so you want {@link org.bitcoinj.core.ECKey.ECDSASignature#toASN1()}
|
||||
* usually encoded using ASN.1 format, so you want {@link ECKey.ECDSASignature#toASN1()}
|
||||
* instead. However sometimes the independent components can be useful, for instance, if you're going to do
|
||||
* further EC maths on them.
|
||||
* @throws KeyCrypterException if this ECKey doesn't have a private part.
|
||||
@ -643,7 +643,7 @@ public class ECKey implements EncryptableItem {
|
||||
|
||||
/**
|
||||
* Signs the given hash and returns the R and S components as BigIntegers. In the Bitcoin protocol, they are
|
||||
* usually encoded using DER format, so you want {@link org.bitcoinj.core.ECKey.ECDSASignature#encodeToDER()}
|
||||
* usually encoded using DER format, so you want {@link ECKey.ECDSASignature#encodeToDER()}
|
||||
* instead. However sometimes the independent components can be useful, for instance, if you're doing to do further
|
||||
* EC maths on them.
|
||||
*
|
||||
@ -1028,7 +1028,7 @@ public class ECKey implements EncryptableItem {
|
||||
|
||||
/**
|
||||
* Exports the private key in the form used by Bitcoin Core's "dumpprivkey" and "importprivkey" commands. Use
|
||||
* the {@link org.bitcoinj.core.DumpedPrivateKey#toString()} method to get the string.
|
||||
* the {@link DumpedPrivateKey#toString()} method to get the string.
|
||||
*
|
||||
* @param params The network this key is intended for use on.
|
||||
* @return Private key bytes as a {@link DumpedPrivateKey}.
|
||||
|
@ -24,10 +24,12 @@ import org.bitcoinj.store.BlockStoreException;
|
||||
import org.bitcoinj.store.FullPrunedBlockStore;
|
||||
import org.bitcoinj.utils.*;
|
||||
import org.bitcoinj.wallet.Wallet;
|
||||
import org.bitcoinj.wallet.WalletExtension;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@ -59,7 +61,7 @@ public class FullPrunedBlockChain extends AbstractBlockChain {
|
||||
/**
|
||||
* Constructs a block chain connected to the given wallet and store. To obtain a {@link Wallet} you can construct
|
||||
* one from scratch, or you can deserialize a saved wallet from disk using
|
||||
* {@link Wallet#loadFromFile(java.io.File, WalletExtension...)}
|
||||
* {@link Wallet#loadFromFile(File, WalletExtension...)}
|
||||
*/
|
||||
public FullPrunedBlockChain(Context context, Wallet wallet, FullPrunedBlockStore blockStore) throws BlockStoreException {
|
||||
this(context, new ArrayList<Wallet>(), blockStore);
|
||||
@ -69,7 +71,7 @@ public class FullPrunedBlockChain extends AbstractBlockChain {
|
||||
/**
|
||||
* Constructs a block chain connected to the given wallet and store. To obtain a {@link Wallet} you can construct
|
||||
* one from scratch, or you can deserialize a saved wallet from disk using
|
||||
* {@link Wallet#loadFromFile(java.io.File, WalletExtension...)}
|
||||
* {@link Wallet#loadFromFile(File, WalletExtension...)}
|
||||
*/
|
||||
public FullPrunedBlockChain(NetworkParameters params, Wallet wallet, FullPrunedBlockStore blockStore) throws BlockStoreException {
|
||||
this(Context.getOrCreate(params), wallet, blockStore);
|
||||
|
@ -370,7 +370,7 @@ public abstract class Message {
|
||||
/**
|
||||
* Set the serializer for this message when deserialized by Java.
|
||||
*/
|
||||
private void readObject(java.io.ObjectInputStream in)
|
||||
private void readObject(ObjectInputStream in)
|
||||
throws IOException, ClassNotFoundException {
|
||||
in.defaultReadObject();
|
||||
if (null != params) {
|
||||
|
@ -286,7 +286,7 @@ public abstract class NetworkParameters {
|
||||
return addrSeeds;
|
||||
}
|
||||
|
||||
/** Returns discovery objects for seeds implementing the Cartographer protocol. See {@link org.bitcoinj.net.discovery.HttpDiscovery} for more info. */
|
||||
/** Returns discovery objects for seeds implementing the Cartographer protocol. See {@link HttpDiscovery} for more info. */
|
||||
public HttpDiscovery.Details[] getHttpSeeds() {
|
||||
return httpSeeds;
|
||||
}
|
||||
@ -317,7 +317,7 @@ public abstract class NetworkParameters {
|
||||
}
|
||||
|
||||
/**
|
||||
* First byte of a base58 encoded address. See {@link org.bitcoinj.core.LegacyAddress}. This is the same as acceptableAddressCodes[0] and
|
||||
* First byte of a base58 encoded address. See {@link LegacyAddress}. This is the same as acceptableAddressCodes[0] and
|
||||
* is the one used for "normal" addresses. Other types of address may be encountered with version codes found in
|
||||
* the acceptableAddressCodes array.
|
||||
*/
|
||||
@ -332,7 +332,7 @@ public abstract class NetworkParameters {
|
||||
return p2shHeader;
|
||||
}
|
||||
|
||||
/** First byte of a base58 encoded dumped private key. See {@link org.bitcoinj.core.DumpedPrivateKey}. */
|
||||
/** First byte of a base58 encoded dumped private key. See {@link DumpedPrivateKey}. */
|
||||
public int getDumpedPrivateKeyHeader() {
|
||||
return dumpedPrivateKeyHeader;
|
||||
}
|
||||
@ -369,7 +369,7 @@ public abstract class NetworkParameters {
|
||||
}
|
||||
|
||||
/**
|
||||
* The key used to sign {@link org.bitcoinj.core.AlertMessage}s. You can use {@link org.bitcoinj.core.ECKey#verify(byte[], byte[], byte[])} to verify
|
||||
* The key used to sign {@link AlertMessage}s. You can use {@link ECKey#verify(byte[], byte[], byte[])} to verify
|
||||
* signatures using it.
|
||||
*/
|
||||
public byte[] getAlertSigningKey() {
|
||||
|
@ -19,6 +19,9 @@ package org.bitcoinj.core;
|
||||
import com.google.common.base.*;
|
||||
import com.google.common.base.Objects;
|
||||
import org.bitcoinj.core.listeners.*;
|
||||
import org.bitcoinj.net.AbstractTimeoutHandler;
|
||||
import org.bitcoinj.net.NioClient;
|
||||
import org.bitcoinj.net.NioClientManager;
|
||||
import org.bitcoinj.net.StreamConnection;
|
||||
import org.bitcoinj.store.BlockStore;
|
||||
import org.bitcoinj.store.BlockStoreException;
|
||||
@ -36,6 +39,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.net.SocketAddress;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
@ -51,8 +55,8 @@ import static com.google.common.base.Preconditions.checkState;
|
||||
* handles low-level message (de)serialization.</p>
|
||||
*
|
||||
* <p>Note that timeouts are handled by the extended
|
||||
* {@link org.bitcoinj.net.AbstractTimeoutHandler} and timeout is automatically disabled (using
|
||||
* {@link org.bitcoinj.net.AbstractTimeoutHandler#setTimeoutEnabled(boolean)}) once the version
|
||||
* {@link AbstractTimeoutHandler} and timeout is automatically disabled (using
|
||||
* {@link AbstractTimeoutHandler#setTimeoutEnabled(boolean)}) once the version
|
||||
* handshake completes.</p>
|
||||
*/
|
||||
public class Peer extends PeerSocketHandler {
|
||||
@ -178,9 +182,9 @@ public class Peer extends PeerSocketHandler {
|
||||
*
|
||||
* <p>Note that this does <b>NOT</b> make a connection to the given remoteAddress, it only creates a handler for a
|
||||
* connection. If you want to create a one-off connection, create a Peer and pass it to
|
||||
* {@link org.bitcoinj.net.NioClientManager#openConnection(java.net.SocketAddress, StreamConnection)}
|
||||
* {@link NioClientManager#openConnection(SocketAddress, StreamConnection)}
|
||||
* or
|
||||
* {@link org.bitcoinj.net.NioClient#NioClient(java.net.SocketAddress, StreamConnection, int)}.</p>
|
||||
* {@link NioClient#NioClient(SocketAddress, StreamConnection, int)}.</p>
|
||||
*
|
||||
* <p>The remoteAddress provided should match the remote address of the peer which is being connected to, and is
|
||||
* used to keep track of which peers relayed transactions and offer more descriptive logging.</p>
|
||||
@ -190,15 +194,15 @@ public class Peer extends PeerSocketHandler {
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Construct a peer that reads/writes from the given block chain. Transactions stored in a {@link org.bitcoinj.core.TxConfidenceTable}
|
||||
* <p>Construct a peer that reads/writes from the given block chain. Transactions stored in a {@link TxConfidenceTable}
|
||||
* will have their confidence levels updated when a peer announces it, to reflect the greater likelyhood that
|
||||
* the transaction is valid.</p>
|
||||
*
|
||||
* <p>Note that this does <b>NOT</b> make a connection to the given remoteAddress, it only creates a handler for a
|
||||
* connection. If you want to create a one-off connection, create a Peer and pass it to
|
||||
* {@link org.bitcoinj.net.NioClientManager#openConnection(java.net.SocketAddress, StreamConnection)}
|
||||
* {@link NioClientManager#openConnection(SocketAddress, StreamConnection)}
|
||||
* or
|
||||
* {@link org.bitcoinj.net.NioClient#NioClient(java.net.SocketAddress, StreamConnection, int)}.</p>
|
||||
* {@link NioClient#NioClient(SocketAddress, StreamConnection, int)}.</p>
|
||||
*
|
||||
* <p>The remoteAddress provided should match the remote address of the peer which is being connected to, and is
|
||||
* used to keep track of which peers relayed transactions and offer more descriptive logging.</p>
|
||||
@ -209,15 +213,15 @@ public class Peer extends PeerSocketHandler {
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Construct a peer that reads/writes from the given block chain. Transactions stored in a {@link org.bitcoinj.core.TxConfidenceTable}
|
||||
* <p>Construct a peer that reads/writes from the given block chain. Transactions stored in a {@link TxConfidenceTable}
|
||||
* will have their confidence levels updated when a peer announces it, to reflect the greater likelyhood that
|
||||
* the transaction is valid.</p>
|
||||
*
|
||||
* <p>Note that this does <b>NOT</b> make a connection to the given remoteAddress, it only creates a handler for a
|
||||
* connection. If you want to create a one-off connection, create a Peer and pass it to
|
||||
* {@link org.bitcoinj.net.NioClientManager#openConnection(java.net.SocketAddress, StreamConnection)}
|
||||
* {@link NioClientManager#openConnection(SocketAddress, StreamConnection)}
|
||||
* or
|
||||
* {@link org.bitcoinj.net.NioClient#NioClient(java.net.SocketAddress, StreamConnection, int)}.</p>
|
||||
* {@link NioClient#NioClient(SocketAddress, StreamConnection, int)}.</p>
|
||||
*
|
||||
* <p>The remoteAddress provided should match the remote address of the peer which is being connected to, and is
|
||||
* used to keep track of which peers relayed transactions and offer more descriptive logging.</p>
|
||||
@ -253,9 +257,9 @@ public class Peer extends PeerSocketHandler {
|
||||
*
|
||||
* <p>Note that this does <b>NOT</b> make a connection to the given remoteAddress, it only creates a handler for a
|
||||
* connection. If you want to create a one-off connection, create a Peer and pass it to
|
||||
* {@link org.bitcoinj.net.NioClientManager#openConnection(java.net.SocketAddress, StreamConnection)}
|
||||
* {@link NioClientManager#openConnection(SocketAddress, StreamConnection)}
|
||||
* or
|
||||
* {@link org.bitcoinj.net.NioClient#NioClient(java.net.SocketAddress, StreamConnection, int)}.</p>
|
||||
* {@link NioClient#NioClient(SocketAddress, StreamConnection, int)}.</p>
|
||||
*
|
||||
* <p>The remoteAddress provided should match the remote address of the peer which is being connected to, and is
|
||||
* used to keep track of which peers relayed transactions and offer more descriptive logging.</p>
|
||||
@ -1559,7 +1563,7 @@ public class Peer extends PeerSocketHandler {
|
||||
/**
|
||||
* Sends the peer a ping message and returns a future that will be invoked when the pong is received back.
|
||||
* The future provides a number which is the number of milliseconds elapsed between the ping and the pong.
|
||||
* Once the pong is received the value returned by {@link org.bitcoinj.core.Peer#getLastPingTime()} is
|
||||
* Once the pong is received the value returned by {@link Peer#getLastPingTime()} is
|
||||
* updated.
|
||||
* @throws ProtocolException if the peer version is too low to support measurable pings.
|
||||
*/
|
||||
@ -1578,7 +1582,7 @@ public class Peer extends PeerSocketHandler {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the elapsed time of the last ping/pong cycle. If {@link org.bitcoinj.core.Peer#ping()} has never
|
||||
* Returns the elapsed time of the last ping/pong cycle. If {@link Peer#ping()} has never
|
||||
* been called or we did not hear back the "pong" message yet, returns {@link Long#MAX_VALUE}.
|
||||
*/
|
||||
public long getLastPingTime() {
|
||||
@ -1593,7 +1597,7 @@ public class Peer extends PeerSocketHandler {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a moving average of the last N ping/pong cycles. If {@link org.bitcoinj.core.Peer#ping()} has never
|
||||
* Returns a moving average of the last N ping/pong cycles. If {@link Peer#ping()} has never
|
||||
* been called or we did not hear back the "pong" message yet, returns {@link Long#MAX_VALUE}. The moving average
|
||||
* window is 5 buckets.
|
||||
*/
|
||||
|
@ -19,7 +19,7 @@ package org.bitcoinj.core;
|
||||
|
||||
/**
|
||||
* An interface which provides the information required to properly filter data downloaded from Peers.
|
||||
* Note that an implementer is responsible for calling {@link PeerGroup#recalculateFastCatchupAndFilter(org.bitcoinj.core.PeerGroup.FilterRecalculateMode)}
|
||||
* Note that an implementer is responsible for calling {@link PeerGroup#recalculateFastCatchupAndFilter(PeerGroup.FilterRecalculateMode)}
|
||||
* whenever a change occurs which effects the data provided via this interface.
|
||||
*/
|
||||
public interface PeerFilterProvider {
|
||||
|
@ -1334,7 +1334,7 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
|
||||
/**
|
||||
* Returns the number of currently connected peers. To be informed when this count changes, register a
|
||||
* {@link org.bitcoinj.core.listeners.PeerConnectionEventListener} and use the onPeerConnected/onPeerDisconnected methods.
|
||||
* {@link PeerConnectionEventListener} and use the onPeerConnected/onPeerDisconnected methods.
|
||||
*/
|
||||
public int numConnectedPeers() {
|
||||
return peers.size();
|
||||
@ -1346,7 +1346,7 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
*
|
||||
* @param address destination IP and port.
|
||||
* @return The newly created Peer object or null if the peer could not be connected.
|
||||
* Use {@link org.bitcoinj.core.Peer#getConnectionOpenFuture()} if you
|
||||
* Use {@link Peer#getConnectionOpenFuture()} if you
|
||||
* want a future which completes when the connection is open.
|
||||
*/
|
||||
@Nullable
|
||||
@ -1903,7 +1903,7 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
|
||||
/**
|
||||
* Returns a future that is triggered when the number of connected peers is equal to the given number of
|
||||
* peers. By using this with {@link org.bitcoinj.core.PeerGroup#getMaxConnections()} you can wait until the
|
||||
* peers. By using this with {@link PeerGroup#getMaxConnections()} you can wait until the
|
||||
* network is fully online. To block immediately, just call get() on the result. Just calls
|
||||
* {@link #waitForPeersOfVersion(int, long)} with zero as the protocol version.
|
||||
*
|
||||
@ -2009,7 +2009,7 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
* enough, {@link PeerGroup#broadcastTransaction(Transaction)} will wait until the minimum number is reached so
|
||||
* propagation across the network can be observed. If no value has been set using
|
||||
* {@link PeerGroup#setMinBroadcastConnections(int)} a default of 80% of whatever
|
||||
* {@link org.bitcoinj.core.PeerGroup#getMaxConnections()} returns is used.
|
||||
* {@link PeerGroup#getMaxConnections()} returns is used.
|
||||
*/
|
||||
public int getMinBroadcastConnections() {
|
||||
lock.lock();
|
||||
@ -2028,7 +2028,7 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link org.bitcoinj.core.PeerGroup#getMinBroadcastConnections()}.
|
||||
* See {@link PeerGroup#getMinBroadcastConnections()}.
|
||||
*/
|
||||
public void setMinBroadcastConnections(int value) {
|
||||
lock.lock();
|
||||
@ -2051,7 +2051,7 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
/**
|
||||
* <p>Given a transaction, sends it un-announced to one peer and then waits for it to be received back from other
|
||||
* peers. Once all connected peers have announced the transaction, the future available via the
|
||||
* {@link org.bitcoinj.core.TransactionBroadcast#future()} method will be completed. If anything goes
|
||||
* {@link TransactionBroadcast#future()} method will be completed. If anything goes
|
||||
* wrong the exception will be thrown when get() is called, or you can receive it via a callback on the
|
||||
* {@link ListenableFuture}. This method returns immediately, so if you want it to block just call get() on the
|
||||
* result.</p>
|
||||
@ -2063,7 +2063,7 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
* A good choice for proportion would be between 0.5 and 0.8 but if you want faster transmission during initial
|
||||
* bringup of the peer group you can lower it.</p>
|
||||
*
|
||||
* <p>The returned {@link org.bitcoinj.core.TransactionBroadcast} object can be used to get progress feedback,
|
||||
* <p>The returned {@link TransactionBroadcast} object can be used to get progress feedback,
|
||||
* which is calculated by watching the transaction propagate across the network and be announced by peers.</p>
|
||||
*/
|
||||
public TransactionBroadcast broadcastTransaction(final Transaction tx, final int minConnections) {
|
||||
@ -2114,7 +2114,7 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
|
||||
/**
|
||||
* Returns the period between pings for an individual peer. Setting this lower means more accurate and timely ping
|
||||
* times are available via {@link org.bitcoinj.core.Peer#getLastPingTime()} but it increases load on the
|
||||
* times are available via {@link Peer#getLastPingTime()} but it increases load on the
|
||||
* remote node. It defaults to {@link PeerGroup#DEFAULT_PING_INTERVAL_MSEC}.
|
||||
*/
|
||||
public long getPingIntervalMsec() {
|
||||
@ -2128,10 +2128,10 @@ public class PeerGroup implements TransactionBroadcaster {
|
||||
|
||||
/**
|
||||
* Sets the period between pings for an individual peer. Setting this lower means more accurate and timely ping
|
||||
* times are available via {@link org.bitcoinj.core.Peer#getLastPingTime()} but it increases load on the
|
||||
* times are available via {@link Peer#getLastPingTime()} but it increases load on the
|
||||
* remote node. It defaults to {@link PeerGroup#DEFAULT_PING_INTERVAL_MSEC}.
|
||||
* Setting the value to be smaller or equals 0 disables pinging entirely, although you can still request one yourself
|
||||
* using {@link org.bitcoinj.core.Peer#ping()}.
|
||||
* using {@link Peer#ping()}.
|
||||
*/
|
||||
public void setPingIntervalMsec(long pingIntervalMsec) {
|
||||
lock.lock();
|
||||
|
@ -838,7 +838,7 @@ public class Transaction extends ChildMessage {
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as {@link #addSignedInput(TransactionOutPoint, org.bitcoinj.script.Script, ECKey, org.bitcoinj.core.Transaction.SigHash, boolean)}
|
||||
* Same as {@link #addSignedInput(TransactionOutPoint, Script, ECKey, Transaction.SigHash, boolean)}
|
||||
* but defaults to {@link SigHash#ALL} and "false" for the anyoneCanPay flag. This is normally what you want.
|
||||
*/
|
||||
public TransactionInput addSignedInput(TransactionOutPoint prevOut, Script scriptPubKey, ECKey sigKey) throws ScriptException {
|
||||
@ -912,7 +912,7 @@ public class Transaction extends ChildMessage {
|
||||
|
||||
/**
|
||||
* Calculates a signature that is valid for being inserted into the input at the given position. This is simply
|
||||
* a wrapper around calling {@link Transaction#hashForSignature(int, byte[], org.bitcoinj.core.Transaction.SigHash, boolean)}
|
||||
* a wrapper around calling {@link Transaction#hashForSignature(int, byte[], Transaction.SigHash, boolean)}
|
||||
* followed by {@link ECKey#sign(Sha256Hash)} and then returning a new {@link TransactionSignature}. The key
|
||||
* must be usable for signing as-is: if the key is encrypted it must be decrypted first external to this method.
|
||||
*
|
||||
@ -932,7 +932,7 @@ public class Transaction extends ChildMessage {
|
||||
|
||||
/**
|
||||
* Calculates a signature that is valid for being inserted into the input at the given position. This is simply
|
||||
* a wrapper around calling {@link Transaction#hashForSignature(int, byte[], org.bitcoinj.core.Transaction.SigHash, boolean)}
|
||||
* a wrapper around calling {@link Transaction#hashForSignature(int, byte[], Transaction.SigHash, boolean)}
|
||||
* followed by {@link ECKey#sign(Sha256Hash)} and then returning a new {@link TransactionSignature}.
|
||||
*
|
||||
* @param inputIndex Which input to calculate the signature for, as an index.
|
||||
@ -951,7 +951,7 @@ public class Transaction extends ChildMessage {
|
||||
|
||||
/**
|
||||
* Calculates a signature that is valid for being inserted into the input at the given position. This is simply
|
||||
* a wrapper around calling {@link Transaction#hashForSignature(int, byte[], org.bitcoinj.core.Transaction.SigHash, boolean)}
|
||||
* a wrapper around calling {@link Transaction#hashForSignature(int, byte[], Transaction.SigHash, boolean)}
|
||||
* followed by {@link ECKey#sign(Sha256Hash)} and then returning a new {@link TransactionSignature}. The key
|
||||
* must be usable for signing as-is: if the key is encrypted it must be decrypted first external to this method.
|
||||
*
|
||||
@ -973,7 +973,7 @@ public class Transaction extends ChildMessage {
|
||||
|
||||
/**
|
||||
* Calculates a signature that is valid for being inserted into the input at the given position. This is simply
|
||||
* a wrapper around calling {@link Transaction#hashForSignature(int, byte[], org.bitcoinj.core.Transaction.SigHash, boolean)}
|
||||
* a wrapper around calling {@link Transaction#hashForSignature(int, byte[], Transaction.SigHash, boolean)}
|
||||
* followed by {@link ECKey#sign(Sha256Hash)} and then returning a new {@link TransactionSignature}.
|
||||
*
|
||||
* @param inputIndex Which input to calculate the signature for, as an index.
|
||||
@ -1221,7 +1221,7 @@ public class Transaction extends ChildMessage {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the confidence object for this transaction from the {@link org.bitcoinj.core.TxConfidenceTable}
|
||||
* Returns the confidence object for this transaction from the {@link TxConfidenceTable}
|
||||
* referenced by the implicit {@link Context}.
|
||||
*/
|
||||
public TransactionConfidence getConfidence() {
|
||||
@ -1229,7 +1229,7 @@ public class Transaction extends ChildMessage {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the confidence object for this transaction from the {@link org.bitcoinj.core.TxConfidenceTable}
|
||||
* Returns the confidence object for this transaction from the {@link TxConfidenceTable}
|
||||
* referenced by the given {@link Context}.
|
||||
*/
|
||||
public TransactionConfidence getConfidence(Context context) {
|
||||
@ -1237,7 +1237,7 @@ public class Transaction extends ChildMessage {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the confidence object for this transaction from the {@link org.bitcoinj.core.TxConfidenceTable}
|
||||
* Returns the confidence object for this transaction from the {@link TxConfidenceTable}
|
||||
*/
|
||||
public TransactionConfidence getConfidence(TxConfidenceTable table) {
|
||||
if (confidence == null)
|
||||
|
@ -17,12 +17,13 @@
|
||||
package org.bitcoinj.core;
|
||||
|
||||
import org.bitcoinj.script.Script;
|
||||
import org.bitcoinj.wallet.Wallet;
|
||||
import org.bitcoinj.wallet.WalletTransaction;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* This interface is used to abstract the {@link org.bitcoinj.wallet.Wallet} and the {@link org.bitcoinj.core.Transaction}
|
||||
* This interface is used to abstract the {@link Wallet} and the {@link Transaction}
|
||||
*/
|
||||
public interface TransactionBag {
|
||||
/** Returns true if this wallet contains a public key which hashes to the given hash. */
|
||||
|
@ -263,7 +263,7 @@ public class TransactionBroadcast {
|
||||
|
||||
/**
|
||||
* Sets the given callback for receiving progress values, which will run on the user thread. See
|
||||
* {@link org.bitcoinj.utils.Threading} for details. If the broadcast has already started then the callback will
|
||||
* {@link Threading} for details. If the broadcast has already started then the callback will
|
||||
* be invoked immediately with the current progress.
|
||||
*/
|
||||
public void setProgressCallback(ProgressCallback callback) {
|
||||
|
@ -18,7 +18,7 @@ package org.bitcoinj.core;
|
||||
|
||||
/**
|
||||
* A general interface which declares the ability to broadcast transactions. This is implemented
|
||||
* by {@link org.bitcoinj.core.PeerGroup}.
|
||||
* by {@link PeerGroup}.
|
||||
*/
|
||||
public interface TransactionBroadcaster {
|
||||
/** Broadcast the given transaction on the network */
|
||||
|
@ -22,6 +22,7 @@ import com.google.common.util.concurrent.*;
|
||||
|
||||
import org.bitcoinj.core.listeners.BlockChainListener;
|
||||
import org.bitcoinj.utils.*;
|
||||
import org.bitcoinj.wallet.CoinSelector;
|
||||
import org.bitcoinj.wallet.Wallet;
|
||||
|
||||
import javax.annotation.*;
|
||||
@ -56,9 +57,9 @@ import static com.google.common.base.Preconditions.*;
|
||||
* <p>Alternatively, you may know that the transaction is "dead", that is, one or more of its inputs have
|
||||
* been double spent and will never confirm unless there is another re-org.</p>
|
||||
*
|
||||
* <p>TransactionConfidence is updated via the {@link org.bitcoinj.core.TransactionConfidence#incrementDepthInBlocks()}
|
||||
* <p>TransactionConfidence is updated via the {@link TransactionConfidence#incrementDepthInBlocks()}
|
||||
* method to ensure the block depth is up to date.</p>
|
||||
* To make a copy that won't be changed, use {@link org.bitcoinj.core.TransactionConfidence#duplicate()}.
|
||||
* To make a copy that won't be changed, use {@link TransactionConfidence#duplicate()}.
|
||||
*/
|
||||
public class TransactionConfidence {
|
||||
|
||||
@ -88,7 +89,7 @@ public class TransactionConfidence {
|
||||
* announced and is considered valid by the network. A pending transaction will be announced if the containing
|
||||
* wallet has been attached to a live {@link PeerGroup} using {@link PeerGroup#addWallet(Wallet)}.
|
||||
* You can estimate how likely the transaction is to be included by connecting to a bunch of nodes then measuring
|
||||
* how many announce it, using {@link org.bitcoinj.core.TransactionConfidence#numBroadcastPeers()}.
|
||||
* how many announce it, using {@link TransactionConfidence#numBroadcastPeers()}.
|
||||
* Or if you saw it from a trusted peer, you can assume it's valid and will get mined sooner or later as well.
|
||||
*/
|
||||
PENDING(2),
|
||||
@ -165,7 +166,7 @@ public class TransactionConfidence {
|
||||
/** An enum that describes why a transaction confidence listener is being invoked (i.e. the class of change). */
|
||||
enum ChangeReason {
|
||||
/**
|
||||
* Occurs when the type returned by {@link org.bitcoinj.core.TransactionConfidence#getConfidenceType()}
|
||||
* Occurs when the type returned by {@link TransactionConfidence#getConfidenceType()}
|
||||
* has changed. For example, if a PENDING transaction changes to BUILDING or DEAD, then this reason will
|
||||
* be given. It's a high level summary.
|
||||
*/
|
||||
@ -464,7 +465,7 @@ public class TransactionConfidence {
|
||||
/**
|
||||
* The source of a transaction tries to identify where it came from originally. For instance, did we download it
|
||||
* from the peer to peer network, or make it ourselves, or receive it via Bluetooth, or import it from another app,
|
||||
* and so on. This information is useful for {@link org.bitcoinj.wallet.CoinSelector} implementations to risk analyze
|
||||
* and so on. This information is useful for {@link CoinSelector} implementations to risk analyze
|
||||
* transactions and decide when to spend them.
|
||||
*/
|
||||
public synchronized Source getSource() {
|
||||
@ -474,7 +475,7 @@ public class TransactionConfidence {
|
||||
/**
|
||||
* The source of a transaction tries to identify where it came from originally. For instance, did we download it
|
||||
* from the peer to peer network, or make it ourselves, or receive it via Bluetooth, or import it from another app,
|
||||
* and so on. This information is useful for {@link org.bitcoinj.wallet.CoinSelector} implementations to risk analyze
|
||||
* and so on. This information is useful for {@link CoinSelector} implementations to risk analyze
|
||||
* transactions and decide when to spend them.
|
||||
*/
|
||||
public synchronized void setSource(Source source) {
|
||||
|
@ -288,7 +288,7 @@ public class TransactionInput extends ChildMessage {
|
||||
|
||||
/**
|
||||
* Alias for getOutpoint().getConnectedRedeemData(keyBag)
|
||||
* @see TransactionOutPoint#getConnectedRedeemData(org.bitcoinj.wallet.KeyBag)
|
||||
* @see TransactionOutPoint#getConnectedRedeemData(KeyBag)
|
||||
*/
|
||||
@Nullable
|
||||
public RedeemData getConnectedRedeemData(KeyBag keyBag) throws ScriptException {
|
||||
|
@ -130,7 +130,7 @@ public class TransactionOutPoint extends ChildMessage {
|
||||
|
||||
/**
|
||||
* Returns the ECKey identified in the connected output, for either P2PKH scripts or P2PK scripts.
|
||||
* For P2SH scripts you can use {@link #getConnectedRedeemData(org.bitcoinj.wallet.KeyBag)} and then get the
|
||||
* For P2SH scripts you can use {@link #getConnectedRedeemData(KeyBag)} and then get the
|
||||
* key from RedeemData.
|
||||
* If the script form cannot be understood, throws ScriptException.
|
||||
*
|
||||
|
@ -204,7 +204,7 @@ public class TransactionOutput extends ChildMessage {
|
||||
* so we call them "dust outputs" and they're made non standard. The choice of one third is somewhat arbitrary and
|
||||
* may change in future.</p>
|
||||
*
|
||||
* <p>You probably should use {@link org.bitcoinj.core.TransactionOutput#getMinNonDustValue()} which uses
|
||||
* <p>You probably should use {@link TransactionOutput#getMinNonDustValue()} which uses
|
||||
* a safe fee-per-kb by default.</p>
|
||||
*
|
||||
* @param feePerKb The fee required per kilobyte. Note that this is the same as Bitcoin Core's -minrelaytxfee * 3
|
||||
|
@ -131,7 +131,7 @@ public class TxConfidenceTable {
|
||||
|
||||
/**
|
||||
* Called by peers when they see a transaction advertised in an "inv" message. It passes the data on to the relevant
|
||||
* {@link org.bitcoinj.core.TransactionConfidence} object, creating it if needed.
|
||||
* {@link TransactionConfidence} object, creating it if needed.
|
||||
*
|
||||
* @return the number of peers that have now announced this hash (including the caller)
|
||||
*/
|
||||
|
@ -16,13 +16,15 @@
|
||||
|
||||
package org.bitcoinj.core;
|
||||
|
||||
import org.bitcoinj.store.FullPrunedBlockStore;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A UTXOProvider encapsulates functionality for returning unspent transaction outputs,
|
||||
* for use by the wallet or other code that crafts spends.
|
||||
*
|
||||
* <p>A {@link org.bitcoinj.store.FullPrunedBlockStore} is an internal implementation within bitcoinj.</p>
|
||||
* <p>A {@link FullPrunedBlockStore} is an internal implementation within bitcoinj.</p>
|
||||
*/
|
||||
public interface UTXOProvider {
|
||||
/**
|
||||
|
@ -17,6 +17,8 @@
|
||||
package org.bitcoinj.core;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import org.bitcoinj.net.discovery.HttpDiscovery;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
@ -28,7 +30,7 @@ import java.util.List;
|
||||
* {@link GetUTXOsMessage} ("getutxos"). Note that both this message and the query that generates it are not
|
||||
* supported by Bitcoin Core. An implementation is available in <a href="https://github.com/bitcoinxt/bitcoinxt">Bitcoin XT</a>,
|
||||
* a patch set on top of Core. Thus if you want to use it, you must find some XT peers to connect to. This can be done
|
||||
* using a {@link org.bitcoinj.net.discovery.HttpDiscovery} class combined with an HTTP/Cartographer seed.</p>
|
||||
* using a {@link HttpDiscovery} class combined with an HTTP/Cartographer seed.</p>
|
||||
*
|
||||
* <p>The getutxos/utxos protocol is defined in <a href="https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki">BIP 65</a>.
|
||||
* In that document you can find a discussion of the security of this protocol (briefly, there is none). Because the
|
||||
|
@ -60,7 +60,7 @@ public class Utils {
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* The regular {@link java.math.BigInteger#toByteArray()} includes the sign bit of the number and
|
||||
* The regular {@link BigInteger#toByteArray()} includes the sign bit of the number and
|
||||
* might result in an extra byte addition. This method removes this extra byte.
|
||||
* </p>
|
||||
* <p>
|
||||
|
@ -17,6 +17,7 @@
|
||||
package org.bitcoinj.core.listeners;
|
||||
|
||||
import org.bitcoinj.core.*;
|
||||
import org.bitcoinj.utils.Threading;
|
||||
|
||||
import javax.annotation.*;
|
||||
import java.util.*;
|
||||
@ -33,7 +34,7 @@ public interface GetDataEventListener {
|
||||
* items as possible which appear in the {@link GetDataMessage}, or null if you're not interested in responding.</p>
|
||||
*
|
||||
* <p>Note that this will never be called if registered with any executor other than
|
||||
* {@link org.bitcoinj.utils.Threading#SAME_THREAD}</p>
|
||||
* {@link Threading#SAME_THREAD}</p>
|
||||
*/
|
||||
@Nullable
|
||||
List<Message> getData(Peer peer, GetDataMessage m);
|
||||
|
@ -16,7 +16,10 @@
|
||||
|
||||
package org.bitcoinj.core.listeners;
|
||||
|
||||
import org.bitcoinj.core.AbstractBlockChain;
|
||||
import org.bitcoinj.core.Sha256Hash;
|
||||
import org.bitcoinj.core.StoredBlock;
|
||||
import org.bitcoinj.core.Transaction;
|
||||
import org.bitcoinj.core.VerificationException;
|
||||
|
||||
/**
|
||||
@ -26,8 +29,8 @@ public interface NewBestBlockListener {
|
||||
/**
|
||||
* Called when a new block on the best chain is seen, after relevant
|
||||
* transactions are extracted and sent to us via either
|
||||
* {@link TransactionReceivedInBlockListener#receiveFromBlock(org.bitcoinj.core.Transaction, StoredBlock, org.bitcoinj.core.AbstractBlockChain.NewBlockType, int)}
|
||||
* or {@link TransactionReceivedInBlockListener#notifyTransactionIsInBlock(org.bitcoinj.core.Sha256Hash, StoredBlock, org.bitcoinj.core.AbstractBlockChain.NewBlockType, int)}.
|
||||
* {@link TransactionReceivedInBlockListener#receiveFromBlock(Transaction, StoredBlock, AbstractBlockChain.NewBlockType, int)}
|
||||
* or {@link TransactionReceivedInBlockListener#notifyTransactionIsInBlock(Sha256Hash, StoredBlock, AbstractBlockChain.NewBlockType, int)}.
|
||||
* If this block is causing a re-organise to a new chain, this method is NOT
|
||||
* called even though the block may be the new best block: your reorganize
|
||||
* implementation is expected to do whatever would normally be done do for a
|
||||
|
@ -17,6 +17,7 @@
|
||||
package org.bitcoinj.core.listeners;
|
||||
|
||||
import org.bitcoinj.core.*;
|
||||
import org.bitcoinj.utils.Threading;
|
||||
|
||||
/**
|
||||
* <p>Implementors can listen to events like blocks being downloaded/transactions being broadcast/connect/disconnects,
|
||||
@ -32,7 +33,7 @@ public interface PreMessageReceivedEventListener {
|
||||
* callback is passed as "m" to the next, forming a chain.</p>
|
||||
*
|
||||
* <p>Note that this will never be called if registered with any executor other than
|
||||
* {@link org.bitcoinj.utils.Threading#SAME_THREAD}</p>
|
||||
* {@link Threading#SAME_THREAD}</p>
|
||||
*/
|
||||
Message onPreMessageReceived(Peer peer, Message m);
|
||||
}
|
||||
|
@ -17,6 +17,8 @@
|
||||
package org.bitcoinj.core.listeners;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bitcoinj.core.BlockChain;
|
||||
import org.bitcoinj.core.StoredBlock;
|
||||
import org.bitcoinj.core.VerificationException;
|
||||
|
||||
@ -26,7 +28,7 @@ import org.bitcoinj.core.VerificationException;
|
||||
public interface ReorganizeListener {
|
||||
|
||||
/**
|
||||
* Called by the {@link org.bitcoinj.core.BlockChain} when the best chain
|
||||
* Called by the {@link BlockChain} when the best chain
|
||||
* (representing total work done) has changed. In this case,
|
||||
* we need to go through our transactions and find out if any have become invalid. It's possible for our balance
|
||||
* to go down in this case: money we thought we had can suddenly vanish if the rest of the network agrees it
|
||||
|
@ -16,13 +16,14 @@
|
||||
|
||||
package org.bitcoinj.crypto;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.google.common.primitives.Ints;
|
||||
|
||||
/**
|
||||
* <p>This is just a wrapper for the i (child number) as per BIP 32 with a boolean getter for the most significant bit
|
||||
* and a getter for the actual 0-based child number. A {@link java.util.List} of these forms a <i>path</i> through a
|
||||
* and a getter for the actual 0-based child number. A {@link List} of these forms a <i>path</i> through a
|
||||
* {@link DeterministicHierarchy}. This class is immutable.
|
||||
*/
|
||||
public class ChildNumber implements Comparable<ChildNumber> {
|
||||
|
@ -338,7 +338,7 @@ public class DeterministicKey extends ECKey {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this keys {@link org.bitcoinj.crypto.KeyCrypter} <b>or</b> the keycrypter of its parent key.
|
||||
* Returns this keys {@link KeyCrypter} <b>or</b> the keycrypter of its parent key.
|
||||
*/
|
||||
@Override @Nullable
|
||||
public KeyCrypter getKeyCrypter() {
|
||||
@ -559,7 +559,7 @@ public class DeterministicKey extends ECKey {
|
||||
|
||||
/**
|
||||
* The creation time of a deterministic key is equal to that of its parent, unless this key is the root of a tree
|
||||
* in which case the time is stored alongside the key as per normal, see {@link org.bitcoinj.core.ECKey#getCreationTimeSeconds()}.
|
||||
* in which case the time is stored alongside the key as per normal, see {@link ECKey#getCreationTimeSeconds()}.
|
||||
*/
|
||||
@Override
|
||||
public long getCreationTimeSeconds() {
|
||||
|
@ -22,7 +22,7 @@ import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Provides a uniform way to access something that can be optionally encrypted with a
|
||||
* {@link org.bitcoinj.crypto.KeyCrypter}, yielding an {@link org.bitcoinj.crypto.EncryptedData}, and
|
||||
* {@link KeyCrypter}, yielding an {@link EncryptedData}, and
|
||||
* which can have a creation time associated with it.
|
||||
*/
|
||||
public interface EncryptableItem {
|
||||
|
@ -26,7 +26,7 @@ import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
|
||||
/**
|
||||
* A TransactionSignature wraps an {@link org.bitcoinj.core.ECKey.ECDSASignature} and adds methods for handling
|
||||
* A TransactionSignature wraps an {@link ECKey.ECDSASignature} and adds methods for handling
|
||||
* the additional SIGHASH mode byte that is used.
|
||||
*/
|
||||
public class TransactionSignature extends ECKey.ECDSASignature {
|
||||
|
@ -27,7 +27,7 @@ import java.security.KeyStoreException;
|
||||
|
||||
/**
|
||||
* An implementation of TrustStoreLoader handles fetching a KeyStore from the operating system, a file, etc. It's
|
||||
* necessary because the Java {@link java.security.KeyStore} abstraction is not completely seamless and for example
|
||||
* necessary because the Java {@link KeyStore} abstraction is not completely seamless and for example
|
||||
* we sometimes need slightly different techniques to load the key store on different versions of Android, MacOS,
|
||||
* Windows, etc.
|
||||
*/
|
||||
|
@ -17,6 +17,7 @@
|
||||
package org.bitcoinj.crypto;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import org.bitcoinj.protocols.payments.PaymentSession;
|
||||
import org.spongycastle.asn1.ASN1ObjectIdentifier;
|
||||
import org.spongycastle.asn1.ASN1String;
|
||||
import org.spongycastle.asn1.x500.AttributeTypeAndValue;
|
||||
@ -38,7 +39,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* X509Utils provides tools for working with X.509 certificates and keystores, as used in the BIP 70 payment protocol.
|
||||
* For more details on this, see {@link org.bitcoinj.protocols.payments.PaymentSession}, the article "Working with
|
||||
* For more details on this, see {@link PaymentSession}, the article "Working with
|
||||
* the payment protocol" on the bitcoinj website, or the Bitcoin developer guide.
|
||||
*/
|
||||
public class X509Utils {
|
||||
|
@ -56,7 +56,7 @@ import static com.google.common.base.Preconditions.*;
|
||||
* means doing potentially blocking file IO, generating keys and other potentially intensive operations. By running it
|
||||
* on a background thread, there's no risk of accidentally causing UI lag.</p>
|
||||
*
|
||||
* <p>Note that {@link #awaitRunning()} can throw an unchecked {@link java.lang.IllegalStateException}
|
||||
* <p>Note that {@link #awaitRunning()} can throw an unchecked {@link IllegalStateException}
|
||||
* if anything goes wrong during startup - you should probably handle it and use {@link Exception#getCause()} to figure
|
||||
* out what went wrong more precisely. Same thing if you just use the {@link #startAsync()} method.</p>
|
||||
*/
|
||||
|
@ -20,15 +20,16 @@ import com.google.common.collect.Lists;
|
||||
import org.bitcoinj.core.BloomFilter;
|
||||
import org.bitcoinj.core.PeerFilterProvider;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.bitcoinj.core.PeerGroup;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
// This code is unit tested by the PeerGroup tests.
|
||||
|
||||
/**
|
||||
* <p>A reusable object that will calculate, given a list of {@link org.bitcoinj.core.PeerFilterProvider}s, a merged
|
||||
* {@link org.bitcoinj.core.BloomFilter} and earliest key time for all of them.
|
||||
* Used by the {@link org.bitcoinj.core.PeerGroup} class internally.</p>
|
||||
* <p>A reusable object that will calculate, given a list of {@link PeerFilterProvider}s, a merged
|
||||
* {@link BloomFilter} and earliest key time for all of them.
|
||||
* Used by the {@link PeerGroup} class internally.</p>
|
||||
*
|
||||
* <p>Thread safety: threading here can be complicated. Each filter provider is given a begin event, which may acquire
|
||||
* a lock (and is guaranteed to receive an end event). This class is mostly thread unsafe and is meant to be used from a
|
||||
|
@ -22,7 +22,7 @@ import java.math.BigInteger;
|
||||
|
||||
/**
|
||||
* Network parameters used by the bitcoinj unit tests (and potentially your own). This lets you solve a block using
|
||||
* {@link org.bitcoinj.core.Block#solve()} by setting difficulty to the easiest possible.
|
||||
* {@link Block#solve()} by setting difficulty to the easiest possible.
|
||||
*/
|
||||
public class UnitTestParams extends AbstractBitcoinNetParams {
|
||||
public static final int UNITNET_MAJORITY_WINDOW = 8;
|
||||
|
@ -47,7 +47,7 @@ public interface IPaymentChannelClient {
|
||||
* intending to reopen the channel later. There is likely little reason to use this in a stateless protocol.</p>
|
||||
*
|
||||
* <p>Note that this <b>MUST</b> still be called even after either
|
||||
* {@link org.bitcoinj.protocols.channels.IPaymentChannelClient.ClientConnection#destroyConnection(org.bitcoinj.protocols.channels.PaymentChannelCloseException.CloseReason)} or
|
||||
* {@link IPaymentChannelClient.ClientConnection#destroyConnection(PaymentChannelCloseException.CloseReason)} or
|
||||
* {@link IPaymentChannelClient#settle()} is called, to actually handle the connection close logic.</p>
|
||||
*/
|
||||
void connectionClosed();
|
||||
@ -56,7 +56,7 @@ public interface IPaymentChannelClient {
|
||||
* <p>Settles the channel, notifying the server it can broadcast the most recent payment transaction.</p>
|
||||
*
|
||||
* <p>Note that this only generates a CLOSE message for the server and calls
|
||||
* {@link org.bitcoinj.protocols.channels.IPaymentChannelClient.ClientConnection#destroyConnection(org.bitcoinj.protocols.channels.PaymentChannelCloseException.CloseReason)}
|
||||
* {@link IPaymentChannelClient.ClientConnection#destroyConnection(PaymentChannelCloseException.CloseReason)}
|
||||
* to settle the connection, it does not actually handle connection close logic, and
|
||||
* {@link PaymentChannelClient#connectionClosed()} must still be called after the connection fully settles.</p>
|
||||
*
|
||||
@ -103,25 +103,25 @@ public interface IPaymentChannelClient {
|
||||
* however the order of messages must be preserved.</p>
|
||||
*
|
||||
* <p>If the send fails, no exception should be thrown, however
|
||||
* {@link org.bitcoinj.protocols.channels.PaymentChannelClient#connectionClosed()} should be called immediately. In the case of messages which
|
||||
* {@link PaymentChannelClient#connectionClosed()} should be called immediately. In the case of messages which
|
||||
* are a part of initialization, initialization will simply fail and the refund transaction will be broadcasted
|
||||
* when it unlocks (if necessary). In the case of a payment message, the payment will be lost however if the
|
||||
* channel is resumed it will begin again from the channel value <i>after</i> the failed payment.</p>
|
||||
*
|
||||
* <p>Called while holding a lock on the {@link org.bitcoinj.protocols.channels.PaymentChannelClient} object - be careful about reentrancy</p>
|
||||
* <p>Called while holding a lock on the {@link PaymentChannelClient} object - be careful about reentrancy</p>
|
||||
*/
|
||||
void sendToServer(Protos.TwoWayChannelMessage msg);
|
||||
|
||||
/**
|
||||
* <p>Requests that the connection to the server be closed. For stateless protocols, note that after this call,
|
||||
* no more messages should be received from the server and this object is no longer usable. A
|
||||
* {@link org.bitcoinj.protocols.channels.PaymentChannelClient#connectionClosed()} event should be generated immediately after this call.</p>
|
||||
* {@link PaymentChannelClient#connectionClosed()} event should be generated immediately after this call.</p>
|
||||
*
|
||||
* <p>Called while holding a lock on the {@link org.bitcoinj.protocols.channels.PaymentChannelClient} object - be careful about reentrancy</p>
|
||||
* <p>Called while holding a lock on the {@link PaymentChannelClient} object - be careful about reentrancy</p>
|
||||
*
|
||||
* @param reason The reason for the closure, see the individual values for more details.
|
||||
* It is usually safe to ignore this and treat any value below
|
||||
* {@link org.bitcoinj.protocols.channels.PaymentChannelCloseException.CloseReason#CLIENT_REQUESTED_CLOSE} as "unrecoverable error" and all others as
|
||||
* {@link PaymentChannelCloseException.CloseReason#CLIENT_REQUESTED_CLOSE} as "unrecoverable error" and all others as
|
||||
* "try again once and see if it works then"
|
||||
*/
|
||||
void destroyConnection(PaymentChannelCloseException.CloseReason reason);
|
||||
@ -129,7 +129,7 @@ public interface IPaymentChannelClient {
|
||||
|
||||
/**
|
||||
* <p>Queries if the expire time proposed by server is acceptable. If {@code false} is return the channel
|
||||
* will be closed with a {@link org.bitcoinj.protocols.channels.PaymentChannelCloseException.CloseReason#TIME_WINDOW_UNACCEPTABLE}.</p>
|
||||
* will be closed with a {@link PaymentChannelCloseException.CloseReason#TIME_WINDOW_UNACCEPTABLE}.</p>
|
||||
* @param expireTime The time, in seconds, when this channel will be closed by the server. Note this is in absolute time, i.e. seconds since 1970-01-01T00:00:00.
|
||||
* @return {@code true} if the proposed time is acceptable {@code false} otherwise.
|
||||
*/
|
||||
@ -137,10 +137,10 @@ public interface IPaymentChannelClient {
|
||||
|
||||
/**
|
||||
* <p>Indicates the channel has been successfully opened and
|
||||
* {@link org.bitcoinj.protocols.channels.PaymentChannelClient#incrementPayment(Coin)}
|
||||
* {@link PaymentChannelClient#incrementPayment(Coin)}
|
||||
* may be called at will.</p>
|
||||
*
|
||||
* <p>Called while holding a lock on the {@link org.bitcoinj.protocols.channels.PaymentChannelClient}
|
||||
* <p>Called while holding a lock on the {@link PaymentChannelClient}
|
||||
* object - be careful about reentrancy</p>
|
||||
*
|
||||
* @param wasInitiated If true, the channel is newly opened. If false, it was resumed.
|
||||
@ -168,7 +168,7 @@ public interface IPaymentChannelClient {
|
||||
/**
|
||||
* The time in seconds, relative to now, on how long this channel should be kept open. Note that is is
|
||||
* a proposal to the server. The server may in turn propose something different.
|
||||
* See {@link org.bitcoinj.protocols.channels.IPaymentChannelClient.ClientConnection#acceptExpireTime(long)}
|
||||
* See {@link IPaymentChannelClient.ClientConnection#acceptExpireTime(long)}
|
||||
*
|
||||
*/
|
||||
long timeWindow();
|
||||
|
@ -536,7 +536,7 @@ public class PaymentChannelClient implements IPaymentChannelClient {
|
||||
* intending to reopen the channel later. There is likely little reason to use this in a stateless protocol.</p>
|
||||
*
|
||||
* <p>Note that this <b>MUST</b> still be called even after either
|
||||
* {@link org.bitcoinj.protocols.channels.IPaymentChannelClient.ClientConnection#destroyConnection(org.bitcoinj.protocols.channels.PaymentChannelCloseException.CloseReason)} or
|
||||
* {@link IPaymentChannelClient.ClientConnection#destroyConnection(PaymentChannelCloseException.CloseReason)} or
|
||||
* {@link PaymentChannelClient#settle()} is called, to actually handle the connection close logic.</p>
|
||||
*/
|
||||
@Override
|
||||
@ -556,7 +556,7 @@ public class PaymentChannelClient implements IPaymentChannelClient {
|
||||
* payment transaction.</p>
|
||||
*
|
||||
* <p>Note that this only generates a CLOSE message for the server and calls
|
||||
* {@link org.bitcoinj.protocols.channels.IPaymentChannelClient.ClientConnection#destroyConnection(org.bitcoinj.protocols.channels.PaymentChannelCloseException.CloseReason)} to settle the connection, it does not
|
||||
* {@link IPaymentChannelClient.ClientConnection#destroyConnection(PaymentChannelCloseException.CloseReason)} to settle the connection, it does not
|
||||
* actually handle connection close logic, and {@link PaymentChannelClient#connectionClosed()} must still be called
|
||||
* after the connection fully closes.</p>
|
||||
*
|
||||
|
@ -50,7 +50,7 @@ public class PaymentChannelClientConnection {
|
||||
/**
|
||||
* Attempts to open a new connection to and open a payment channel with the given host and port, blocking until the
|
||||
* connection is open. The server is requested to keep the channel open for
|
||||
* {@link org.bitcoinj.protocols.channels.PaymentChannelClient#DEFAULT_TIME_WINDOW}
|
||||
* {@link PaymentChannelClient#DEFAULT_TIME_WINDOW}
|
||||
* seconds. If the server proposes a longer time the channel will be closed.
|
||||
*
|
||||
* @param server The host/port pair where the server is listening.
|
||||
@ -75,7 +75,7 @@ public class PaymentChannelClientConnection {
|
||||
/**
|
||||
* Attempts to open a new connection to and open a payment channel with the given host and port, blocking until the
|
||||
* connection is open. The server is requested to keep the channel open for
|
||||
* {@link org.bitcoinj.protocols.channels.PaymentChannelClient#DEFAULT_TIME_WINDOW} seconds.
|
||||
* {@link PaymentChannelClient#DEFAULT_TIME_WINDOW} seconds.
|
||||
* If the server proposes a longer time the channel will be closed.
|
||||
*
|
||||
* @param server The host/port pair where the server is listening.
|
||||
@ -191,7 +191,7 @@ public class PaymentChannelClientConnection {
|
||||
*
|
||||
* <p>After this future completes successfully, you may call
|
||||
* {@link PaymentChannelClientConnection#incrementPayment(Coin)} or
|
||||
* {@link PaymentChannelClientConnection#incrementPayment(Coin, com.google.protobuf.ByteString, KeyParameter)} to
|
||||
* {@link PaymentChannelClientConnection#incrementPayment(Coin, ByteString, KeyParameter)} to
|
||||
* begin paying the server.</p>
|
||||
*/
|
||||
public ListenableFuture<PaymentChannelClientConnection> getChannelOpenFuture() {
|
||||
|
@ -60,7 +60,7 @@ import static com.google.common.base.Preconditions.*;
|
||||
* the given time (within a few hours), the channel must be closed or else the client will broadcast the refund
|
||||
* transaction and take back all the money once the expiry time is reached.</p>
|
||||
*
|
||||
* <p>To begin, the client calls {@link PaymentChannelClientState#initiate(KeyParameter, org.bitcoinj.protocols.channels.IPaymentChannelClient.ClientChannelProperties)}, which moves the channel into state
|
||||
* <p>To begin, the client calls {@link PaymentChannelClientState#initiate(KeyParameter, IPaymentChannelClient.ClientChannelProperties)}, which moves the channel into state
|
||||
* INITIATED and creates the initial multi-sig contract and refund transaction. If the wallet has insufficient funds an
|
||||
* exception will be thrown at this point. Once this is done, call
|
||||
* {@link PaymentChannelV1ClientState#getIncompleteRefundTransaction()} and pass the resultant transaction through to the
|
||||
@ -126,9 +126,9 @@ public abstract class PaymentChannelClientState {
|
||||
|
||||
/**
|
||||
* Creates a state object for a payment channel client. It is expected that you be ready to
|
||||
* {@link PaymentChannelClientState#initiate(KeyParameter, org.bitcoinj.protocols.channels.IPaymentChannelClient.ClientChannelProperties)} after construction (to avoid creating objects for channels which are
|
||||
* {@link PaymentChannelClientState#initiate(KeyParameter, IPaymentChannelClient.ClientChannelProperties)} after construction (to avoid creating objects for channels which are
|
||||
* not going to finish opening) and thus some parameters provided here are only used in
|
||||
* {@link PaymentChannelClientState#initiate(KeyParameter, org.bitcoinj.protocols.channels.IPaymentChannelClient.ClientChannelProperties)} to create the Multisig contract and refund transaction.
|
||||
* {@link PaymentChannelClientState#initiate(KeyParameter, IPaymentChannelClient.ClientChannelProperties)} to create the Multisig contract and refund transaction.
|
||||
*
|
||||
* @param wallet a wallet that contains at least the specified amount of value.
|
||||
* @param myKey a freshly generated private key for this channel.
|
||||
@ -383,7 +383,7 @@ public abstract class PaymentChannelClientState {
|
||||
|
||||
/**
|
||||
* Returns the fees that will be paid if the refund transaction has to be claimed because the server failed to settle
|
||||
* the channel properly. May only be called after {@link PaymentChannelClientState#initiate(KeyParameter, org.bitcoinj.protocols.channels.IPaymentChannelClient.ClientChannelProperties)}
|
||||
* the channel properly. May only be called after {@link PaymentChannelClientState#initiate(KeyParameter, IPaymentChannelClient.ClientChannelProperties)}
|
||||
*/
|
||||
public abstract Coin getRefundTxFees();
|
||||
|
||||
|
@ -34,7 +34,7 @@ public class PaymentChannelCloseException extends Exception {
|
||||
// Values after here indicate its probably possible to try reopening channel again
|
||||
|
||||
/**
|
||||
* <p>The {@link org.bitcoinj.protocols.channels.PaymentChannelClient#settle()} method was called or the
|
||||
* <p>The {@link PaymentChannelClient#settle()} 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 is settling and the payment
|
||||
* transaction (if any) will be broadcast. If the client attempts to open a new connection, a new channel will
|
||||
@ -43,7 +43,7 @@ public class PaymentChannelCloseException extends Exception {
|
||||
CLIENT_REQUESTED_CLOSE,
|
||||
|
||||
/**
|
||||
* <p>The {@link org.bitcoinj.protocols.channels.PaymentChannelServer#close()} method was called or server
|
||||
* <p>The {@link PaymentChannelServer#close()} method was called or server
|
||||
* sent a CLOSE message.</p>
|
||||
*
|
||||
* <p>This may occur if the server opts to close the connection for some reason, or automatically if the channel
|
||||
|
@ -595,7 +595,7 @@ public class PaymentChannelServer {
|
||||
* resume this channel in the future and stops generating messages for the client.</p>
|
||||
*
|
||||
* <p>Note that this <b>MUST</b> still be called even after either
|
||||
* {@link org.bitcoinj.protocols.channels.PaymentChannelServer.ServerConnection#destroyConnection(org.bitcoinj.protocols.channels.PaymentChannelCloseException.CloseReason)} or
|
||||
* {@link PaymentChannelServer.ServerConnection#destroyConnection(PaymentChannelCloseException.CloseReason)} or
|
||||
* {@link PaymentChannelServer#close()} is called to actually handle the connection close logic.</p>
|
||||
*/
|
||||
public void connectionClosed() {
|
||||
@ -638,7 +638,7 @@ public class PaymentChannelServer {
|
||||
|
||||
/**
|
||||
* <p>Closes the connection by generating a settle message for the client and calls
|
||||
* {@link org.bitcoinj.protocols.channels.PaymentChannelServer.ServerConnection#destroyConnection(org.bitcoinj.protocols.channels.PaymentChannelCloseException.CloseReason)}. Note that this does not broadcast
|
||||
* {@link PaymentChannelServer.ServerConnection#destroyConnection(PaymentChannelCloseException.CloseReason)}. Note that this does not broadcast
|
||||
* the payment transaction and the client may still resume the same channel if they reconnect</p>
|
||||
* <p>
|
||||
* <p>Note that {@link PaymentChannelServer#connectionClosed()} must still be called after the connection fully
|
||||
|
@ -73,9 +73,9 @@ public class PaymentChannelV1ClientState extends PaymentChannelClientState {
|
||||
|
||||
/**
|
||||
* Creates a state object for a payment channel client. It is expected that you be ready to
|
||||
* {@link PaymentChannelClientState#initiate(KeyParameter, org.bitcoinj.protocols.channels.IPaymentChannelClient.ClientChannelProperties)} after construction (to avoid creating objects for channels which are
|
||||
* {@link PaymentChannelClientState#initiate(KeyParameter, IPaymentChannelClient.ClientChannelProperties)} after construction (to avoid creating objects for channels which are
|
||||
* not going to finish opening) and thus some parameters provided here are only used in
|
||||
* {@link PaymentChannelClientState#initiate(KeyParameter, org.bitcoinj.protocols.channels.IPaymentChannelClient.ClientChannelProperties)} to create the Multisig contract and refund transaction.
|
||||
* {@link PaymentChannelClientState#initiate(KeyParameter, IPaymentChannelClient.ClientChannelProperties)} to create the Multisig contract and refund transaction.
|
||||
*
|
||||
* @param wallet a wallet that contains at least the specified amount of value.
|
||||
* @param myKey a freshly generated private key for this channel.
|
||||
|
@ -177,11 +177,11 @@ public class PaymentChannelV1ServerState extends PaymentChannelServerState {
|
||||
/**
|
||||
* <p>Closes this channel and broadcasts the highest value payment transaction on the network.</p>
|
||||
*
|
||||
* <p>This will set the state to {@link org.bitcoinj.protocols.channels.PaymentChannelServerState.State#CLOSED} if the transaction is successfully broadcast on the network.
|
||||
* If we fail to broadcast for some reason, the state is set to {@link org.bitcoinj.protocols.channels.PaymentChannelServerState.State#ERROR}.</p>
|
||||
* <p>This will set the state to {@link PaymentChannelServerState.State#CLOSED} if the transaction is successfully broadcast on the network.
|
||||
* If we fail to broadcast for some reason, the state is set to {@link PaymentChannelServerState.State#ERROR}.</p>
|
||||
*
|
||||
* <p>If the current state is before {@link org.bitcoinj.protocols.channels.PaymentChannelServerState.State#READY} (ie we have not finished initializing the channel), we
|
||||
* simply set the state to {@link org.bitcoinj.protocols.channels.PaymentChannelServerState.State#CLOSED} and let the client handle getting its refund transaction confirmed.
|
||||
* <p>If the current state is before {@link PaymentChannelServerState.State#READY} (ie we have not finished initializing the channel), we
|
||||
* simply set the state to {@link PaymentChannelServerState.State#CLOSED} and let the client handle getting its refund transaction confirmed.
|
||||
* </p>
|
||||
*
|
||||
* @param userKey The AES key to use for decryption of the private key. If null then no decryption is required.
|
||||
|
@ -43,8 +43,8 @@ public abstract class ServerConnectionEventHandler {
|
||||
* <p>Note that this does <i>NOT</i> actually broadcast the most recent payment transaction, which will be triggered
|
||||
* automatically when the channel times out by the {@link StoredPaymentChannelServerStates}, or manually by calling
|
||||
* {@link StoredPaymentChannelServerStates#closeChannel(StoredServerChannel)} with the channel returned by
|
||||
* {@link StoredPaymentChannelServerStates#getChannel(org.bitcoinj.core.Sha256Hash)} with the id provided in
|
||||
* {@link ServerConnectionEventHandler#channelOpen(org.bitcoinj.core.Sha256Hash)}</p>
|
||||
* {@link StoredPaymentChannelServerStates#getChannel(Sha256Hash)} with the id provided in
|
||||
* {@link ServerConnectionEventHandler#channelOpen(Sha256Hash)}</p>
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// The warning 'unchecked call to write(MessageType)' being suppressed here comes from the build()
|
||||
|
@ -88,7 +88,7 @@ public class StoredServerChannel {
|
||||
}
|
||||
|
||||
/**
|
||||
* If a handler is connected, call its {@link org.bitcoinj.protocols.channels.PaymentChannelServer#close()}
|
||||
* If a handler is connected, call its {@link PaymentChannelServer#close()}
|
||||
* method thus disconnecting the TCP connection.
|
||||
*/
|
||||
synchronized void closeConnectedHandler() {
|
||||
|
@ -54,7 +54,7 @@ public class PaymentProtocol {
|
||||
|
||||
/**
|
||||
* Create a payment request with one standard pay to address output. You may want to sign the request using
|
||||
* {@link #signPaymentRequest}. Use {@link org.bitcoin.protocols.payments.Protos.PaymentRequest.Builder#build} to get the actual payment
|
||||
* {@link #signPaymentRequest}. Use {@link Protos.PaymentRequest.Builder#build} to get the actual payment
|
||||
* request.
|
||||
*
|
||||
* @param params network parameters
|
||||
@ -74,7 +74,7 @@ public class PaymentProtocol {
|
||||
|
||||
/**
|
||||
* Create a payment request. You may want to sign the request using {@link #signPaymentRequest}. Use
|
||||
* {@link org.bitcoin.protocols.payments.Protos.PaymentRequest.Builder#build} to get the actual payment request.
|
||||
* {@link Protos.PaymentRequest.Builder#build} to get the actual payment request.
|
||||
*
|
||||
* @param params network parameters
|
||||
* @param outputs list of outputs to request coins to
|
||||
@ -157,7 +157,7 @@ public class PaymentProtocol {
|
||||
*
|
||||
* @param paymentRequest Payment request to verify.
|
||||
* @param trustStore KeyStore of trusted root certificate authorities.
|
||||
* @return verification data, or null if no PKI method was specified in the {@link org.bitcoin.protocols.payments.Protos.PaymentRequest}.
|
||||
* @return verification data, or null if no PKI method was specified in the {@link Protos.PaymentRequest}.
|
||||
* @throws PaymentProtocolException if payment request could not be verified.
|
||||
*/
|
||||
@Nullable
|
||||
|
@ -48,8 +48,8 @@ import java.util.concurrent.Callable;
|
||||
*
|
||||
* <ul>
|
||||
* <li>A {@link BitcoinURI} object that conforms to BIP 0072</li>
|
||||
* <li>A url where the {@link org.bitcoin.protocols.payments.Protos.PaymentRequest} can be fetched</li>
|
||||
* <li>Directly with a {@link org.bitcoin.protocols.payments.Protos.PaymentRequest} object</li>
|
||||
* <li>A url where the {@link Protos.PaymentRequest} can be fetched</li>
|
||||
* <li>Directly with a {@link Protos.PaymentRequest} object</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>If initialized with a BitcoinURI or a url, a network request is made for the payment request object and a
|
||||
@ -59,10 +59,10 @@ import java.util.concurrent.Callable;
|
||||
* amount and recipient are correct, perform any additional steps, and then construct a list of transactions to pass to
|
||||
* the sendPayment method.</p>
|
||||
*
|
||||
* <p>Call sendPayment with a list of transactions that will be broadcast. A {@link org.bitcoin.protocols.payments.Protos.Payment} message will be sent
|
||||
* <p>Call sendPayment with a list of transactions that will be broadcast. A {@link Protos.Payment} message will be sent
|
||||
* to the merchant if a payment url is provided in the PaymentRequest. NOTE: sendPayment does NOT broadcast the
|
||||
* transactions to the bitcoin network. Instead it returns a ListenableFuture that will be notified when a
|
||||
* {@link org.bitcoin.protocols.payments.Protos.PaymentACK} is received from the merchant. Typically a wallet will show the message to the user
|
||||
* {@link Protos.PaymentACK} is received from the merchant. Typically a wallet will show the message to the user
|
||||
* as a confirmation message that the payment is now "processing" or that an error occurred, and then broadcast the
|
||||
* tx itself later if needed.</p>
|
||||
*
|
||||
@ -83,7 +83,7 @@ public class PaymentSession {
|
||||
|
||||
/**
|
||||
* <p>Returns a future that will be notified with a PaymentSession object after it is fetched using the provided uri.
|
||||
* uri is a BIP-72-style BitcoinURI object that specifies where the {@link org.bitcoin.protocols.payments.Protos.PaymentRequest} object may
|
||||
* uri is a BIP-72-style BitcoinURI object that specifies where the {@link Protos.PaymentRequest} object may
|
||||
* be fetched in the r= parameter.</p>
|
||||
*
|
||||
* <p>If the payment request object specifies a PKI method, then the system trust store will be used to verify
|
||||
@ -96,7 +96,7 @@ public class PaymentSession {
|
||||
|
||||
/**
|
||||
* Returns a future that will be notified with a PaymentSession object after it is fetched using the provided uri.
|
||||
* uri is a BIP-72-style BitcoinURI object that specifies where the {@link org.bitcoin.protocols.payments.Protos.PaymentRequest} object may
|
||||
* uri is a BIP-72-style BitcoinURI object that specifies where the {@link Protos.PaymentRequest} object may
|
||||
* be fetched in the r= parameter.
|
||||
* If verifyPki is specified and the payment request object specifies a PKI method, then the system trust store will
|
||||
* be used to verify the signature provided by the payment request. An exception is thrown by the future if the
|
||||
@ -109,7 +109,7 @@ public class PaymentSession {
|
||||
|
||||
/**
|
||||
* Returns a future that will be notified with a PaymentSession object after it is fetched using the provided uri.
|
||||
* uri is a BIP-72-style BitcoinURI object that specifies where the {@link org.bitcoin.protocols.payments.Protos.PaymentRequest} object may
|
||||
* uri is a BIP-72-style BitcoinURI object that specifies where the {@link Protos.PaymentRequest} object may
|
||||
* be fetched in the r= parameter.
|
||||
* If verifyPki is specified and the payment request object specifies a PKI method, then the system trust store will
|
||||
* be used to verify the signature provided by the payment request. An exception is thrown by the future if the
|
||||
@ -130,7 +130,7 @@ public class PaymentSession {
|
||||
|
||||
/**
|
||||
* Returns a future that will be notified with a PaymentSession object after it is fetched using the provided url.
|
||||
* url is an address where the {@link org.bitcoin.protocols.payments.Protos.PaymentRequest} object may be fetched.
|
||||
* url is an address where the {@link Protos.PaymentRequest} object may be fetched.
|
||||
* If verifyPki is specified and the payment request object specifies a PKI method, then the system trust store will
|
||||
* be used to verify the signature provided by the payment request. An exception is thrown by the future if the
|
||||
* signature cannot be verified.
|
||||
@ -141,7 +141,7 @@ public class PaymentSession {
|
||||
|
||||
/**
|
||||
* Returns a future that will be notified with a PaymentSession object after it is fetched using the provided url.
|
||||
* url is an address where the {@link org.bitcoin.protocols.payments.Protos.PaymentRequest} object may be fetched.
|
||||
* url is an address where the {@link Protos.PaymentRequest} object may be fetched.
|
||||
* If the payment request object specifies a PKI method, then the system trust store will
|
||||
* be used to verify the signature provided by the payment request. An exception is thrown by the future if the
|
||||
* signature cannot be verified.
|
||||
@ -153,7 +153,7 @@ public class PaymentSession {
|
||||
|
||||
/**
|
||||
* Returns a future that will be notified with a PaymentSession object after it is fetched using the provided url.
|
||||
* url is an address where the {@link org.bitcoin.protocols.payments.Protos.PaymentRequest} object may be fetched.
|
||||
* url is an address where the {@link Protos.PaymentRequest} object may be fetched.
|
||||
* If the payment request object specifies a PKI method, then the system trust store will
|
||||
* be used to verify the signature provided by the payment request. An exception is thrown by the future if the
|
||||
* signature cannot be verified.
|
||||
@ -184,7 +184,7 @@ public class PaymentSession {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a PaymentSession from the provided {@link org.bitcoin.protocols.payments.Protos.PaymentRequest}.
|
||||
* Creates a PaymentSession from the provided {@link Protos.PaymentRequest}.
|
||||
* Verifies PKI by default.
|
||||
*/
|
||||
public PaymentSession(Protos.PaymentRequest request) throws PaymentProtocolException {
|
||||
@ -192,7 +192,7 @@ public class PaymentSession {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a PaymentSession from the provided {@link org.bitcoin.protocols.payments.Protos.PaymentRequest}.
|
||||
* Creates a PaymentSession from the provided {@link Protos.PaymentRequest}.
|
||||
* If verifyPki is true, also validates the signature and throws an exception if it fails.
|
||||
*/
|
||||
public PaymentSession(Protos.PaymentRequest request, boolean verifyPki) throws PaymentProtocolException {
|
||||
@ -200,7 +200,7 @@ public class PaymentSession {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a PaymentSession from the provided {@link org.bitcoin.protocols.payments.Protos.PaymentRequest}.
|
||||
* Creates a PaymentSession from the provided {@link Protos.PaymentRequest}.
|
||||
* If verifyPki is true, also validates the signature and throws an exception if it fails.
|
||||
* If trustStoreLoader is null, the system default trust store is used.
|
||||
*/
|
||||
|
@ -736,12 +736,12 @@ public class Script {
|
||||
|
||||
/**
|
||||
* Exposes the script interpreter. Normally you should not use this directly, instead use
|
||||
* {@link org.bitcoinj.core.TransactionInput#verify(org.bitcoinj.core.TransactionOutput)} or
|
||||
* {@link org.bitcoinj.script.Script#correctlySpends(org.bitcoinj.core.Transaction, long, Script)}. This method
|
||||
* {@link TransactionInput#verify(TransactionOutput)} or
|
||||
* {@link Script#correctlySpends(Transaction, long, Script)}. This method
|
||||
* is useful if you need more precise control or access to the final state of the stack. This interface is very
|
||||
* likely to change in future.
|
||||
*
|
||||
* @deprecated Use {@link #executeScript(org.bitcoinj.core.Transaction, long, org.bitcoinj.script.Script, java.util.LinkedList, java.util.Set)}
|
||||
* @deprecated Use {@link #executeScript(Transaction, long, Script, LinkedList, Set)}
|
||||
* instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@ -756,8 +756,8 @@ public class Script {
|
||||
|
||||
/**
|
||||
* Exposes the script interpreter. Normally you should not use this directly, instead use
|
||||
* {@link org.bitcoinj.core.TransactionInput#verify(org.bitcoinj.core.TransactionOutput)} or
|
||||
* {@link org.bitcoinj.script.Script#correctlySpends(org.bitcoinj.core.Transaction, long, Script)}. This method
|
||||
* {@link TransactionInput#verify(TransactionOutput)} or
|
||||
* {@link Script#correctlySpends(Transaction, long, Script)}. This method
|
||||
* is useful if you need more precise control or access to the final state of the stack. This interface is very
|
||||
* likely to change in future.
|
||||
*/
|
||||
@ -1520,7 +1520,7 @@ public class Script {
|
||||
* Accessing txContainingThis from another thread while this method runs results in undefined behavior.
|
||||
* @param scriptSigIndex The index in txContainingThis of the scriptSig (note: NOT the index of the scriptPubKey).
|
||||
* @param scriptPubKey The connected scriptPubKey containing the conditions needed to claim the value.
|
||||
* @deprecated Use {@link #correctlySpends(org.bitcoinj.core.Transaction, long, org.bitcoinj.script.Script, java.util.Set)}
|
||||
* @deprecated Use {@link #correctlySpends(Transaction, long, Script, Set)}
|
||||
* instead so that verification flags do not change as new verification options
|
||||
* are added.
|
||||
*/
|
||||
@ -1604,7 +1604,7 @@ public class Script {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link org.bitcoinj.script.Script.ScriptType}.
|
||||
* Get the {@link Script.ScriptType}.
|
||||
* @return The script type, or null if the script is of unknown type
|
||||
*/
|
||||
public @Nullable ScriptType getScriptType() {
|
||||
|
@ -23,6 +23,7 @@ import org.bitcoinj.core.Address;
|
||||
import org.bitcoinj.core.LegacyAddress;
|
||||
import org.bitcoinj.core.ECKey;
|
||||
import org.bitcoinj.core.SegwitAddress;
|
||||
import org.bitcoinj.core.Transaction;
|
||||
import org.bitcoinj.core.Utils;
|
||||
import org.bitcoinj.crypto.TransactionSignature;
|
||||
import org.bitcoinj.script.Script.ScriptType;
|
||||
@ -41,7 +42,7 @@ import static org.bitcoinj.script.ScriptOpCodes.*;
|
||||
|
||||
/**
|
||||
* <p>Tools for the construction of commonly used script types. You don't normally need this as it's hidden behind
|
||||
* convenience methods on {@link org.bitcoinj.core.Transaction}, but they are useful when working with the
|
||||
* convenience methods on {@link Transaction}, but they are useful when working with the
|
||||
* protocol at a lower level.</p>
|
||||
*/
|
||||
public class ScriptBuilder {
|
||||
|
@ -22,7 +22,7 @@ import java.util.Map;
|
||||
|
||||
/**
|
||||
* Various constants that define the assembly-like scripting language that forms part of the Bitcoin protocol.
|
||||
* See {@link org.bitcoinj.script.Script} for details. Also provides a method to convert them to a string.
|
||||
* See {@link Script} for details. Also provides a method to convert them to a string.
|
||||
*/
|
||||
public class ScriptOpCodes {
|
||||
// push value
|
||||
|
@ -34,7 +34,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
/**
|
||||
* <p>This signer may be used as a template for creating custom multisig transaction signers.</p>
|
||||
* <p>
|
||||
* Concrete implementations have to implement {@link #getSignature(org.bitcoinj.core.Sha256Hash, java.util.List)}
|
||||
* Concrete implementations have to implement {@link #getSignature(Sha256Hash, List)}
|
||||
* method returning a signature and a public key of the keypair used to created that signature.
|
||||
* It's up to custom implementation where to locate signatures: it may be a network connection,
|
||||
* some local API or something else.
|
||||
|
@ -31,16 +31,16 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* <p>{@link TransactionSigner} implementation for signing inputs using keys from provided {@link org.bitcoinj.wallet.KeyBag}.</p>
|
||||
* <p>{@link TransactionSigner} implementation for signing inputs using keys from provided {@link KeyBag}.</p>
|
||||
* <p>This signer doesn't create input scripts for tx inputs. Instead it expects inputs to contain scripts with
|
||||
* empty sigs and replaces one of the empty sigs with calculated signature.
|
||||
* </p>
|
||||
* <p>This signer is always implicitly added into every wallet and it is the first signer to be executed during tx
|
||||
* completion. As the first signer to create a signature, it stores derivation path of the signing key in a given
|
||||
* {@link org.bitcoinj.signers.TransactionSigner.ProposedTransaction} object that will be also passed then to the next signer in chain. This allows other
|
||||
* {@link TransactionSigner.ProposedTransaction} object that will be also passed then to the next signer in chain. This allows other
|
||||
* signers to use correct signing key for P2SH inputs, because all the keys involved in a single P2SH address have
|
||||
* the same derivation path.</p>
|
||||
* <p>This signer always uses {@link org.bitcoinj.core.Transaction.SigHash#ALL} signing mode.</p>
|
||||
* <p>This signer always uses {@link Transaction.SigHash#ALL} signing mode.</p>
|
||||
*/
|
||||
public class LocalTransactionSigner extends StatelessTransactionSigner {
|
||||
private static final Logger log = LoggerFactory.getLogger(LocalTransactionSigner.class);
|
||||
|
@ -28,7 +28,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* This transaction signer resolves missing signatures in accordance with the given {@link org.bitcoinj.wallet.Wallet.MissingSigsMode}.
|
||||
* This transaction signer resolves missing signatures in accordance with the given {@link Wallet.MissingSigsMode}.
|
||||
* If missingSigsMode is USE_OP_ZERO this signer does nothing assuming missing signatures are already presented in
|
||||
* scriptSigs as OP_0.
|
||||
* In MissingSigsMode.THROW mode this signer will throw an exception. It would be MissingSignatureException
|
||||
|
@ -20,6 +20,7 @@ import org.bitcoinj.core.Transaction;
|
||||
import org.bitcoinj.crypto.ChildNumber;
|
||||
import org.bitcoinj.script.Script;
|
||||
import org.bitcoinj.wallet.KeyBag;
|
||||
import org.bitcoinj.wallet.Wallet;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -29,7 +30,7 @@ import java.util.Map;
|
||||
* <p>Implementations of this interface are intended to sign inputs of the given transaction. Given transaction may already
|
||||
* be partially signed or somehow altered by other signers.</p>
|
||||
* <p>To make use of the signer, you need to add it into the wallet by
|
||||
* calling {@link org.bitcoinj.wallet.Wallet#addTransactionSigner(TransactionSigner)}. Signer will be serialized
|
||||
* calling {@link Wallet#addTransactionSigner(TransactionSigner)}. Signer will be serialized
|
||||
* along with the wallet data. In order for a wallet to recreate signer after deserialization, each signer
|
||||
* should have no-args constructor</p>
|
||||
*/
|
||||
|
@ -19,4 +19,4 @@
|
||||
* local private keys or fetching them from remote servers. The {@link org.bitcoinj.wallet.Wallet} class uses these
|
||||
* when sending money.
|
||||
*/
|
||||
package org.bitcoinj.signers;
|
||||
package org.bitcoinj.signers;
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
package org.bitcoinj.store;
|
||||
|
||||
import org.bitcoinj.core.BlockChain;
|
||||
import org.bitcoinj.core.NetworkParameters;
|
||||
import org.bitcoinj.core.Sha256Hash;
|
||||
import org.bitcoinj.core.StoredBlock;
|
||||
@ -46,8 +47,8 @@ public interface BlockStore {
|
||||
|
||||
/**
|
||||
* Returns the {@link StoredBlock} that represents the top of the chain of greatest total work. Note that this
|
||||
* can be arbitrarily expensive, you probably should use {@link org.bitcoinj.core.BlockChain#getChainHead()}
|
||||
* or perhaps {@link org.bitcoinj.core.BlockChain#getBestChainHeight()} which will run in constant time and
|
||||
* can be arbitrarily expensive, you probably should use {@link BlockChain#getChainHead()}
|
||||
* or perhaps {@link BlockChain#getBestChainHeight()} which will run in constant time and
|
||||
* not take any heavyweight locks.
|
||||
*/
|
||||
StoredBlock getChainHead() throws BlockStoreException;
|
||||
@ -61,7 +62,7 @@ public interface BlockStore {
|
||||
void close() throws BlockStoreException;
|
||||
|
||||
/**
|
||||
* Get the {@link org.bitcoinj.core.NetworkParameters} of this store.
|
||||
* Get the {@link NetworkParameters} of this store.
|
||||
* @return The network params.
|
||||
*/
|
||||
NetworkParameters getParams();
|
||||
|
@ -212,7 +212,7 @@ public abstract class DatabaseFullPrunedBlockStore implements FullPrunedBlockSto
|
||||
|
||||
/**
|
||||
* Get the database specific error code that indicated a duplicate key error when inserting a record.
|
||||
* <p>This is the code returned by {@link java.sql.SQLException#getSQLState()}</p>
|
||||
* <p>This is the code returned by {@link SQLException#getSQLState()}</p>
|
||||
* @return The database duplicate error code.
|
||||
*/
|
||||
protected abstract String getDuplicateKeyErrorCode();
|
||||
@ -546,7 +546,7 @@ public abstract class DatabaseFullPrunedBlockStore implements FullPrunedBlockSto
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new store for the given {@link org.bitcoinj.core.NetworkParameters}.
|
||||
* Create a new store for the given {@link NetworkParameters}.
|
||||
* @param params The network.
|
||||
* @throws BlockStoreException If the store couldn't be created.
|
||||
*/
|
||||
@ -1106,10 +1106,10 @@ public abstract class DatabaseFullPrunedBlockStore implements FullPrunedBlockSto
|
||||
/**
|
||||
* Calculate the balance for a coinbase, to-address, or p2sh address.
|
||||
*
|
||||
* <p>The balance {@link org.bitcoinj.store.DatabaseFullPrunedBlockStore#getBalanceSelectSQL()} returns
|
||||
* <p>The balance {@link DatabaseFullPrunedBlockStore#getBalanceSelectSQL()} returns
|
||||
* the balance (summed) as an number, then use calculateClientSide=false</p>
|
||||
*
|
||||
* <p>The balance {@link org.bitcoinj.store.DatabaseFullPrunedBlockStore#getBalanceSelectSQL()} returns
|
||||
* <p>The balance {@link DatabaseFullPrunedBlockStore#getBalanceSelectSQL()} returns
|
||||
* the all the openoutputs as stored in the DB (binary), then use calculateClientSide=true</p>
|
||||
*
|
||||
* @param address The address to calculate the balance of
|
||||
|
@ -72,17 +72,17 @@ public interface FullPrunedBlockStore extends BlockStore, UTXOProvider {
|
||||
StoredUndoableBlock getUndoBlock(Sha256Hash hash) throws BlockStoreException;
|
||||
|
||||
/**
|
||||
* Gets a {@link org.bitcoinj.core.UTXO} with the given hash and index, or null if none is found
|
||||
* Gets a {@link UTXO} with the given hash and index, or null if none is found
|
||||
*/
|
||||
UTXO getTransactionOutput(Sha256Hash hash, long index) throws BlockStoreException;
|
||||
|
||||
/**
|
||||
* Adds a {@link org.bitcoinj.core.UTXO} to the list of unspent TransactionOutputs
|
||||
* Adds a {@link UTXO} to the list of unspent TransactionOutputs
|
||||
*/
|
||||
void addUnspentTransactionOutput(UTXO out) throws BlockStoreException;
|
||||
|
||||
/**
|
||||
* Removes a {@link org.bitcoinj.core.UTXO} from the list of unspent TransactionOutputs
|
||||
* Removes a {@link UTXO} from the list of unspent TransactionOutputs
|
||||
* Note that the coinbase of the genesis block should NEVER be spendable and thus never in the list.
|
||||
* @throws BlockStoreException if there is an underlying storage issue, or out was not in the list.
|
||||
*/
|
||||
|
@ -22,7 +22,7 @@ import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Keeps {@link org.bitcoinj.core.StoredBlock}s in memory. Used primarily for unit testing.
|
||||
* Keeps {@link StoredBlock}s in memory. Used primarily for unit testing.
|
||||
*/
|
||||
public class MemoryBlockStore implements BlockStore {
|
||||
private LinkedHashMap<Sha256Hash, StoredBlock> blockMap = new LinkedHashMap<Sha256Hash, StoredBlock>() {
|
||||
|
@ -229,7 +229,7 @@ class TransactionalMultiKeyHashMap<UniqueKeyType, MultiKeyType, ValueType> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Keeps {@link StoredBlock}s, {@link StoredUndoableBlock}s and {@link org.bitcoinj.core.UTXO}s in memory.
|
||||
* Keeps {@link StoredBlock}s, {@link StoredUndoableBlock}s and {@link UTXO}s in memory.
|
||||
* Used primarily for unit testing.
|
||||
*/
|
||||
public class MemoryFullPrunedBlockStore implements FullPrunedBlockStore {
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
package org.bitcoinj.store;
|
||||
|
||||
import org.bitcoinj.core.Address;
|
||||
import org.bitcoinj.core.NetworkParameters;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -24,7 +25,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>A full pruned block store using the MySQL database engine. As an added bonus an address index is calculated,
|
||||
* so you can use {@link #calculateBalanceForAddress(org.bitcoinj.core.Address)} to quickly look up
|
||||
* so you can use {@link #calculateBalanceForAddress(Address)} to quickly look up
|
||||
* the quantity of bitcoins controlled by that address.</p>
|
||||
*/
|
||||
public class MySQLFullPrunedBlockStore extends DatabaseFullPrunedBlockStore {
|
||||
|
@ -34,7 +34,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>A full pruned block store using the Postgres database engine. As an added bonus an address index is calculated,
|
||||
* so you can use {@link #calculateBalanceForAddress(org.bitcoinj.core.Address)} to quickly look up
|
||||
* so you can use {@link #calculateBalanceForAddress(Address)} to quickly look up
|
||||
* the quantity of bitcoins controlled by that address.</p>
|
||||
*/
|
||||
public class PostgresFullPrunedBlockStore extends DatabaseFullPrunedBlockStore {
|
||||
|
@ -85,8 +85,8 @@ public class BitcoinURI {
|
||||
public static final String FIELD_PAYMENT_REQUEST_URL = "r";
|
||||
|
||||
/**
|
||||
* URI for Bitcoin network. Use {@link org.bitcoinj.params.AbstractBitcoinNetParams#BITCOIN_SCHEME} if you specifically
|
||||
* need Bitcoin, or use {@link org.bitcoinj.core.NetworkParameters#getUriScheme} to get the scheme
|
||||
* URI for Bitcoin network. Use {@link AbstractBitcoinNetParams#BITCOIN_SCHEME} if you specifically
|
||||
* need Bitcoin, or use {@link NetworkParameters#getUriScheme} to get the scheme
|
||||
* from network parameters.
|
||||
*/
|
||||
@Deprecated
|
||||
|
@ -17,7 +17,7 @@
|
||||
package org.bitcoinj.uri;
|
||||
|
||||
/**
|
||||
* <p>Exception to provide the following to {@link org.bitcoinj.uri.BitcoinURI}:</p>
|
||||
* <p>Exception to provide the following to {@link BitcoinURI}:</p>
|
||||
* <ul>
|
||||
* <li>Provision of parsing error messages</li>
|
||||
* </ul>
|
||||
|
@ -19,8 +19,11 @@ package org.bitcoinj.utils;
|
||||
import static org.bitcoinj.core.Coin.SMALLEST_UNIT_EXPONENT;
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import com.google.common.base.Objects;
|
||||
import org.bitcoinj.core.Coin;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.Format;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Locale;
|
||||
import java.util.List;
|
||||
@ -38,12 +41,12 @@ import java.util.List;
|
||||
*
|
||||
* <p>A more detailed explanation, including examples, is in the documentation for the
|
||||
* {@link BtcFormat} class, and further information beyond that is in the documentation for the
|
||||
* {@link java.text.Format} class, from which this class descends.</p>
|
||||
* {@link Format} class, from which this class descends.</p>
|
||||
|
||||
* @see java.text.Format
|
||||
* @see java.text.NumberFormat
|
||||
* @see java.text.DecimalFormat
|
||||
* @see org.bitcoinj.core.Coin
|
||||
* @see Format
|
||||
* @see NumberFormat
|
||||
* @see DecimalFormat
|
||||
* @see Coin
|
||||
*/
|
||||
|
||||
public final class BtcFixedFormat extends BtcFormat {
|
||||
|
@ -267,10 +267,10 @@ import java.util.regex.Pattern;
|
||||
* <h3>Formatting</h3>
|
||||
*
|
||||
* <p>You format a Bitcoin monetary value by passing it to the {@link BtcFormat#format(Object)}
|
||||
* method. This argument can be either a {@link org.bitcoinj.core.Coin}-type object or a
|
||||
* numerical object such as {@link java.lang.Long} or {@link java.math.BigDecimal}.
|
||||
* Integer-based types such as {@link java.math.BigInteger} are interpreted as representing a
|
||||
* number of satoshis, while a {@link java.math.BigDecimal} is interpreted as representing a
|
||||
* method. This argument can be either a {@link Coin}-type object or a
|
||||
* numerical object such as {@link Long} or {@link BigDecimal}.
|
||||
* Integer-based types such as {@link BigInteger} are interpreted as representing a
|
||||
* number of satoshis, while a {@link BigDecimal} is interpreted as representing a
|
||||
* number of bitcoins. A value having a fractional amount of satoshis is rounded to the
|
||||
* nearest whole satoshi at least, and possibly to a greater unit depending on the number of
|
||||
* fractional decimal-places displayed. The {@code format()} method will not accept an
|
||||
@ -322,9 +322,9 @@ import java.util.regex.Pattern;
|
||||
* <p>When using an automatically-denominating formatter, you might
|
||||
* want to know what denomination was chosen. You can get the
|
||||
* currency-units indicator, as well as any other field in the
|
||||
* formatted output, by using a {@link java.text.FieldPosition} instance
|
||||
* formatted output, by using a {@link FieldPosition} instance
|
||||
* constructed using an appropriate constant from the {@link
|
||||
* java.text.NumberFormat.Field} class:</p>
|
||||
* NumberFormat.Field} class:</p>
|
||||
*
|
||||
* <blockquote><pre>
|
||||
* BtcFormat de = BtcFormat.getInstance(Locale.GERMANY);
|
||||
@ -393,7 +393,7 @@ import java.util.regex.Pattern;
|
||||
* </pre></blockquote>
|
||||
*
|
||||
* <p>If you need to vertically-align columns printed in a proportional font,
|
||||
* then see the documentation for the {@link java.text.NumberFormat} class
|
||||
* then see the documentation for the {@link NumberFormat} class
|
||||
* for an explanation of how to do that.</p>
|
||||
*
|
||||
* <h3>Parsing</h3>
|
||||
@ -447,7 +447,7 @@ import java.util.regex.Pattern;
|
||||
*
|
||||
* <h4>Parsing</h4>
|
||||
*
|
||||
* <p>Parsing is performed by an underlying {@link java.text.NumberFormat} object. While this
|
||||
* <p>Parsing is performed by an underlying {@link NumberFormat} object. While this
|
||||
* delivers the benefit of recognizing locale-specific patterns, some have criticized other
|
||||
* aspects of its behavior. For example, see <a
|
||||
* href="http://www.ibm.com/developerworks/library/j-numberformat/">this article by Joe Sam
|
||||
@ -465,12 +465,12 @@ import java.util.regex.Pattern;
|
||||
*
|
||||
* <p>Instances of this class are immutable.</p>
|
||||
*
|
||||
* @see java.text.Format
|
||||
* @see java.text.NumberFormat
|
||||
* @see java.text.DecimalFormat
|
||||
* @see java.text.DecimalFormatSymbols
|
||||
* @see java.text.FieldPosition
|
||||
* @see org.bitcoinj.core.Coin
|
||||
* @see Format
|
||||
* @see NumberFormat
|
||||
* @see DecimalFormat
|
||||
* @see DecimalFormatSymbols
|
||||
* @see FieldPosition
|
||||
* @see Coin
|
||||
*/
|
||||
|
||||
public abstract class BtcFormat extends Format {
|
||||
@ -635,7 +635,7 @@ public abstract class BtcFormat extends Format {
|
||||
* if that method is not invoked. */
|
||||
public Builder fractionGroups(int... val) { fractionGroups = val; return this; }
|
||||
|
||||
/** Specify the {@link java.util.Locale} for formatting and parsing.
|
||||
/** Specify the {@link Locale} for formatting and parsing.
|
||||
* If this method is not invoked, then the runtime default locale will be used. */
|
||||
public Builder locale(Locale val) { locale = val; return this; }
|
||||
|
||||
@ -660,7 +660,7 @@ public abstract class BtcFormat extends Format {
|
||||
public Builder code(String val) { code = val; return this; }
|
||||
|
||||
/** Use the given pattern when formatting and parsing. The format of this pattern is
|
||||
* identical to that used by the {@link java.text.DecimalFormat} class.
|
||||
* identical to that used by the {@link DecimalFormat} class.
|
||||
*
|
||||
* <p>If the pattern lacks a negative subpattern, then the formatter will indicate
|
||||
* negative values by placing a minus sign immediately preceding the number part of
|
||||
@ -687,7 +687,7 @@ public abstract class BtcFormat extends Format {
|
||||
}
|
||||
|
||||
/** Use the given localized-pattern for formatting and parsing. The format of this
|
||||
* pattern is identical to the patterns used by the {@link java.text.DecimalFormat}
|
||||
* pattern is identical to the patterns used by the {@link DecimalFormat}
|
||||
* class.
|
||||
*
|
||||
* <p>The pattern is localized according to the locale of the {@code BtcFormat}
|
||||
@ -1116,12 +1116,12 @@ public abstract class BtcFormat extends Format {
|
||||
// ****** FORMATTING *****
|
||||
|
||||
/**
|
||||
* Formats a bitcoin monetary value and returns an {@link java.text.AttributedCharacterIterator}.
|
||||
* Formats a bitcoin monetary value and returns an {@link AttributedCharacterIterator}.
|
||||
* By iterating, you can examine what fields apply to each character. This can be useful
|
||||
* since a character may be part of more than one field, for example a grouping separator
|
||||
* that is also part of the integer field.
|
||||
*
|
||||
* @see java.text.AttributedCharacterIterator
|
||||
* @see AttributedCharacterIterator
|
||||
*/
|
||||
@Override
|
||||
public AttributedCharacterIterator formatToCharacterIterator(Object obj) { synchronized(numberFormat) {
|
||||
@ -1303,8 +1303,8 @@ public abstract class BtcFormat extends Format {
|
||||
|
||||
/**
|
||||
* Parse a {@link String} representation of a Bitcoin monetary value. Returns a
|
||||
* {@link org.bitcoinj.core.Coin} object that represents the parsed value.
|
||||
* @see java.text.NumberFormat */
|
||||
* {@link Coin} object that represents the parsed value.
|
||||
* @see NumberFormat */
|
||||
@Override
|
||||
public final Object parseObject(String source, ParsePosition pos) { return parse(source, pos); }
|
||||
|
||||
@ -1501,7 +1501,7 @@ public abstract class BtcFormat extends Format {
|
||||
*
|
||||
* <p>This method accommodates an imperfection in the Java formatting code and distributed
|
||||
* locale data. To wit: the subpattern for negative numbers is optional and not all
|
||||
* locales have one. In those cases, {@link java.text.DecimalFormat} will indicate numbers
|
||||
* locales have one. In those cases, {@link DecimalFormat} will indicate numbers
|
||||
* less than zero by adding a negative sign as the first character of the prefix of the
|
||||
* positive subpattern.
|
||||
*
|
||||
@ -1521,7 +1521,7 @@ public abstract class BtcFormat extends Format {
|
||||
|
||||
/**
|
||||
* Return an array of all locales for which the getInstance() method of this class can
|
||||
* return localized instances. See {@link java.text.NumberFormat#getAvailableLocales()}
|
||||
* return localized instances. See {@link NumberFormat#getAvailableLocales()}
|
||||
*/
|
||||
public static Locale[] getAvailableLocales() { return NumberFormat.getAvailableLocales(); }
|
||||
|
||||
|
@ -23,7 +23,7 @@ import org.slf4j.*;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
/**
|
||||
* A {@link java.util.concurrent.ThreadFactory} that propagates a {@link org.bitcoinj.core.Context} from the creating
|
||||
* A {@link ThreadFactory} that propagates a {@link Context} from the creating
|
||||
* thread into the new thread. This factory creates daemon threads.
|
||||
*/
|
||||
public class ContextPropagatingThreadFactory implements ThreadFactory {
|
||||
|
@ -21,13 +21,14 @@ import static com.google.common.base.Preconditions.checkArgument;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.bitcoinj.core.Monetary;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.math.LongMath;
|
||||
import com.google.common.primitives.Longs;
|
||||
|
||||
/**
|
||||
* Represents a monetary fiat value. It was decided to not fold this into {@link org.bitcoinj.core.Coin} because of type
|
||||
* Represents a monetary fiat value. It was decided to not fold this into {@link Coin} because of type
|
||||
* safety. Fiat values always come with an attached currency code.
|
||||
*
|
||||
* This class is immutable.
|
||||
|
@ -393,7 +393,7 @@ public final class MonetaryFormat {
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a human readable coin value to a {@link org.bitcoinj.core.Coin} instance.
|
||||
* Parse a human readable coin value to a {@link Coin} instance.
|
||||
*
|
||||
* @throws NumberFormatException
|
||||
* if the string cannot be parsed for some reason
|
||||
@ -403,7 +403,7 @@ public final class MonetaryFormat {
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a human readable fiat value to a {@link org.bitcoinj.utils.Fiat} instance.
|
||||
* Parse a human readable fiat value to a {@link Fiat} instance.
|
||||
*
|
||||
* @throws NumberFormatException
|
||||
* if the string cannot be parsed for some reason
|
||||
|
@ -39,7 +39,7 @@ public interface TaggableObject {
|
||||
@Nullable ByteString maybeGetTag(String tag);
|
||||
|
||||
/**
|
||||
* Returns the immutable byte array associated with the given tag name, or throws {@link java.lang.IllegalArgumentException}
|
||||
* Returns the immutable byte array associated with the given tag name, or throws {@link IllegalArgumentException}
|
||||
* if that tag wasn't set yet.
|
||||
*/
|
||||
ByteString getTag(String tag);
|
||||
|
@ -434,7 +434,7 @@ public class BasicKeyChain implements EncryptableKeyChain {
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Convenience wrapper around {@link #toEncrypted(org.bitcoinj.crypto.KeyCrypter,
|
||||
* Convenience wrapper around {@link #toEncrypted(KeyCrypter,
|
||||
* org.spongycastle.crypto.params.KeyParameter)} which uses the default Scrypt key derivation algorithm and
|
||||
* parameters, derives a key from the given password and returns the created key.
|
||||
*/
|
||||
@ -449,7 +449,7 @@ public class BasicKeyChain implements EncryptableKeyChain {
|
||||
|
||||
/**
|
||||
* Encrypt the wallet using the KeyCrypter and the AES key. A good default KeyCrypter to use is
|
||||
* {@link org.bitcoinj.crypto.KeyCrypterScrypt}.
|
||||
* {@link KeyCrypterScrypt}.
|
||||
*
|
||||
* @param keyCrypter The KeyCrypter that specifies how to encrypt/ decrypt a key
|
||||
* @param aesKey AES key to use (normally created using KeyCrypter#deriveKey and cached as it is time consuming
|
||||
|
@ -20,10 +20,11 @@ import org.bitcoinj.core.Coin;
|
||||
import org.bitcoinj.core.TransactionOutput;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents the results of a
|
||||
* {@link CoinSelector#select(Coin, java.util.List)} operation. A
|
||||
* {@link CoinSelector#select(Coin, List)} operation. A
|
||||
* coin selection represents a list of spendable transaction outputs that sum together to give valueGathered.
|
||||
* Different coin selections could be produced by different coin selectors from the same input set, according
|
||||
* to their varying policies.
|
||||
|
@ -28,7 +28,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* A DecryptingKeyBag filters a pre-existing key bag, decrypting keys as they are requested using the provided
|
||||
* AES key. If the keys are encrypted and no AES key provided, {@link org.bitcoinj.core.ECKey.KeyIsEncryptedException}
|
||||
* AES key. If the keys are encrypted and no AES key provided, {@link ECKey.KeyIsEncryptedException}
|
||||
* will be thrown.
|
||||
*/
|
||||
public class DecryptingKeyBag implements KeyBag {
|
||||
|
@ -121,7 +121,7 @@ public class DefaultRiskAnalysis implements RiskAnalysis {
|
||||
|
||||
/**
|
||||
* The reason a transaction is considered non-standard, returned by
|
||||
* {@link #isStandard(org.bitcoinj.core.Transaction)}.
|
||||
* {@link #isStandard(Transaction)}.
|
||||
*/
|
||||
public enum RuleViolation {
|
||||
NONE,
|
||||
|
@ -48,10 +48,10 @@ import static com.google.common.collect.Lists.newLinkedList;
|
||||
/**
|
||||
* <p>A deterministic key chain is a {@link KeyChain} that uses the
|
||||
* <a href="https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki">BIP 32 standard</a>, as implemented by
|
||||
* {@link org.bitcoinj.crypto.DeterministicHierarchy}, to derive all the keys in the keychain from a master seed.
|
||||
* {@link DeterministicHierarchy}, to derive all the keys in the keychain from a master seed.
|
||||
* This type of wallet is extremely convenient and flexible. Although backing up full wallet files is always a good
|
||||
* idea, to recover money only the root seed needs to be preserved and that is a number small enough that it can be
|
||||
* written down on paper or, when represented using a BIP 39 {@link org.bitcoinj.crypto.MnemonicCode},
|
||||
* written down on paper or, when represented using a BIP 39 {@link MnemonicCode},
|
||||
* dictated over the phone (possibly even memorized).</p>
|
||||
*
|
||||
* <p>Deterministic key chains have other advantages: parts of the key tree can be selectively revealed to allow
|
||||
@ -61,14 +61,14 @@ import static com.google.common.collect.Lists.newLinkedList;
|
||||
* A watching wallet is not instantiated using the public part of the master key as you may imagine. Instead, you
|
||||
* need to take the account key (first child of the master key) and provide the public part of that to the watching
|
||||
* wallet instead. You can do this by calling {@link #getWatchingKey()} and then serializing it with
|
||||
* {@link org.bitcoinj.crypto.DeterministicKey#serializePubB58(org.bitcoinj.core.NetworkParameters)}. The resulting "xpub..." string encodes
|
||||
* {@link DeterministicKey#serializePubB58(NetworkParameters)}. The resulting "xpub..." string encodes
|
||||
* sufficient information about the account key to create a watching chain via
|
||||
* {@link org.bitcoinj.crypto.DeterministicKey#deserializeB58(org.bitcoinj.crypto.DeterministicKey, String, org.bitcoinj.core.NetworkParameters)}
|
||||
* {@link DeterministicKey#deserializeB58(DeterministicKey, String, NetworkParameters)}
|
||||
* (with null as the first parameter) and then
|
||||
* {@link DeterministicKeyChain#DeterministicKeyChain(org.bitcoinj.crypto.DeterministicKey)}.</p>
|
||||
* {@link DeterministicKeyChain#DeterministicKeyChain(DeterministicKey)}.</p>
|
||||
*
|
||||
* <p>This class builds on {@link org.bitcoinj.crypto.DeterministicHierarchy} and
|
||||
* {@link org.bitcoinj.crypto.DeterministicKey} by adding support for serialization to and from protobufs,
|
||||
* <p>This class builds on {@link DeterministicHierarchy} and
|
||||
* {@link DeterministicKey} by adding support for serialization to and from protobufs,
|
||||
* and encryption of parts of the key tree. Internally it arranges itself as per the BIP 32 spec, with the seed being
|
||||
* used to derive a master key, which is then used to derive an account key, the account key is used to derive two
|
||||
* child keys called the <i>internal</i> and <i>external</i> parent keys (for change and handing out addresses respectively)
|
||||
@ -197,7 +197,7 @@ public class DeterministicKeyChain implements EncryptableKeyChain {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a new key chain with entropy selected randomly from the given {@link java.security.SecureRandom}
|
||||
* Generates a new key chain with entropy selected randomly from the given {@link SecureRandom}
|
||||
* object and of the requested size in bits. The derived seed is further protected with a user selected passphrase
|
||||
* (see BIP 39).
|
||||
* @param random the random number generator - use new SecureRandom().
|
||||
@ -210,7 +210,7 @@ public class DeterministicKeyChain implements EncryptableKeyChain {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a new key chain with 128 bits of entropy selected randomly from the given {@link java.security.SecureRandom}
|
||||
* Generates a new key chain with 128 bits of entropy selected randomly from the given {@link SecureRandom}
|
||||
* object. The derived seed is further protected with a user selected passphrase
|
||||
* (see BIP 39).
|
||||
* @param random the random number generator - use new SecureRandom().
|
||||
@ -268,7 +268,7 @@ public class DeterministicKeyChain implements EncryptableKeyChain {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a new key chain with entropy selected randomly from the given {@link java.security.SecureRandom}
|
||||
* Generates a new key chain with entropy selected randomly from the given {@link SecureRandom}
|
||||
* object and the default entropy size.
|
||||
*/
|
||||
public DeterministicKeyChain(SecureRandom random) {
|
||||
@ -276,7 +276,7 @@ public class DeterministicKeyChain implements EncryptableKeyChain {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a new key chain with entropy selected randomly from the given {@link java.security.SecureRandom}
|
||||
* Generates a new key chain with entropy selected randomly from the given {@link SecureRandom}
|
||||
* object and of the requested size in bits.
|
||||
*/
|
||||
public DeterministicKeyChain(SecureRandom random, int bits) {
|
||||
@ -284,7 +284,7 @@ public class DeterministicKeyChain implements EncryptableKeyChain {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a new key chain with entropy selected randomly from the given {@link java.security.SecureRandom}
|
||||
* Generates a new key chain with entropy selected randomly from the given {@link SecureRandom}
|
||||
* object and of the requested size in bits. The derived seed is further protected with a user selected passphrase
|
||||
* (see BIP 39).
|
||||
*/
|
||||
@ -399,7 +399,7 @@ public class DeterministicKeyChain implements EncryptableKeyChain {
|
||||
|
||||
/**
|
||||
* Creates a deterministic key chain with an encrypted deterministic seed using the provided account path.
|
||||
* Using {@link org.bitcoinj.crypto.KeyCrypter KeyCrypter} to decrypt.
|
||||
* Using {@link KeyCrypter KeyCrypter} to decrypt.
|
||||
*/
|
||||
protected DeterministicKeyChain(DeterministicSeed seed, @Nullable KeyCrypter crypter,
|
||||
ImmutableList<ChildNumber> accountPath) {
|
||||
@ -673,7 +673,7 @@ public class DeterministicKeyChain implements EncryptableKeyChain {
|
||||
* <p>An alias for {@code getKeyByPath(getAccountPath())}.</p>
|
||||
*
|
||||
* <p>Use this when you would like to create a watching key chain that follows this one, but can't spend money from it.
|
||||
* The returned key can be serialized and then passed into {@link #watch(org.bitcoinj.crypto.DeterministicKey)}
|
||||
* The returned key can be serialized and then passed into {@link #watch(DeterministicKey)}
|
||||
* on another system to watch the hierarchy.</p>
|
||||
*
|
||||
* <p>Note that the returned key is not pubkey only unless this key chain already is: the returned key can still
|
||||
|
@ -71,7 +71,7 @@ public class DeterministicSeed implements EncryptableItem {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a seed from a BIP 39 mnemonic code. See {@link org.bitcoinj.crypto.MnemonicCode} for more
|
||||
* Constructs a seed from a BIP 39 mnemonic code. See {@link MnemonicCode} for more
|
||||
* details on this scheme.
|
||||
* @param mnemonicCode A list of words.
|
||||
* @param seed The derived seed, or pass null to derive it from mnemonicCode (slow)
|
||||
@ -83,7 +83,7 @@ public class DeterministicSeed implements EncryptableItem {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a seed from a BIP 39 mnemonic code. See {@link org.bitcoinj.crypto.MnemonicCode} for more
|
||||
* Constructs a seed from a BIP 39 mnemonic code. See {@link MnemonicCode} for more
|
||||
* details on this scheme.
|
||||
* @param random Entropy source
|
||||
* @param bits number of bits, must be divisible by 32
|
||||
@ -95,7 +95,7 @@ public class DeterministicSeed implements EncryptableItem {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a seed from a BIP 39 mnemonic code. See {@link org.bitcoinj.crypto.MnemonicCode} for more
|
||||
* Constructs a seed from a BIP 39 mnemonic code. See {@link MnemonicCode} for more
|
||||
* details on this scheme.
|
||||
* @param entropy entropy bits, length must be divisible by 32
|
||||
* @param passphrase A user supplied passphrase, or an empty string if there is no passphrase
|
||||
|
@ -18,6 +18,7 @@ package org.bitcoinj.wallet;
|
||||
|
||||
import org.bitcoinj.crypto.KeyCrypter;
|
||||
import org.bitcoinj.crypto.KeyCrypterException;
|
||||
import org.bitcoinj.crypto.KeyCrypterScrypt;
|
||||
import org.spongycastle.crypto.params.KeyParameter;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -28,8 +29,8 @@ import javax.annotation.Nullable;
|
||||
public interface EncryptableKeyChain extends KeyChain {
|
||||
/**
|
||||
* Takes the given password, which should be strong, derives a key from it and then invokes
|
||||
* {@link #toEncrypted(org.bitcoinj.crypto.KeyCrypter, org.spongycastle.crypto.params.KeyParameter)} with
|
||||
* {@link org.bitcoinj.crypto.KeyCrypterScrypt} as the crypter.
|
||||
* {@link #toEncrypted(KeyCrypter, KeyParameter)} with
|
||||
* {@link KeyCrypterScrypt} as the crypter.
|
||||
*
|
||||
* @return The derived key, in case you wish to cache it for future use.
|
||||
*/
|
||||
@ -42,7 +43,7 @@ public interface EncryptableKeyChain extends KeyChain {
|
||||
EncryptableKeyChain toEncrypted(KeyCrypter keyCrypter, KeyParameter aesKey);
|
||||
|
||||
/**
|
||||
* Decrypts the key chain with the given password. See {@link #toDecrypted(org.spongycastle.crypto.params.KeyParameter)}
|
||||
* Decrypts the key chain with the given password. See {@link #toDecrypted(KeyParameter)}
|
||||
* for details.
|
||||
*/
|
||||
EncryptableKeyChain toDecrypted(CharSequence password);
|
||||
@ -50,7 +51,7 @@ public interface EncryptableKeyChain extends KeyChain {
|
||||
/**
|
||||
* Decrypt the key chain with the given AES key and whatever {@link KeyCrypter} is already set. Note that if you
|
||||
* just want to spend money from an encrypted wallet, don't decrypt the whole thing first. Instead, set the
|
||||
* {@link org.bitcoinj.wallet.SendRequest#aesKey} field before asking the wallet to build the send.
|
||||
* {@link SendRequest#aesKey} field before asking the wallet to build the send.
|
||||
*
|
||||
* @param aesKey AES key to use (normally created using KeyCrypter#deriveKey and cached as it is time consuming to
|
||||
* create from a password)
|
||||
|
@ -24,7 +24,7 @@ import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
/**
|
||||
* <p>A KeyChain is a class that stores a collection of keys for a {@link org.bitcoinj.wallet.Wallet}. Key chains
|
||||
* <p>A KeyChain is a class that stores a collection of keys for a {@link Wallet}. Key chains
|
||||
* are expected to be able to look up keys given a hash (i.e. address) or pubkey bytes, and provide keys on request
|
||||
* for a given purpose. They can inform event listeners about new keys being added.</p>
|
||||
*
|
||||
@ -88,7 +88,7 @@ public interface KeyChain {
|
||||
* <p>This is used to generate a {@link BloomFilter} which can be {@link BloomFilter#merge(BloomFilter)}d with
|
||||
* another. It could also be used if you have a specific target for the filter's size.</p>
|
||||
*
|
||||
* <p>See the docs for {@link org.bitcoinj.core.BloomFilter#BloomFilter(int, double, long)} for a brief
|
||||
* <p>See the docs for {@link BloomFilter#BloomFilter(int, double, long)} for a brief
|
||||
* explanation of anonymity when using bloom filters, and for the meaning of these parameters.</p>
|
||||
*/
|
||||
BloomFilter getFilter(int size, double falsePositiveRate, long tweak);
|
||||
|
@ -42,7 +42,7 @@ import java.util.concurrent.*;
|
||||
import static com.google.common.base.Preconditions.*;
|
||||
|
||||
/**
|
||||
* <p>A KeyChainGroup is used by the {@link org.bitcoinj.wallet.Wallet} and
|
||||
* <p>A KeyChainGroup is used by the {@link Wallet} and
|
||||
* manages: a {@link BasicKeyChain} object (which will normally be empty), and zero or more
|
||||
* {@link DeterministicKeyChain}s. A deterministic key chain will be created lazily/on demand
|
||||
* when a fresh or current key is requested, possibly being initialized from the private key bytes of the earliest non
|
||||
@ -504,7 +504,7 @@ public class KeyChainGroup implements KeyBag {
|
||||
|
||||
/**
|
||||
* Encrypt the keys in the group using the KeyCrypter and the AES key. A good default KeyCrypter to use is
|
||||
* {@link org.bitcoinj.crypto.KeyCrypterScrypt}.
|
||||
* {@link KeyCrypterScrypt}.
|
||||
*
|
||||
* @throws org.bitcoinj.crypto.KeyCrypterException Thrown if the wallet encryption fails for some reason,
|
||||
* leaving the group unchanged.
|
||||
@ -531,7 +531,7 @@ public class KeyChainGroup implements KeyBag {
|
||||
|
||||
/**
|
||||
* Decrypt the keys in the group using the previously given key crypter and the AES key. A good default
|
||||
* KeyCrypter to use is {@link org.bitcoinj.crypto.KeyCrypterScrypt}.
|
||||
* KeyCrypter to use is {@link KeyCrypterScrypt}.
|
||||
*
|
||||
* @throws org.bitcoinj.crypto.KeyCrypterException Thrown if the wallet decryption fails for some reason, leaving the group unchanged.
|
||||
*/
|
||||
|
@ -37,7 +37,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
public class KeyTimeCoinSelector implements CoinSelector {
|
||||
private static final Logger log = LoggerFactory.getLogger(KeyTimeCoinSelector.class);
|
||||
|
||||
/** A number of inputs chosen to avoid hitting {@link org.bitcoinj.core.Transaction#MAX_STANDARD_TX_SIZE} */
|
||||
/** A number of inputs chosen to avoid hitting {@link Transaction#MAX_STANDARD_TX_SIZE} */
|
||||
public static final int MAX_SIMULTANEOUS_INPUTS = 600;
|
||||
|
||||
private final long unixTimeSeconds;
|
||||
|
@ -66,7 +66,7 @@ public class SendRequest {
|
||||
|
||||
/**
|
||||
* When emptyWallet is set, all coins selected by the coin selector are sent to the first output in tx
|
||||
* (its value is ignored and set to {@link org.bitcoinj.wallet.Wallet#getBalance()} - the fees required
|
||||
* (its value is ignored and set to {@link Wallet#getBalance()} - the fees required
|
||||
* for the transaction). Any additional outputs are removed.
|
||||
*/
|
||||
public boolean emptyWallet = false;
|
||||
@ -116,7 +116,7 @@ public class SendRequest {
|
||||
public KeyParameter aesKey = null;
|
||||
|
||||
/**
|
||||
* If not null, the {@link org.bitcoinj.wallet.CoinSelector} to use instead of the wallets default. Coin selectors are
|
||||
* If not null, the {@link CoinSelector} to use instead of the wallets default. Coin selectors are
|
||||
* responsible for choosing which transaction outputs (coins) in a wallet to use given the desired send value
|
||||
* amount.
|
||||
*/
|
||||
|
@ -116,7 +116,7 @@ import static com.google.common.base.Preconditions.*;
|
||||
* auto-save feature that simplifies this for you although you're still responsible for manually triggering a save when
|
||||
* your app is about to quit because the auto-save feature waits a moment before actually committing to disk to avoid IO
|
||||
* thrashing when the wallet is changing very fast (eg due to a block chain sync). See
|
||||
* {@link Wallet#autosaveToFile(java.io.File, long, java.util.concurrent.TimeUnit, org.bitcoinj.wallet.WalletFiles.Listener)}
|
||||
* {@link Wallet#autosaveToFile(File, long, TimeUnit, WalletFiles.Listener)}
|
||||
* for more information about this.</p>
|
||||
*/
|
||||
public class Wallet extends BaseTaggableObject
|
||||
@ -268,7 +268,7 @@ public class Wallet extends BaseTaggableObject
|
||||
* @param params network parameters
|
||||
* @param seed deterministic seed
|
||||
* @return a wallet from a deterministic seed with a
|
||||
* {@link org.bitcoinj.wallet.DeterministicKeyChain#ACCOUNT_ZERO_PATH 0 hardened path}
|
||||
* {@link DeterministicKeyChain#ACCOUNT_ZERO_PATH 0 hardened path}
|
||||
*/
|
||||
public static Wallet fromSeed(NetworkParameters params, DeterministicSeed seed) {
|
||||
return new Wallet(params, new KeyChainGroup(params, seed));
|
||||
@ -444,7 +444,7 @@ public class Wallet extends BaseTaggableObject
|
||||
/**
|
||||
* Returns a key that hasn't been seen in a transaction yet, and which is suitable for displaying in a wallet
|
||||
* user interface as "a convenient key to receive funds on" when the purpose parameter is
|
||||
* {@link org.bitcoinj.wallet.KeyChain.KeyPurpose#RECEIVE_FUNDS}. The returned key is stable until
|
||||
* {@link KeyChain.KeyPurpose#RECEIVE_FUNDS}. The returned key is stable until
|
||||
* it's actually seen in a pending or confirmed transaction, at which point this method will start returning
|
||||
* a different key (for each purpose independently).
|
||||
*/
|
||||
@ -459,15 +459,15 @@ public class Wallet extends BaseTaggableObject
|
||||
}
|
||||
|
||||
/**
|
||||
* An alias for calling {@link #currentKey(org.bitcoinj.wallet.KeyChain.KeyPurpose)} with
|
||||
* {@link org.bitcoinj.wallet.KeyChain.KeyPurpose#RECEIVE_FUNDS} as the parameter.
|
||||
* An alias for calling {@link #currentKey(KeyChain.KeyPurpose)} with
|
||||
* {@link KeyChain.KeyPurpose#RECEIVE_FUNDS} as the parameter.
|
||||
*/
|
||||
public DeterministicKey currentReceiveKey() {
|
||||
return currentKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns address for a {@link #currentKey(org.bitcoinj.wallet.KeyChain.KeyPurpose)}
|
||||
* Returns address for a {@link #currentKey(KeyChain.KeyPurpose)}
|
||||
*/
|
||||
public Address currentAddress(KeyChain.KeyPurpose purpose) {
|
||||
keyChainGroupLock.lock();
|
||||
@ -480,8 +480,8 @@ public class Wallet extends BaseTaggableObject
|
||||
}
|
||||
|
||||
/**
|
||||
* An alias for calling {@link #currentAddress(org.bitcoinj.wallet.KeyChain.KeyPurpose)} with
|
||||
* {@link org.bitcoinj.wallet.KeyChain.KeyPurpose#RECEIVE_FUNDS} as the parameter.
|
||||
* An alias for calling {@link #currentAddress(KeyChain.KeyPurpose)} with
|
||||
* {@link KeyChain.KeyPurpose#RECEIVE_FUNDS} as the parameter.
|
||||
*/
|
||||
public Address currentReceiveAddress() {
|
||||
return currentAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS);
|
||||
@ -490,8 +490,8 @@ public class Wallet extends BaseTaggableObject
|
||||
/**
|
||||
* Returns a key that has not been returned by this method before (fresh). You can think of this as being
|
||||
* a newly created key, although the notion of "create" is not really valid for a
|
||||
* {@link org.bitcoinj.wallet.DeterministicKeyChain}. When the parameter is
|
||||
* {@link org.bitcoinj.wallet.KeyChain.KeyPurpose#RECEIVE_FUNDS} the returned key is suitable for being put
|
||||
* {@link DeterministicKeyChain}. When the parameter is
|
||||
* {@link KeyChain.KeyPurpose#RECEIVE_FUNDS} the returned key is suitable for being put
|
||||
* into a receive coins wizard type UI. You should use this when the user is definitely going to hand this key out
|
||||
* to someone who wishes to send money.
|
||||
*/
|
||||
@ -502,8 +502,8 @@ public class Wallet extends BaseTaggableObject
|
||||
/**
|
||||
* Returns a key/s that has not been returned by this method before (fresh). You can think of this as being
|
||||
* a newly created key/s, although the notion of "create" is not really valid for a
|
||||
* {@link org.bitcoinj.wallet.DeterministicKeyChain}. When the parameter is
|
||||
* {@link org.bitcoinj.wallet.KeyChain.KeyPurpose#RECEIVE_FUNDS} the returned key is suitable for being put
|
||||
* {@link DeterministicKeyChain}. When the parameter is
|
||||
* {@link KeyChain.KeyPurpose#RECEIVE_FUNDS} the returned key is suitable for being put
|
||||
* into a receive coins wizard type UI. You should use this when the user is definitely going to hand this key/s out
|
||||
* to someone who wishes to send money.
|
||||
*/
|
||||
@ -523,15 +523,15 @@ public class Wallet extends BaseTaggableObject
|
||||
}
|
||||
|
||||
/**
|
||||
* An alias for calling {@link #freshKey(org.bitcoinj.wallet.KeyChain.KeyPurpose)} with
|
||||
* {@link org.bitcoinj.wallet.KeyChain.KeyPurpose#RECEIVE_FUNDS} as the parameter.
|
||||
* An alias for calling {@link #freshKey(KeyChain.KeyPurpose)} with
|
||||
* {@link KeyChain.KeyPurpose#RECEIVE_FUNDS} as the parameter.
|
||||
*/
|
||||
public DeterministicKey freshReceiveKey() {
|
||||
return freshKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns address for a {@link #freshKey(org.bitcoinj.wallet.KeyChain.KeyPurpose)}
|
||||
* Returns address for a {@link #freshKey(KeyChain.KeyPurpose)}
|
||||
*/
|
||||
public Address freshAddress(KeyChain.KeyPurpose purpose) {
|
||||
Address address;
|
||||
@ -546,8 +546,8 @@ public class Wallet extends BaseTaggableObject
|
||||
}
|
||||
|
||||
/**
|
||||
* An alias for calling {@link #freshAddress(org.bitcoinj.wallet.KeyChain.KeyPurpose)} with
|
||||
* {@link org.bitcoinj.wallet.KeyChain.KeyPurpose#RECEIVE_FUNDS} as the parameter.
|
||||
* An alias for calling {@link #freshAddress(KeyChain.KeyPurpose)} with
|
||||
* {@link KeyChain.KeyPurpose#RECEIVE_FUNDS} as the parameter.
|
||||
*/
|
||||
public Address freshReceiveAddress() {
|
||||
return freshAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS);
|
||||
@ -596,7 +596,7 @@ public class Wallet extends BaseTaggableObject
|
||||
|
||||
/**
|
||||
* Returns true if the wallet contains random keys and no HD chains, in which case you should call
|
||||
* {@link #upgradeToDeterministic(org.spongycastle.crypto.params.KeyParameter)} before attempting to do anything
|
||||
* {@link #upgradeToDeterministic(KeyParameter)} before attempting to do anything
|
||||
* that would require a new address or key.
|
||||
*/
|
||||
public boolean isDeterministicUpgradeRequired() {
|
||||
@ -704,7 +704,7 @@ public class Wallet extends BaseTaggableObject
|
||||
|
||||
/**
|
||||
* Imports the given keys to the wallet.
|
||||
* If {@link Wallet#autosaveToFile(java.io.File, long, java.util.concurrent.TimeUnit, org.bitcoinj.wallet.WalletFiles.Listener)}
|
||||
* If {@link Wallet#autosaveToFile(File, long, TimeUnit, WalletFiles.Listener)}
|
||||
* has been called, triggers an auto save bypassing the normal coalescing delay and event handlers.
|
||||
* Returns the number of keys added, after duplicates are ignored. The onKeyAdded event will be called for each key
|
||||
* in the list that was not already present.
|
||||
@ -772,7 +772,7 @@ public class Wallet extends BaseTaggableObject
|
||||
}
|
||||
}
|
||||
|
||||
/** See {@link org.bitcoinj.wallet.DeterministicKeyChain#setLookaheadSize(int)} for more info on this. */
|
||||
/** See {@link DeterministicKeyChain#setLookaheadSize(int)} for more info on this. */
|
||||
public void setKeyChainGroupLookaheadSize(int lookaheadSize) {
|
||||
keyChainGroupLock.lock();
|
||||
try {
|
||||
@ -782,7 +782,7 @@ public class Wallet extends BaseTaggableObject
|
||||
}
|
||||
}
|
||||
|
||||
/** See {@link org.bitcoinj.wallet.DeterministicKeyChain#setLookaheadSize(int)} for more info on this. */
|
||||
/** See {@link DeterministicKeyChain#setLookaheadSize(int)} for more info on this. */
|
||||
public int getKeyChainGroupLookaheadSize() {
|
||||
keyChainGroupLock.lock();
|
||||
try {
|
||||
@ -792,7 +792,7 @@ public class Wallet extends BaseTaggableObject
|
||||
}
|
||||
}
|
||||
|
||||
/** See {@link org.bitcoinj.wallet.DeterministicKeyChain#setLookaheadThreshold(int)} for more info on this. */
|
||||
/** See {@link DeterministicKeyChain#setLookaheadThreshold(int)} for more info on this. */
|
||||
public void setKeyChainGroupLookaheadThreshold(int num) {
|
||||
keyChainGroupLock.lock();
|
||||
try {
|
||||
@ -803,7 +803,7 @@ public class Wallet extends BaseTaggableObject
|
||||
}
|
||||
}
|
||||
|
||||
/** See {@link org.bitcoinj.wallet.DeterministicKeyChain#setLookaheadThreshold(int)} for more info on this. */
|
||||
/** See {@link DeterministicKeyChain#setLookaheadThreshold(int)} for more info on this. */
|
||||
public int getKeyChainGroupLookaheadThreshold() {
|
||||
keyChainGroupLock.lock();
|
||||
try {
|
||||
@ -1072,7 +1072,7 @@ public class Wallet extends BaseTaggableObject
|
||||
|
||||
/**
|
||||
* Marks all keys used in the transaction output as used in the wallet.
|
||||
* See {@link org.bitcoinj.wallet.DeterministicKeyChain#markKeyAsUsed(DeterministicKey)} for more info on this.
|
||||
* See {@link DeterministicKeyChain#markKeyAsUsed(DeterministicKey)} for more info on this.
|
||||
*/
|
||||
private void markKeysAsUsed(Transaction tx) {
|
||||
keyChainGroupLock.lock();
|
||||
@ -1132,7 +1132,7 @@ public class Wallet extends BaseTaggableObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience wrapper around {@link Wallet#encrypt(org.bitcoinj.crypto.KeyCrypter,
|
||||
* Convenience wrapper around {@link Wallet#encrypt(KeyCrypter,
|
||||
* org.spongycastle.crypto.params.KeyParameter)} which uses the default Scrypt key derivation algorithm and
|
||||
* parameters to derive a key from the given password.
|
||||
*/
|
||||
@ -1149,7 +1149,7 @@ public class Wallet extends BaseTaggableObject
|
||||
|
||||
/**
|
||||
* Encrypt the wallet using the KeyCrypter and the AES key. A good default KeyCrypter to use is
|
||||
* {@link org.bitcoinj.crypto.KeyCrypterScrypt}.
|
||||
* {@link KeyCrypterScrypt}.
|
||||
*
|
||||
* @param keyCrypter The KeyCrypter that specifies how to encrypt/ decrypt a key
|
||||
* @param aesKey AES key to use (normally created using KeyCrypter#deriveKey and cached as it is time consuming to create from a password)
|
||||
@ -1449,7 +1449,7 @@ public class Wallet extends BaseTaggableObject
|
||||
/**
|
||||
* <p>
|
||||
* Disables auto-saving, after it had been enabled with
|
||||
* {@link Wallet#autosaveToFile(java.io.File, long, java.util.concurrent.TimeUnit, org.bitcoinj.wallet.WalletFiles.Listener)}
|
||||
* {@link Wallet#autosaveToFile(File, long, TimeUnit, WalletFiles.Listener)}
|
||||
* before. This method blocks until finished.
|
||||
* </p>
|
||||
*/
|
||||
@ -1679,7 +1679,7 @@ public class Wallet extends BaseTaggableObject
|
||||
* and if you trust the sender of the transaction you can choose to assume they are in fact valid and will not
|
||||
* be double spent as an optimization.</p>
|
||||
*
|
||||
* <p>This is the same as {@link Wallet#receivePending(Transaction, java.util.List)} but allows you to override the
|
||||
* <p>This is the same as {@link Wallet#receivePending(Transaction, List)} but allows you to override the
|
||||
* {@link Wallet#isPendingTransactionRelevant(Transaction)} sanity-check to keep track of transactions that are not
|
||||
* spendable or spend our coins. This can be useful when you want to keep track of transaction confidence on
|
||||
* arbitrary transactions. Note that transactions added in this way will still be relayed to peers and appear in
|
||||
@ -1772,7 +1772,7 @@ public class Wallet extends BaseTaggableObject
|
||||
/**
|
||||
* This method is used by a {@link Peer} to find out if a transaction that has been announced is interesting,
|
||||
* that is, whether we should bother downloading its dependencies and exploring the transaction to decide how
|
||||
* risky it is. If this method returns true then {@link Wallet#receivePending(Transaction, java.util.List)}
|
||||
* risky it is. If this method returns true then {@link Wallet#receivePending(Transaction, List)}
|
||||
* will soon be called with the transactions dependencies as well.
|
||||
*/
|
||||
public boolean isPendingTransactionRelevant(Transaction tx) throws ScriptException {
|
||||
@ -2111,7 +2111,7 @@ public class Wallet extends BaseTaggableObject
|
||||
/**
|
||||
* <p>Called by the {@link BlockChain} when a new block on the best chain is seen, AFTER relevant wallet
|
||||
* transactions are extracted and sent to us UNLESS the new block caused a re-org, in which case this will
|
||||
* not be called (the {@link Wallet#reorganize(StoredBlock, java.util.List, java.util.List)} method will
|
||||
* not be called (the {@link Wallet#reorganize(StoredBlock, List, List)} method will
|
||||
* call this one in that case).</p>
|
||||
* <p>Used to update confidence data in each transaction and last seen block hash. Triggers auto saving.
|
||||
* Invokes the onWalletChanged event listener if there were any affected transactions.</p>
|
||||
@ -2252,7 +2252,7 @@ public class Wallet extends BaseTaggableObject
|
||||
* up with the block chain. It can also happen if a block includes a transaction we never saw at broadcast time.
|
||||
* If this tx double spends, it takes precedence over our pending transactions and the pending tx goes dead.</p>
|
||||
*
|
||||
* <p>The other context it can be called is from {@link Wallet#receivePending(Transaction, java.util.List)},
|
||||
* <p>The other context it can be called is from {@link Wallet#receivePending(Transaction, List)},
|
||||
* ie we saw a tx be broadcast or one was submitted directly that spends our own coins. If this tx double spends
|
||||
* it does NOT take precedence because the winner will be resolved by the miners - we assume that our version will
|
||||
* win, if we are wrong then when a block appears the tx will go dead.</p>
|
||||
@ -3289,7 +3289,7 @@ public class Wallet extends BaseTaggableObject
|
||||
|
||||
/**
|
||||
* Returns the earliest creation time of keys or watched scripts in this wallet, in seconds since the epoch, ie the min
|
||||
* of {@link org.bitcoinj.core.ECKey#getCreationTimeSeconds()}. This can return zero if at least one key does
|
||||
* of {@link ECKey#getCreationTimeSeconds()}. This can return zero if at least one key does
|
||||
* not have that data (was created before key timestamping was implemented). <p>
|
||||
*
|
||||
* This method is most often used in conjunction with {@link PeerGroup#setFastCatchupTimeSecs(long)} in order to
|
||||
@ -3534,7 +3534,7 @@ public class Wallet extends BaseTaggableObject
|
||||
* money to fail! Finally please be aware that any listeners on the future will run either on the calling thread
|
||||
* if it completes immediately, or eventually on a background thread if the balance is not yet at the right
|
||||
* level. If you do something that means you know the balance should be sufficient to trigger the future,
|
||||
* you can use {@link org.bitcoinj.utils.Threading#waitForUserCode()} to block until the future had a
|
||||
* you can use {@link Threading#waitForUserCode()} to block until the future had a
|
||||
* chance to be updated.</p>
|
||||
*/
|
||||
public ListenableFuture<Coin> getBalanceFuture(final Coin value, final BalanceType type) {
|
||||
@ -3686,8 +3686,8 @@ public class Wallet extends BaseTaggableObject
|
||||
*/
|
||||
USE_DUMMY_SIG,
|
||||
/**
|
||||
* If signature is missing, {@link org.bitcoinj.signers.TransactionSigner.MissingSignatureException}
|
||||
* will be thrown for P2SH and {@link org.bitcoinj.core.ECKey.MissingPrivateKeyException} for other tx types.
|
||||
* If signature is missing, {@link TransactionSigner.MissingSignatureException}
|
||||
* will be thrown for P2SH and {@link ECKey.MissingPrivateKeyException} for other tx types.
|
||||
*/
|
||||
THROW
|
||||
}
|
||||
@ -4627,7 +4627,7 @@ public class Wallet extends BaseTaggableObject
|
||||
* <p>This is used to generate a BloomFilter which can be {@link BloomFilter#merge(BloomFilter)}d with another.
|
||||
* It could also be used if you have a specific target for the filter's size.</p>
|
||||
*
|
||||
* <p>See the docs for {@link BloomFilter#BloomFilter(int, double, long, org.bitcoinj.core.BloomFilter.BloomUpdate)} for a brief explanation of anonymity when using bloom
|
||||
* <p>See the docs for {@link BloomFilter#BloomFilter(int, double, long, BloomFilter.BloomUpdate)} for a brief explanation of anonymity when using bloom
|
||||
* filters.</p>
|
||||
*/
|
||||
@Override @GuardedBy("keyChainGroupLock")
|
||||
@ -5013,7 +5013,7 @@ public class Wallet extends BaseTaggableObject
|
||||
* <p>When a key rotation time is set, any money controlled by keys created before the given timestamp T will be
|
||||
* automatically respent to any key that was created after T. This can be used to recover from a situation where
|
||||
* a set of keys is believed to be compromised. You can stop key rotation by calling this method again with zero
|
||||
* as the argument. Once set up, calling {@link #doMaintenance(org.spongycastle.crypto.params.KeyParameter, boolean)}
|
||||
* as the argument. Once set up, calling {@link #doMaintenance(KeyParameter, boolean)}
|
||||
* will create and possibly send rotation transactions: but it won't be done automatically (because you might have
|
||||
* to ask for the users password).</p>
|
||||
*
|
||||
|
@ -17,8 +17,17 @@
|
||||
|
||||
package org.bitcoinj.wallet;
|
||||
|
||||
import org.bitcoinj.core.*;
|
||||
import com.google.protobuf.Message;
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.bitcoinj.core.NetworkParameters;
|
||||
import org.bitcoinj.core.PeerAddress;
|
||||
import org.bitcoinj.core.Sha256Hash;
|
||||
import org.bitcoinj.core.Transaction;
|
||||
import org.bitcoinj.core.TransactionConfidence;
|
||||
import org.bitcoinj.core.TransactionConfidence.ConfidenceType;
|
||||
import org.bitcoinj.core.TransactionInput;
|
||||
import org.bitcoinj.core.TransactionOutPoint;
|
||||
import org.bitcoinj.core.TransactionOutput;
|
||||
import org.bitcoinj.crypto.KeyCrypter;
|
||||
import org.bitcoinj.crypto.KeyCrypterScrypt;
|
||||
import org.bitcoinj.script.Script;
|
||||
@ -40,6 +49,9 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
@ -59,8 +71,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
* format is defined by the <tt>wallet.proto</tt> file in the bitcoinj source distribution.<p>
|
||||
*
|
||||
* This class is used through its static methods. The most common operations are writeWallet and readWallet, which do
|
||||
* the obvious operations on Output/InputStreams. You can use a {@link java.io.ByteArrayInputStream} and equivalent
|
||||
* {@link java.io.ByteArrayOutputStream} if you'd like byte arrays instead. The protocol buffer can also be manipulated
|
||||
* the obvious operations on Output/InputStreams. You can use a {@link ByteArrayInputStream} and equivalent
|
||||
* {@link ByteArrayOutputStream} if you'd like byte arrays instead. The protocol buffer can also be manipulated
|
||||
* in its object form if you'd like to modify the flattened data structure before serialization to binary.<p>
|
||||
*
|
||||
* You can extend the wallet format with additional fields specific to your application if you want, but make sure
|
||||
@ -147,7 +159,7 @@ public class WalletProtobufSerializer {
|
||||
|
||||
/**
|
||||
* Returns the given wallet formatted as text. The text format is that used by protocol buffers and although it
|
||||
* can also be parsed using {@link TextFormat#merge(CharSequence, com.google.protobuf.Message.Builder)},
|
||||
* can also be parsed using {@link TextFormat#merge(CharSequence, Message.Builder)},
|
||||
* it is designed more for debugging than storage. It is not well specified and wallets are largely binary data
|
||||
* structures anyway, consisting as they do of keys (large random numbers) and {@link Transaction}s which also
|
||||
* mostly contain keys and hashes.
|
||||
@ -617,7 +629,7 @@ public class WalletProtobufSerializer {
|
||||
|
||||
/**
|
||||
* Returns the loaded protocol buffer from the given byte stream. You normally want
|
||||
* {@link Wallet#loadFromFile(java.io.File, WalletExtension...)} instead - this method is designed for low level
|
||||
* {@link Wallet#loadFromFile(File, WalletExtension...)} instead - this method is designed for low level
|
||||
* work involving the wallet file format itself.
|
||||
*/
|
||||
public static Protos.Wallet parseToProto(InputStream input) throws IOException {
|
||||
|
@ -21,7 +21,7 @@ import org.bitcoinj.core.Transaction;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Stores data about a transaction that is only relevant to the {@link org.bitcoinj.wallet.Wallet} class.
|
||||
* Stores data about a transaction that is only relevant to the {@link Wallet} class.
|
||||
*/
|
||||
public class WalletTransaction {
|
||||
public enum Pool {
|
||||
|
@ -31,7 +31,7 @@ public interface WalletCoinsReceivedEventListener {
|
||||
* was broadcast across the network or because a block was received. If a transaction is seen when it was broadcast,
|
||||
* onCoinsReceived won't be called again when a block containing it is received. If you want to know when such a
|
||||
* transaction receives its first confirmation, register a {@link TransactionConfidence} event listener using
|
||||
* the object retrieved via {@link org.bitcoinj.core.Transaction#getConfidence()}. It's safe to modify the
|
||||
* the object retrieved via {@link Transaction#getConfidence()}. It's safe to modify the
|
||||
* wallet in this callback, for example, by spending the transaction just received.
|
||||
*
|
||||
* @param wallet The wallet object that received the coins
|
||||
|
@ -26,7 +26,7 @@ import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
|
||||
/**
|
||||
* An extension of {@link org.bitcoinj.core.PeerSocketHandler} that keeps inbound messages in a queue for later processing
|
||||
* An extension of {@link PeerSocketHandler} that keeps inbound messages in a queue for later processing
|
||||
*/
|
||||
public abstract class InboundMessageQueuer extends PeerSocketHandler {
|
||||
public final BlockingQueue<Message> inboundMessages = new ArrayBlockingQueue<>(1000);
|
||||
|
@ -25,7 +25,7 @@ import com.google.common.base.Preconditions;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/** Very thin wrapper around {@link org.bitcoinj.utils.BlockFileLoader} */
|
||||
/** Very thin wrapper around {@link BlockFileLoader} */
|
||||
public class BlockImporter {
|
||||
public static void main(String[] args) throws BlockStoreException, VerificationException, PrunedException {
|
||||
System.out.println("USAGE: BlockImporter (prod|test) (H2|Disk|MemFull|Mem|SPV) [blockStore]");
|
||||
|
@ -26,6 +26,7 @@ import org.bitcoinj.wallet.SendRequest;
|
||||
import org.bitcoinj.wallet.Wallet;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
/**
|
||||
* A program that sends a transaction with the specified fee and measures how long it takes to confirm.
|
||||
@ -57,7 +58,7 @@ public class TestFeeLevel {
|
||||
}
|
||||
}
|
||||
|
||||
private static void go(Coin feeRateToTest, int numOutputs) throws InterruptedException, java.util.concurrent.ExecutionException, InsufficientMoneyException {
|
||||
private static void go(Coin feeRateToTest, int numOutputs) throws InterruptedException, ExecutionException, InsufficientMoneyException {
|
||||
System.out.println("Wallet has " + kit.wallet().getBalance().toFriendlyString()
|
||||
+ "; current receive address is " + kit.wallet().currentReceiveAddress());
|
||||
|
||||
|
@ -21,7 +21,7 @@ import javafx.application.Platform;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
* A simple wrapper around {@link javafx.application.Platform#runLater(Runnable)} which will do nothing if the previous
|
||||
* A simple wrapper around {@link Platform#runLater(Runnable)} which will do nothing if the previous
|
||||
* invocation of runLater didn't execute on the JavaFX UI thread yet. In this way you can avoid flooding
|
||||
* the event loop if you have a background thread that for whatever reason wants to update the UI very
|
||||
* frequently. Without this class you could end up bloating up memory usage and causing the UI to stutter
|
||||
|
Loading…
x
Reference in New Issue
Block a user