Skip to content

Commit 1d15d95

Browse files
author
Andreas Schildbach
committed
Some Javadoc changes related to addresses.
1 parent 44474be commit 1d15d95

File tree

4 files changed

+40
-18
lines changed

4 files changed

+40
-18
lines changed

core/src/main/java/org/bitcoinj/core/Address.java

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ private Address(NetworkParameters params, int version, byte[] hash160) throws Wr
7272
}
7373

7474
/**
75-
* Construct an {@link Address} that represents the given pubkey hash. The resulting address will be a P2PKH type of
75+
* Construct a {@link Address} that represents the given pubkey hash. The resulting address will be a P2PKH type of
7676
* address.
7777
*
7878
* @param params
79-
* the network this address is valid for
79+
* network this address is valid for
8080
* @param hash160
8181
* 20-byte pubkey hash
8282
* @return constructed address
@@ -86,34 +86,58 @@ public static Address fromPubKeyHash(NetworkParameters params, byte[] hash160) {
8686
}
8787

8888
/**
89-
* Returns an {@link Address} that represents the public part of the given {@link ECKey}. Note that an address is
90-
* derived from a hash of the public key and is not the public key itself (which is too large to be convenient).
89+
* Construct a {@link Address} that represents the public part of the given {@link ECKey}. Note that an address is
90+
* derived from a hash of the public key and is not the public key itself.
91+
*
92+
* @param params
93+
* network this address is valid for
94+
* @param key
95+
* only the public part is used
96+
* @return constructed address
9197
*/
9298
public static Address fromKey(NetworkParameters params, ECKey key) {
9399
return fromPubKeyHash(params, key.getPubKeyHash());
94100
}
95101

96-
/** Returns an Address that represents the given P2SH script hash. */
102+
/**
103+
* Construct a {@link Address} that represents the given P2SH script hash.
104+
*
105+
* @param params
106+
* network this address is valid for
107+
* @param hash160
108+
* P2SH script hash
109+
* @return constructed address
110+
*/
97111
public static Address fromP2SHHash(NetworkParameters params, byte[] hash160) {
98112
try {
99113
return new Address(params, params.getP2SHHeader(), hash160);
100114
} catch (WrongNetworkException e) {
101-
throw new RuntimeException(e); // Cannot happen.
115+
throw new RuntimeException(e); // Cannot happen.
102116
}
103117
}
104118

105-
/** Returns an Address that represents the script hash extracted from the given scriptPubKey */
119+
/**
120+
* Constructs a {@link Address} that represents the script hash extracted from the given scriptPubKey.
121+
*
122+
* @param params
123+
* network this address is valid for
124+
* @param scriptPubKey
125+
* scriptPubKey
126+
* @return constructed address
127+
*/
106128
public static Address fromP2SHScript(NetworkParameters params, Script scriptPubKey) {
107129
checkArgument(ScriptPattern.isPayToScriptHash(scriptPubKey), "Not a P2SH script");
108130
return fromP2SHHash(params, ScriptPattern.extractHashFromPayToScriptHash(scriptPubKey));
109131
}
110132

111133
/**
112-
* Construct an address from its Base58 representation.
134+
* Construct a {@link Address} from its base58 form.
135+
*
113136
* @param params
114-
* The expected NetworkParameters or null if you don't want validation.
137+
* expected network this address is valid for, or null if if the network should be derived from the
138+
* base58
115139
* @param base58
116-
* The textual form of the address, such as "17kzeh4N8g49GFvdDzSf8PjaPfyoD1MndL".
140+
* base58-encoded textual form of the address
117141
* @throws AddressFormatException
118142
* if the given base58 doesn't parse or the checksum is invalid
119143
* @throws WrongNetworkException
@@ -173,7 +197,7 @@ public boolean isP2SHAddress() {
173197
* compatible with the current wallet. You should be able to handle a null response from this method. Note that the
174198
* parameters returned is not necessarily the same as the one the Address was created with.
175199
*
176-
* @return a NetworkParameters representing the network the address is intended for.
200+
* @return network the address is valid for
177201
*/
178202
public NetworkParameters getParameters() {
179203
return params;
@@ -183,7 +207,8 @@ public NetworkParameters getParameters() {
183207
* Given an address, examines the version byte and attempts to find a matching NetworkParameters. If you aren't sure
184208
* which network the address is intended for (eg, it was provided by a user), you can use this to decide if it is
185209
* compatible with the current wallet.
186-
* @return a NetworkParameters of the address
210+
*
211+
* @return network the address is valid for
187212
* @throws AddressFormatException if the string wasn't of a known version
188213
*/
189214
public static NetworkParameters getParametersFromAddress(String address) throws AddressFormatException {
@@ -205,9 +230,6 @@ private static boolean isAcceptableVersion(NetworkParameters params, int version
205230
return false;
206231
}
207232

208-
/**
209-
* This implementation narrows the return type to <code>Address</code>.
210-
*/
211233
@Override
212234
public Address clone() throws CloneNotSupportedException {
213235
return (Address) super.clone();

core/src/main/java/org/bitcoinj/core/WrongNetworkException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package org.bitcoinj.core;
1818

1919
/**
20-
* This exception is thrown by the Address class when you try and decode an address with a version code that isn't
20+
* This exception is thrown by the address class when you try and decode an address with a version code that isn't
2121
* used by that network. You shouldn't allow the user to proceed in this case as they are trying to send money across
2222
* different chains, an operation that is guaranteed to destroy the money.
2323
*/

core/src/main/java/org/bitcoinj/params/Networks.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import java.util.Set;
2525

2626
/**
27-
* Utility class that holds all the registered NetworkParameters types used for Address auto discovery.
27+
* Utility class that holds all the registered NetworkParameters types used for address auto discovery.
2828
* By default only MainNetParams and TestNet3Params are used. If you want to use TestNet2, RegTestParams or
2929
* UnitTestParams use the register and unregister the TestNet3Params as they don't have their own address
3030
* version/type code.

core/src/main/java/org/bitcoinj/uri/BitcoinURI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ private void putWithValidation(String key, Object value) throws BitcoinURIParseE
255255
}
256256

257257
/**
258-
* The Bitcoin Address from the URI, if one was present. It's possible to have Bitcoin URI's with no address if a
258+
* The Bitcoin address from the URI, if one was present. It's possible to have Bitcoin URI's with no address if a
259259
* r= payment protocol parameter is specified, though this form is not recommended as older wallets can't understand
260260
* it.
261261
*/

0 commit comments

Comments
 (0)