mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-07-30 19:41:24 +00:00
Wallet: Add isAddressMine() convenience method.
This commit is contained in:
@@ -58,6 +58,7 @@ import org.bitcoinj.core.VerificationException;
|
||||
import org.bitcoinj.core.TransactionConfidence.*;
|
||||
import org.bitcoinj.crypto.*;
|
||||
import org.bitcoinj.script.*;
|
||||
import org.bitcoinj.script.Script.ScriptType;
|
||||
import org.bitcoinj.signers.*;
|
||||
import org.bitcoinj.utils.*;
|
||||
import org.bitcoinj.wallet.Protos.Wallet.*;
|
||||
@@ -1015,6 +1016,17 @@ public class Wallet extends BaseTaggableObject
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the address is belongs to this wallet.
|
||||
*/
|
||||
public boolean isAddressMine(Address address) {
|
||||
final ScriptType scriptType = address.getOutputScriptType();
|
||||
if (scriptType == ScriptType.P2PKH || scriptType == ScriptType.P2WPKH)
|
||||
return isPubKeyHashMine(address.getHash());
|
||||
else
|
||||
throw new IllegalArgumentException(address.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPubKeyHashMine(byte[] pubkeyHash) {
|
||||
return findKeyFromPubHash(pubkeyHash) != null;
|
||||
|
Reference in New Issue
Block a user