diff --git a/core/src/main/java/com/google/bitcoin/core/PeerAddress.java b/core/src/main/java/com/google/bitcoin/core/PeerAddress.java
index <HASH>..<HASH> 100644
--- a/core/src/main/java/com/google/bitcoin/core/PeerAddress.java
+++ b/core/src/main/java/com/google/bitcoin/core/PeerAddress.java
@@ -99,6 +99,14 @@ public class PeerAddress extends ChildMessage {
         this(addr.getAddress(), addr.getPort());
     }
 
+    public static PeerAddress localhost(NetworkParameters params) {
+        try {
+            return new PeerAddress(InetAddress.getLocalHost(), params.getPort());
+        } catch (UnknownHostException e) {
+            throw new RuntimeException(e);  // Broken system.
+        }
+    }
+
     @Override
     protected void bitcoinSerializeToStream(OutputStream stream) throws IOException {
         if (protocolVersion >= 31402) {
Add a PeerAddress.localhost() helper.