Explore all Wrapper open source software, libraries, packages, source code, cloud functions and APIs.

Popular New Releases in Wrapper

node-serialport

ReLinker

1.4.3

pyserial

classgraph

classgraph-4.8.146

javacpp-presets

JavaCPP Presets 1.5.6

Popular Libraries in Wrapper

jna

by java-native-access doticonjavadoticon

star image 6675 doticonNOASSERTION

Java Native Access

node-serialport

by serialport doticontypescriptdoticon

star image 5146 doticonMIT

Access serial ports with JavaScript. Linux, OSX and Windows. Welcome your robotic JavaScript overlords. Better yet, program them!

lunchy

by eddiezane doticonrubydoticon

star image 2795 doticonMIT

A friendly wrapper for launchctl

ReLinker

by KeepSafe doticonjavadoticon

star image 2474 doticonApache-2.0

A robust native library loader for Android.

pyserial

by pyserial doticonpythondoticon

star image 2386 doticonNOASSERTION

Python serial port access library

rust-bindgen

by rust-lang doticonc++doticon

star image 2298 doticonBSD-3-Clause

Automatically generates Rust FFI bindings to C (and some C++) libraries.

esp-link

by jeelabs doticoncdoticon

star image 2255 doticonNOASSERTION

esp8266 wifi-serial bridge, outbound TCP, and arduino/AVR/LPC/NXP programmer

classgraph

by classgraph doticonjavadoticon

star image 2206 doticonMIT

An uber-fast parallelized Java classpath scanner and module scanner.

python-magic

by ahupp doticonpythondoticon

star image 2030 doticonNOASSERTION

A python wrapper for libmagic

Trending New libraries in Wrapper

flutter_rust_bridge

by fzyzcjy doticonrustdoticon

star image 1054 doticonMIT

High-level memory-safe binding generator for Flutter/Dart <-> Rust

lines-of-code

by sebastianbergmann doticonphpdoticon

star image 504 doticonNOASSERTION

Library for counting the lines of code in PHP source code

safer_ffi

by getditto doticonrustdoticon

star image 460 doticonMIT

Write safer FFI code in Rust without polluting it with unsafe code

KeepAlive

by lcodecorex doticoncdoticon

star image 422 doticonMIT

Fighting against force-stop kill process on Android with binder ioctl / Android高级保活

ID-INVADED-WINDOWED

by COLOR-SKY doticonpythondoticon

star image 365 doticonMIT

Source code of my project ID:INVADED(WINDOWED)

DefaultCodable

by gonzalezreal doticonswiftdoticon

star image 304 doticonMIT

A convenient way to handle default values with Swift Codable types

codeinterview-backend

by areebbeigh doticonpythondoticon

star image 204 doticonApache-2.0

Backend code repository for CodeInterview

ffmpeg-go

by u2takey doticongodoticon

star image 196 doticonApache-2.0

golang binding for ffmpeg

rsmpeg

by larksuite doticonrustdoticon

star image 195 doticonMIT

A Rust crate that exposes FFmpeg's power as much as possible.

Top Authors in Wrapper

1

postmodern

10 Libraries

star icon110

2

dcuddeback

8 Libraries

star icon388

3

sophsec

7 Libraries

star icon79

4

jnr

5 Libraries

star icon1061

5

lemonrock

5 Libraries

star icon14

6

luapower

5 Libraries

star icon30

7

adam-singer

4 Libraries

star icon22

8

PerlFFI

4 Libraries

star icon94

9

xanthium-enterprises

4 Libraries

star icon21

10

nabijaczleweli

4 Libraries

star icon61

1

10 Libraries

star icon110

2

8 Libraries

star icon388

3

7 Libraries

star icon79

4

5 Libraries

star icon1061

5

5 Libraries

star icon14

6

5 Libraries

star icon30

7

4 Libraries

star icon22

8

4 Libraries

star icon94

9

4 Libraries

star icon21

10

4 Libraries

star icon61

Trending Kits in Wrapper

No Trending Kits are available at this moment for Wrapper

Trending Discussions on Wrapper

Could not GET 'play-services-location/maven-metadata.xml'. Received status code 502 from server: Bad Gateway

Android app won't build -- The minCompileSdk (31) specified in a dependency's androidx.work:work-runtime:2.7.0-beta01

Vue 3 passing array warning: Extraneous non-props attributes were passed to component but could not be automatically inherited

AttributeError: Can't get attribute 'new_block' on &lt;module 'pandas.core.internals.blocks'&gt;

&quot;Cannot read properties of undefined (reading 'pathname')&quot; when testing pages in the v6 React Router

pymongo [SSL: CERTIFICATE_VERIFY_FAILED]: certificate has expired on Mongo Atlas

How to set max-height of dropdown selection area?

How do I get details of a veracode vulnerability report?

How can I get notified when money has been sent to a particular Bitcoin address on a local regtest network?

ModuleNotFoundError: No module named 'jsonschema.compat'

QUESTION

Could not GET 'play-services-location/maven-metadata.xml'. Received status code 502 from server: Bad Gateway

Asked 2022-Mar-28 at 07:02

I have a project which was running well yesterday, but today I find this problem:

Could not resolve all files for configuration ':app:debugRuntimeClasspath'. Could not resolve com.google.android.gms:play-services-location:16.+. Required by: project :app > project :location > Failed to list versions for com.google.android.gms:play-services-location. > Unable to load Maven meta-data from https://google.bintray.com/exoplayer/com/google/android/gms/play-services-location/maven-metadata.xml. > Could not get resource 'https://google.bintray.com/exoplayer/com/google/android/gms/play-services-location/maven-metadata.xml'. > Could not GET 'https://google.bintray.com/exoplayer/com/google/android/gms/play-services-location/maven-metadata.xml'. Received status code 502 from server: Bad Gateway

acutely I'm using classpath 'com.android.tools.build:gradle:4.1.0'with distributionUrl=https://services.gradle.org/distributions/gradle-6.5-bin.zip I have followed this question and I upgraded 'com.android.tools.build:gradle:4.1.0' to classpath 'com.android.tools.build:gradle:4.2.0' then I changed distributionUrl=https://services.gradle.org/distributions/gradle-6.5-bin.zip to distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip but I still got the error.

my android/build.gradle:

1buildscript {
2    repositories {
3        google()
4        jcenter()
5    }
6
7    dependencies {
8        classpath 'com.android.tools.build:gradle:4.2.0'
9    }
10}
11
12allprojects {
13    repositories {
14        google()
15        jcenter()
16    }
17}
18
19rootProject.buildDir = '../build'
20subprojects {
21    project.buildDir = &quot;${rootProject.buildDir}/${project.name}&quot;
22}
23subprojects {
24    project.evaluationDependsOn(':app')
25}
26
27task clean(type: Delete) {
28    delete rootProject.buildDir
29}
30

and gradle-wrapper.properties:

1buildscript {
2    repositories {
3        google()
4        jcenter()
5    }
6
7    dependencies {
8        classpath 'com.android.tools.build:gradle:4.2.0'
9    }
10}
11
12allprojects {
13    repositories {
14        google()
15        jcenter()
16    }
17}
18
19rootProject.buildDir = '../build'
20subprojects {
21    project.buildDir = &quot;${rootProject.buildDir}/${project.name}&quot;
22}
23subprojects {
24    project.evaluationDependsOn(':app')
25}
26
27task clean(type: Delete) {
28    delete rootProject.buildDir
29}
30distributionBase=GRADLE_USER_HOME
31distributionPath=wrapper/dists
32zipStoreBase=GRADLE_USER_HOME
33zipStorePath=wrapper/dists
34distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
35

Also I have changed the compileSdkVersion , minSdkVersion and targetSdkVersion to be 30 but nothing happened.

ANSWER

Answered 2021-Dec-01 at 09:09

It looks like a temporary issue, the server with these libraries is down. I have the same problem now with Room:

1buildscript {
2    repositories {
3        google()
4        jcenter()
5    }
6
7    dependencies {
8        classpath 'com.android.tools.build:gradle:4.2.0'
9    }
10}
11
12allprojects {
13    repositories {
14        google()
15        jcenter()
16    }
17}
18
19rootProject.buildDir = '../build'
20subprojects {
21    project.buildDir = &quot;${rootProject.buildDir}/${project.name}&quot;
22}
23subprojects {
24    project.evaluationDependsOn(':app')
25}
26
27task clean(type: Delete) {
28    delete rootProject.buildDir
29}
30distributionBase=GRADLE_USER_HOME
31distributionPath=wrapper/dists
32zipStoreBase=GRADLE_USER_HOME
33zipStorePath=wrapper/dists
34distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
35Could not GET 'https://google.bintray.com/exoplayer/androidx/room/room-common/maven-metadata.xml'. Received status code 502 from server: Bad Gateway
36

You can try using offline mode if you're using Android Studio, then it will use the cached version of this library if you have it until it is fixed.

UPD. I switched to an alpha version of a flutter lib which caused this (workmanager) and it works well now. As far as I understand it was depending on an old version of Android Room library which is not available anymore since Bintray is not available. The new version of Room is available as it's being downloaded thorough another link. So for you the solution could be updating to a newer version of Flutter location package or forking it and changing the version of play-services-location to the most recent one.

Source https://stackoverflow.com/questions/70166663

QUESTION

Android app won't build -- The minCompileSdk (31) specified in a dependency's androidx.work:work-runtime:2.7.0-beta01

Asked 2022-Mar-11 at 16:01

I'm trying to build a project in my M1,

but I got this error when I run npx react-native run-android

1FAILURE: Build failed with an exception.
2
3* What went wrong:
4Execution failed for task ':app:checkDebugAarMetadata'.
5&gt; A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
6   &gt; The minCompileSdk (31) specified in a
7     dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
8     is greater than this module's compileSdkVersion (android-30).
9     Dependency: androidx.work:work-runtime:2.7.0-beta01.
10     AAR metadata file: /Users/macpro/.gradle/caches/transforms-3/999e9d813832e06d8f1b7de52647a502/transformed/work-runtime-2.7.0-beta01/META-INF/com/android/build/gradle/aar-metadata.properties.
11

Android/build.gradle

1FAILURE: Build failed with an exception.
2
3* What went wrong:
4Execution failed for task ':app:checkDebugAarMetadata'.
5&gt; A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
6   &gt; The minCompileSdk (31) specified in a
7     dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
8     is greater than this module's compileSdkVersion (android-30).
9     Dependency: androidx.work:work-runtime:2.7.0-beta01.
10     AAR metadata file: /Users/macpro/.gradle/caches/transforms-3/999e9d813832e06d8f1b7de52647a502/transformed/work-runtime-2.7.0-beta01/META-INF/com/android/build/gradle/aar-metadata.properties.
11// Top-level build file where you can add configuration options common to all sub-projects/modules.
12
13buildscript {
14    ext {
15        buildToolsVersion = &quot;30.0.0&quot;
16        minSdkVersion = 21
17        compileSdkVersion = 30
18        targetSdkVersion = 30
19        supportLibVersion   = &quot;28.0.0&quot;
20    }
21    repositories {
22        google()
23        jcenter()
24    }
25    dependencies {
26        classpath('com.android.tools.build:gradle:4.1.2')
27        classpath('com.google.gms:google-services:4.3.0')
28        // NOTE: Do not place your application dependencies here; they belong
29        // in the individual module build.gradle files
30    }
31}
32
33allprojects {
34    repositories {
35        mavenLocal()
36        maven {
37            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
38            url(&quot;$rootDir/../node_modules/react-native/android&quot;)
39        }
40        maven {
41            // Android JSC is installed from npm
42            url(&quot;$rootDir/../node_modules/jsc-android/dist&quot;)
43        }
44
45        google()
46        jcenter()
47        maven { url 'https://www.jitpack.io' }
48    }
49    
50}
51

gradle-wrapper.properties

1FAILURE: Build failed with an exception.
2
3* What went wrong:
4Execution failed for task ':app:checkDebugAarMetadata'.
5&gt; A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
6   &gt; The minCompileSdk (31) specified in a
7     dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
8     is greater than this module's compileSdkVersion (android-30).
9     Dependency: androidx.work:work-runtime:2.7.0-beta01.
10     AAR metadata file: /Users/macpro/.gradle/caches/transforms-3/999e9d813832e06d8f1b7de52647a502/transformed/work-runtime-2.7.0-beta01/META-INF/com/android/build/gradle/aar-metadata.properties.
11// Top-level build file where you can add configuration options common to all sub-projects/modules.
12
13buildscript {
14    ext {
15        buildToolsVersion = &quot;30.0.0&quot;
16        minSdkVersion = 21
17        compileSdkVersion = 30
18        targetSdkVersion = 30
19        supportLibVersion   = &quot;28.0.0&quot;
20    }
21    repositories {
22        google()
23        jcenter()
24    }
25    dependencies {
26        classpath('com.android.tools.build:gradle:4.1.2')
27        classpath('com.google.gms:google-services:4.3.0')
28        // NOTE: Do not place your application dependencies here; they belong
29        // in the individual module build.gradle files
30    }
31}
32
33allprojects {
34    repositories {
35        mavenLocal()
36        maven {
37            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
38            url(&quot;$rootDir/../node_modules/react-native/android&quot;)
39        }
40        maven {
41            // Android JSC is installed from npm
42            url(&quot;$rootDir/../node_modules/jsc-android/dist&quot;)
43        }
44
45        google()
46        jcenter()
47        maven { url 'https://www.jitpack.io' }
48    }
49    
50}
51distributionBase=GRADLE_USER_HOME
52distributionPath=wrapper/dists
53distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip
54zipStoreBase=GRADLE_USER_HOME
55zipStorePath=wrapper/dists
56

ANSWER

Answered 2021-Sep-02 at 23:03

The error is being caused because one of your dependencies is internally using WorkManager 2.7.0-beta01 that was released today (which needs API 31). In my case it was CheckAarMetadata.kt.

You can fix it by forcing Gradle to use an older version of Work Manager for the transitive dependency that works with API 30. In your build.gradle file add:

1FAILURE: Build failed with an exception.
2
3* What went wrong:
4Execution failed for task ':app:checkDebugAarMetadata'.
5&gt; A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
6   &gt; The minCompileSdk (31) specified in a
7     dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
8     is greater than this module's compileSdkVersion (android-30).
9     Dependency: androidx.work:work-runtime:2.7.0-beta01.
10     AAR metadata file: /Users/macpro/.gradle/caches/transforms-3/999e9d813832e06d8f1b7de52647a502/transformed/work-runtime-2.7.0-beta01/META-INF/com/android/build/gradle/aar-metadata.properties.
11// Top-level build file where you can add configuration options common to all sub-projects/modules.
12
13buildscript {
14    ext {
15        buildToolsVersion = &quot;30.0.0&quot;
16        minSdkVersion = 21
17        compileSdkVersion = 30
18        targetSdkVersion = 30
19        supportLibVersion   = &quot;28.0.0&quot;
20    }
21    repositories {
22        google()
23        jcenter()
24    }
25    dependencies {
26        classpath('com.android.tools.build:gradle:4.1.2')
27        classpath('com.google.gms:google-services:4.3.0')
28        // NOTE: Do not place your application dependencies here; they belong
29        // in the individual module build.gradle files
30    }
31}
32
33allprojects {
34    repositories {
35        mavenLocal()
36        maven {
37            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
38            url(&quot;$rootDir/../node_modules/react-native/android&quot;)
39        }
40        maven {
41            // Android JSC is installed from npm
42            url(&quot;$rootDir/../node_modules/jsc-android/dist&quot;)
43        }
44
45        google()
46        jcenter()
47        maven { url 'https://www.jitpack.io' }
48    }
49    
50}
51distributionBase=GRADLE_USER_HOME
52distributionPath=wrapper/dists
53distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip
54zipStoreBase=GRADLE_USER_HOME
55zipStorePath=wrapper/dists
56dependencies {
57    def work_version = &quot;2.6.0&quot;
58    // Force WorkManager 2.6.0 for transitive dependency
59    implementation(&quot;androidx.work:work-runtime-ktx:$work_version&quot;) {
60        force = true
61    }
62}
63

This should fix it.

Source https://stackoverflow.com/questions/69037481

QUESTION

Vue 3 passing array warning: Extraneous non-props attributes were passed to component but could not be automatically inherited

Asked 2022-Feb-26 at 21:48

please, I'm learning a VueJS 3 and I have probably begineer problem. I have warn in browser developer console like this one:

enter image description here

The Message is:

1[Vue warn]: Extraneous non-props attributes (class) were passed to component but could not be automatically inherited because component renders fragment or text root nodes.
2

I'm passing array of objects to the child Component. In my parent views/Home.vue compoment I have this implemenation:

1[Vue warn]: Extraneous non-props attributes (class) were passed to component but could not be automatically inherited because component renders fragment or text root nodes.
2&lt;template&gt;
3  &lt;div class=&quot;wrapper&quot;&gt;
4    &lt;section v-for=&quot;(item, index) in items&quot; :key=&quot;index&quot; class=&quot;box&quot;&gt;
5      &lt;ItemProperties class=&quot;infobox-item-properties&quot; :info=&quot;item.properties&quot; /&gt;
6    &lt;/section&gt;
7  &lt;/div&gt;
8&lt;/template&gt;
9&lt;script&gt;
10import { ref } from 'vue'
11import { data } from '@/data.js'
12import ItemProperties from '@/components/ItemProperties.vue'
13
14export default {
15  components: {
16    ItemDescription,
17  },
18  setup() {
19    const items = ref(data)
20
21    return {
22      items,
23    }
24  },
25&lt;/script&gt;
26

In child compoment components/ItemProperties.vue I have this code:

1[Vue warn]: Extraneous non-props attributes (class) were passed to component but could not be automatically inherited because component renders fragment or text root nodes.
2&lt;template&gt;
3  &lt;div class=&quot;wrapper&quot;&gt;
4    &lt;section v-for=&quot;(item, index) in items&quot; :key=&quot;index&quot; class=&quot;box&quot;&gt;
5      &lt;ItemProperties class=&quot;infobox-item-properties&quot; :info=&quot;item.properties&quot; /&gt;
6    &lt;/section&gt;
7  &lt;/div&gt;
8&lt;/template&gt;
9&lt;script&gt;
10import { ref } from 'vue'
11import { data } from '@/data.js'
12import ItemProperties from '@/components/ItemProperties.vue'
13
14export default {
15  components: {
16    ItemDescription,
17  },
18  setup() {
19    const items = ref(data)
20
21    return {
22      items,
23    }
24  },
25&lt;/script&gt;
26&lt;template&gt;
27  &lt;div class=&quot;infobox-item-property&quot; v-for=&quot;(object, index) in info&quot; :key=&quot;index&quot;&gt;
28    &lt;span class=&quot;infobox-item-title&quot;&gt;{{ object.name }}:&lt;/span&gt;
29    &lt;span v-if=&quot;object.type === 'rating'&quot;&gt;
30      &lt;span v-for=&quot;(v, k) in object.value&quot; :key=&quot;k&quot;&gt;{{ object.icon }}&lt;/span&gt;
31    &lt;/span&gt;
32    &lt;span v-else&gt;
33      &lt;span&gt;{{ object.value }}&lt;/span&gt;
34    &lt;/span&gt;
35  &lt;/div&gt;
36&lt;/template&gt;
37
38&lt;script&gt;
39export default {
40  props: {
41    info: {
42      type: Array,
43      required: false,
44      default: () =&gt; [
45        {
46          name: '',
47          value: '',
48          type: 'string',
49          icon: '',
50        },
51      ],
52    },
53  },
54}
55&lt;/script&gt;
56

It doesn't matter if I have default() function or not. Also doesn't matter if I have v-if condition or not. If I have cycle in the Array, I got this warning

Data are in data.js file. The part of file is here:

1[Vue warn]: Extraneous non-props attributes (class) were passed to component but could not be automatically inherited because component renders fragment or text root nodes.
2&lt;template&gt;
3  &lt;div class=&quot;wrapper&quot;&gt;
4    &lt;section v-for=&quot;(item, index) in items&quot; :key=&quot;index&quot; class=&quot;box&quot;&gt;
5      &lt;ItemProperties class=&quot;infobox-item-properties&quot; :info=&quot;item.properties&quot; /&gt;
6    &lt;/section&gt;
7  &lt;/div&gt;
8&lt;/template&gt;
9&lt;script&gt;
10import { ref } from 'vue'
11import { data } from '@/data.js'
12import ItemProperties from '@/components/ItemProperties.vue'
13
14export default {
15  components: {
16    ItemDescription,
17  },
18  setup() {
19    const items = ref(data)
20
21    return {
22      items,
23    }
24  },
25&lt;/script&gt;
26&lt;template&gt;
27  &lt;div class=&quot;infobox-item-property&quot; v-for=&quot;(object, index) in info&quot; :key=&quot;index&quot;&gt;
28    &lt;span class=&quot;infobox-item-title&quot;&gt;{{ object.name }}:&lt;/span&gt;
29    &lt;span v-if=&quot;object.type === 'rating'&quot;&gt;
30      &lt;span v-for=&quot;(v, k) in object.value&quot; :key=&quot;k&quot;&gt;{{ object.icon }}&lt;/span&gt;
31    &lt;/span&gt;
32    &lt;span v-else&gt;
33      &lt;span&gt;{{ object.value }}&lt;/span&gt;
34    &lt;/span&gt;
35  &lt;/div&gt;
36&lt;/template&gt;
37
38&lt;script&gt;
39export default {
40  props: {
41    info: {
42      type: Array,
43      required: false,
44      default: () =&gt; [
45        {
46          name: '',
47          value: '',
48          type: 'string',
49          icon: '',
50        },
51      ],
52    },
53  },
54}
55&lt;/script&gt;
56export const data = [
57  {
58    title: 'White shirt',
59    properties: [
60      { name: 'Material', value: 'Cotton', type: 'string', icon: '' },
61      { name: 'Size', value: 'M', type: 'string', icon: '' },
62      { name: 'Count', value: 4, type: 'number', icon: '' },
63      { name: 'Absorption', value: 4, type: 'rating', icon: '💧' },
64      { name: 'Rating', value: 2, type: 'rating', icon: '⭐️' },
65      { name: 'Confort', value: 2, type: 'rating', icon: '🛏' },
66      { name: 'Sleeves', value: 'Short', type: 'string', icon: '' },
67      { name: 'Color', value: 'White', type: 'string', icon: '' },
68    ],
69  },
70]
71

PS: Application works but I'm afraid about that warning. What can I do please like right way?

I will be glad for any advice. Thank you very much.

ANSWER

Answered 2021-Aug-16 at 13:32

The ItemProperties component has multiple root nodes because it renders a list in the root with v-for.

Based on the class name (infobox-item-properties), I think you want the class to be applied to a container element, so a simple solution is to just add that element (e.g., a div) in your component at the root:

1[Vue warn]: Extraneous non-props attributes (class) were passed to component but could not be automatically inherited because component renders fragment or text root nodes.
2&lt;template&gt;
3  &lt;div class=&quot;wrapper&quot;&gt;
4    &lt;section v-for=&quot;(item, index) in items&quot; :key=&quot;index&quot; class=&quot;box&quot;&gt;
5      &lt;ItemProperties class=&quot;infobox-item-properties&quot; :info=&quot;item.properties&quot; /&gt;
6    &lt;/section&gt;
7  &lt;/div&gt;
8&lt;/template&gt;
9&lt;script&gt;
10import { ref } from 'vue'
11import { data } from '@/data.js'
12import ItemProperties from '@/components/ItemProperties.vue'
13
14export default {
15  components: {
16    ItemDescription,
17  },
18  setup() {
19    const items = ref(data)
20
21    return {
22      items,
23    }
24  },
25&lt;/script&gt;
26&lt;template&gt;
27  &lt;div class=&quot;infobox-item-property&quot; v-for=&quot;(object, index) in info&quot; :key=&quot;index&quot;&gt;
28    &lt;span class=&quot;infobox-item-title&quot;&gt;{{ object.name }}:&lt;/span&gt;
29    &lt;span v-if=&quot;object.type === 'rating'&quot;&gt;
30      &lt;span v-for=&quot;(v, k) in object.value&quot; :key=&quot;k&quot;&gt;{{ object.icon }}&lt;/span&gt;
31    &lt;/span&gt;
32    &lt;span v-else&gt;
33      &lt;span&gt;{{ object.value }}&lt;/span&gt;
34    &lt;/span&gt;
35  &lt;/div&gt;
36&lt;/template&gt;
37
38&lt;script&gt;
39export default {
40  props: {
41    info: {
42      type: Array,
43      required: false,
44      default: () =&gt; [
45        {
46          name: '',
47          value: '',
48          type: 'string',
49          icon: '',
50        },
51      ],
52    },
53  },
54}
55&lt;/script&gt;
56export const data = [
57  {
58    title: 'White shirt',
59    properties: [
60      { name: 'Material', value: 'Cotton', type: 'string', icon: '' },
61      { name: 'Size', value: 'M', type: 'string', icon: '' },
62      { name: 'Count', value: 4, type: 'number', icon: '' },
63      { name: 'Absorption', value: 4, type: 'rating', icon: '💧' },
64      { name: 'Rating', value: 2, type: 'rating', icon: '⭐️' },
65      { name: 'Confort', value: 2, type: 'rating', icon: '🛏' },
66      { name: 'Sleeves', value: 'Short', type: 'string', icon: '' },
67      { name: 'Color', value: 'White', type: 'string', icon: '' },
68    ],
69  },
70]
71// ItemProperties.vue
72&lt;template&gt;
73  &lt;div&gt;
74    &lt;section v-for=&quot;(item, index) in items&quot; :key=&quot;index&quot; class=&quot;box&quot;&gt;
75    ...
76    &lt;/section&gt;
77  &lt;/div&gt;
78&lt;/template&gt;
79

Source https://stackoverflow.com/questions/68803137

QUESTION

AttributeError: Can't get attribute 'new_block' on &lt;module 'pandas.core.internals.blocks'&gt;

Asked 2022-Feb-25 at 13:18

I was using pyspark on AWS EMR (4 r5.xlarge as 4 workers, each has one executor and 4 cores), and I got AttributeError: Can't get attribute 'new_block' on <module 'pandas.core.internals.blocks'. Below is a snippet of the code that threw this error:

1search =  SearchEngine(db_file_dir = &quot;/tmp/db&quot;)
2conn = sqlite3.connect(&quot;/tmp/db/simple_db.sqlite&quot;)
3pdf_ = pd.read_sql_query('''select  zipcode, lat, lng, 
4                        bounds_west, bounds_east, bounds_north, bounds_south from 
5                        simple_zipcode''',conn)
6brd_pdf = spark.sparkContext.broadcast(pdf_) 
7conn.close()
8
9
10@udf('string')
11def get_zip_b(lat, lng):
12    pdf = brd_pdf.value 
13    out = pdf[(np.array(pdf[&quot;bounds_north&quot;]) &gt;= lat) &amp; 
14              (np.array(pdf[&quot;bounds_south&quot;]) &lt;= lat) &amp; 
15              (np.array(pdf['bounds_west']) &lt;= lng) &amp; 
16              (np.array(pdf['bounds_east']) &gt;= lng) ]
17    if len(out):
18        min_index = np.argmin( (np.array(out[&quot;lat&quot;]) - lat)**2 + (np.array(out[&quot;lng&quot;]) - lng)**2)
19        zip_ = str(out[&quot;zipcode&quot;].iloc[min_index])
20    else:
21        zip_ = 'bad'
22    return zip_
23
24df = df.withColumn('zipcode', get_zip_b(col(&quot;latitude&quot;),col(&quot;longitude&quot;)))
25

Below is the traceback, where line 102, in get_zip_b refers to pdf = brd_pdf.value:

1search =  SearchEngine(db_file_dir = &quot;/tmp/db&quot;)
2conn = sqlite3.connect(&quot;/tmp/db/simple_db.sqlite&quot;)
3pdf_ = pd.read_sql_query('''select  zipcode, lat, lng, 
4                        bounds_west, bounds_east, bounds_north, bounds_south from 
5                        simple_zipcode''',conn)
6brd_pdf = spark.sparkContext.broadcast(pdf_) 
7conn.close()
8
9
10@udf('string')
11def get_zip_b(lat, lng):
12    pdf = brd_pdf.value 
13    out = pdf[(np.array(pdf[&quot;bounds_north&quot;]) &gt;= lat) &amp; 
14              (np.array(pdf[&quot;bounds_south&quot;]) &lt;= lat) &amp; 
15              (np.array(pdf['bounds_west']) &lt;= lng) &amp; 
16              (np.array(pdf['bounds_east']) &gt;= lng) ]
17    if len(out):
18        min_index = np.argmin( (np.array(out[&quot;lat&quot;]) - lat)**2 + (np.array(out[&quot;lng&quot;]) - lng)**2)
19        zip_ = str(out[&quot;zipcode&quot;].iloc[min_index])
20    else:
21        zip_ = 'bad'
22    return zip_
23
24df = df.withColumn('zipcode', get_zip_b(col(&quot;latitude&quot;),col(&quot;longitude&quot;)))
2521/08/02 06:18:19 WARN TaskSetManager: Lost task 12.0 in stage 7.0 (TID 1814, ip-10-22-17-94.pclc0.merkle.local, executor 6): org.apache.spark.api.python.PythonException: Traceback (most recent call last):
26  File &quot;/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/worker.py&quot;, line 605, in main
27    process()
28  File &quot;/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/worker.py&quot;, line 597, in process
29    serializer.dump_stream(out_iter, outfile)
30  File &quot;/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/serializers.py&quot;, line 223, in dump_stream
31    self.serializer.dump_stream(self._batched(iterator), stream)
32  File &quot;/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/serializers.py&quot;, line 141, in dump_stream
33    for obj in iterator:
34  File &quot;/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/serializers.py&quot;, line 212, in _batched
35    for item in iterator:
36  File &quot;/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/worker.py&quot;, line 450, in mapper
37    result = tuple(f(*[a[o] for o in arg_offsets]) for (arg_offsets, f) in udfs)
38  File &quot;/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/worker.py&quot;, line 450, in &lt;genexpr&gt;
39    result = tuple(f(*[a[o] for o in arg_offsets]) for (arg_offsets, f) in udfs)
40  File &quot;/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/worker.py&quot;, line 90, in &lt;lambda&gt;
41    return lambda *a: f(*a)
42  File &quot;/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/util.py&quot;, line 121, in wrapper
43    return f(*args, **kwargs)
44  File &quot;/mnt/var/lib/hadoop/steps/s-1IBFS0SYWA19Z/Mobile_ID_process_center.py&quot;, line 102, in get_zip_b
45  File &quot;/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/broadcast.py&quot;, line 146, in value
46    self._value = self.load_from_path(self._path)
47  File &quot;/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/broadcast.py&quot;, line 123, in load_from_path
48    return self.load(f)
49  File &quot;/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/broadcast.py&quot;, line 129, in load
50    return pickle.load(file)
51AttributeError: Can't get attribute 'new_block' on &lt;module 'pandas.core.internals.blocks' from '/mnt/miniconda/lib/python3.9/site-packages/pandas/core/internals/blocks.py'&gt;
52

Some observations and thought process:

1, After doing some search online, the AttributeError in pyspark seems to be caused by mismatched pandas versions between driver and workers?

2, But I ran the same code on two different datasets, one worked without any errors but the other didn't, which seems very strange and undeterministic, and it seems like the errors may not be caused by mismatched pandas versions. Otherwise, neither two datasets would succeed.

3, I then ran the same code on the successful dataset again, but this time with different spark configurations: setting spark.driver.memory from 2048M to 4192m, and it threw AttributeError.

4, In conclusion, I think the AttributeError has something to do with driver. But I can't tell how they are related from the error message, and how to fix it: AttributeError: Can't get attribute 'new_block' on <module 'pandas.core.internals.blocks'.

ANSWER

Answered 2021-Aug-26 at 14:53

I had the same error using pandas 1.3.2 in the server while 1.2 in my client. Downgrading pandas to 1.2 solved the problem.

Source https://stackoverflow.com/questions/68625748

QUESTION

&quot;Cannot read properties of undefined (reading 'pathname')&quot; when testing pages in the v6 React Router

Asked 2022-Feb-03 at 00:48

When testing components with <Link>s, for example in my answer to Recommended approach for route-based tests within routes of react-router, I often use the following pattern to get access to the current location for testing purposes:

1const renderInRouter = () =&gt; {
2  const history = createMemoryHistory();
3  const wrapper = render(
4    &lt;Router history={history}&gt;
5      &lt;MyPage /&gt;
6    &lt;/Router&gt;
7  );
8  return { ...wrapper, history };
9}
10

This worked fine up to v5.3, but after upgrading to v6 I get:

1const renderInRouter = () =&gt; {
2  const history = createMemoryHistory();
3  const wrapper = render(
4    &lt;Router history={history}&gt;
5      &lt;MyPage /&gt;
6    &lt;/Router&gt;
7  );
8  return { ...wrapper, history };
9}
10 FAIL  ./demo.test.js
11  ✕ works (205 ms)
12
13  ● works
14
15    TypeError: Cannot read properties of undefined (reading 'pathname')
16
17      at Router (../packages/react-router/index.tsx:281:5)
18
19      ...
20

This use-case isn't covered in the migration docs, v6 has no testing guides so far and, although the API reference does show that the history prop is no longer expected:

1const renderInRouter = () =&gt; {
2  const history = createMemoryHistory();
3  const wrapper = render(
4    &lt;Router history={history}&gt;
5      &lt;MyPage /&gt;
6    &lt;/Router&gt;
7  );
8  return { ...wrapper, history };
9}
10 FAIL  ./demo.test.js
11  ✕ works (205 ms)
12
13  ● works
14
15    TypeError: Cannot read properties of undefined (reading 'pathname')
16
17      at Router (../packages/react-router/index.tsx:281:5)
18
19      ...
20interface RouterProps {
21  basename?: string;
22  children?: React.ReactNode;
23  location: Partial&lt;Location&gt; | string;
24  navigationType?: NavigationType;
25  navigator: Navigator;
26  static?: boolean;
27}
28

it's not clear what the v6 equivalent is; I tried switching to navigator={history} but still got the same error.

To reproduce, copy the following files into a new directory and run npm install then npm test:

package.json

1const renderInRouter = () =&gt; {
2  const history = createMemoryHistory();
3  const wrapper = render(
4    &lt;Router history={history}&gt;
5      &lt;MyPage /&gt;
6    &lt;/Router&gt;
7  );
8  return { ...wrapper, history };
9}
10 FAIL  ./demo.test.js
11  ✕ works (205 ms)
12
13  ● works
14
15    TypeError: Cannot read properties of undefined (reading 'pathname')
16
17      at Router (../packages/react-router/index.tsx:281:5)
18
19      ...
20interface RouterProps {
21  basename?: string;
22  children?: React.ReactNode;
23  location: Partial&lt;Location&gt; | string;
24  navigationType?: NavigationType;
25  navigator: Navigator;
26  static?: boolean;
27}
28{
29  &quot;name&quot;: &quot;router6-demo&quot;,
30  &quot;version&quot;: &quot;1.0.0&quot;,
31  &quot;description&quot;: &quot;&quot;,
32  &quot;main&quot;: &quot;index.js&quot;,
33  &quot;scripts&quot;: {
34    &quot;test&quot;: &quot;jest&quot;
35  },
36  &quot;jest&quot;: {
37    &quot;testEnvironment&quot;: &quot;jsdom&quot;
38  },
39  &quot;babel&quot;: {
40    &quot;presets&quot;: [
41      &quot;@babel/preset-react&quot;
42    ]
43  },
44  &quot;keywords&quot;: [],
45  &quot;author&quot;: &quot;&quot;,
46  &quot;license&quot;: &quot;ISC&quot;,
47  &quot;devDependencies&quot;: {
48    &quot;@babel/preset-react&quot;: &quot;^7.16.0&quot;,
49    &quot;@testing-library/react&quot;: &quot;^12.1.2&quot;,
50    &quot;jest&quot;: &quot;^27.3.1&quot;,
51    &quot;react&quot;: &quot;^17.0.2&quot;,
52    &quot;react-dom&quot;: &quot;^17.0.2&quot;,
53    &quot;react-router-dom&quot;: &quot;^6.0.0&quot;
54  }
55}
56
57

index.test.js:

1const renderInRouter = () =&gt; {
2  const history = createMemoryHistory();
3  const wrapper = render(
4    &lt;Router history={history}&gt;
5      &lt;MyPage /&gt;
6    &lt;/Router&gt;
7  );
8  return { ...wrapper, history };
9}
10 FAIL  ./demo.test.js
11  ✕ works (205 ms)
12
13  ● works
14
15    TypeError: Cannot read properties of undefined (reading 'pathname')
16
17      at Router (../packages/react-router/index.tsx:281:5)
18
19      ...
20interface RouterProps {
21  basename?: string;
22  children?: React.ReactNode;
23  location: Partial&lt;Location&gt; | string;
24  navigationType?: NavigationType;
25  navigator: Navigator;
26  static?: boolean;
27}
28{
29  &quot;name&quot;: &quot;router6-demo&quot;,
30  &quot;version&quot;: &quot;1.0.0&quot;,
31  &quot;description&quot;: &quot;&quot;,
32  &quot;main&quot;: &quot;index.js&quot;,
33  &quot;scripts&quot;: {
34    &quot;test&quot;: &quot;jest&quot;
35  },
36  &quot;jest&quot;: {
37    &quot;testEnvironment&quot;: &quot;jsdom&quot;
38  },
39  &quot;babel&quot;: {
40    &quot;presets&quot;: [
41      &quot;@babel/preset-react&quot;
42    ]
43  },
44  &quot;keywords&quot;: [],
45  &quot;author&quot;: &quot;&quot;,
46  &quot;license&quot;: &quot;ISC&quot;,
47  &quot;devDependencies&quot;: {
48    &quot;@babel/preset-react&quot;: &quot;^7.16.0&quot;,
49    &quot;@testing-library/react&quot;: &quot;^12.1.2&quot;,
50    &quot;jest&quot;: &quot;^27.3.1&quot;,
51    &quot;react&quot;: &quot;^17.0.2&quot;,
52    &quot;react-dom&quot;: &quot;^17.0.2&quot;,
53    &quot;react-router-dom&quot;: &quot;^6.0.0&quot;
54  }
55}
56
57const { render } = require(&quot;@testing-library/react&quot;);
58const { createMemoryHistory } = require(&quot;history&quot;);
59const React = require(&quot;react&quot;);
60const { Router } = require(&quot;react-router-dom&quot;);
61
62it(&quot;used to work&quot;, () =&gt; {
63  render(
64    &lt;Router history={createMemoryHistory()}&gt;&lt;/Router&gt;
65  );
66});
67

If you npm install --save-dev react-router@5 and run npm test again, you can see that this passes in v5.

ANSWER

Answered 2021-Nov-06 at 10:28

React Router v6 splits apart the history into multiple pieces, for this use case the relevant parts are the navigator and the location. This change is hinted at in Use useNavigate instead of useHistory, and you can see it in the definition of the Navigator type used in the Router props:

1const renderInRouter = () =&gt; {
2  const history = createMemoryHistory();
3  const wrapper = render(
4    &lt;Router history={history}&gt;
5      &lt;MyPage /&gt;
6    &lt;/Router&gt;
7  );
8  return { ...wrapper, history };
9}
10 FAIL  ./demo.test.js
11  ✕ works (205 ms)
12
13  ● works
14
15    TypeError: Cannot read properties of undefined (reading 'pathname')
16
17      at Router (../packages/react-router/index.tsx:281:5)
18
19      ...
20interface RouterProps {
21  basename?: string;
22  children?: React.ReactNode;
23  location: Partial&lt;Location&gt; | string;
24  navigationType?: NavigationType;
25  navigator: Navigator;
26  static?: boolean;
27}
28{
29  &quot;name&quot;: &quot;router6-demo&quot;,
30  &quot;version&quot;: &quot;1.0.0&quot;,
31  &quot;description&quot;: &quot;&quot;,
32  &quot;main&quot;: &quot;index.js&quot;,
33  &quot;scripts&quot;: {
34    &quot;test&quot;: &quot;jest&quot;
35  },
36  &quot;jest&quot;: {
37    &quot;testEnvironment&quot;: &quot;jsdom&quot;
38  },
39  &quot;babel&quot;: {
40    &quot;presets&quot;: [
41      &quot;@babel/preset-react&quot;
42    ]
43  },
44  &quot;keywords&quot;: [],
45  &quot;author&quot;: &quot;&quot;,
46  &quot;license&quot;: &quot;ISC&quot;,
47  &quot;devDependencies&quot;: {
48    &quot;@babel/preset-react&quot;: &quot;^7.16.0&quot;,
49    &quot;@testing-library/react&quot;: &quot;^12.1.2&quot;,
50    &quot;jest&quot;: &quot;^27.3.1&quot;,
51    &quot;react&quot;: &quot;^17.0.2&quot;,
52    &quot;react-dom&quot;: &quot;^17.0.2&quot;,
53    &quot;react-router-dom&quot;: &quot;^6.0.0&quot;
54  }
55}
56
57const { render } = require(&quot;@testing-library/react&quot;);
58const { createMemoryHistory } = require(&quot;history&quot;);
59const React = require(&quot;react&quot;);
60const { Router } = require(&quot;react-router-dom&quot;);
61
62it(&quot;used to work&quot;, () =&gt; {
63  render(
64    &lt;Router history={createMemoryHistory()}&gt;&lt;/Router&gt;
65  );
66});
67export declare type Navigator = Omit&lt;History, &quot;action&quot; | &quot;location&quot; | &quot;back&quot; | &quot;forward&quot; | &quot;listen&quot; | &quot;block&quot;&gt;;
68

Just changing history={history} to navigator={history} still left the location prop, from which the router was trying to access the pathname (among other properties), undefined. To get the test working again, update the rendering as follows:

1const renderInRouter = () =&gt; {
2  const history = createMemoryHistory();
3  const wrapper = render(
4    &lt;Router history={history}&gt;
5      &lt;MyPage /&gt;
6    &lt;/Router&gt;
7  );
8  return { ...wrapper, history };
9}
10 FAIL  ./demo.test.js
11  ✕ works (205 ms)
12
13  ● works
14
15    TypeError: Cannot read properties of undefined (reading 'pathname')
16
17      at Router (../packages/react-router/index.tsx:281:5)
18
19      ...
20interface RouterProps {
21  basename?: string;
22  children?: React.ReactNode;
23  location: Partial&lt;Location&gt; | string;
24  navigationType?: NavigationType;
25  navigator: Navigator;
26  static?: boolean;
27}
28{
29  &quot;name&quot;: &quot;router6-demo&quot;,
30  &quot;version&quot;: &quot;1.0.0&quot;,
31  &quot;description&quot;: &quot;&quot;,
32  &quot;main&quot;: &quot;index.js&quot;,
33  &quot;scripts&quot;: {
34    &quot;test&quot;: &quot;jest&quot;
35  },
36  &quot;jest&quot;: {
37    &quot;testEnvironment&quot;: &quot;jsdom&quot;
38  },
39  &quot;babel&quot;: {
40    &quot;presets&quot;: [
41      &quot;@babel/preset-react&quot;
42    ]
43  },
44  &quot;keywords&quot;: [],
45  &quot;author&quot;: &quot;&quot;,
46  &quot;license&quot;: &quot;ISC&quot;,
47  &quot;devDependencies&quot;: {
48    &quot;@babel/preset-react&quot;: &quot;^7.16.0&quot;,
49    &quot;@testing-library/react&quot;: &quot;^12.1.2&quot;,
50    &quot;jest&quot;: &quot;^27.3.1&quot;,
51    &quot;react&quot;: &quot;^17.0.2&quot;,
52    &quot;react-dom&quot;: &quot;^17.0.2&quot;,
53    &quot;react-router-dom&quot;: &quot;^6.0.0&quot;
54  }
55}
56
57const { render } = require(&quot;@testing-library/react&quot;);
58const { createMemoryHistory } = require(&quot;history&quot;);
59const React = require(&quot;react&quot;);
60const { Router } = require(&quot;react-router-dom&quot;);
61
62it(&quot;used to work&quot;, () =&gt; {
63  render(
64    &lt;Router history={createMemoryHistory()}&gt;&lt;/Router&gt;
65  );
66});
67export declare type Navigator = Omit&lt;History, &quot;action&quot; | &quot;location&quot; | &quot;back&quot; | &quot;forward&quot; | &quot;listen&quot; | &quot;block&quot;&gt;;
68const { render } = require(&quot;@testing-library/react&quot;);
69const { createMemoryHistory } = require(&quot;history&quot;);
70const React = require(&quot;react&quot;);
71const { Router } = require(&quot;react-router-dom&quot;);
72
73it(&quot;works&quot;, () =&gt; {
74  const history = createMemoryHistory();
75  render(
76    &lt;Router location={history.location} navigator={history}&gt;&lt;/Router&gt;
77  );
78});
79

Source https://stackoverflow.com/questions/69859509

QUESTION

pymongo [SSL: CERTIFICATE_VERIFY_FAILED]: certificate has expired on Mongo Atlas

Asked 2022-Jan-29 at 22:03

I am using MongoDB(Mongo Atlas) in my Django app. All was working fine till yesterday. But today, when I ran the server, it is showing me the following error on console

1Exception in thread django-main-thread:
2Traceback (most recent call last):
3  File &quot;c:\users\admin\appdata\local\programs\python\python39\lib\threading.py&quot;, line 973, in _bootstrap_inner
4    self.run()
5  File &quot;c:\users\admin\appdata\local\programs\python\python39\lib\threading.py&quot;, line 910, in run
6    self._target(*self._args, **self._kwargs)
7  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\utils\autoreload.py&quot;, line 64, in wrapper
8    fn(*args, **kwargs)
9  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\core\management\commands\runserver.py&quot;, line 121, in inner_run
10    self.check_migrations()
11  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\core\management\base.py&quot;, line 486, in check_migrations
12    executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
13  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\migrations\executor.py&quot;, line 18, in __init__
14    self.loader = MigrationLoader(self.connection)
15  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\migrations\loader.py&quot;, line 53, in __init__
16    self.build_graph()
17  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\migrations\loader.py&quot;, line 220, in build_graph
18    self.applied_migrations = recorder.applied_migrations()
19  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\migrations\recorder.py&quot;, line 77, in applied_migrations
20    if self.has_table():
21  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\migrations\recorder.py&quot;, line 56, in has_table
22    tables = self.connection.introspection.table_names(cursor)
23  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\backends\base\introspection.py&quot;, line 52, in table_names
24    return get_names(cursor)
25  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\backends\base\introspection.py&quot;, line 47, in get_names
26    return sorted(ti.name for ti in self.get_table_list(cursor)
27  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\djongo\introspection.py&quot;, line 47, in get_table_list
28    for c in cursor.db_conn.list_collection_names()
29  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\database.py&quot;, line 880, in list_collection_names
30    for result in self.list_collections(session=session, **kwargs)]
31  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\database.py&quot;, line 842, in list_collections
32    return self.__client._retryable_read(
33  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\mongo_client.py&quot;, line 1514, in _retryable_read
34    server = self._select_server(
35  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\mongo_client.py&quot;, line 1346, in _select_server
36    server = topology.select_server(server_selector)
37  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\topology.py&quot;, line 244, in select_server
38    return random.choice(self.select_servers(selector,
39  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\topology.py&quot;, line 202, in select_servers
40    server_descriptions = self._select_servers_loop(
41  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\topology.py&quot;, line 218, in _select_servers_loop
42    raise ServerSelectionTimeoutError(
43pymongo.errors.ServerSelectionTimeoutError: cluster0-shard-00-02.mny7y.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129),cluster0-shard-00-01.mny7y.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129),cluster0-shard-00-00.mny7y.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129), Timeout: 30s, Topology Description: &lt;TopologyDescription id: 6155f0c9148b07ff5851a1b3, topology_type: ReplicaSetNoPrimary, servers: [&lt;ServerDescription ('cluster0-shard-00-00.mny7y.mongodb.net', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('cluster0-shard-00-00.mny7y.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129)')&gt;, &lt;ServerDescription ('cluster0-shard-00-01.mny7y.mongodb.net', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('cluster0-shard-00-01.mny7y.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129)')&gt;, &lt;ServerDescription ('cluster0-shard-00-02.mny7y.mongodb.net', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('cluster0-shard-00-02.mny7y.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129)')&gt;]&gt;
44

I am using djongo as the database engine

1Exception in thread django-main-thread:
2Traceback (most recent call last):
3  File &quot;c:\users\admin\appdata\local\programs\python\python39\lib\threading.py&quot;, line 973, in _bootstrap_inner
4    self.run()
5  File &quot;c:\users\admin\appdata\local\programs\python\python39\lib\threading.py&quot;, line 910, in run
6    self._target(*self._args, **self._kwargs)
7  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\utils\autoreload.py&quot;, line 64, in wrapper
8    fn(*args, **kwargs)
9  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\core\management\commands\runserver.py&quot;, line 121, in inner_run
10    self.check_migrations()
11  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\core\management\base.py&quot;, line 486, in check_migrations
12    executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
13  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\migrations\executor.py&quot;, line 18, in __init__
14    self.loader = MigrationLoader(self.connection)
15  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\migrations\loader.py&quot;, line 53, in __init__
16    self.build_graph()
17  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\migrations\loader.py&quot;, line 220, in build_graph
18    self.applied_migrations = recorder.applied_migrations()
19  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\migrations\recorder.py&quot;, line 77, in applied_migrations
20    if self.has_table():
21  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\migrations\recorder.py&quot;, line 56, in has_table
22    tables = self.connection.introspection.table_names(cursor)
23  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\backends\base\introspection.py&quot;, line 52, in table_names
24    return get_names(cursor)
25  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\backends\base\introspection.py&quot;, line 47, in get_names
26    return sorted(ti.name for ti in self.get_table_list(cursor)
27  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\djongo\introspection.py&quot;, line 47, in get_table_list
28    for c in cursor.db_conn.list_collection_names()
29  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\database.py&quot;, line 880, in list_collection_names
30    for result in self.list_collections(session=session, **kwargs)]
31  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\database.py&quot;, line 842, in list_collections
32    return self.__client._retryable_read(
33  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\mongo_client.py&quot;, line 1514, in _retryable_read
34    server = self._select_server(
35  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\mongo_client.py&quot;, line 1346, in _select_server
36    server = topology.select_server(server_selector)
37  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\topology.py&quot;, line 244, in select_server
38    return random.choice(self.select_servers(selector,
39  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\topology.py&quot;, line 202, in select_servers
40    server_descriptions = self._select_servers_loop(
41  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\topology.py&quot;, line 218, in _select_servers_loop
42    raise ServerSelectionTimeoutError(
43pymongo.errors.ServerSelectionTimeoutError: cluster0-shard-00-02.mny7y.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129),cluster0-shard-00-01.mny7y.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129),cluster0-shard-00-00.mny7y.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129), Timeout: 30s, Topology Description: &lt;TopologyDescription id: 6155f0c9148b07ff5851a1b3, topology_type: ReplicaSetNoPrimary, servers: [&lt;ServerDescription ('cluster0-shard-00-00.mny7y.mongodb.net', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('cluster0-shard-00-00.mny7y.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129)')&gt;, &lt;ServerDescription ('cluster0-shard-00-01.mny7y.mongodb.net', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('cluster0-shard-00-01.mny7y.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129)')&gt;, &lt;ServerDescription ('cluster0-shard-00-02.mny7y.mongodb.net', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('cluster0-shard-00-02.mny7y.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129)')&gt;]&gt;
44DATABASES = {
45    'default': {
46            'ENGINE': 'djongo',
47            'NAME': 'DbName',
48            'ENFORCE_SCHEMA': False,
49            'CLIENT': {
50                'host': 'mongodb+srv://username:password@cluster0.mny7y.mongodb.net/DbName?retryWrites=true&amp;w=majority'
51            }  
52    }
53}
54

And following dependencies are being used in the app

1Exception in thread django-main-thread:
2Traceback (most recent call last):
3  File &quot;c:\users\admin\appdata\local\programs\python\python39\lib\threading.py&quot;, line 973, in _bootstrap_inner
4    self.run()
5  File &quot;c:\users\admin\appdata\local\programs\python\python39\lib\threading.py&quot;, line 910, in run
6    self._target(*self._args, **self._kwargs)
7  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\utils\autoreload.py&quot;, line 64, in wrapper
8    fn(*args, **kwargs)
9  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\core\management\commands\runserver.py&quot;, line 121, in inner_run
10    self.check_migrations()
11  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\core\management\base.py&quot;, line 486, in check_migrations
12    executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
13  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\migrations\executor.py&quot;, line 18, in __init__
14    self.loader = MigrationLoader(self.connection)
15  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\migrations\loader.py&quot;, line 53, in __init__
16    self.build_graph()
17  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\migrations\loader.py&quot;, line 220, in build_graph
18    self.applied_migrations = recorder.applied_migrations()
19  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\migrations\recorder.py&quot;, line 77, in applied_migrations
20    if self.has_table():
21  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\migrations\recorder.py&quot;, line 56, in has_table
22    tables = self.connection.introspection.table_names(cursor)
23  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\backends\base\introspection.py&quot;, line 52, in table_names
24    return get_names(cursor)
25  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\backends\base\introspection.py&quot;, line 47, in get_names
26    return sorted(ti.name for ti in self.get_table_list(cursor)
27  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\djongo\introspection.py&quot;, line 47, in get_table_list
28    for c in cursor.db_conn.list_collection_names()
29  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\database.py&quot;, line 880, in list_collection_names
30    for result in self.list_collections(session=session, **kwargs)]
31  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\database.py&quot;, line 842, in list_collections
32    return self.__client._retryable_read(
33  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\mongo_client.py&quot;, line 1514, in _retryable_read
34    server = self._select_server(
35  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\mongo_client.py&quot;, line 1346, in _select_server
36    server = topology.select_server(server_selector)
37  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\topology.py&quot;, line 244, in select_server
38    return random.choice(self.select_servers(selector,
39  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\topology.py&quot;, line 202, in select_servers
40    server_descriptions = self._select_servers_loop(
41  File &quot;C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\topology.py&quot;, line 218, in _select_servers_loop
42    raise ServerSelectionTimeoutError(
43pymongo.errors.ServerSelectionTimeoutError: cluster0-shard-00-02.mny7y.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129),cluster0-shard-00-01.mny7y.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129),cluster0-shard-00-00.mny7y.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129), Timeout: 30s, Topology Description: &lt;TopologyDescription id: 6155f0c9148b07ff5851a1b3, topology_type: ReplicaSetNoPrimary, servers: [&lt;ServerDescription ('cluster0-shard-00-00.mny7y.mongodb.net', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('cluster0-shard-00-00.mny7y.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129)')&gt;, &lt;ServerDescription ('cluster0-shard-00-01.mny7y.mongodb.net', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('cluster0-shard-00-01.mny7y.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129)')&gt;, &lt;ServerDescription ('cluster0-shard-00-02.mny7y.mongodb.net', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('cluster0-shard-00-02.mny7y.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129)')&gt;]&gt;
44DATABASES = {
45    'default': {
46            'ENGINE': 'djongo',
47            'NAME': 'DbName',
48            'ENFORCE_SCHEMA': False,
49            'CLIENT': {
50                'host': 'mongodb+srv://username:password@cluster0.mny7y.mongodb.net/DbName?retryWrites=true&amp;w=majority'
51            }  
52    }
53}
54dj-database-url==0.5.0
55Django==3.2.5
56djangorestframework==3.12.4
57django-cors-headers==3.7.0
58gunicorn==20.1.0
59psycopg2==2.9.1
60pytz==2021.1
61whitenoise==5.3.0
62djongo==1.3.6
63dnspython==2.1.0
64

What should be done in order to resolve this error?

ANSWER

Answered 2021-Oct-03 at 05:57

This is because of a root CA Let’s Encrypt uses (and Mongo Atals uses Let's Encrypt) has expired on 2020-09-30 - namely the "IdentTrust DST Root CA X3" one.

The fix is to manually install in the Windows certificate store the "ISRG Root X1" and "ISRG Root X2" root certificates, and the "Let’s Encrypt R3" intermediate one - link to their official site - https://letsencrypt.org/certificates/

Copy from the comments: download the .der field from the 1st category, download, double click and follow the wizard to install it.

Source https://stackoverflow.com/questions/69397039

QUESTION

How to set max-height of dropdown selection area?

Asked 2022-Jan-21 at 05:26

In vuejs2 app having select input with rather big options list it breaks design of my page on extra small devices. Searching in net I found “size” property, but that not what I I need : I want to have dropdown selection, which is the default. Are there some other decision, maybe with CSS to set max-height of dropdown selection area.

Modeified PART # 1: I made testing demo page at http://photographers.my-demo-apps.tk/sel_test it has 2 select inputs with custom design and events as in this example link How to Set Height for the Drop Down of Select box and following workaround at js fiddle:

1select{
2    color: red;
3}
1select{
2    color: red;
3}&lt;select onfocus='this.size=10;' onblur='this.size=1;' onchange='this.size=1; this.blur();'&gt;
4  &lt;option&gt;1&lt;/option&gt;
5  &lt;option&gt;2&lt;/option&gt;
6  &lt;option&gt;3&lt;/option&gt;
7  &lt;option&gt;4&lt;/option&gt;
8  &lt;option&gt;5&lt;/option&gt;
9  &lt;option&gt;6&lt;/option&gt;
10  &lt;option&gt;7&lt;/option&gt;
11  &lt;option&gt;8&lt;/option&gt;
12  &lt;option&gt;9&lt;/option&gt;
13  &lt;option&gt;10&lt;/option&gt;
14  &lt;option&gt;11&lt;/option&gt;
15  &lt;option&gt;12&lt;/option&gt;
16  &lt;option&gt;13&lt;/option&gt;
17  &lt;option&gt;14&lt;/option&gt;
18  &lt;option&gt;15&lt;/option&gt;
19  &lt;option&gt;16&lt;/option&gt;
20  &lt;option&gt;17&lt;/option&gt;
21  &lt;option&gt;18&lt;/option&gt;
22  &lt;option&gt;19&lt;/option&gt;
23  &lt;option&gt;20&lt;/option&gt;
24  &lt;option&gt;21&lt;/option&gt;
25&lt;/select&gt;
26&lt;div&gt;Popular Tags:&lt;/div&gt;

are applied to the second select input and it does not look/work properly. I suppose it conflicts somehow with current desing. Can it be fixed somehow?

as that is vuejs2 page I know that there are some select components at https://github.com/vuejs/awesome-vue#select and I used some of them, like vue-select but I need to keep custom design so I try to use original select input...

Modified PART # 2 : I added 2 classes definitions :

1select{
2    color: red;
3}&lt;select onfocus='this.size=10;' onblur='this.size=1;' onchange='this.size=1; this.blur();'&gt;
4  &lt;option&gt;1&lt;/option&gt;
5  &lt;option&gt;2&lt;/option&gt;
6  &lt;option&gt;3&lt;/option&gt;
7  &lt;option&gt;4&lt;/option&gt;
8  &lt;option&gt;5&lt;/option&gt;
9  &lt;option&gt;6&lt;/option&gt;
10  &lt;option&gt;7&lt;/option&gt;
11  &lt;option&gt;8&lt;/option&gt;
12  &lt;option&gt;9&lt;/option&gt;
13  &lt;option&gt;10&lt;/option&gt;
14  &lt;option&gt;11&lt;/option&gt;
15  &lt;option&gt;12&lt;/option&gt;
16  &lt;option&gt;13&lt;/option&gt;
17  &lt;option&gt;14&lt;/option&gt;
18  &lt;option&gt;15&lt;/option&gt;
19  &lt;option&gt;16&lt;/option&gt;
20  &lt;option&gt;17&lt;/option&gt;
21  &lt;option&gt;18&lt;/option&gt;
22  &lt;option&gt;19&lt;/option&gt;
23  &lt;option&gt;20&lt;/option&gt;
24  &lt;option&gt;21&lt;/option&gt;
25&lt;/select&gt;
26&lt;div&gt;Popular Tags:&lt;/div&gt;.select-wrapper {
27    height: 50px !important;
28    overflow-y: visible !important;
29    background-color: yellow !important;
30}
31
32.select {
33    width: 100% !important;
34    /* make it min-height*/
35    min-height: 50px !important;
36    border-radius: 25px !important;
37    border-color: #555 !important;
38    padding: 10px  !important;
39    border:2px dotted red !important;
40}
41

Also I set background-color and border to these classes to be sure that these classes are applied and !important to all properties. But it did not help. Could you please to take a look!

Thank you!

ANSWER

Answered 2022-Jan-15 at 16:00

Unfortunately, you cannot chant the height of a dropdown list (while using <select>). It is confirmed here.

you can build it yourself using divs & v-for (assuming you get the list from an outsource) and then you can style it as you wish.

apologies for barring bad news.

Source https://stackoverflow.com/questions/70722984

QUESTION

How do I get details of a veracode vulnerability report?

Asked 2022-Jan-07 at 21:46

How do I get details of a veracode vulnerability report?

I'm a maintainer of a popular JS library, Ramda, and we've recently received a report that the library is subject to a prototype pollution vulnerability. This has been tracked back to a veracode report that says:

ramda is vulnerable to prototype pollution. An attacker can inject properties into existing construct prototypes via the _curry2 function and modify attributes such as __proto__, constructor, and prototype.

I understand what they're talking about for Prototype Pollution. A good explanation is at snyk's writeup for lodash.merge. Ramda's design is different, and the obvious analogous Ramda code is not subject to this sort of vulnerability. That does not mean that no part of Ramda is subject to it. But the report contains no details, no code snippet, and no means to challenge their findings.

The details of their description are clearly wrong. _curry2 could not possibly be subject to this problem. But as that function is used as a wrapper to many other functions, it's possible that there is a real vulnerability hidden by the reporter's misunderstanding.

Is there a way to get details of this error report? A snippet of code that demonstrates the problem? Anything? I have filled out their contact form. An answer may still be coming, as it was only 24 hours ago, but I'm not holding my breath -- it seems to be mostly a sales form. All the searching I've done leads to information about how to use their security tool and pretty much nothing about how their custom reports are created. And I can't find this in CVE databases.

ANSWER

Answered 2022-Jan-07 at 21:46

Ok, so to answer my own question, here's how to get the details on a Veracode vulnerability report in less than four weeks and in only fifty-five easy steps.


Pre-work Day 1
  • Receive a comment on the issue that says that the user has received

    a VULN ticket to fix this Prototype Pollution vulnerability found in ramda.

  • Carry on a discussion regarding this comment to learn that there is a report that claims that

    ramda is vulnerable to prototype pollution. An attacker can inject properties into existing construct prototypes via the _curry2 function and modify attributes such as __proto__, constructor, and prototype.

    and eventually learn that this is due to a report from the software security company Veracode.

Days 2 & 3
  • Examine that report to find that it has no details, no explanation of how to trigger the vulnerability, and no suggested fix.

  • Examine the report and other parts of the Veracode site to find there is no public mechanism to challenge such a report.

Day 4
  • Report back to the library's issue that the report must be wrong, as the function mentioned could not possibly generate the behavior described.

  • Post an actual example of the vulnerability under discussion and a parallel snippet from the library to demonstrate that it doesn't share the problem.

  • Find Veracode's online support form, and submit a request for help. Keep your expectations low, as this is probably for the sales department.

  • Post a StackOverflow Question2 asking how to find details of a Veracode vulnerability report, using enough details that if the community has the knowledge, it should be easy to answer.

Days 5 & 6
  • Try to enjoy your Friday and Saturday. Don't obsessively check your email to see if Veracode has responded. Don't visit the StackOverflow question every hour to see if anyone has posted a solution. Really, don't do these things; they don't help.
Day 7
  • Add a 250-reputation point bounty to the StackOverflow question, trying to get additional attention from the smart people who must have dealt with this before.
Day 8
  • Find direct email support addresses on the Veracode site, and send an email asking for details of the supposed vulnerability, a snippet that demonstrates the issue, and procedures to challenge their findings.
Day 9
  • Receive a response from a Veracode Support email addressthat says, in part,

    Are you saying our vuln db is not correct per your github source? If so, I can send it to our research team to ensure it looks good and if not, to update it.

    As for snips of code, we do not provide that.

  • Reply, explaining that you find the report missing the details necessary to challenge it, but that yes, you expect it is incorrect.

  • Receive a response that this has been "shot up the chain" and that you will be hearing from them soon.

Days 10 - 11
  • Again, don't obsessively check your email or the StackOverflow question. But if you do happen to glance at StackOverflow, notice that while there are still no answers to it, there are enough upvotes to cover over half the cost of the bounty. Clearly you're not alone in wanting to know how to do this.
Day 12
  • Receive an email from Veracode:

    Thank you for your interest in Application Security and Veracode.

    Do you have time next week to connect?

    Also, to make sure you are aligned with the right rep, where is your company headquartered?

  • Respond that you're not a potential customer and explain again what you're looking for.

  • Add a comment to the StackOverflow to explain where the process has gotten to and expressing your frustration.

Days 13 - 14
  • Watch another weekend go by without any way to address this concern.

  • Get involved in a somewhat interesting discussion about prototype pollution in the comments to the StackOverflow post.

Day 15
  • Receive an actually helpful email from Veracode, sent by someone new, whose signature says he's a sales manager. The email will look like this:

    Hi Scott, I asked my team to help out with your question, here was their response:

    We have based this artifact from the information available in https://github.com/ramda/ramda/pull/3192. In the Pull Request, there is a POC (https://jsfiddle.net/3pomzw5g/2/) clearly demonstrating the prototype pollution vulnerability in the mapObjIndexed function. In the demo, the user object is modified via the __proto__​ property and is
    considered a violation to the Integrity of the CIA triad. This has been reflected in our CVSS scoring for this vulnerability in our vuln db.

    There is also an unmerged fix for the vulnerability which has also been
    included in our artifact (https://github.com/ramda/ramda/pull/3192/commits/774f767a10f37d1f844168cb7e6412ea6660112d )

    Please let me know if there is a dispute against the POC, and we can look further into this.

  • Try to avoid banging your head against the wall for too long when you realize that the issue you thought might have been raised by someone who'd seen the Veracode report was instead the source of that report.

  • Respond to this helpful person that yes you will have a dispute for this, and ask if you can be put directly in touch with the relevant Veracode people so there doesn't have to be a middleman.

  • Receive an email from this helpful person -- who needs a name, let's call him "Kevin" -- receive an email from Kevin adding to the email chain the research team. (I told you he was helpful!)

  • Respond to Kevin and the team with a brief note that you will spend some time to write up a response and get back to them soon.

  • Look again at the Veracode Report and note that the description has been changed to

    ramda is vulnerable to prototype pollution. An attacker is able to inject and modify attributes of an object through the mapObjIndexed function via the proto property.

    but note also that it still contains no details, no snippets, no dispute process.

  • Receive a bounced-email notification because that research team's email is for internal Veracode use only.

  • Laugh because the only other option is to cry.

  • Tell Kevin what happened and make sure he's willing to remain as an intermediary. Again he's helpful and will agree right away.

  • Spend several hours writing up a detailed response, explaining what prototype pollution is and how the examples do not display this behavior. Post it ahead of time on the issue. (Remember the issue? This is a story about the issue.3) Ask those reading for suggestions before you send the email... mostly as a way to ensure you're not sending this in anger.

  • Go ahead and email it right away anyway; if you said something too angry you probably don't want to be talked out of it now, anyhow.

  • Note that the nonrefundable StackOverflow bounty has expired without a single answer being offered.

Days 16 - 21
  • Twiddle your thumbs for a week, but meanwhile...

  • Receive a marketing email from Veracode, who has never sent you one before.

  • Note that Veracode has again updated the description to say

    ramda allows object prototype manipulation. An attacker is able to inject and modify attributes of an object through the mapObjIndexed function via the proto property. However, due to ramda's design where object immutability is the default, the impact of this vulnerability is limited to the scope of the object instead of the underlying object prototype. Nonetheless, the possibility of object prototype manipulation as demonstrated in the proof-of-concept under References can potentially cause unexpected behaviors in the application. There are currently no known exploits.

    If that's not clear, a translation would be, "Hey, we reported this, and we don't want to back down, so we're going to say that even though the behavior we noted didn't actually happen, the behavior that's there is still, umm, err, somehow wrong."

  • Note that a fan of the library whose employer has a Veracode account has been able to glean more information from their reports. It turns out that their details are restricted to logged-in users, leaving it entirely unclear how they thing such vulnerabilities should be fixed.

Day 22
  • Send a follow-up email to Kevin4 saying

    I'm wondering if there is any response to this.

    I see that the vulnerability report has been updated but not removed.
    I still dispute the altered version of it. If this behavior is a true vulnerability, could you point me to the equivalent report on JavaScript's Object.assign, which, as demonstrated earlier, has the exact same issue as the function in question.

    My immediate goal is to see this report retracted. But I also want to point out the pain involved in this process, pain that I think Veracode could fix:

    I am not a customer, but your customers are coming to me as Ramda's maintainer to fix a problem you've reported. That report really should have enough information in it to allow me to confirm the vulnerability reported. I've learned that such information is available to a logged- in customer. That doesn't help me or others in my position to find the information. Resorting to email and filtering it through your sales department, is a pretty horrible process. Could you alter your public reports to contain or point to a proof of concept of the vulnerability?
    And could you further offer in the report some hint at a dispute process?

Day 23
  • Receive an email from the still-helpful Kevin, which says

    Thanks for the follow up [ ... ], I will continue to manage the communication with my team, at this time they are looking into the matter and it has been raised up to the highest levels.

    Please reach back out to me if you don’t have a response within 72 hrs.

    Thank you for your patience as we investigate the issue, this is a new process for me as well.

  • Laugh out loud at the notion that he thinks you're being patient.

  • Respond, apologizing to Kevin that he's caught in the middle, and read his good-natured reply.

Day 25
  • Hear back from Kevin that your main objective has been met:

    Hi Scott, I wanted to provide an update, my engineering team got back
    to me with the following:

    “updating our DB to remove the report is the final outcome”

    I have also asked for them to let me know about your question regarding the ability to contend findings and will relay that back once feedback is received.

    Otherwise, I hope this satisfies your request and please let me know if any further action is needed from us at this time.

  • Respond gratefully to Kevin and note that you would still like to hear about how they're changing their processes.

  • Reply to your own email to apologize to Kevin for all the misspelling that happened when you try to type anything more than a short text on your mobile device.

  • Check with that helpful Ramda user with Veracode log-in abilities whether the site seems to be updated properly.

  • Reach out to that same user on Twitter when he hasn't responded in five minutes. It's not that you're anxious and want to put this behind you. Really it's not. You're not that kind of person.

  • Read that user's detailed response explaining that all is well.

  • Receive a follow-up from the Veracode Support email address telling you that

    After much consideration we have decided to update our db to remove this report.

    and that they're closing the issue.

  • Laugh about the fact that they are sending this after what seem likely the close of business for the week (7:00 PM your time on a Friday.)

  • Respond politely to say that you're grateful for the result, but that you would still like to see their dispute process modernized.

Day 27
  • Write a 2257-word answer5 to your own Stack Overflow question explaining in great detail the process you went through to resolve this issue.

And that's all it takes. So the next time you run into this, you can solve it too!




Update

(because you knew it couldn't be that easy!)

Day 61
  • Receive an email from a new Veracode account executive which says

    Thanks for your interest! Introducing myself as your point of contact at Veracode.

    I'd welcome the chance to answer any questions you may have around Veracode's services and approach to the space.

    Do you have a few minutes free to touch base? Please let me know a convenient time for you and I'll follow up accordingly.

  • Politely respond to that email suggesting a talk with Kevin and including a link to this list of steps.



1 This is standard behavior with Ramda issues, but it might be the main reason Veracode chose to report this.

2 Be careful not to get into an infinite loop. This recursion does not have a base case.

3 Hey, this was taking place around Thanksgiving. There had to be an Alice's Restaurant reference!

4 If you haven't yet found a Kevin, now would be a good time to insist that Veracode supply you with one.

5 Including footnotes.

Source https://stackoverflow.com/questions/69936667

QUESTION

How can I get notified when money has been sent to a particular Bitcoin address on a local regtest network?

Asked 2021-Nov-18 at 19:39

I want to programmatically detect whenever someone sends Bitcoin to some address. This happens on a local testnet which I start using this docker-compose.yml file.

Once the local testnet runs, I create a new address using

1docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli getnewaddress
2

Let's say it returns 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181.

I put this address into the following Java code:

1docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli getnewaddress
2import org.bitcoinj.core.Address;
3import org.bitcoinj.core.Coin;
4import org.bitcoinj.core.NetworkParameters;
5import org.bitcoinj.core.Transaction;
6import org.bitcoinj.wallet.Wallet;
7import org.bitcoinj.wallet.listeners.WalletCoinsReceivedEventListener;
8
9public class WalletObserver {
10    public void init() {
11        final NetworkParameters netParams = NetworkParameters.fromID(NetworkParameters.ID_REGTEST);
12
13        try {
14            final Wallet wallet = Wallet.createBasic(netParams);
15
16            wallet.addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
17
18            wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
19                @Override
20                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
21                    System.out.println(&quot;Heyo!&quot;);
22                }
23            });
24        }
25        catch (Exception exception) {
26            exception.printStackTrace();
27        }
28    }
29}
30

Then I start the Java application with this class.

Then I send some test Bitcoin to the address in question:

1docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli getnewaddress
2import org.bitcoinj.core.Address;
3import org.bitcoinj.core.Coin;
4import org.bitcoinj.core.NetworkParameters;
5import org.bitcoinj.core.Transaction;
6import org.bitcoinj.wallet.Wallet;
7import org.bitcoinj.wallet.listeners.WalletCoinsReceivedEventListener;
8
9public class WalletObserver {
10    public void init() {
11        final NetworkParameters netParams = NetworkParameters.fromID(NetworkParameters.ID_REGTEST);
12
13        try {
14            final Wallet wallet = Wallet.createBasic(netParams);
15
16            wallet.addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
17
18            wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
19                @Override
20                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
21                    System.out.println(&quot;Heyo!&quot;);
22                }
23            });
24        }
25        catch (Exception exception) {
26            exception.printStackTrace();
27        }
28    }
29}
30% docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.5
31068c377bab961356ad9a3919229a764aa929711c68aefd5dbd4c7c348eef3406
32

If I go to http://localhost:3002/tx/068c377bab961356ad9a3919229a764aa929711c68aefd5dbd4c7c348eef3406, I see that the transaction details.

Screenshot of the transaction page

However, the breakpoint in the listener (onCoinsReceived method) never activates.

How do I need to modify my code and/or the commands I use to send test BTC so that whenever money is received by that account, onCoinsReceived method is called? Is there a place where I can tell Wallet or NetworkParameters that I want to connect to localhost?

I am using version 0.15.10 of bitcoinj-core.

Update 1:

I modified docker-compose.yml and added following port mappings:

1docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli getnewaddress
2import org.bitcoinj.core.Address;
3import org.bitcoinj.core.Coin;
4import org.bitcoinj.core.NetworkParameters;
5import org.bitcoinj.core.Transaction;
6import org.bitcoinj.wallet.Wallet;
7import org.bitcoinj.wallet.listeners.WalletCoinsReceivedEventListener;
8
9public class WalletObserver {
10    public void init() {
11        final NetworkParameters netParams = NetworkParameters.fromID(NetworkParameters.ID_REGTEST);
12
13        try {
14            final Wallet wallet = Wallet.createBasic(netParams);
15
16            wallet.addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
17
18            wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
19                @Override
20                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
21                    System.out.println(&quot;Heyo!&quot;);
22                }
23            });
24        }
25        catch (Exception exception) {
26            exception.printStackTrace();
27        }
28    }
29}
30% docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.5
31068c377bab961356ad9a3919229a764aa929711c68aefd5dbd4c7c348eef3406
32    ports:
33      - &quot;51001:50001&quot;
34      - &quot;51002:50002&quot;
35      - &quot;19001:19001&quot;
36      - &quot;19000:19000&quot;
37      - &quot;28332:28332&quot;
38

Then I rewrote the init method so that I can connect to localhost and specify the port:

1docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli getnewaddress
2import org.bitcoinj.core.Address;
3import org.bitcoinj.core.Coin;
4import org.bitcoinj.core.NetworkParameters;
5import org.bitcoinj.core.Transaction;
6import org.bitcoinj.wallet.Wallet;
7import org.bitcoinj.wallet.listeners.WalletCoinsReceivedEventListener;
8
9public class WalletObserver {
10    public void init() {
11        final NetworkParameters netParams = NetworkParameters.fromID(NetworkParameters.ID_REGTEST);
12
13        try {
14            final Wallet wallet = Wallet.createBasic(netParams);
15
16            wallet.addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
17
18            wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
19                @Override
20                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
21                    System.out.println(&quot;Heyo!&quot;);
22                }
23            });
24        }
25        catch (Exception exception) {
26            exception.printStackTrace();
27        }
28    }
29}
30% docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.5
31068c377bab961356ad9a3919229a764aa929711c68aefd5dbd4c7c348eef3406
32    ports:
33      - &quot;51001:50001&quot;
34      - &quot;51002:50002&quot;
35      - &quot;19001:19001&quot;
36      - &quot;19000:19000&quot;
37      - &quot;28332:28332&quot;
38public class WalletObserver {
39    public void init() {
40        final LocalTestNetParams netParams = new LocalTestNetParams();
41        netParams.setPort(50001);
42        try {
43            final WalletAppKit kit = new WalletAppKit(netParams, new File(&quot;.&quot;), &quot;_minimalCryptoExchangeBtcWallet&quot;);
44            kit.setAutoSave(true);
45            kit.connectToLocalHost();
46
47            kit.startAsync();
48            kit.awaitRunning(); // I never get past this point
49            kit.peerGroup().addPeerDiscovery(new DnsDiscovery(netParams));
50            kit.wallet().addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
51
52            kit.wallet().addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
53                @Override
54                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
55                    System.out.println(&quot;Heyo!&quot;);
56                }
57            });
58        }
59        catch (Exception exception) {
60            exception.printStackTrace();
61        }
62    }
63

LocalTestNetParams allows to specify the port:

1docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli getnewaddress
2import org.bitcoinj.core.Address;
3import org.bitcoinj.core.Coin;
4import org.bitcoinj.core.NetworkParameters;
5import org.bitcoinj.core.Transaction;
6import org.bitcoinj.wallet.Wallet;
7import org.bitcoinj.wallet.listeners.WalletCoinsReceivedEventListener;
8
9public class WalletObserver {
10    public void init() {
11        final NetworkParameters netParams = NetworkParameters.fromID(NetworkParameters.ID_REGTEST);
12
13        try {
14            final Wallet wallet = Wallet.createBasic(netParams);
15
16            wallet.addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
17
18            wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
19                @Override
20                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
21                    System.out.println(&quot;Heyo!&quot;);
22                }
23            });
24        }
25        catch (Exception exception) {
26            exception.printStackTrace();
27        }
28    }
29}
30% docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.5
31068c377bab961356ad9a3919229a764aa929711c68aefd5dbd4c7c348eef3406
32    ports:
33      - &quot;51001:50001&quot;
34      - &quot;51002:50002&quot;
35      - &quot;19001:19001&quot;
36      - &quot;19000:19000&quot;
37      - &quot;28332:28332&quot;
38public class WalletObserver {
39    public void init() {
40        final LocalTestNetParams netParams = new LocalTestNetParams();
41        netParams.setPort(50001);
42        try {
43            final WalletAppKit kit = new WalletAppKit(netParams, new File(&quot;.&quot;), &quot;_minimalCryptoExchangeBtcWallet&quot;);
44            kit.setAutoSave(true);
45            kit.connectToLocalHost();
46
47            kit.startAsync();
48            kit.awaitRunning(); // I never get past this point
49            kit.peerGroup().addPeerDiscovery(new DnsDiscovery(netParams));
50            kit.wallet().addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
51
52            kit.wallet().addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
53                @Override
54                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
55                    System.out.println(&quot;Heyo!&quot;);
56                }
57            });
58        }
59        catch (Exception exception) {
60            exception.printStackTrace();
61        }
62    }
63package com.dpisarenko.minimalcryptoexchange.logic.btc;
64
65import org.bitcoinj.params.RegTestParams;
66
67public class LocalTestNetParams extends RegTestParams {
68    public void setPort(final int newPort) {
69        this.port = newPort;
70    }
71}
72

I tried all of the aforementioned ports in netParams.setPort(50001);.

In all cases I get the following messages after kit.awaitRunning();:

1docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli getnewaddress
2import org.bitcoinj.core.Address;
3import org.bitcoinj.core.Coin;
4import org.bitcoinj.core.NetworkParameters;
5import org.bitcoinj.core.Transaction;
6import org.bitcoinj.wallet.Wallet;
7import org.bitcoinj.wallet.listeners.WalletCoinsReceivedEventListener;
8
9public class WalletObserver {
10    public void init() {
11        final NetworkParameters netParams = NetworkParameters.fromID(NetworkParameters.ID_REGTEST);
12
13        try {
14            final Wallet wallet = Wallet.createBasic(netParams);
15
16            wallet.addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
17
18            wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
19                @Override
20                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
21                    System.out.println(&quot;Heyo!&quot;);
22                }
23            });
24        }
25        catch (Exception exception) {
26            exception.printStackTrace();
27        }
28    }
29}
30% docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.5
31068c377bab961356ad9a3919229a764aa929711c68aefd5dbd4c7c348eef3406
32    ports:
33      - &quot;51001:50001&quot;
34      - &quot;51002:50002&quot;
35      - &quot;19001:19001&quot;
36      - &quot;19000:19000&quot;
37      - &quot;28332:28332&quot;
38public class WalletObserver {
39    public void init() {
40        final LocalTestNetParams netParams = new LocalTestNetParams();
41        netParams.setPort(50001);
42        try {
43            final WalletAppKit kit = new WalletAppKit(netParams, new File(&quot;.&quot;), &quot;_minimalCryptoExchangeBtcWallet&quot;);
44            kit.setAutoSave(true);
45            kit.connectToLocalHost();
46
47            kit.startAsync();
48            kit.awaitRunning(); // I never get past this point
49            kit.peerGroup().addPeerDiscovery(new DnsDiscovery(netParams));
50            kit.wallet().addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
51
52            kit.wallet().addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
53                @Override
54                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
55                    System.out.println(&quot;Heyo!&quot;);
56                }
57            });
58        }
59        catch (Exception exception) {
60            exception.printStackTrace();
61        }
62    }
63package com.dpisarenko.minimalcryptoexchange.logic.btc;
64
65import org.bitcoinj.params.RegTestParams;
66
67public class LocalTestNetParams extends RegTestParams {
68    public void setPort(final int newPort) {
69        this.port = newPort;
70    }
71}
7222:16:34.245 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
7322:16:34.265 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
74java.net.ConnectException: Connection refused
75    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
76    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
77    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
78    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
79    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
80    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
81    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
82    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
83    at java.base/java.lang.Thread.run(Thread.java:830)
8422:16:34.267 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
8522:16:34.267 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 21.84 μs and returned 0 items from 0 discoverers
8622:16:34.269 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 1502 ms before next connect attempt to [10.10.1.218]:50001
8722:16:35.776 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
8822:16:35.778 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
89java.net.ConnectException: Connection refused
90    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
91    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
92    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
93    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
94    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
95    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
96    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
97    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
98    at java.base/java.lang.Thread.run(Thread.java:830)
9922:16:35.778 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
10022:16:35.779 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 8.752 μs and returned 0 items from 0 discoverers
101

10.10.1.218 seems to be generated by InetAddress.getLocalHost() in org.bitcoinj.kits.WalletAppKit#connectToLocalHost:

1docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli getnewaddress
2import org.bitcoinj.core.Address;
3import org.bitcoinj.core.Coin;
4import org.bitcoinj.core.NetworkParameters;
5import org.bitcoinj.core.Transaction;
6import org.bitcoinj.wallet.Wallet;
7import org.bitcoinj.wallet.listeners.WalletCoinsReceivedEventListener;
8
9public class WalletObserver {
10    public void init() {
11        final NetworkParameters netParams = NetworkParameters.fromID(NetworkParameters.ID_REGTEST);
12
13        try {
14            final Wallet wallet = Wallet.createBasic(netParams);
15
16            wallet.addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
17
18            wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
19                @Override
20                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
21                    System.out.println(&quot;Heyo!&quot;);
22                }
23            });
24        }
25        catch (Exception exception) {
26            exception.printStackTrace();
27        }
28    }
29}
30% docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.5
31068c377bab961356ad9a3919229a764aa929711c68aefd5dbd4c7c348eef3406
32    ports:
33      - &quot;51001:50001&quot;
34      - &quot;51002:50002&quot;
35      - &quot;19001:19001&quot;
36      - &quot;19000:19000&quot;
37      - &quot;28332:28332&quot;
38public class WalletObserver {
39    public void init() {
40        final LocalTestNetParams netParams = new LocalTestNetParams();
41        netParams.setPort(50001);
42        try {
43            final WalletAppKit kit = new WalletAppKit(netParams, new File(&quot;.&quot;), &quot;_minimalCryptoExchangeBtcWallet&quot;);
44            kit.setAutoSave(true);
45            kit.connectToLocalHost();
46
47            kit.startAsync();
48            kit.awaitRunning(); // I never get past this point
49            kit.peerGroup().addPeerDiscovery(new DnsDiscovery(netParams));
50            kit.wallet().addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
51
52            kit.wallet().addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
53                @Override
54                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
55                    System.out.println(&quot;Heyo!&quot;);
56                }
57            });
58        }
59        catch (Exception exception) {
60            exception.printStackTrace();
61        }
62    }
63package com.dpisarenko.minimalcryptoexchange.logic.btc;
64
65import org.bitcoinj.params.RegTestParams;
66
67public class LocalTestNetParams extends RegTestParams {
68    public void setPort(final int newPort) {
69        this.port = newPort;
70    }
71}
7222:16:34.245 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
7322:16:34.265 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
74java.net.ConnectException: Connection refused
75    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
76    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
77    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
78    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
79    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
80    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
81    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
82    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
83    at java.base/java.lang.Thread.run(Thread.java:830)
8422:16:34.267 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
8522:16:34.267 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 21.84 μs and returned 0 items from 0 discoverers
8622:16:34.269 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 1502 ms before next connect attempt to [10.10.1.218]:50001
8722:16:35.776 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
8822:16:35.778 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
89java.net.ConnectException: Connection refused
90    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
91    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
92    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
93    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
94    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
95    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
96    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
97    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
98    at java.base/java.lang.Thread.run(Thread.java:830)
9922:16:35.778 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
10022:16:35.779 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 8.752 μs and returned 0 items from 0 discoverers
101    public WalletAppKit connectToLocalHost() {
102        try {
103            InetAddress localHost = InetAddress.getLocalHost();
104            return this.setPeerNodes(new PeerAddress(this.params, localHost, this.params.getPort()));
105        } catch (UnknownHostException var2) {
106            throw new RuntimeException(var2);
107        }
108    }
109
110

Update 1:

I tried to use network_mode: "host".

If I add it to node as in

1docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli getnewaddress
2import org.bitcoinj.core.Address;
3import org.bitcoinj.core.Coin;
4import org.bitcoinj.core.NetworkParameters;
5import org.bitcoinj.core.Transaction;
6import org.bitcoinj.wallet.Wallet;
7import org.bitcoinj.wallet.listeners.WalletCoinsReceivedEventListener;
8
9public class WalletObserver {
10    public void init() {
11        final NetworkParameters netParams = NetworkParameters.fromID(NetworkParameters.ID_REGTEST);
12
13        try {
14            final Wallet wallet = Wallet.createBasic(netParams);
15
16            wallet.addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
17
18            wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
19                @Override
20                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
21                    System.out.println(&quot;Heyo!&quot;);
22                }
23            });
24        }
25        catch (Exception exception) {
26            exception.printStackTrace();
27        }
28    }
29}
30% docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.5
31068c377bab961356ad9a3919229a764aa929711c68aefd5dbd4c7c348eef3406
32    ports:
33      - &quot;51001:50001&quot;
34      - &quot;51002:50002&quot;
35      - &quot;19001:19001&quot;
36      - &quot;19000:19000&quot;
37      - &quot;28332:28332&quot;
38public class WalletObserver {
39    public void init() {
40        final LocalTestNetParams netParams = new LocalTestNetParams();
41        netParams.setPort(50001);
42        try {
43            final WalletAppKit kit = new WalletAppKit(netParams, new File(&quot;.&quot;), &quot;_minimalCryptoExchangeBtcWallet&quot;);
44            kit.setAutoSave(true);
45            kit.connectToLocalHost();
46
47            kit.startAsync();
48            kit.awaitRunning(); // I never get past this point
49            kit.peerGroup().addPeerDiscovery(new DnsDiscovery(netParams));
50            kit.wallet().addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
51
52            kit.wallet().addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
53                @Override
54                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
55                    System.out.println(&quot;Heyo!&quot;);
56                }
57            });
58        }
59        catch (Exception exception) {
60            exception.printStackTrace();
61        }
62    }
63package com.dpisarenko.minimalcryptoexchange.logic.btc;
64
65import org.bitcoinj.params.RegTestParams;
66
67public class LocalTestNetParams extends RegTestParams {
68    public void setPort(final int newPort) {
69        this.port = newPort;
70    }
71}
7222:16:34.245 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
7322:16:34.265 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
74java.net.ConnectException: Connection refused
75    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
76    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
77    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
78    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
79    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
80    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
81    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
82    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
83    at java.base/java.lang.Thread.run(Thread.java:830)
8422:16:34.267 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
8522:16:34.267 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 21.84 μs and returned 0 items from 0 discoverers
8622:16:34.269 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 1502 ms before next connect attempt to [10.10.1.218]:50001
8722:16:35.776 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
8822:16:35.778 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
89java.net.ConnectException: Connection refused
90    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
91    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
92    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
93    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
94    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
95    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
96    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
97    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
98    at java.base/java.lang.Thread.run(Thread.java:830)
9922:16:35.778 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
10022:16:35.779 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 8.752 μs and returned 0 items from 0 discoverers
101    public WalletAppKit connectToLocalHost() {
102        try {
103            InetAddress localHost = InetAddress.getLocalHost();
104            return this.setPeerNodes(new PeerAddress(this.params, localHost, this.params.getPort()));
105        } catch (UnknownHostException var2) {
106            throw new RuntimeException(var2);
107        }
108    }
109
110  node:
111    image: ulamlabs/bitcoind-custom-regtest:latest
112    network_mode: &quot;host&quot;
113

I get the following error when I run docker-compose up -d:

1docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli getnewaddress
2import org.bitcoinj.core.Address;
3import org.bitcoinj.core.Coin;
4import org.bitcoinj.core.NetworkParameters;
5import org.bitcoinj.core.Transaction;
6import org.bitcoinj.wallet.Wallet;
7import org.bitcoinj.wallet.listeners.WalletCoinsReceivedEventListener;
8
9public class WalletObserver {
10    public void init() {
11        final NetworkParameters netParams = NetworkParameters.fromID(NetworkParameters.ID_REGTEST);
12
13        try {
14            final Wallet wallet = Wallet.createBasic(netParams);
15
16            wallet.addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
17
18            wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
19                @Override
20                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
21                    System.out.println(&quot;Heyo!&quot;);
22                }
23            });
24        }
25        catch (Exception exception) {
26            exception.printStackTrace();
27        }
28    }
29}
30% docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.5
31068c377bab961356ad9a3919229a764aa929711c68aefd5dbd4c7c348eef3406
32    ports:
33      - &quot;51001:50001&quot;
34      - &quot;51002:50002&quot;
35      - &quot;19001:19001&quot;
36      - &quot;19000:19000&quot;
37      - &quot;28332:28332&quot;
38public class WalletObserver {
39    public void init() {
40        final LocalTestNetParams netParams = new LocalTestNetParams();
41        netParams.setPort(50001);
42        try {
43            final WalletAppKit kit = new WalletAppKit(netParams, new File(&quot;.&quot;), &quot;_minimalCryptoExchangeBtcWallet&quot;);
44            kit.setAutoSave(true);
45            kit.connectToLocalHost();
46
47            kit.startAsync();
48            kit.awaitRunning(); // I never get past this point
49            kit.peerGroup().addPeerDiscovery(new DnsDiscovery(netParams));
50            kit.wallet().addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
51
52            kit.wallet().addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
53                @Override
54                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
55                    System.out.println(&quot;Heyo!&quot;);
56                }
57            });
58        }
59        catch (Exception exception) {
60            exception.printStackTrace();
61        }
62    }
63package com.dpisarenko.minimalcryptoexchange.logic.btc;
64
65import org.bitcoinj.params.RegTestParams;
66
67public class LocalTestNetParams extends RegTestParams {
68    public void setPort(final int newPort) {
69        this.port = newPort;
70    }
71}
7222:16:34.245 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
7322:16:34.265 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
74java.net.ConnectException: Connection refused
75    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
76    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
77    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
78    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
79    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
80    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
81    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
82    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
83    at java.base/java.lang.Thread.run(Thread.java:830)
8422:16:34.267 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
8522:16:34.267 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 21.84 μs and returned 0 items from 0 discoverers
8622:16:34.269 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 1502 ms before next connect attempt to [10.10.1.218]:50001
8722:16:35.776 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
8822:16:35.778 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
89java.net.ConnectException: Connection refused
90    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
91    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
92    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
93    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
94    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
95    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
96    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
97    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
98    at java.base/java.lang.Thread.run(Thread.java:830)
9922:16:35.778 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
10022:16:35.779 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 8.752 μs and returned 0 items from 0 discoverers
101    public WalletAppKit connectToLocalHost() {
102        try {
103            InetAddress localHost = InetAddress.getLocalHost();
104            return this.setPeerNodes(new PeerAddress(this.params, localHost, this.params.getPort()));
105        } catch (UnknownHostException var2) {
106            throw new RuntimeException(var2);
107        }
108    }
109
110  node:
111    image: ulamlabs/bitcoind-custom-regtest:latest
112    network_mode: &quot;host&quot;
113minimal-crypto-exchange % docker-compose up -d
114Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
115Creating minimal-crypto-exchange_postgres_1  ... done
116Creating minimal-crypto-exchange_geth_1     ...
117Creating minimal-crypto-exchange_node_1     ... done
118Creating minimal-crypto-exchange_electrumx_1 ...
119Creating minimal-crypto-exchange_electrumx_1 ... error
120
121ERROR: for minimal-crypto-exchange_electrumx_1  Cannot start service electrumx: driver fail
122Creating minimal-crypto-exchange_geth_1      ... done
123f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
124Creating minimal-crypto-exchange_blockscout_1 ... done
125
126ERROR: for electrumx  Cannot start service electrumx: driver failed programming external connectivity on endpoint minimal-crypto-exchange_electrumx_1 (8eaa4f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
127ERROR: Encountered errors while bringing up the project.
128

If I add it to electrumx part as in

1docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli getnewaddress
2import org.bitcoinj.core.Address;
3import org.bitcoinj.core.Coin;
4import org.bitcoinj.core.NetworkParameters;
5import org.bitcoinj.core.Transaction;
6import org.bitcoinj.wallet.Wallet;
7import org.bitcoinj.wallet.listeners.WalletCoinsReceivedEventListener;
8
9public class WalletObserver {
10    public void init() {
11        final NetworkParameters netParams = NetworkParameters.fromID(NetworkParameters.ID_REGTEST);
12
13        try {
14            final Wallet wallet = Wallet.createBasic(netParams);
15
16            wallet.addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
17
18            wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
19                @Override
20                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
21                    System.out.println(&quot;Heyo!&quot;);
22                }
23            });
24        }
25        catch (Exception exception) {
26            exception.printStackTrace();
27        }
28    }
29}
30% docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.5
31068c377bab961356ad9a3919229a764aa929711c68aefd5dbd4c7c348eef3406
32    ports:
33      - &quot;51001:50001&quot;
34      - &quot;51002:50002&quot;
35      - &quot;19001:19001&quot;
36      - &quot;19000:19000&quot;
37      - &quot;28332:28332&quot;
38public class WalletObserver {
39    public void init() {
40        final LocalTestNetParams netParams = new LocalTestNetParams();
41        netParams.setPort(50001);
42        try {
43            final WalletAppKit kit = new WalletAppKit(netParams, new File(&quot;.&quot;), &quot;_minimalCryptoExchangeBtcWallet&quot;);
44            kit.setAutoSave(true);
45            kit.connectToLocalHost();
46
47            kit.startAsync();
48            kit.awaitRunning(); // I never get past this point
49            kit.peerGroup().addPeerDiscovery(new DnsDiscovery(netParams));
50            kit.wallet().addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
51
52            kit.wallet().addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
53                @Override
54                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
55                    System.out.println(&quot;Heyo!&quot;);
56                }
57            });
58        }
59        catch (Exception exception) {
60            exception.printStackTrace();
61        }
62    }
63package com.dpisarenko.minimalcryptoexchange.logic.btc;
64
65import org.bitcoinj.params.RegTestParams;
66
67public class LocalTestNetParams extends RegTestParams {
68    public void setPort(final int newPort) {
69        this.port = newPort;
70    }
71}
7222:16:34.245 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
7322:16:34.265 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
74java.net.ConnectException: Connection refused
75    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
76    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
77    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
78    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
79    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
80    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
81    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
82    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
83    at java.base/java.lang.Thread.run(Thread.java:830)
8422:16:34.267 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
8522:16:34.267 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 21.84 μs and returned 0 items from 0 discoverers
8622:16:34.269 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 1502 ms before next connect attempt to [10.10.1.218]:50001
8722:16:35.776 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
8822:16:35.778 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
89java.net.ConnectException: Connection refused
90    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
91    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
92    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
93    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
94    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
95    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
96    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
97    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
98    at java.base/java.lang.Thread.run(Thread.java:830)
9922:16:35.778 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
10022:16:35.779 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 8.752 μs and returned 0 items from 0 discoverers
101    public WalletAppKit connectToLocalHost() {
102        try {
103            InetAddress localHost = InetAddress.getLocalHost();
104            return this.setPeerNodes(new PeerAddress(this.params, localHost, this.params.getPort()));
105        } catch (UnknownHostException var2) {
106            throw new RuntimeException(var2);
107        }
108    }
109
110  node:
111    image: ulamlabs/bitcoind-custom-regtest:latest
112    network_mode: &quot;host&quot;
113minimal-crypto-exchange % docker-compose up -d
114Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
115Creating minimal-crypto-exchange_postgres_1  ... done
116Creating minimal-crypto-exchange_geth_1     ...
117Creating minimal-crypto-exchange_node_1     ... done
118Creating minimal-crypto-exchange_electrumx_1 ...
119Creating minimal-crypto-exchange_electrumx_1 ... error
120
121ERROR: for minimal-crypto-exchange_electrumx_1  Cannot start service electrumx: driver fail
122Creating minimal-crypto-exchange_geth_1      ... done
123f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
124Creating minimal-crypto-exchange_blockscout_1 ... done
125
126ERROR: for electrumx  Cannot start service electrumx: driver failed programming external connectivity on endpoint minimal-crypto-exchange_electrumx_1 (8eaa4f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
127ERROR: Encountered errors while bringing up the project.
128  electrumx:
129    image: lukechilds/electrumx:latest
130    network_mode: &quot;host&quot;
131

I get another error:

1docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli getnewaddress
2import org.bitcoinj.core.Address;
3import org.bitcoinj.core.Coin;
4import org.bitcoinj.core.NetworkParameters;
5import org.bitcoinj.core.Transaction;
6import org.bitcoinj.wallet.Wallet;
7import org.bitcoinj.wallet.listeners.WalletCoinsReceivedEventListener;
8
9public class WalletObserver {
10    public void init() {
11        final NetworkParameters netParams = NetworkParameters.fromID(NetworkParameters.ID_REGTEST);
12
13        try {
14            final Wallet wallet = Wallet.createBasic(netParams);
15
16            wallet.addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
17
18            wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
19                @Override
20                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
21                    System.out.println(&quot;Heyo!&quot;);
22                }
23            });
24        }
25        catch (Exception exception) {
26            exception.printStackTrace();
27        }
28    }
29}
30% docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.5
31068c377bab961356ad9a3919229a764aa929711c68aefd5dbd4c7c348eef3406
32    ports:
33      - &quot;51001:50001&quot;
34      - &quot;51002:50002&quot;
35      - &quot;19001:19001&quot;
36      - &quot;19000:19000&quot;
37      - &quot;28332:28332&quot;
38public class WalletObserver {
39    public void init() {
40        final LocalTestNetParams netParams = new LocalTestNetParams();
41        netParams.setPort(50001);
42        try {
43            final WalletAppKit kit = new WalletAppKit(netParams, new File(&quot;.&quot;), &quot;_minimalCryptoExchangeBtcWallet&quot;);
44            kit.setAutoSave(true);
45            kit.connectToLocalHost();
46
47            kit.startAsync();
48            kit.awaitRunning(); // I never get past this point
49            kit.peerGroup().addPeerDiscovery(new DnsDiscovery(netParams));
50            kit.wallet().addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
51
52            kit.wallet().addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
53                @Override
54                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
55                    System.out.println(&quot;Heyo!&quot;);
56                }
57            });
58        }
59        catch (Exception exception) {
60            exception.printStackTrace();
61        }
62    }
63package com.dpisarenko.minimalcryptoexchange.logic.btc;
64
65import org.bitcoinj.params.RegTestParams;
66
67public class LocalTestNetParams extends RegTestParams {
68    public void setPort(final int newPort) {
69        this.port = newPort;
70    }
71}
7222:16:34.245 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
7322:16:34.265 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
74java.net.ConnectException: Connection refused
75    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
76    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
77    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
78    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
79    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
80    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
81    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
82    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
83    at java.base/java.lang.Thread.run(Thread.java:830)
8422:16:34.267 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
8522:16:34.267 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 21.84 μs and returned 0 items from 0 discoverers
8622:16:34.269 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 1502 ms before next connect attempt to [10.10.1.218]:50001
8722:16:35.776 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
8822:16:35.778 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
89java.net.ConnectException: Connection refused
90    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
91    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
92    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
93    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
94    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
95    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
96    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
97    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
98    at java.base/java.lang.Thread.run(Thread.java:830)
9922:16:35.778 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
10022:16:35.779 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 8.752 μs and returned 0 items from 0 discoverers
101    public WalletAppKit connectToLocalHost() {
102        try {
103            InetAddress localHost = InetAddress.getLocalHost();
104            return this.setPeerNodes(new PeerAddress(this.params, localHost, this.params.getPort()));
105        } catch (UnknownHostException var2) {
106            throw new RuntimeException(var2);
107        }
108    }
109
110  node:
111    image: ulamlabs/bitcoind-custom-regtest:latest
112    network_mode: &quot;host&quot;
113minimal-crypto-exchange % docker-compose up -d
114Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
115Creating minimal-crypto-exchange_postgres_1  ... done
116Creating minimal-crypto-exchange_geth_1     ...
117Creating minimal-crypto-exchange_node_1     ... done
118Creating minimal-crypto-exchange_electrumx_1 ...
119Creating minimal-crypto-exchange_electrumx_1 ... error
120
121ERROR: for minimal-crypto-exchange_electrumx_1  Cannot start service electrumx: driver fail
122Creating minimal-crypto-exchange_geth_1      ... done
123f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
124Creating minimal-crypto-exchange_blockscout_1 ... done
125
126ERROR: for electrumx  Cannot start service electrumx: driver failed programming external connectivity on endpoint minimal-crypto-exchange_electrumx_1 (8eaa4f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
127ERROR: Encountered errors while bringing up the project.
128  electrumx:
129    image: lukechilds/electrumx:latest
130    network_mode: &quot;host&quot;
131minimal-crypto-exchange % docker-compose up -d
132minimal-crypto-exchange_postgres_1 is up-to-date
133minimal-crypto-exchange_geth_1 is up-to-date
134Recreating minimal-crypto-exchange_node_1 ...
135Recreating minimal-crypto-exchange_node_1 ... done
136Recreating minimal-crypto-exchange_electrumx_1 ...
137
138ERROR: for minimal-crypto-exchange_electrumx_1  &quot;host&quot; network_mode is incompatible with port_bindings
139
140ERROR: for electrumx  &quot;host&quot; network_mode is incompatible with port_bindings
141Traceback (most recent call last):
142  File &quot;docker-compose&quot;, line 3, in &lt;module&gt;
143  File &quot;compose/cli/main.py&quot;, line 81, in main
144  File &quot;compose/cli/main.py&quot;, line 203, in perform_command
145  File &quot;compose/metrics/decorator.py&quot;, line 18, in wrapper
146  File &quot;compose/cli/main.py&quot;, line 1186, in up
147  File &quot;compose/cli/main.py&quot;, line 1166, in up
148  File &quot;compose/project.py&quot;, line 697, in up
149  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
150  File &quot;compose/parallel.py&quot;, line 206, in producer
151  File &quot;compose/project.py&quot;, line 679, in do
152  File &quot;compose/service.py&quot;, line 579, in execute_convergence_plan
153  File &quot;compose/service.py&quot;, line 499, in _execute_convergence_recreate
154  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
155  File &quot;compose/parallel.py&quot;, line 206, in producer
156  File &quot;compose/service.py&quot;, line 494, in recreate
157  File &quot;compose/service.py&quot;, line 612, in recreate_container
158  File &quot;compose/service.py&quot;, line 330, in create_container
159  File &quot;compose/service.py&quot;, line 939, in _get_container_create_options
160  File &quot;compose/service.py&quot;, line 1014, in _get_container_host_config
161  File &quot;docker/api/container.py&quot;, line 598, in create_host_config
162  File &quot;docker/types/containers.py&quot;, line 338, in __init__
163docker.errors.InvalidArgument: &quot;host&quot; network_mode is incompatible with port_bindings
164[44262] Failed to execute script docker-compose
165

Update 2:

If I comment out port bindings as in

1docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli getnewaddress
2import org.bitcoinj.core.Address;
3import org.bitcoinj.core.Coin;
4import org.bitcoinj.core.NetworkParameters;
5import org.bitcoinj.core.Transaction;
6import org.bitcoinj.wallet.Wallet;
7import org.bitcoinj.wallet.listeners.WalletCoinsReceivedEventListener;
8
9public class WalletObserver {
10    public void init() {
11        final NetworkParameters netParams = NetworkParameters.fromID(NetworkParameters.ID_REGTEST);
12
13        try {
14            final Wallet wallet = Wallet.createBasic(netParams);
15
16            wallet.addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
17
18            wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
19                @Override
20                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
21                    System.out.println(&quot;Heyo!&quot;);
22                }
23            });
24        }
25        catch (Exception exception) {
26            exception.printStackTrace();
27        }
28    }
29}
30% docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.5
31068c377bab961356ad9a3919229a764aa929711c68aefd5dbd4c7c348eef3406
32    ports:
33      - &quot;51001:50001&quot;
34      - &quot;51002:50002&quot;
35      - &quot;19001:19001&quot;
36      - &quot;19000:19000&quot;
37      - &quot;28332:28332&quot;
38public class WalletObserver {
39    public void init() {
40        final LocalTestNetParams netParams = new LocalTestNetParams();
41        netParams.setPort(50001);
42        try {
43            final WalletAppKit kit = new WalletAppKit(netParams, new File(&quot;.&quot;), &quot;_minimalCryptoExchangeBtcWallet&quot;);
44            kit.setAutoSave(true);
45            kit.connectToLocalHost();
46
47            kit.startAsync();
48            kit.awaitRunning(); // I never get past this point
49            kit.peerGroup().addPeerDiscovery(new DnsDiscovery(netParams));
50            kit.wallet().addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
51
52            kit.wallet().addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
53                @Override
54                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
55                    System.out.println(&quot;Heyo!&quot;);
56                }
57            });
58        }
59        catch (Exception exception) {
60            exception.printStackTrace();
61        }
62    }
63package com.dpisarenko.minimalcryptoexchange.logic.btc;
64
65import org.bitcoinj.params.RegTestParams;
66
67public class LocalTestNetParams extends RegTestParams {
68    public void setPort(final int newPort) {
69        this.port = newPort;
70    }
71}
7222:16:34.245 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
7322:16:34.265 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
74java.net.ConnectException: Connection refused
75    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
76    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
77    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
78    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
79    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
80    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
81    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
82    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
83    at java.base/java.lang.Thread.run(Thread.java:830)
8422:16:34.267 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
8522:16:34.267 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 21.84 μs and returned 0 items from 0 discoverers
8622:16:34.269 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 1502 ms before next connect attempt to [10.10.1.218]:50001
8722:16:35.776 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
8822:16:35.778 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
89java.net.ConnectException: Connection refused
90    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
91    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
92    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
93    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
94    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
95    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
96    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
97    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
98    at java.base/java.lang.Thread.run(Thread.java:830)
9922:16:35.778 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
10022:16:35.779 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 8.752 μs and returned 0 items from 0 discoverers
101    public WalletAppKit connectToLocalHost() {
102        try {
103            InetAddress localHost = InetAddress.getLocalHost();
104            return this.setPeerNodes(new PeerAddress(this.params, localHost, this.params.getPort()));
105        } catch (UnknownHostException var2) {
106            throw new RuntimeException(var2);
107        }
108    }
109
110  node:
111    image: ulamlabs/bitcoind-custom-regtest:latest
112    network_mode: &quot;host&quot;
113minimal-crypto-exchange % docker-compose up -d
114Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
115Creating minimal-crypto-exchange_postgres_1  ... done
116Creating minimal-crypto-exchange_geth_1     ...
117Creating minimal-crypto-exchange_node_1     ... done
118Creating minimal-crypto-exchange_electrumx_1 ...
119Creating minimal-crypto-exchange_electrumx_1 ... error
120
121ERROR: for minimal-crypto-exchange_electrumx_1  Cannot start service electrumx: driver fail
122Creating minimal-crypto-exchange_geth_1      ... done
123f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
124Creating minimal-crypto-exchange_blockscout_1 ... done
125
126ERROR: for electrumx  Cannot start service electrumx: driver failed programming external connectivity on endpoint minimal-crypto-exchange_electrumx_1 (8eaa4f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
127ERROR: Encountered errors while bringing up the project.
128  electrumx:
129    image: lukechilds/electrumx:latest
130    network_mode: &quot;host&quot;
131minimal-crypto-exchange % docker-compose up -d
132minimal-crypto-exchange_postgres_1 is up-to-date
133minimal-crypto-exchange_geth_1 is up-to-date
134Recreating minimal-crypto-exchange_node_1 ...
135Recreating minimal-crypto-exchange_node_1 ... done
136Recreating minimal-crypto-exchange_electrumx_1 ...
137
138ERROR: for minimal-crypto-exchange_electrumx_1  &quot;host&quot; network_mode is incompatible with port_bindings
139
140ERROR: for electrumx  &quot;host&quot; network_mode is incompatible with port_bindings
141Traceback (most recent call last):
142  File &quot;docker-compose&quot;, line 3, in &lt;module&gt;
143  File &quot;compose/cli/main.py&quot;, line 81, in main
144  File &quot;compose/cli/main.py&quot;, line 203, in perform_command
145  File &quot;compose/metrics/decorator.py&quot;, line 18, in wrapper
146  File &quot;compose/cli/main.py&quot;, line 1186, in up
147  File &quot;compose/cli/main.py&quot;, line 1166, in up
148  File &quot;compose/project.py&quot;, line 697, in up
149  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
150  File &quot;compose/parallel.py&quot;, line 206, in producer
151  File &quot;compose/project.py&quot;, line 679, in do
152  File &quot;compose/service.py&quot;, line 579, in execute_convergence_plan
153  File &quot;compose/service.py&quot;, line 499, in _execute_convergence_recreate
154  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
155  File &quot;compose/parallel.py&quot;, line 206, in producer
156  File &quot;compose/service.py&quot;, line 494, in recreate
157  File &quot;compose/service.py&quot;, line 612, in recreate_container
158  File &quot;compose/service.py&quot;, line 330, in create_container
159  File &quot;compose/service.py&quot;, line 939, in _get_container_create_options
160  File &quot;compose/service.py&quot;, line 1014, in _get_container_host_config
161  File &quot;docker/api/container.py&quot;, line 598, in create_host_config
162  File &quot;docker/types/containers.py&quot;, line 338, in __init__
163docker.errors.InvalidArgument: &quot;host&quot; network_mode is incompatible with port_bindings
164[44262] Failed to execute script docker-compose
165  electrumx:
166    image: lukechilds/electrumx:latest
167    network_mode: host
168    links:
169      - node
170# Port settings see https://github.com/ulamlabs/bitcoind-custom-regtest
171#    ports:
172#      - &quot;51001:50001&quot;
173#      - &quot;51002:50002&quot;
174#      - &quot;19001:19001&quot;
175#      - &quot;19000:19000&quot;
176#      - &quot;28332:28332&quot;
177

and run docker-compose up -d I get

1docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli getnewaddress
2import org.bitcoinj.core.Address;
3import org.bitcoinj.core.Coin;
4import org.bitcoinj.core.NetworkParameters;
5import org.bitcoinj.core.Transaction;
6import org.bitcoinj.wallet.Wallet;
7import org.bitcoinj.wallet.listeners.WalletCoinsReceivedEventListener;
8
9public class WalletObserver {
10    public void init() {
11        final NetworkParameters netParams = NetworkParameters.fromID(NetworkParameters.ID_REGTEST);
12
13        try {
14            final Wallet wallet = Wallet.createBasic(netParams);
15
16            wallet.addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
17
18            wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
19                @Override
20                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
21                    System.out.println(&quot;Heyo!&quot;);
22                }
23            });
24        }
25        catch (Exception exception) {
26            exception.printStackTrace();
27        }
28    }
29}
30% docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.5
31068c377bab961356ad9a3919229a764aa929711c68aefd5dbd4c7c348eef3406
32    ports:
33      - &quot;51001:50001&quot;
34      - &quot;51002:50002&quot;
35      - &quot;19001:19001&quot;
36      - &quot;19000:19000&quot;
37      - &quot;28332:28332&quot;
38public class WalletObserver {
39    public void init() {
40        final LocalTestNetParams netParams = new LocalTestNetParams();
41        netParams.setPort(50001);
42        try {
43            final WalletAppKit kit = new WalletAppKit(netParams, new File(&quot;.&quot;), &quot;_minimalCryptoExchangeBtcWallet&quot;);
44            kit.setAutoSave(true);
45            kit.connectToLocalHost();
46
47            kit.startAsync();
48            kit.awaitRunning(); // I never get past this point
49            kit.peerGroup().addPeerDiscovery(new DnsDiscovery(netParams));
50            kit.wallet().addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
51
52            kit.wallet().addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
53                @Override
54                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
55                    System.out.println(&quot;Heyo!&quot;);
56                }
57            });
58        }
59        catch (Exception exception) {
60            exception.printStackTrace();
61        }
62    }
63package com.dpisarenko.minimalcryptoexchange.logic.btc;
64
65import org.bitcoinj.params.RegTestParams;
66
67public class LocalTestNetParams extends RegTestParams {
68    public void setPort(final int newPort) {
69        this.port = newPort;
70    }
71}
7222:16:34.245 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
7322:16:34.265 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
74java.net.ConnectException: Connection refused
75    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
76    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
77    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
78    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
79    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
80    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
81    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
82    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
83    at java.base/java.lang.Thread.run(Thread.java:830)
8422:16:34.267 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
8522:16:34.267 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 21.84 μs and returned 0 items from 0 discoverers
8622:16:34.269 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 1502 ms before next connect attempt to [10.10.1.218]:50001
8722:16:35.776 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
8822:16:35.778 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
89java.net.ConnectException: Connection refused
90    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
91    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
92    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
93    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
94    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
95    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
96    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
97    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
98    at java.base/java.lang.Thread.run(Thread.java:830)
9922:16:35.778 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
10022:16:35.779 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 8.752 μs and returned 0 items from 0 discoverers
101    public WalletAppKit connectToLocalHost() {
102        try {
103            InetAddress localHost = InetAddress.getLocalHost();
104            return this.setPeerNodes(new PeerAddress(this.params, localHost, this.params.getPort()));
105        } catch (UnknownHostException var2) {
106            throw new RuntimeException(var2);
107        }
108    }
109
110  node:
111    image: ulamlabs/bitcoind-custom-regtest:latest
112    network_mode: &quot;host&quot;
113minimal-crypto-exchange % docker-compose up -d
114Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
115Creating minimal-crypto-exchange_postgres_1  ... done
116Creating minimal-crypto-exchange_geth_1     ...
117Creating minimal-crypto-exchange_node_1     ... done
118Creating minimal-crypto-exchange_electrumx_1 ...
119Creating minimal-crypto-exchange_electrumx_1 ... error
120
121ERROR: for minimal-crypto-exchange_electrumx_1  Cannot start service electrumx: driver fail
122Creating minimal-crypto-exchange_geth_1      ... done
123f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
124Creating minimal-crypto-exchange_blockscout_1 ... done
125
126ERROR: for electrumx  Cannot start service electrumx: driver failed programming external connectivity on endpoint minimal-crypto-exchange_electrumx_1 (8eaa4f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
127ERROR: Encountered errors while bringing up the project.
128  electrumx:
129    image: lukechilds/electrumx:latest
130    network_mode: &quot;host&quot;
131minimal-crypto-exchange % docker-compose up -d
132minimal-crypto-exchange_postgres_1 is up-to-date
133minimal-crypto-exchange_geth_1 is up-to-date
134Recreating minimal-crypto-exchange_node_1 ...
135Recreating minimal-crypto-exchange_node_1 ... done
136Recreating minimal-crypto-exchange_electrumx_1 ...
137
138ERROR: for minimal-crypto-exchange_electrumx_1  &quot;host&quot; network_mode is incompatible with port_bindings
139
140ERROR: for electrumx  &quot;host&quot; network_mode is incompatible with port_bindings
141Traceback (most recent call last):
142  File &quot;docker-compose&quot;, line 3, in &lt;module&gt;
143  File &quot;compose/cli/main.py&quot;, line 81, in main
144  File &quot;compose/cli/main.py&quot;, line 203, in perform_command
145  File &quot;compose/metrics/decorator.py&quot;, line 18, in wrapper
146  File &quot;compose/cli/main.py&quot;, line 1186, in up
147  File &quot;compose/cli/main.py&quot;, line 1166, in up
148  File &quot;compose/project.py&quot;, line 697, in up
149  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
150  File &quot;compose/parallel.py&quot;, line 206, in producer
151  File &quot;compose/project.py&quot;, line 679, in do
152  File &quot;compose/service.py&quot;, line 579, in execute_convergence_plan
153  File &quot;compose/service.py&quot;, line 499, in _execute_convergence_recreate
154  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
155  File &quot;compose/parallel.py&quot;, line 206, in producer
156  File &quot;compose/service.py&quot;, line 494, in recreate
157  File &quot;compose/service.py&quot;, line 612, in recreate_container
158  File &quot;compose/service.py&quot;, line 330, in create_container
159  File &quot;compose/service.py&quot;, line 939, in _get_container_create_options
160  File &quot;compose/service.py&quot;, line 1014, in _get_container_host_config
161  File &quot;docker/api/container.py&quot;, line 598, in create_host_config
162  File &quot;docker/types/containers.py&quot;, line 338, in __init__
163docker.errors.InvalidArgument: &quot;host&quot; network_mode is incompatible with port_bindings
164[44262] Failed to execute script docker-compose
165  electrumx:
166    image: lukechilds/electrumx:latest
167    network_mode: host
168    links:
169      - node
170# Port settings see https://github.com/ulamlabs/bitcoind-custom-regtest
171#    ports:
172#      - &quot;51001:50001&quot;
173#      - &quot;51002:50002&quot;
174#      - &quot;19001:19001&quot;
175#      - &quot;19000:19000&quot;
176#      - &quot;28332:28332&quot;
177 % docker-compose up -d
178Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
179Creating minimal-crypto-exchange_geth_1 ...
180Creating minimal-crypto-exchange_postgres_1  ... done
181Creating minimal-crypto-exchange_node_1     ... done
182Creating minimal-crypto-exchange_electrumx_1 ... error
183Creating minimal-crypto-exchange_geth_1      ... done
184ERROR: for minimal-crypto-exchange_electrumx_1  Cannot create container for service electrumx: conflicting options: host type networking can't be used with links. This would result in undefined behavior
185Creating minimal-crypto-exchange_blockscout_1 ... done
186
187ERROR: for electrumx  Cannot create container for service electrumx: conflicting options: host type networking can't be used with links. This would result in undefined behavior
188ERROR: Encountered errors while bringing up the project.
189

Update 3: I assume that the root of the error is that in my Java code I try to connect to the ElectrumX server instead of the actual Bitcoin node (node in docker-compose.yml).

Update 4:

I changed docker-compose.yml as follows:

1docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli getnewaddress
2import org.bitcoinj.core.Address;
3import org.bitcoinj.core.Coin;
4import org.bitcoinj.core.NetworkParameters;
5import org.bitcoinj.core.Transaction;
6import org.bitcoinj.wallet.Wallet;
7import org.bitcoinj.wallet.listeners.WalletCoinsReceivedEventListener;
8
9public class WalletObserver {
10    public void init() {
11        final NetworkParameters netParams = NetworkParameters.fromID(NetworkParameters.ID_REGTEST);
12
13        try {
14            final Wallet wallet = Wallet.createBasic(netParams);
15
16            wallet.addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
17
18            wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
19                @Override
20                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
21                    System.out.println(&quot;Heyo!&quot;);
22                }
23            });
24        }
25        catch (Exception exception) {
26            exception.printStackTrace();
27        }
28    }
29}
30% docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.5
31068c377bab961356ad9a3919229a764aa929711c68aefd5dbd4c7c348eef3406
32    ports:
33      - &quot;51001:50001&quot;
34      - &quot;51002:50002&quot;
35      - &quot;19001:19001&quot;
36      - &quot;19000:19000&quot;
37      - &quot;28332:28332&quot;
38public class WalletObserver {
39    public void init() {
40        final LocalTestNetParams netParams = new LocalTestNetParams();
41        netParams.setPort(50001);
42        try {
43            final WalletAppKit kit = new WalletAppKit(netParams, new File(&quot;.&quot;), &quot;_minimalCryptoExchangeBtcWallet&quot;);
44            kit.setAutoSave(true);
45            kit.connectToLocalHost();
46
47            kit.startAsync();
48            kit.awaitRunning(); // I never get past this point
49            kit.peerGroup().addPeerDiscovery(new DnsDiscovery(netParams));
50            kit.wallet().addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
51
52            kit.wallet().addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
53                @Override
54                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
55                    System.out.println(&quot;Heyo!&quot;);
56                }
57            });
58        }
59        catch (Exception exception) {
60            exception.printStackTrace();
61        }
62    }
63package com.dpisarenko.minimalcryptoexchange.logic.btc;
64
65import org.bitcoinj.params.RegTestParams;
66
67public class LocalTestNetParams extends RegTestParams {
68    public void setPort(final int newPort) {
69        this.port = newPort;
70    }
71}
7222:16:34.245 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
7322:16:34.265 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
74java.net.ConnectException: Connection refused
75    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
76    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
77    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
78    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
79    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
80    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
81    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
82    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
83    at java.base/java.lang.Thread.run(Thread.java:830)
8422:16:34.267 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
8522:16:34.267 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 21.84 μs and returned 0 items from 0 discoverers
8622:16:34.269 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 1502 ms before next connect attempt to [10.10.1.218]:50001
8722:16:35.776 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
8822:16:35.778 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
89java.net.ConnectException: Connection refused
90    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
91    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
92    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
93    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
94    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
95    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
96    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
97    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
98    at java.base/java.lang.Thread.run(Thread.java:830)
9922:16:35.778 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
10022:16:35.779 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 8.752 μs and returned 0 items from 0 discoverers
101    public WalletAppKit connectToLocalHost() {
102        try {
103            InetAddress localHost = InetAddress.getLocalHost();
104            return this.setPeerNodes(new PeerAddress(this.params, localHost, this.params.getPort()));
105        } catch (UnknownHostException var2) {
106            throw new RuntimeException(var2);
107        }
108    }
109
110  node:
111    image: ulamlabs/bitcoind-custom-regtest:latest
112    network_mode: &quot;host&quot;
113minimal-crypto-exchange % docker-compose up -d
114Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
115Creating minimal-crypto-exchange_postgres_1  ... done
116Creating minimal-crypto-exchange_geth_1     ...
117Creating minimal-crypto-exchange_node_1     ... done
118Creating minimal-crypto-exchange_electrumx_1 ...
119Creating minimal-crypto-exchange_electrumx_1 ... error
120
121ERROR: for minimal-crypto-exchange_electrumx_1  Cannot start service electrumx: driver fail
122Creating minimal-crypto-exchange_geth_1      ... done
123f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
124Creating minimal-crypto-exchange_blockscout_1 ... done
125
126ERROR: for electrumx  Cannot start service electrumx: driver failed programming external connectivity on endpoint minimal-crypto-exchange_electrumx_1 (8eaa4f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
127ERROR: Encountered errors while bringing up the project.
128  electrumx:
129    image: lukechilds/electrumx:latest
130    network_mode: &quot;host&quot;
131minimal-crypto-exchange % docker-compose up -d
132minimal-crypto-exchange_postgres_1 is up-to-date
133minimal-crypto-exchange_geth_1 is up-to-date
134Recreating minimal-crypto-exchange_node_1 ...
135Recreating minimal-crypto-exchange_node_1 ... done
136Recreating minimal-crypto-exchange_electrumx_1 ...
137
138ERROR: for minimal-crypto-exchange_electrumx_1  &quot;host&quot; network_mode is incompatible with port_bindings
139
140ERROR: for electrumx  &quot;host&quot; network_mode is incompatible with port_bindings
141Traceback (most recent call last):
142  File &quot;docker-compose&quot;, line 3, in &lt;module&gt;
143  File &quot;compose/cli/main.py&quot;, line 81, in main
144  File &quot;compose/cli/main.py&quot;, line 203, in perform_command
145  File &quot;compose/metrics/decorator.py&quot;, line 18, in wrapper
146  File &quot;compose/cli/main.py&quot;, line 1186, in up
147  File &quot;compose/cli/main.py&quot;, line 1166, in up
148  File &quot;compose/project.py&quot;, line 697, in up
149  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
150  File &quot;compose/parallel.py&quot;, line 206, in producer
151  File &quot;compose/project.py&quot;, line 679, in do
152  File &quot;compose/service.py&quot;, line 579, in execute_convergence_plan
153  File &quot;compose/service.py&quot;, line 499, in _execute_convergence_recreate
154  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
155  File &quot;compose/parallel.py&quot;, line 206, in producer
156  File &quot;compose/service.py&quot;, line 494, in recreate
157  File &quot;compose/service.py&quot;, line 612, in recreate_container
158  File &quot;compose/service.py&quot;, line 330, in create_container
159  File &quot;compose/service.py&quot;, line 939, in _get_container_create_options
160  File &quot;compose/service.py&quot;, line 1014, in _get_container_host_config
161  File &quot;docker/api/container.py&quot;, line 598, in create_host_config
162  File &quot;docker/types/containers.py&quot;, line 338, in __init__
163docker.errors.InvalidArgument: &quot;host&quot; network_mode is incompatible with port_bindings
164[44262] Failed to execute script docker-compose
165  electrumx:
166    image: lukechilds/electrumx:latest
167    network_mode: host
168    links:
169      - node
170# Port settings see https://github.com/ulamlabs/bitcoind-custom-regtest
171#    ports:
172#      - &quot;51001:50001&quot;
173#      - &quot;51002:50002&quot;
174#      - &quot;19001:19001&quot;
175#      - &quot;19000:19000&quot;
176#      - &quot;28332:28332&quot;
177 % docker-compose up -d
178Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
179Creating minimal-crypto-exchange_geth_1 ...
180Creating minimal-crypto-exchange_postgres_1  ... done
181Creating minimal-crypto-exchange_node_1     ... done
182Creating minimal-crypto-exchange_electrumx_1 ... error
183Creating minimal-crypto-exchange_geth_1      ... done
184ERROR: for minimal-crypto-exchange_electrumx_1  Cannot create container for service electrumx: conflicting options: host type networking can't be used with links. This would result in undefined behavior
185Creating minimal-crypto-exchange_blockscout_1 ... done
186
187ERROR: for electrumx  Cannot create container for service electrumx: conflicting options: host type networking can't be used with links. This would result in undefined behavior
188ERROR: Encountered errors while bringing up the project.
189  node:
190    image: ulamlabs/bitcoind-custom-regtest:latest
191# For ports used by node see
192# https://github.com/ulamlabs/bitcoind-custom-regtest/blob/master/bitcoin.conf
193    ports:
194      - &quot;19001:19001&quot;
195      - &quot;19000:19000&quot;
196      - &quot;28332:28332&quot;
197  electrumx:
198    image: lukechilds/electrumx:latest
199    links:
200      - node
201# Port settings see https://github.com/ulamlabs/bitcoind-custom-regtest
202    ports:
203      - &quot;51001:50001&quot;
204      - &quot;51002:50002&quot;
205#      - &quot;19001:19001&quot;
206#      - &quot;19000:19000&quot;
207#      - &quot;28332:28332&quot;
208

Now I am getting different errors (full log available here):

1docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli getnewaddress
2import org.bitcoinj.core.Address;
3import org.bitcoinj.core.Coin;
4import org.bitcoinj.core.NetworkParameters;
5import org.bitcoinj.core.Transaction;
6import org.bitcoinj.wallet.Wallet;
7import org.bitcoinj.wallet.listeners.WalletCoinsReceivedEventListener;
8
9public class WalletObserver {
10    public void init() {
11        final NetworkParameters netParams = NetworkParameters.fromID(NetworkParameters.ID_REGTEST);
12
13        try {
14            final Wallet wallet = Wallet.createBasic(netParams);
15
16            wallet.addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
17
18            wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
19                @Override
20                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
21                    System.out.println(&quot;Heyo!&quot;);
22                }
23            });
24        }
25        catch (Exception exception) {
26            exception.printStackTrace();
27        }
28    }
29}
30% docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.5
31068c377bab961356ad9a3919229a764aa929711c68aefd5dbd4c7c348eef3406
32    ports:
33      - &quot;51001:50001&quot;
34      - &quot;51002:50002&quot;
35      - &quot;19001:19001&quot;
36      - &quot;19000:19000&quot;
37      - &quot;28332:28332&quot;
38public class WalletObserver {
39    public void init() {
40        final LocalTestNetParams netParams = new LocalTestNetParams();
41        netParams.setPort(50001);
42        try {
43            final WalletAppKit kit = new WalletAppKit(netParams, new File(&quot;.&quot;), &quot;_minimalCryptoExchangeBtcWallet&quot;);
44            kit.setAutoSave(true);
45            kit.connectToLocalHost();
46
47            kit.startAsync();
48            kit.awaitRunning(); // I never get past this point
49            kit.peerGroup().addPeerDiscovery(new DnsDiscovery(netParams));
50            kit.wallet().addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
51
52            kit.wallet().addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
53                @Override
54                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
55                    System.out.println(&quot;Heyo!&quot;);
56                }
57            });
58        }
59        catch (Exception exception) {
60            exception.printStackTrace();
61        }
62    }
63package com.dpisarenko.minimalcryptoexchange.logic.btc;
64
65import org.bitcoinj.params.RegTestParams;
66
67public class LocalTestNetParams extends RegTestParams {
68    public void setPort(final int newPort) {
69        this.port = newPort;
70    }
71}
7222:16:34.245 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
7322:16:34.265 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
74java.net.ConnectException: Connection refused
75    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
76    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
77    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
78    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
79    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
80    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
81    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
82    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
83    at java.base/java.lang.Thread.run(Thread.java:830)
8422:16:34.267 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
8522:16:34.267 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 21.84 μs and returned 0 items from 0 discoverers
8622:16:34.269 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 1502 ms before next connect attempt to [10.10.1.218]:50001
8722:16:35.776 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
8822:16:35.778 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
89java.net.ConnectException: Connection refused
90    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
91    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
92    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
93    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
94    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
95    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
96    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
97    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
98    at java.base/java.lang.Thread.run(Thread.java:830)
9922:16:35.778 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
10022:16:35.779 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 8.752 μs and returned 0 items from 0 discoverers
101    public WalletAppKit connectToLocalHost() {
102        try {
103            InetAddress localHost = InetAddress.getLocalHost();
104            return this.setPeerNodes(new PeerAddress(this.params, localHost, this.params.getPort()));
105        } catch (UnknownHostException var2) {
106            throw new RuntimeException(var2);
107        }
108    }
109
110  node:
111    image: ulamlabs/bitcoind-custom-regtest:latest
112    network_mode: &quot;host&quot;
113minimal-crypto-exchange % docker-compose up -d
114Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
115Creating minimal-crypto-exchange_postgres_1  ... done
116Creating minimal-crypto-exchange_geth_1     ...
117Creating minimal-crypto-exchange_node_1     ... done
118Creating minimal-crypto-exchange_electrumx_1 ...
119Creating minimal-crypto-exchange_electrumx_1 ... error
120
121ERROR: for minimal-crypto-exchange_electrumx_1  Cannot start service electrumx: driver fail
122Creating minimal-crypto-exchange_geth_1      ... done
123f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
124Creating minimal-crypto-exchange_blockscout_1 ... done
125
126ERROR: for electrumx  Cannot start service electrumx: driver failed programming external connectivity on endpoint minimal-crypto-exchange_electrumx_1 (8eaa4f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
127ERROR: Encountered errors while bringing up the project.
128  electrumx:
129    image: lukechilds/electrumx:latest
130    network_mode: &quot;host&quot;
131minimal-crypto-exchange % docker-compose up -d
132minimal-crypto-exchange_postgres_1 is up-to-date
133minimal-crypto-exchange_geth_1 is up-to-date
134Recreating minimal-crypto-exchange_node_1 ...
135Recreating minimal-crypto-exchange_node_1 ... done
136Recreating minimal-crypto-exchange_electrumx_1 ...
137
138ERROR: for minimal-crypto-exchange_electrumx_1  &quot;host&quot; network_mode is incompatible with port_bindings
139
140ERROR: for electrumx  &quot;host&quot; network_mode is incompatible with port_bindings
141Traceback (most recent call last):
142  File &quot;docker-compose&quot;, line 3, in &lt;module&gt;
143  File &quot;compose/cli/main.py&quot;, line 81, in main
144  File &quot;compose/cli/main.py&quot;, line 203, in perform_command
145  File &quot;compose/metrics/decorator.py&quot;, line 18, in wrapper
146  File &quot;compose/cli/main.py&quot;, line 1186, in up
147  File &quot;compose/cli/main.py&quot;, line 1166, in up
148  File &quot;compose/project.py&quot;, line 697, in up
149  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
150  File &quot;compose/parallel.py&quot;, line 206, in producer
151  File &quot;compose/project.py&quot;, line 679, in do
152  File &quot;compose/service.py&quot;, line 579, in execute_convergence_plan
153  File &quot;compose/service.py&quot;, line 499, in _execute_convergence_recreate
154  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
155  File &quot;compose/parallel.py&quot;, line 206, in producer
156  File &quot;compose/service.py&quot;, line 494, in recreate
157  File &quot;compose/service.py&quot;, line 612, in recreate_container
158  File &quot;compose/service.py&quot;, line 330, in create_container
159  File &quot;compose/service.py&quot;, line 939, in _get_container_create_options
160  File &quot;compose/service.py&quot;, line 1014, in _get_container_host_config
161  File &quot;docker/api/container.py&quot;, line 598, in create_host_config
162  File &quot;docker/types/containers.py&quot;, line 338, in __init__
163docker.errors.InvalidArgument: &quot;host&quot; network_mode is incompatible with port_bindings
164[44262] Failed to execute script docker-compose
165  electrumx:
166    image: lukechilds/electrumx:latest
167    network_mode: host
168    links:
169      - node
170# Port settings see https://github.com/ulamlabs/bitcoind-custom-regtest
171#    ports:
172#      - &quot;51001:50001&quot;
173#      - &quot;51002:50002&quot;
174#      - &quot;19001:19001&quot;
175#      - &quot;19000:19000&quot;
176#      - &quot;28332:28332&quot;
177 % docker-compose up -d
178Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
179Creating minimal-crypto-exchange_geth_1 ...
180Creating minimal-crypto-exchange_postgres_1  ... done
181Creating minimal-crypto-exchange_node_1     ... done
182Creating minimal-crypto-exchange_electrumx_1 ... error
183Creating minimal-crypto-exchange_geth_1      ... done
184ERROR: for minimal-crypto-exchange_electrumx_1  Cannot create container for service electrumx: conflicting options: host type networking can't be used with links. This would result in undefined behavior
185Creating minimal-crypto-exchange_blockscout_1 ... done
186
187ERROR: for electrumx  Cannot create container for service electrumx: conflicting options: host type networking can't be used with links. This would result in undefined behavior
188ERROR: Encountered errors while bringing up the project.
189  node:
190    image: ulamlabs/bitcoind-custom-regtest:latest
191# For ports used by node see
192# https://github.com/ulamlabs/bitcoind-custom-regtest/blob/master/bitcoin.conf
193    ports:
194      - &quot;19001:19001&quot;
195      - &quot;19000:19000&quot;
196      - &quot;28332:28332&quot;
197  electrumx:
198    image: lukechilds/electrumx:latest
199    links:
200      - node
201# Port settings see https://github.com/ulamlabs/bitcoind-custom-regtest
202    ports:
203      - &quot;51001:50001&quot;
204      - &quot;51002:50002&quot;
205#      - &quot;19001:19001&quot;
206#      - &quot;19000:19000&quot;
207#      - &quot;28332:28332&quot;
20811:33:51.865 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [192.168.10.208]:19000: Peer died      (0 connected, 0 pending, 1 max)
20911:33:51.865 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - Not yet setting download peer because there is no clear candidate.
21011:33:51.865 [NioClientManager] DEBUG org.bitcoinj.core.BitcoinSerializer - Received 168 byte 'alert' message: 60010000000000000000000000ffffff7f00000000ffffff7ffeffff7f01ffffff7f00000000ffffff7f00ffffff7f002f555247454e543a20416c657274206b657920636f6d70726f6d697365642c2075706772616465207265717569726564004630440220653febd6410f470f6bae11cad19c48413becb1ac2c17f908fd0fd53bdc3abd5202206d0e9c96fe88d4a0f01ed9dedae2b6f9e00da94cad0fecaae66ecf689bf71b50
21111:33:51.866 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 999 ms before next connect attempt to [127.0.0.1]:19000
21211:33:51.866 [NioClientManager] DEBUG org.bitcoinj.core.Peer - Received alert from peer Peer{[192.168.10.208]:19000, version=70015, subVer=/Satoshi:0.19.1(bitcore)/, services=1033 (NETWORK, WITNESS, NETWORK_LIMITED), time=2021-11-06 11:33:52, height=5}: URGENT: Alert key compromised, upgrade required
21311:33:51.867 [NioClientManager] WARN  org.bitcoinj.net.ConnectionHandler - Error handling SelectionKey: java.nio.channels.CancelledKeyException 
214java.nio.channels.CancelledKeyException: null
215    at java.base/sun.nio.ch.SelectionKeyImpl.ensureValid(SelectionKeyImpl.java:71)
216    at java.base/sun.nio.ch.SelectionKeyImpl.readyOps(SelectionKeyImpl.java:130)
217    at java.base/java.nio.channels.SelectionKey.isWritable(SelectionKey.java:377)
218    at org.bitcoinj.net.ConnectionHandler.handleKey(ConnectionHandler.java:244)
219    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:86)
220    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
221    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
222    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
223    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
224    at java.base/java.lang.Thread.run(Thread.java:830)
225

Update 5:

Someone suggested (in a now removed comment) that in the output of the application there is this Peer does not support bloom filtering message:

1docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli getnewaddress
2import org.bitcoinj.core.Address;
3import org.bitcoinj.core.Coin;
4import org.bitcoinj.core.NetworkParameters;
5import org.bitcoinj.core.Transaction;
6import org.bitcoinj.wallet.Wallet;
7import org.bitcoinj.wallet.listeners.WalletCoinsReceivedEventListener;
8
9public class WalletObserver {
10    public void init() {
11        final NetworkParameters netParams = NetworkParameters.fromID(NetworkParameters.ID_REGTEST);
12
13        try {
14            final Wallet wallet = Wallet.createBasic(netParams);
15
16            wallet.addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
17
18            wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
19                @Override
20                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
21                    System.out.println(&quot;Heyo!&quot;);
22                }
23            });
24        }
25        catch (Exception exception) {
26            exception.printStackTrace();
27        }
28    }
29}
30% docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.5
31068c377bab961356ad9a3919229a764aa929711c68aefd5dbd4c7c348eef3406
32    ports:
33      - &quot;51001:50001&quot;
34      - &quot;51002:50002&quot;
35      - &quot;19001:19001&quot;
36      - &quot;19000:19000&quot;
37      - &quot;28332:28332&quot;
38public class WalletObserver {
39    public void init() {
40        final LocalTestNetParams netParams = new LocalTestNetParams();
41        netParams.setPort(50001);
42        try {
43            final WalletAppKit kit = new WalletAppKit(netParams, new File(&quot;.&quot;), &quot;_minimalCryptoExchangeBtcWallet&quot;);
44            kit.setAutoSave(true);
45            kit.connectToLocalHost();
46
47            kit.startAsync();
48            kit.awaitRunning(); // I never get past this point
49            kit.peerGroup().addPeerDiscovery(new DnsDiscovery(netParams));
50            kit.wallet().addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
51
52            kit.wallet().addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
53                @Override
54                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
55                    System.out.println(&quot;Heyo!&quot;);
56                }
57            });
58        }
59        catch (Exception exception) {
60            exception.printStackTrace();
61        }
62    }
63package com.dpisarenko.minimalcryptoexchange.logic.btc;
64
65import org.bitcoinj.params.RegTestParams;
66
67public class LocalTestNetParams extends RegTestParams {
68    public void setPort(final int newPort) {
69        this.port = newPort;
70    }
71}
7222:16:34.245 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
7322:16:34.265 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
74java.net.ConnectException: Connection refused
75    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
76    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
77    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
78    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
79    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
80    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
81    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
82    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
83    at java.base/java.lang.Thread.run(Thread.java:830)
8422:16:34.267 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
8522:16:34.267 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 21.84 μs and returned 0 items from 0 discoverers
8622:16:34.269 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 1502 ms before next connect attempt to [10.10.1.218]:50001
8722:16:35.776 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
8822:16:35.778 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
89java.net.ConnectException: Connection refused
90    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
91    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
92    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
93    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
94    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
95    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
96    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
97    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
98    at java.base/java.lang.Thread.run(Thread.java:830)
9922:16:35.778 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
10022:16:35.779 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 8.752 μs and returned 0 items from 0 discoverers
101    public WalletAppKit connectToLocalHost() {
102        try {
103            InetAddress localHost = InetAddress.getLocalHost();
104            return this.setPeerNodes(new PeerAddress(this.params, localHost, this.params.getPort()));
105        } catch (UnknownHostException var2) {
106            throw new RuntimeException(var2);
107        }
108    }
109
110  node:
111    image: ulamlabs/bitcoind-custom-regtest:latest
112    network_mode: &quot;host&quot;
113minimal-crypto-exchange % docker-compose up -d
114Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
115Creating minimal-crypto-exchange_postgres_1  ... done
116Creating minimal-crypto-exchange_geth_1     ...
117Creating minimal-crypto-exchange_node_1     ... done
118Creating minimal-crypto-exchange_electrumx_1 ...
119Creating minimal-crypto-exchange_electrumx_1 ... error
120
121ERROR: for minimal-crypto-exchange_electrumx_1  Cannot start service electrumx: driver fail
122Creating minimal-crypto-exchange_geth_1      ... done
123f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
124Creating minimal-crypto-exchange_blockscout_1 ... done
125
126ERROR: for electrumx  Cannot start service electrumx: driver failed programming external connectivity on endpoint minimal-crypto-exchange_electrumx_1 (8eaa4f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
127ERROR: Encountered errors while bringing up the project.
128  electrumx:
129    image: lukechilds/electrumx:latest
130    network_mode: &quot;host&quot;
131minimal-crypto-exchange % docker-compose up -d
132minimal-crypto-exchange_postgres_1 is up-to-date
133minimal-crypto-exchange_geth_1 is up-to-date
134Recreating minimal-crypto-exchange_node_1 ...
135Recreating minimal-crypto-exchange_node_1 ... done
136Recreating minimal-crypto-exchange_electrumx_1 ...
137
138ERROR: for minimal-crypto-exchange_electrumx_1  &quot;host&quot; network_mode is incompatible with port_bindings
139
140ERROR: for electrumx  &quot;host&quot; network_mode is incompatible with port_bindings
141Traceback (most recent call last):
142  File &quot;docker-compose&quot;, line 3, in &lt;module&gt;
143  File &quot;compose/cli/main.py&quot;, line 81, in main
144  File &quot;compose/cli/main.py&quot;, line 203, in perform_command
145  File &quot;compose/metrics/decorator.py&quot;, line 18, in wrapper
146  File &quot;compose/cli/main.py&quot;, line 1186, in up
147  File &quot;compose/cli/main.py&quot;, line 1166, in up
148  File &quot;compose/project.py&quot;, line 697, in up
149  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
150  File &quot;compose/parallel.py&quot;, line 206, in producer
151  File &quot;compose/project.py&quot;, line 679, in do
152  File &quot;compose/service.py&quot;, line 579, in execute_convergence_plan
153  File &quot;compose/service.py&quot;, line 499, in _execute_convergence_recreate
154  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
155  File &quot;compose/parallel.py&quot;, line 206, in producer
156  File &quot;compose/service.py&quot;, line 494, in recreate
157  File &quot;compose/service.py&quot;, line 612, in recreate_container
158  File &quot;compose/service.py&quot;, line 330, in create_container
159  File &quot;compose/service.py&quot;, line 939, in _get_container_create_options
160  File &quot;compose/service.py&quot;, line 1014, in _get_container_host_config
161  File &quot;docker/api/container.py&quot;, line 598, in create_host_config
162  File &quot;docker/types/containers.py&quot;, line 338, in __init__
163docker.errors.InvalidArgument: &quot;host&quot; network_mode is incompatible with port_bindings
164[44262] Failed to execute script docker-compose
165  electrumx:
166    image: lukechilds/electrumx:latest
167    network_mode: host
168    links:
169      - node
170# Port settings see https://github.com/ulamlabs/bitcoind-custom-regtest
171#    ports:
172#      - &quot;51001:50001&quot;
173#      - &quot;51002:50002&quot;
174#      - &quot;19001:19001&quot;
175#      - &quot;19000:19000&quot;
176#      - &quot;28332:28332&quot;
177 % docker-compose up -d
178Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
179Creating minimal-crypto-exchange_geth_1 ...
180Creating minimal-crypto-exchange_postgres_1  ... done
181Creating minimal-crypto-exchange_node_1     ... done
182Creating minimal-crypto-exchange_electrumx_1 ... error
183Creating minimal-crypto-exchange_geth_1      ... done
184ERROR: for minimal-crypto-exchange_electrumx_1  Cannot create container for service electrumx: conflicting options: host type networking can't be used with links. This would result in undefined behavior
185Creating minimal-crypto-exchange_blockscout_1 ... done
186
187ERROR: for electrumx  Cannot create container for service electrumx: conflicting options: host type networking can't be used with links. This would result in undefined behavior
188ERROR: Encountered errors while bringing up the project.
189  node:
190    image: ulamlabs/bitcoind-custom-regtest:latest
191# For ports used by node see
192# https://github.com/ulamlabs/bitcoind-custom-regtest/blob/master/bitcoin.conf
193    ports:
194      - &quot;19001:19001&quot;
195      - &quot;19000:19000&quot;
196      - &quot;28332:28332&quot;
197  electrumx:
198    image: lukechilds/electrumx:latest
199    links:
200      - node
201# Port settings see https://github.com/ulamlabs/bitcoind-custom-regtest
202    ports:
203      - &quot;51001:50001&quot;
204      - &quot;51002:50002&quot;
205#      - &quot;19001:19001&quot;
206#      - &quot;19000:19000&quot;
207#      - &quot;28332:28332&quot;
20811:33:51.865 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [192.168.10.208]:19000: Peer died      (0 connected, 0 pending, 1 max)
20911:33:51.865 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - Not yet setting download peer because there is no clear candidate.
21011:33:51.865 [NioClientManager] DEBUG org.bitcoinj.core.BitcoinSerializer - Received 168 byte 'alert' message: 60010000000000000000000000ffffff7f00000000ffffff7ffeffff7f01ffffff7f00000000ffffff7f00ffffff7f002f555247454e543a20416c657274206b657920636f6d70726f6d697365642c2075706772616465207265717569726564004630440220653febd6410f470f6bae11cad19c48413becb1ac2c17f908fd0fd53bdc3abd5202206d0e9c96fe88d4a0f01ed9dedae2b6f9e00da94cad0fecaae66ecf689bf71b50
21111:33:51.866 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 999 ms before next connect attempt to [127.0.0.1]:19000
21211:33:51.866 [NioClientManager] DEBUG org.bitcoinj.core.Peer - Received alert from peer Peer{[192.168.10.208]:19000, version=70015, subVer=/Satoshi:0.19.1(bitcore)/, services=1033 (NETWORK, WITNESS, NETWORK_LIMITED), time=2021-11-06 11:33:52, height=5}: URGENT: Alert key compromised, upgrade required
21311:33:51.867 [NioClientManager] WARN  org.bitcoinj.net.ConnectionHandler - Error handling SelectionKey: java.nio.channels.CancelledKeyException 
214java.nio.channels.CancelledKeyException: null
215    at java.base/sun.nio.ch.SelectionKeyImpl.ensureValid(SelectionKeyImpl.java:71)
216    at java.base/sun.nio.ch.SelectionKeyImpl.readyOps(SelectionKeyImpl.java:130)
217    at java.base/java.nio.channels.SelectionKey.isWritable(SelectionKey.java:377)
218    at org.bitcoinj.net.ConnectionHandler.handleKey(ConnectionHandler.java:244)
219    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:86)
220    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
221    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
222    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
223    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
224    at java.base/java.lang.Thread.run(Thread.java:830)
22511:32:43.482 [NioClientManager] INFO  org.bitcoinj.core.Peer - Peer{[127.0.0.1]:19000, version=70015, subVer=/Satoshi:0.19.1(bitcore)/, services=1033 (NETWORK, WITNESS, NETWORK_LIMITED), time=2021-11-06 11:32:43, height=4}: Peer does not support bloom filtering.
226

So I tried to fork the original image and change the bitcoin.conf file to enable Bloom filtering:

1docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli getnewaddress
2import org.bitcoinj.core.Address;
3import org.bitcoinj.core.Coin;
4import org.bitcoinj.core.NetworkParameters;
5import org.bitcoinj.core.Transaction;
6import org.bitcoinj.wallet.Wallet;
7import org.bitcoinj.wallet.listeners.WalletCoinsReceivedEventListener;
8
9public class WalletObserver {
10    public void init() {
11        final NetworkParameters netParams = NetworkParameters.fromID(NetworkParameters.ID_REGTEST);
12
13        try {
14            final Wallet wallet = Wallet.createBasic(netParams);
15
16            wallet.addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
17
18            wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
19                @Override
20                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
21                    System.out.println(&quot;Heyo!&quot;);
22                }
23            });
24        }
25        catch (Exception exception) {
26            exception.printStackTrace();
27        }
28    }
29}
30% docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.5
31068c377bab961356ad9a3919229a764aa929711c68aefd5dbd4c7c348eef3406
32    ports:
33      - &quot;51001:50001&quot;
34      - &quot;51002:50002&quot;
35      - &quot;19001:19001&quot;
36      - &quot;19000:19000&quot;
37      - &quot;28332:28332&quot;
38public class WalletObserver {
39    public void init() {
40        final LocalTestNetParams netParams = new LocalTestNetParams();
41        netParams.setPort(50001);
42        try {
43            final WalletAppKit kit = new WalletAppKit(netParams, new File(&quot;.&quot;), &quot;_minimalCryptoExchangeBtcWallet&quot;);
44            kit.setAutoSave(true);
45            kit.connectToLocalHost();
46
47            kit.startAsync();
48            kit.awaitRunning(); // I never get past this point
49            kit.peerGroup().addPeerDiscovery(new DnsDiscovery(netParams));
50            kit.wallet().addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
51
52            kit.wallet().addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
53                @Override
54                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
55                    System.out.println(&quot;Heyo!&quot;);
56                }
57            });
58        }
59        catch (Exception exception) {
60            exception.printStackTrace();
61        }
62    }
63package com.dpisarenko.minimalcryptoexchange.logic.btc;
64
65import org.bitcoinj.params.RegTestParams;
66
67public class LocalTestNetParams extends RegTestParams {
68    public void setPort(final int newPort) {
69        this.port = newPort;
70    }
71}
7222:16:34.245 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
7322:16:34.265 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
74java.net.ConnectException: Connection refused
75    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
76    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
77    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
78    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
79    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
80    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
81    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
82    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
83    at java.base/java.lang.Thread.run(Thread.java:830)
8422:16:34.267 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
8522:16:34.267 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 21.84 μs and returned 0 items from 0 discoverers
8622:16:34.269 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 1502 ms before next connect attempt to [10.10.1.218]:50001
8722:16:35.776 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
8822:16:35.778 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
89java.net.ConnectException: Connection refused
90    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
91    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
92    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
93    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
94    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
95    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
96    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
97    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
98    at java.base/java.lang.Thread.run(Thread.java:830)
9922:16:35.778 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
10022:16:35.779 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 8.752 μs and returned 0 items from 0 discoverers
101    public WalletAppKit connectToLocalHost() {
102        try {
103            InetAddress localHost = InetAddress.getLocalHost();
104            return this.setPeerNodes(new PeerAddress(this.params, localHost, this.params.getPort()));
105        } catch (UnknownHostException var2) {
106            throw new RuntimeException(var2);
107        }
108    }
109
110  node:
111    image: ulamlabs/bitcoind-custom-regtest:latest
112    network_mode: &quot;host&quot;
113minimal-crypto-exchange % docker-compose up -d
114Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
115Creating minimal-crypto-exchange_postgres_1  ... done
116Creating minimal-crypto-exchange_geth_1     ...
117Creating minimal-crypto-exchange_node_1     ... done
118Creating minimal-crypto-exchange_electrumx_1 ...
119Creating minimal-crypto-exchange_electrumx_1 ... error
120
121ERROR: for minimal-crypto-exchange_electrumx_1  Cannot start service electrumx: driver fail
122Creating minimal-crypto-exchange_geth_1      ... done
123f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
124Creating minimal-crypto-exchange_blockscout_1 ... done
125
126ERROR: for electrumx  Cannot start service electrumx: driver failed programming external connectivity on endpoint minimal-crypto-exchange_electrumx_1 (8eaa4f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
127ERROR: Encountered errors while bringing up the project.
128  electrumx:
129    image: lukechilds/electrumx:latest
130    network_mode: &quot;host&quot;
131minimal-crypto-exchange % docker-compose up -d
132minimal-crypto-exchange_postgres_1 is up-to-date
133minimal-crypto-exchange_geth_1 is up-to-date
134Recreating minimal-crypto-exchange_node_1 ...
135Recreating minimal-crypto-exchange_node_1 ... done
136Recreating minimal-crypto-exchange_electrumx_1 ...
137
138ERROR: for minimal-crypto-exchange_electrumx_1  &quot;host&quot; network_mode is incompatible with port_bindings
139
140ERROR: for electrumx  &quot;host&quot; network_mode is incompatible with port_bindings
141Traceback (most recent call last):
142  File &quot;docker-compose&quot;, line 3, in &lt;module&gt;
143  File &quot;compose/cli/main.py&quot;, line 81, in main
144  File &quot;compose/cli/main.py&quot;, line 203, in perform_command
145  File &quot;compose/metrics/decorator.py&quot;, line 18, in wrapper
146  File &quot;compose/cli/main.py&quot;, line 1186, in up
147  File &quot;compose/cli/main.py&quot;, line 1166, in up
148  File &quot;compose/project.py&quot;, line 697, in up
149  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
150  File &quot;compose/parallel.py&quot;, line 206, in producer
151  File &quot;compose/project.py&quot;, line 679, in do
152  File &quot;compose/service.py&quot;, line 579, in execute_convergence_plan
153  File &quot;compose/service.py&quot;, line 499, in _execute_convergence_recreate
154  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
155  File &quot;compose/parallel.py&quot;, line 206, in producer
156  File &quot;compose/service.py&quot;, line 494, in recreate
157  File &quot;compose/service.py&quot;, line 612, in recreate_container
158  File &quot;compose/service.py&quot;, line 330, in create_container
159  File &quot;compose/service.py&quot;, line 939, in _get_container_create_options
160  File &quot;compose/service.py&quot;, line 1014, in _get_container_host_config
161  File &quot;docker/api/container.py&quot;, line 598, in create_host_config
162  File &quot;docker/types/containers.py&quot;, line 338, in __init__
163docker.errors.InvalidArgument: &quot;host&quot; network_mode is incompatible with port_bindings
164[44262] Failed to execute script docker-compose
165  electrumx:
166    image: lukechilds/electrumx:latest
167    network_mode: host
168    links:
169      - node
170# Port settings see https://github.com/ulamlabs/bitcoind-custom-regtest
171#    ports:
172#      - &quot;51001:50001&quot;
173#      - &quot;51002:50002&quot;
174#      - &quot;19001:19001&quot;
175#      - &quot;19000:19000&quot;
176#      - &quot;28332:28332&quot;
177 % docker-compose up -d
178Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
179Creating minimal-crypto-exchange_geth_1 ...
180Creating minimal-crypto-exchange_postgres_1  ... done
181Creating minimal-crypto-exchange_node_1     ... done
182Creating minimal-crypto-exchange_electrumx_1 ... error
183Creating minimal-crypto-exchange_geth_1      ... done
184ERROR: for minimal-crypto-exchange_electrumx_1  Cannot create container for service electrumx: conflicting options: host type networking can't be used with links. This would result in undefined behavior
185Creating minimal-crypto-exchange_blockscout_1 ... done
186
187ERROR: for electrumx  Cannot create container for service electrumx: conflicting options: host type networking can't be used with links. This would result in undefined behavior
188ERROR: Encountered errors while bringing up the project.
189  node:
190    image: ulamlabs/bitcoind-custom-regtest:latest
191# For ports used by node see
192# https://github.com/ulamlabs/bitcoind-custom-regtest/blob/master/bitcoin.conf
193    ports:
194      - &quot;19001:19001&quot;
195      - &quot;19000:19000&quot;
196      - &quot;28332:28332&quot;
197  electrumx:
198    image: lukechilds/electrumx:latest
199    links:
200      - node
201# Port settings see https://github.com/ulamlabs/bitcoind-custom-regtest
202    ports:
203      - &quot;51001:50001&quot;
204      - &quot;51002:50002&quot;
205#      - &quot;19001:19001&quot;
206#      - &quot;19000:19000&quot;
207#      - &quot;28332:28332&quot;
20811:33:51.865 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [192.168.10.208]:19000: Peer died      (0 connected, 0 pending, 1 max)
20911:33:51.865 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - Not yet setting download peer because there is no clear candidate.
21011:33:51.865 [NioClientManager] DEBUG org.bitcoinj.core.BitcoinSerializer - Received 168 byte 'alert' message: 60010000000000000000000000ffffff7f00000000ffffff7ffeffff7f01ffffff7f00000000ffffff7f00ffffff7f002f555247454e543a20416c657274206b657920636f6d70726f6d697365642c2075706772616465207265717569726564004630440220653febd6410f470f6bae11cad19c48413becb1ac2c17f908fd0fd53bdc3abd5202206d0e9c96fe88d4a0f01ed9dedae2b6f9e00da94cad0fecaae66ecf689bf71b50
21111:33:51.866 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 999 ms before next connect attempt to [127.0.0.1]:19000
21211:33:51.866 [NioClientManager] DEBUG org.bitcoinj.core.Peer - Received alert from peer Peer{[192.168.10.208]:19000, version=70015, subVer=/Satoshi:0.19.1(bitcore)/, services=1033 (NETWORK, WITNESS, NETWORK_LIMITED), time=2021-11-06 11:33:52, height=5}: URGENT: Alert key compromised, upgrade required
21311:33:51.867 [NioClientManager] WARN  org.bitcoinj.net.ConnectionHandler - Error handling SelectionKey: java.nio.channels.CancelledKeyException 
214java.nio.channels.CancelledKeyException: null
215    at java.base/sun.nio.ch.SelectionKeyImpl.ensureValid(SelectionKeyImpl.java:71)
216    at java.base/sun.nio.ch.SelectionKeyImpl.readyOps(SelectionKeyImpl.java:130)
217    at java.base/java.nio.channels.SelectionKey.isWritable(SelectionKey.java:377)
218    at org.bitcoinj.net.ConnectionHandler.handleKey(ConnectionHandler.java:244)
219    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:86)
220    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
221    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
222    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
223    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
224    at java.base/java.lang.Thread.run(Thread.java:830)
22511:32:43.482 [NioClientManager] INFO  org.bitcoinj.core.Peer - Peer{[127.0.0.1]:19000, version=70015, subVer=/Satoshi:0.19.1(bitcore)/, services=1033 (NETWORK, WITNESS, NETWORK_LIMITED), time=2021-11-06 11:32:43, height=4}: Peer does not support bloom filtering.
226peerbloomfilters=1
227

When I run docker build -t mentiflectax/bitcoind-custom-regtest:latest . I get the following error message (part of remaining output can be found here):

1docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli getnewaddress
2import org.bitcoinj.core.Address;
3import org.bitcoinj.core.Coin;
4import org.bitcoinj.core.NetworkParameters;
5import org.bitcoinj.core.Transaction;
6import org.bitcoinj.wallet.Wallet;
7import org.bitcoinj.wallet.listeners.WalletCoinsReceivedEventListener;
8
9public class WalletObserver {
10    public void init() {
11        final NetworkParameters netParams = NetworkParameters.fromID(NetworkParameters.ID_REGTEST);
12
13        try {
14            final Wallet wallet = Wallet.createBasic(netParams);
15
16            wallet.addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
17
18            wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
19                @Override
20                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
21                    System.out.println(&quot;Heyo!&quot;);
22                }
23            });
24        }
25        catch (Exception exception) {
26            exception.printStackTrace();
27        }
28    }
29}
30% docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.5
31068c377bab961356ad9a3919229a764aa929711c68aefd5dbd4c7c348eef3406
32    ports:
33      - &quot;51001:50001&quot;
34      - &quot;51002:50002&quot;
35      - &quot;19001:19001&quot;
36      - &quot;19000:19000&quot;
37      - &quot;28332:28332&quot;
38public class WalletObserver {
39    public void init() {
40        final LocalTestNetParams netParams = new LocalTestNetParams();
41        netParams.setPort(50001);
42        try {
43            final WalletAppKit kit = new WalletAppKit(netParams, new File(&quot;.&quot;), &quot;_minimalCryptoExchangeBtcWallet&quot;);
44            kit.setAutoSave(true);
45            kit.connectToLocalHost();
46
47            kit.startAsync();
48            kit.awaitRunning(); // I never get past this point
49            kit.peerGroup().addPeerDiscovery(new DnsDiscovery(netParams));
50            kit.wallet().addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
51
52            kit.wallet().addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
53                @Override
54                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
55                    System.out.println(&quot;Heyo!&quot;);
56                }
57            });
58        }
59        catch (Exception exception) {
60            exception.printStackTrace();
61        }
62    }
63package com.dpisarenko.minimalcryptoexchange.logic.btc;
64
65import org.bitcoinj.params.RegTestParams;
66
67public class LocalTestNetParams extends RegTestParams {
68    public void setPort(final int newPort) {
69        this.port = newPort;
70    }
71}
7222:16:34.245 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
7322:16:34.265 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
74java.net.ConnectException: Connection refused
75    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
76    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
77    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
78    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
79    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
80    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
81    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
82    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
83    at java.base/java.lang.Thread.run(Thread.java:830)
8422:16:34.267 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
8522:16:34.267 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 21.84 μs and returned 0 items from 0 discoverers
8622:16:34.269 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 1502 ms before next connect attempt to [10.10.1.218]:50001
8722:16:35.776 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
8822:16:35.778 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
89java.net.ConnectException: Connection refused
90    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
91    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
92    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
93    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
94    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
95    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
96    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
97    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
98    at java.base/java.lang.Thread.run(Thread.java:830)
9922:16:35.778 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
10022:16:35.779 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 8.752 μs and returned 0 items from 0 discoverers
101    public WalletAppKit connectToLocalHost() {
102        try {
103            InetAddress localHost = InetAddress.getLocalHost();
104            return this.setPeerNodes(new PeerAddress(this.params, localHost, this.params.getPort()));
105        } catch (UnknownHostException var2) {
106            throw new RuntimeException(var2);
107        }
108    }
109
110  node:
111    image: ulamlabs/bitcoind-custom-regtest:latest
112    network_mode: &quot;host&quot;
113minimal-crypto-exchange % docker-compose up -d
114Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
115Creating minimal-crypto-exchange_postgres_1  ... done
116Creating minimal-crypto-exchange_geth_1     ...
117Creating minimal-crypto-exchange_node_1     ... done
118Creating minimal-crypto-exchange_electrumx_1 ...
119Creating minimal-crypto-exchange_electrumx_1 ... error
120
121ERROR: for minimal-crypto-exchange_electrumx_1  Cannot start service electrumx: driver fail
122Creating minimal-crypto-exchange_geth_1      ... done
123f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
124Creating minimal-crypto-exchange_blockscout_1 ... done
125
126ERROR: for electrumx  Cannot start service electrumx: driver failed programming external connectivity on endpoint minimal-crypto-exchange_electrumx_1 (8eaa4f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
127ERROR: Encountered errors while bringing up the project.
128  electrumx:
129    image: lukechilds/electrumx:latest
130    network_mode: &quot;host&quot;
131minimal-crypto-exchange % docker-compose up -d
132minimal-crypto-exchange_postgres_1 is up-to-date
133minimal-crypto-exchange_geth_1 is up-to-date
134Recreating minimal-crypto-exchange_node_1 ...
135Recreating minimal-crypto-exchange_node_1 ... done
136Recreating minimal-crypto-exchange_electrumx_1 ...
137
138ERROR: for minimal-crypto-exchange_electrumx_1  &quot;host&quot; network_mode is incompatible with port_bindings
139
140ERROR: for electrumx  &quot;host&quot; network_mode is incompatible with port_bindings
141Traceback (most recent call last):
142  File &quot;docker-compose&quot;, line 3, in &lt;module&gt;
143  File &quot;compose/cli/main.py&quot;, line 81, in main
144  File &quot;compose/cli/main.py&quot;, line 203, in perform_command
145  File &quot;compose/metrics/decorator.py&quot;, line 18, in wrapper
146  File &quot;compose/cli/main.py&quot;, line 1186, in up
147  File &quot;compose/cli/main.py&quot;, line 1166, in up
148  File &quot;compose/project.py&quot;, line 697, in up
149  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
150  File &quot;compose/parallel.py&quot;, line 206, in producer
151  File &quot;compose/project.py&quot;, line 679, in do
152  File &quot;compose/service.py&quot;, line 579, in execute_convergence_plan
153  File &quot;compose/service.py&quot;, line 499, in _execute_convergence_recreate
154  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
155  File &quot;compose/parallel.py&quot;, line 206, in producer
156  File &quot;compose/service.py&quot;, line 494, in recreate
157  File &quot;compose/service.py&quot;, line 612, in recreate_container
158  File &quot;compose/service.py&quot;, line 330, in create_container
159  File &quot;compose/service.py&quot;, line 939, in _get_container_create_options
160  File &quot;compose/service.py&quot;, line 1014, in _get_container_host_config
161  File &quot;docker/api/container.py&quot;, line 598, in create_host_config
162  File &quot;docker/types/containers.py&quot;, line 338, in __init__
163docker.errors.InvalidArgument: &quot;host&quot; network_mode is incompatible with port_bindings
164[44262] Failed to execute script docker-compose
165  electrumx:
166    image: lukechilds/electrumx:latest
167    network_mode: host
168    links:
169      - node
170# Port settings see https://github.com/ulamlabs/bitcoind-custom-regtest
171#    ports:
172#      - &quot;51001:50001&quot;
173#      - &quot;51002:50002&quot;
174#      - &quot;19001:19001&quot;
175#      - &quot;19000:19000&quot;
176#      - &quot;28332:28332&quot;
177 % docker-compose up -d
178Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
179Creating minimal-crypto-exchange_geth_1 ...
180Creating minimal-crypto-exchange_postgres_1  ... done
181Creating minimal-crypto-exchange_node_1     ... done
182Creating minimal-crypto-exchange_electrumx_1 ... error
183Creating minimal-crypto-exchange_geth_1      ... done
184ERROR: for minimal-crypto-exchange_electrumx_1  Cannot create container for service electrumx: conflicting options: host type networking can't be used with links. This would result in undefined behavior
185Creating minimal-crypto-exchange_blockscout_1 ... done
186
187ERROR: for electrumx  Cannot create container for service electrumx: conflicting options: host type networking can't be used with links. This would result in undefined behavior
188ERROR: Encountered errors while bringing up the project.
189  node:
190    image: ulamlabs/bitcoind-custom-regtest:latest
191# For ports used by node see
192# https://github.com/ulamlabs/bitcoind-custom-regtest/blob/master/bitcoin.conf
193    ports:
194      - &quot;19001:19001&quot;
195      - &quot;19000:19000&quot;
196      - &quot;28332:28332&quot;
197  electrumx:
198    image: lukechilds/electrumx:latest
199    links:
200      - node
201# Port settings see https://github.com/ulamlabs/bitcoind-custom-regtest
202    ports:
203      - &quot;51001:50001&quot;
204      - &quot;51002:50002&quot;
205#      - &quot;19001:19001&quot;
206#      - &quot;19000:19000&quot;
207#      - &quot;28332:28332&quot;
20811:33:51.865 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [192.168.10.208]:19000: Peer died      (0 connected, 0 pending, 1 max)
20911:33:51.865 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - Not yet setting download peer because there is no clear candidate.
21011:33:51.865 [NioClientManager] DEBUG org.bitcoinj.core.BitcoinSerializer - Received 168 byte 'alert' message: 60010000000000000000000000ffffff7f00000000ffffff7ffeffff7f01ffffff7f00000000ffffff7f00ffffff7f002f555247454e543a20416c657274206b657920636f6d70726f6d697365642c2075706772616465207265717569726564004630440220653febd6410f470f6bae11cad19c48413becb1ac2c17f908fd0fd53bdc3abd5202206d0e9c96fe88d4a0f01ed9dedae2b6f9e00da94cad0fecaae66ecf689bf71b50
21111:33:51.866 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 999 ms before next connect attempt to [127.0.0.1]:19000
21211:33:51.866 [NioClientManager] DEBUG org.bitcoinj.core.Peer - Received alert from peer Peer{[192.168.10.208]:19000, version=70015, subVer=/Satoshi:0.19.1(bitcore)/, services=1033 (NETWORK, WITNESS, NETWORK_LIMITED), time=2021-11-06 11:33:52, height=5}: URGENT: Alert key compromised, upgrade required
21311:33:51.867 [NioClientManager] WARN  org.bitcoinj.net.ConnectionHandler - Error handling SelectionKey: java.nio.channels.CancelledKeyException 
214java.nio.channels.CancelledKeyException: null
215    at java.base/sun.nio.ch.SelectionKeyImpl.ensureValid(SelectionKeyImpl.java:71)
216    at java.base/sun.nio.ch.SelectionKeyImpl.readyOps(SelectionKeyImpl.java:130)
217    at java.base/java.nio.channels.SelectionKey.isWritable(SelectionKey.java:377)
218    at org.bitcoinj.net.ConnectionHandler.handleKey(ConnectionHandler.java:244)
219    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:86)
220    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
221    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
222    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
223    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
224    at java.base/java.lang.Thread.run(Thread.java:830)
22511:32:43.482 [NioClientManager] INFO  org.bitcoinj.core.Peer - Peer{[127.0.0.1]:19000, version=70015, subVer=/Satoshi:0.19.1(bitcore)/, services=1033 (NETWORK, WITNESS, NETWORK_LIMITED), time=2021-11-06 11:32:43, height=4}: Peer does not support bloom filtering.
226peerbloomfilters=1
227#13 922.4 g++: fatal error: Killed signal terminated program cc1plus
228#13 922.4 compilation terminated.
229#13 922.4 make[2]: *** [Makefile:8044: libbitcoin_server_a-init.o] Error 1
230#13 922.4 make[2]: *** Waiting for unfinished jobs....
231#13 965.8 make[2]: Leaving directory '/bitcoin-0.19.1/src'
232#13 965.8 make[1]: *** [Makefile:13765: all-recursive] Error 1
233#13 965.9 make[1]: Leaving directory '/bitcoin-0.19.1/src'
234#13 965.9 make: *** [Makefile:776: all-recursive] Error 1
235------
236executor failed running [/bin/sh -c tar -xzf *.tar.gz     &amp;&amp; cd bitcoin-${BITCOIN_VERSION}     &amp;&amp; sed -i 's/consensus.nSubsidyHalvingInterval = 150/consensus.nSubsidyHalvingInterval = 210000/g' src/chainparams.cpp     &amp;&amp; ./autogen.sh     &amp;&amp; ./configure LDFLAGS=-L`ls -d /opt/db`/lib/ CPPFLAGS=-I`ls -d /opt/db`/include/     --prefix=/opt/bitcoin     --disable-man     --disable-tests     --disable-bench     --disable-ccache     --with-gui=no     --enable-util-cli     --with-daemon     &amp;&amp; make -j4     &amp;&amp; make install     &amp;&amp; strip /opt/bitcoin/bin/bitcoin-cli     &amp;&amp; strip /opt/bitcoin/bin/bitcoind]: exit code: 2
237

Update 6: The correct port seems to be 19000.

If I use port 19001, I get following errors after kit.awaitRunning():

1docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli getnewaddress
2import org.bitcoinj.core.Address;
3import org.bitcoinj.core.Coin;
4import org.bitcoinj.core.NetworkParameters;
5import org.bitcoinj.core.Transaction;
6import org.bitcoinj.wallet.Wallet;
7import org.bitcoinj.wallet.listeners.WalletCoinsReceivedEventListener;
8
9public class WalletObserver {
10    public void init() {
11        final NetworkParameters netParams = NetworkParameters.fromID(NetworkParameters.ID_REGTEST);
12
13        try {
14            final Wallet wallet = Wallet.createBasic(netParams);
15
16            wallet.addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
17
18            wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
19                @Override
20                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
21                    System.out.println(&quot;Heyo!&quot;);
22                }
23            });
24        }
25        catch (Exception exception) {
26            exception.printStackTrace();
27        }
28    }
29}
30% docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.5
31068c377bab961356ad9a3919229a764aa929711c68aefd5dbd4c7c348eef3406
32    ports:
33      - &quot;51001:50001&quot;
34      - &quot;51002:50002&quot;
35      - &quot;19001:19001&quot;
36      - &quot;19000:19000&quot;
37      - &quot;28332:28332&quot;
38public class WalletObserver {
39    public void init() {
40        final LocalTestNetParams netParams = new LocalTestNetParams();
41        netParams.setPort(50001);
42        try {
43            final WalletAppKit kit = new WalletAppKit(netParams, new File(&quot;.&quot;), &quot;_minimalCryptoExchangeBtcWallet&quot;);
44            kit.setAutoSave(true);
45            kit.connectToLocalHost();
46
47            kit.startAsync();
48            kit.awaitRunning(); // I never get past this point
49            kit.peerGroup().addPeerDiscovery(new DnsDiscovery(netParams));
50            kit.wallet().addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
51
52            kit.wallet().addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
53                @Override
54                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
55                    System.out.println(&quot;Heyo!&quot;);
56                }
57            });
58        }
59        catch (Exception exception) {
60            exception.printStackTrace();
61        }
62    }
63package com.dpisarenko.minimalcryptoexchange.logic.btc;
64
65import org.bitcoinj.params.RegTestParams;
66
67public class LocalTestNetParams extends RegTestParams {
68    public void setPort(final int newPort) {
69        this.port = newPort;
70    }
71}
7222:16:34.245 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
7322:16:34.265 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
74java.net.ConnectException: Connection refused
75    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
76    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
77    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
78    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
79    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
80    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
81    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
82    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
83    at java.base/java.lang.Thread.run(Thread.java:830)
8422:16:34.267 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
8522:16:34.267 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 21.84 μs and returned 0 items from 0 discoverers
8622:16:34.269 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 1502 ms before next connect attempt to [10.10.1.218]:50001
8722:16:35.776 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
8822:16:35.778 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
89java.net.ConnectException: Connection refused
90    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
91    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
92    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
93    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
94    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
95    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
96    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
97    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
98    at java.base/java.lang.Thread.run(Thread.java:830)
9922:16:35.778 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
10022:16:35.779 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 8.752 μs and returned 0 items from 0 discoverers
101    public WalletAppKit connectToLocalHost() {
102        try {
103            InetAddress localHost = InetAddress.getLocalHost();
104            return this.setPeerNodes(new PeerAddress(this.params, localHost, this.params.getPort()));
105        } catch (UnknownHostException var2) {
106            throw new RuntimeException(var2);
107        }
108    }
109
110  node:
111    image: ulamlabs/bitcoind-custom-regtest:latest
112    network_mode: &quot;host&quot;
113minimal-crypto-exchange % docker-compose up -d
114Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
115Creating minimal-crypto-exchange_postgres_1  ... done
116Creating minimal-crypto-exchange_geth_1     ...
117Creating minimal-crypto-exchange_node_1     ... done
118Creating minimal-crypto-exchange_electrumx_1 ...
119Creating minimal-crypto-exchange_electrumx_1 ... error
120
121ERROR: for minimal-crypto-exchange_electrumx_1  Cannot start service electrumx: driver fail
122Creating minimal-crypto-exchange_geth_1      ... done
123f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
124Creating minimal-crypto-exchange_blockscout_1 ... done
125
126ERROR: for electrumx  Cannot start service electrumx: driver failed programming external connectivity on endpoint minimal-crypto-exchange_electrumx_1 (8eaa4f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
127ERROR: Encountered errors while bringing up the project.
128  electrumx:
129    image: lukechilds/electrumx:latest
130    network_mode: &quot;host&quot;
131minimal-crypto-exchange % docker-compose up -d
132minimal-crypto-exchange_postgres_1 is up-to-date
133minimal-crypto-exchange_geth_1 is up-to-date
134Recreating minimal-crypto-exchange_node_1 ...
135Recreating minimal-crypto-exchange_node_1 ... done
136Recreating minimal-crypto-exchange_electrumx_1 ...
137
138ERROR: for minimal-crypto-exchange_electrumx_1  &quot;host&quot; network_mode is incompatible with port_bindings
139
140ERROR: for electrumx  &quot;host&quot; network_mode is incompatible with port_bindings
141Traceback (most recent call last):
142  File &quot;docker-compose&quot;, line 3, in &lt;module&gt;
143  File &quot;compose/cli/main.py&quot;, line 81, in main
144  File &quot;compose/cli/main.py&quot;, line 203, in perform_command
145  File &quot;compose/metrics/decorator.py&quot;, line 18, in wrapper
146  File &quot;compose/cli/main.py&quot;, line 1186, in up
147  File &quot;compose/cli/main.py&quot;, line 1166, in up
148  File &quot;compose/project.py&quot;, line 697, in up
149  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
150  File &quot;compose/parallel.py&quot;, line 206, in producer
151  File &quot;compose/project.py&quot;, line 679, in do
152  File &quot;compose/service.py&quot;, line 579, in execute_convergence_plan
153  File &quot;compose/service.py&quot;, line 499, in _execute_convergence_recreate
154  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
155  File &quot;compose/parallel.py&quot;, line 206, in producer
156  File &quot;compose/service.py&quot;, line 494, in recreate
157  File &quot;compose/service.py&quot;, line 612, in recreate_container
158  File &quot;compose/service.py&quot;, line 330, in create_container
159  File &quot;compose/service.py&quot;, line 939, in _get_container_create_options
160  File &quot;compose/service.py&quot;, line 1014, in _get_container_host_config
161  File &quot;docker/api/container.py&quot;, line 598, in create_host_config
162  File &quot;docker/types/containers.py&quot;, line 338, in __init__
163docker.errors.InvalidArgument: &quot;host&quot; network_mode is incompatible with port_bindings
164[44262] Failed to execute script docker-compose
165  electrumx:
166    image: lukechilds/electrumx:latest
167    network_mode: host
168    links:
169      - node
170# Port settings see https://github.com/ulamlabs/bitcoind-custom-regtest
171#    ports:
172#      - &quot;51001:50001&quot;
173#      - &quot;51002:50002&quot;
174#      - &quot;19001:19001&quot;
175#      - &quot;19000:19000&quot;
176#      - &quot;28332:28332&quot;
177 % docker-compose up -d
178Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
179Creating minimal-crypto-exchange_geth_1 ...
180Creating minimal-crypto-exchange_postgres_1  ... done
181Creating minimal-crypto-exchange_node_1     ... done
182Creating minimal-crypto-exchange_electrumx_1 ... error
183Creating minimal-crypto-exchange_geth_1      ... done
184ERROR: for minimal-crypto-exchange_electrumx_1  Cannot create container for service electrumx: conflicting options: host type networking can't be used with links. This would result in undefined behavior
185Creating minimal-crypto-exchange_blockscout_1 ... done
186
187ERROR: for electrumx  Cannot create container for service electrumx: conflicting options: host type networking can't be used with links. This would result in undefined behavior
188ERROR: Encountered errors while bringing up the project.
189  node:
190    image: ulamlabs/bitcoind-custom-regtest:latest
191# For ports used by node see
192# https://github.com/ulamlabs/bitcoind-custom-regtest/blob/master/bitcoin.conf
193    ports:
194      - &quot;19001:19001&quot;
195      - &quot;19000:19000&quot;
196      - &quot;28332:28332&quot;
197  electrumx:
198    image: lukechilds/electrumx:latest
199    links:
200      - node
201# Port settings see https://github.com/ulamlabs/bitcoind-custom-regtest
202    ports:
203      - &quot;51001:50001&quot;
204      - &quot;51002:50002&quot;
205#      - &quot;19001:19001&quot;
206#      - &quot;19000:19000&quot;
207#      - &quot;28332:28332&quot;
20811:33:51.865 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [192.168.10.208]:19000: Peer died      (0 connected, 0 pending, 1 max)
20911:33:51.865 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - Not yet setting download peer because there is no clear candidate.
21011:33:51.865 [NioClientManager] DEBUG org.bitcoinj.core.BitcoinSerializer - Received 168 byte 'alert' message: 60010000000000000000000000ffffff7f00000000ffffff7ffeffff7f01ffffff7f00000000ffffff7f00ffffff7f002f555247454e543a20416c657274206b657920636f6d70726f6d697365642c2075706772616465207265717569726564004630440220653febd6410f470f6bae11cad19c48413becb1ac2c17f908fd0fd53bdc3abd5202206d0e9c96fe88d4a0f01ed9dedae2b6f9e00da94cad0fecaae66ecf689bf71b50
21111:33:51.866 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 999 ms before next connect attempt to [127.0.0.1]:19000
21211:33:51.866 [NioClientManager] DEBUG org.bitcoinj.core.Peer - Received alert from peer Peer{[192.168.10.208]:19000, version=70015, subVer=/Satoshi:0.19.1(bitcore)/, services=1033 (NETWORK, WITNESS, NETWORK_LIMITED), time=2021-11-06 11:33:52, height=5}: URGENT: Alert key compromised, upgrade required
21311:33:51.867 [NioClientManager] WARN  org.bitcoinj.net.ConnectionHandler - Error handling SelectionKey: java.nio.channels.CancelledKeyException 
214java.nio.channels.CancelledKeyException: null
215    at java.base/sun.nio.ch.SelectionKeyImpl.ensureValid(SelectionKeyImpl.java:71)
216    at java.base/sun.nio.ch.SelectionKeyImpl.readyOps(SelectionKeyImpl.java:130)
217    at java.base/java.nio.channels.SelectionKey.isWritable(SelectionKey.java:377)
218    at org.bitcoinj.net.ConnectionHandler.handleKey(ConnectionHandler.java:244)
219    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:86)
220    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
221    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
222    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
223    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
224    at java.base/java.lang.Thread.run(Thread.java:830)
22511:32:43.482 [NioClientManager] INFO  org.bitcoinj.core.Peer - Peer{[127.0.0.1]:19000, version=70015, subVer=/Satoshi:0.19.1(bitcore)/, services=1033 (NETWORK, WITNESS, NETWORK_LIMITED), time=2021-11-06 11:32:43, height=4}: Peer does not support bloom filtering.
226peerbloomfilters=1
227#13 922.4 g++: fatal error: Killed signal terminated program cc1plus
228#13 922.4 compilation terminated.
229#13 922.4 make[2]: *** [Makefile:8044: libbitcoin_server_a-init.o] Error 1
230#13 922.4 make[2]: *** Waiting for unfinished jobs....
231#13 965.8 make[2]: Leaving directory '/bitcoin-0.19.1/src'
232#13 965.8 make[1]: *** [Makefile:13765: all-recursive] Error 1
233#13 965.9 make[1]: Leaving directory '/bitcoin-0.19.1/src'
234#13 965.9 make: *** [Makefile:776: all-recursive] Error 1
235------
236executor failed running [/bin/sh -c tar -xzf *.tar.gz     &amp;&amp; cd bitcoin-${BITCOIN_VERSION}     &amp;&amp; sed -i 's/consensus.nSubsidyHalvingInterval = 150/consensus.nSubsidyHalvingInterval = 210000/g' src/chainparams.cpp     &amp;&amp; ./autogen.sh     &amp;&amp; ./configure LDFLAGS=-L`ls -d /opt/db`/lib/ CPPFLAGS=-I`ls -d /opt/db`/include/     --prefix=/opt/bitcoin     --disable-man     --disable-tests     --disable-bench     --disable-ccache     --with-gui=no     --enable-util-cli     --with-daemon     &amp;&amp; make -j4     &amp;&amp; make install     &amp;&amp; strip /opt/bitcoin/bin/bitcoin-cli     &amp;&amp; strip /opt/bitcoin/bin/bitcoind]: exit code: 2
237INFO  org.bitcoinj.core.PeerSocketHandler - [127.0.0.1]:19001: Timed out
238

Full log output is available here.

ANSWER

Answered 2021-Nov-18 at 19:39

I haven't tested your full setup with electrumx and the ethereum stuff present in your docker-compose file, but regarding your problem, the following steps worked properly, and I think it will do as well in your complete setup.

I ran with docker a bitcoin node based in the ulamlabs/bitcoind-custom-regtest:latest image you provided:

1docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli getnewaddress
2import org.bitcoinj.core.Address;
3import org.bitcoinj.core.Coin;
4import org.bitcoinj.core.NetworkParameters;
5import org.bitcoinj.core.Transaction;
6import org.bitcoinj.wallet.Wallet;
7import org.bitcoinj.wallet.listeners.WalletCoinsReceivedEventListener;
8
9public class WalletObserver {
10    public void init() {
11        final NetworkParameters netParams = NetworkParameters.fromID(NetworkParameters.ID_REGTEST);
12
13        try {
14            final Wallet wallet = Wallet.createBasic(netParams);
15
16            wallet.addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
17
18            wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
19                @Override
20                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
21                    System.out.println(&quot;Heyo!&quot;);
22                }
23            });
24        }
25        catch (Exception exception) {
26            exception.printStackTrace();
27        }
28    }
29}
30% docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.5
31068c377bab961356ad9a3919229a764aa929711c68aefd5dbd4c7c348eef3406
32    ports:
33      - &quot;51001:50001&quot;
34      - &quot;51002:50002&quot;
35      - &quot;19001:19001&quot;
36      - &quot;19000:19000&quot;
37      - &quot;28332:28332&quot;
38public class WalletObserver {
39    public void init() {
40        final LocalTestNetParams netParams = new LocalTestNetParams();
41        netParams.setPort(50001);
42        try {
43            final WalletAppKit kit = new WalletAppKit(netParams, new File(&quot;.&quot;), &quot;_minimalCryptoExchangeBtcWallet&quot;);
44            kit.setAutoSave(true);
45            kit.connectToLocalHost();
46
47            kit.startAsync();
48            kit.awaitRunning(); // I never get past this point
49            kit.peerGroup().addPeerDiscovery(new DnsDiscovery(netParams));
50            kit.wallet().addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
51
52            kit.wallet().addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
53                @Override
54                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
55                    System.out.println(&quot;Heyo!&quot;);
56                }
57            });
58        }
59        catch (Exception exception) {
60            exception.printStackTrace();
61        }
62    }
63package com.dpisarenko.minimalcryptoexchange.logic.btc;
64
65import org.bitcoinj.params.RegTestParams;
66
67public class LocalTestNetParams extends RegTestParams {
68    public void setPort(final int newPort) {
69        this.port = newPort;
70    }
71}
7222:16:34.245 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
7322:16:34.265 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
74java.net.ConnectException: Connection refused
75    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
76    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
77    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
78    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
79    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
80    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
81    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
82    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
83    at java.base/java.lang.Thread.run(Thread.java:830)
8422:16:34.267 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
8522:16:34.267 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 21.84 μs and returned 0 items from 0 discoverers
8622:16:34.269 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 1502 ms before next connect attempt to [10.10.1.218]:50001
8722:16:35.776 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
8822:16:35.778 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
89java.net.ConnectException: Connection refused
90    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
91    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
92    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
93    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
94    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
95    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
96    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
97    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
98    at java.base/java.lang.Thread.run(Thread.java:830)
9922:16:35.778 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
10022:16:35.779 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 8.752 μs and returned 0 items from 0 discoverers
101    public WalletAppKit connectToLocalHost() {
102        try {
103            InetAddress localHost = InetAddress.getLocalHost();
104            return this.setPeerNodes(new PeerAddress(this.params, localHost, this.params.getPort()));
105        } catch (UnknownHostException var2) {
106            throw new RuntimeException(var2);
107        }
108    }
109
110  node:
111    image: ulamlabs/bitcoind-custom-regtest:latest
112    network_mode: &quot;host&quot;
113minimal-crypto-exchange % docker-compose up -d
114Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
115Creating minimal-crypto-exchange_postgres_1  ... done
116Creating minimal-crypto-exchange_geth_1     ...
117Creating minimal-crypto-exchange_node_1     ... done
118Creating minimal-crypto-exchange_electrumx_1 ...
119Creating minimal-crypto-exchange_electrumx_1 ... error
120
121ERROR: for minimal-crypto-exchange_electrumx_1  Cannot start service electrumx: driver fail
122Creating minimal-crypto-exchange_geth_1      ... done
123f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
124Creating minimal-crypto-exchange_blockscout_1 ... done
125
126ERROR: for electrumx  Cannot start service electrumx: driver failed programming external connectivity on endpoint minimal-crypto-exchange_electrumx_1 (8eaa4f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
127ERROR: Encountered errors while bringing up the project.
128  electrumx:
129    image: lukechilds/electrumx:latest
130    network_mode: &quot;host&quot;
131minimal-crypto-exchange % docker-compose up -d
132minimal-crypto-exchange_postgres_1 is up-to-date
133minimal-crypto-exchange_geth_1 is up-to-date
134Recreating minimal-crypto-exchange_node_1 ...
135Recreating minimal-crypto-exchange_node_1 ... done
136Recreating minimal-crypto-exchange_electrumx_1 ...
137
138ERROR: for minimal-crypto-exchange_electrumx_1  &quot;host&quot; network_mode is incompatible with port_bindings
139
140ERROR: for electrumx  &quot;host&quot; network_mode is incompatible with port_bindings
141Traceback (most recent call last):
142  File &quot;docker-compose&quot;, line 3, in &lt;module&gt;
143  File &quot;compose/cli/main.py&quot;, line 81, in main
144  File &quot;compose/cli/main.py&quot;, line 203, in perform_command
145  File &quot;compose/metrics/decorator.py&quot;, line 18, in wrapper
146  File &quot;compose/cli/main.py&quot;, line 1186, in up
147  File &quot;compose/cli/main.py&quot;, line 1166, in up
148  File &quot;compose/project.py&quot;, line 697, in up
149  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
150  File &quot;compose/parallel.py&quot;, line 206, in producer
151  File &quot;compose/project.py&quot;, line 679, in do
152  File &quot;compose/service.py&quot;, line 579, in execute_convergence_plan
153  File &quot;compose/service.py&quot;, line 499, in _execute_convergence_recreate
154  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
155  File &quot;compose/parallel.py&quot;, line 206, in producer
156  File &quot;compose/service.py&quot;, line 494, in recreate
157  File &quot;compose/service.py&quot;, line 612, in recreate_container
158  File &quot;compose/service.py&quot;, line 330, in create_container
159  File &quot;compose/service.py&quot;, line 939, in _get_container_create_options
160  File &quot;compose/service.py&quot;, line 1014, in _get_container_host_config
161  File &quot;docker/api/container.py&quot;, line 598, in create_host_config
162  File &quot;docker/types/containers.py&quot;, line 338, in __init__
163docker.errors.InvalidArgument: &quot;host&quot; network_mode is incompatible with port_bindings
164[44262] Failed to execute script docker-compose
165  electrumx:
166    image: lukechilds/electrumx:latest
167    network_mode: host
168    links:
169      - node
170# Port settings see https://github.com/ulamlabs/bitcoind-custom-regtest
171#    ports:
172#      - &quot;51001:50001&quot;
173#      - &quot;51002:50002&quot;
174#      - &quot;19001:19001&quot;
175#      - &quot;19000:19000&quot;
176#      - &quot;28332:28332&quot;
177 % docker-compose up -d
178Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
179Creating minimal-crypto-exchange_geth_1 ...
180Creating minimal-crypto-exchange_postgres_1  ... done
181Creating minimal-crypto-exchange_node_1     ... done
182Creating minimal-crypto-exchange_electrumx_1 ... error
183Creating minimal-crypto-exchange_geth_1      ... done
184ERROR: for minimal-crypto-exchange_electrumx_1  Cannot create container for service electrumx: conflicting options: host type networking can't be used with links. This would result in undefined behavior
185Creating minimal-crypto-exchange_blockscout_1 ... done
186
187ERROR: for electrumx  Cannot create container for service electrumx: conflicting options: host type networking can't be used with links. This would result in undefined behavior
188ERROR: Encountered errors while bringing up the project.
189  node:
190    image: ulamlabs/bitcoind-custom-regtest:latest
191# For ports used by node see
192# https://github.com/ulamlabs/bitcoind-custom-regtest/blob/master/bitcoin.conf
193    ports:
194      - &quot;19001:19001&quot;
195      - &quot;19000:19000&quot;
196      - &quot;28332:28332&quot;
197  electrumx:
198    image: lukechilds/electrumx:latest
199    links:
200      - node
201# Port settings see https://github.com/ulamlabs/bitcoind-custom-regtest
202    ports:
203      - &quot;51001:50001&quot;
204      - &quot;51002:50002&quot;
205#      - &quot;19001:19001&quot;
206#      - &quot;19000:19000&quot;
207#      - &quot;28332:28332&quot;
20811:33:51.865 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [192.168.10.208]:19000: Peer died      (0 connected, 0 pending, 1 max)
20911:33:51.865 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - Not yet setting download peer because there is no clear candidate.
21011:33:51.865 [NioClientManager] DEBUG org.bitcoinj.core.BitcoinSerializer - Received 168 byte 'alert' message: 60010000000000000000000000ffffff7f00000000ffffff7ffeffff7f01ffffff7f00000000ffffff7f00ffffff7f002f555247454e543a20416c657274206b657920636f6d70726f6d697365642c2075706772616465207265717569726564004630440220653febd6410f470f6bae11cad19c48413becb1ac2c17f908fd0fd53bdc3abd5202206d0e9c96fe88d4a0f01ed9dedae2b6f9e00da94cad0fecaae66ecf689bf71b50
21111:33:51.866 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 999 ms before next connect attempt to [127.0.0.1]:19000
21211:33:51.866 [NioClientManager] DEBUG org.bitcoinj.core.Peer - Received alert from peer Peer{[192.168.10.208]:19000, version=70015, subVer=/Satoshi:0.19.1(bitcore)/, services=1033 (NETWORK, WITNESS, NETWORK_LIMITED), time=2021-11-06 11:33:52, height=5}: URGENT: Alert key compromised, upgrade required
21311:33:51.867 [NioClientManager] WARN  org.bitcoinj.net.ConnectionHandler - Error handling SelectionKey: java.nio.channels.CancelledKeyException 
214java.nio.channels.CancelledKeyException: null
215    at java.base/sun.nio.ch.SelectionKeyImpl.ensureValid(SelectionKeyImpl.java:71)
216    at java.base/sun.nio.ch.SelectionKeyImpl.readyOps(SelectionKeyImpl.java:130)
217    at java.base/java.nio.channels.SelectionKey.isWritable(SelectionKey.java:377)
218    at org.bitcoinj.net.ConnectionHandler.handleKey(ConnectionHandler.java:244)
219    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:86)
220    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
221    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
222    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
223    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
224    at java.base/java.lang.Thread.run(Thread.java:830)
22511:32:43.482 [NioClientManager] INFO  org.bitcoinj.core.Peer - Peer{[127.0.0.1]:19000, version=70015, subVer=/Satoshi:0.19.1(bitcore)/, services=1033 (NETWORK, WITNESS, NETWORK_LIMITED), time=2021-11-06 11:32:43, height=4}: Peer does not support bloom filtering.
226peerbloomfilters=1
227#13 922.4 g++: fatal error: Killed signal terminated program cc1plus
228#13 922.4 compilation terminated.
229#13 922.4 make[2]: *** [Makefile:8044: libbitcoin_server_a-init.o] Error 1
230#13 922.4 make[2]: *** Waiting for unfinished jobs....
231#13 965.8 make[2]: Leaving directory '/bitcoin-0.19.1/src'
232#13 965.8 make[1]: *** [Makefile:13765: all-recursive] Error 1
233#13 965.9 make[1]: Leaving directory '/bitcoin-0.19.1/src'
234#13 965.9 make: *** [Makefile:776: all-recursive] Error 1
235------
236executor failed running [/bin/sh -c tar -xzf *.tar.gz     &amp;&amp; cd bitcoin-${BITCOIN_VERSION}     &amp;&amp; sed -i 's/consensus.nSubsidyHalvingInterval = 150/consensus.nSubsidyHalvingInterval = 210000/g' src/chainparams.cpp     &amp;&amp; ./autogen.sh     &amp;&amp; ./configure LDFLAGS=-L`ls -d /opt/db`/lib/ CPPFLAGS=-I`ls -d /opt/db`/include/     --prefix=/opt/bitcoin     --disable-man     --disable-tests     --disable-bench     --disable-ccache     --with-gui=no     --enable-util-cli     --with-daemon     &amp;&amp; make -j4     &amp;&amp; make install     &amp;&amp; strip /opt/bitcoin/bin/bitcoin-cli     &amp;&amp; strip /opt/bitcoin/bin/bitcoind]: exit code: 2
237INFO  org.bitcoinj.core.PeerSocketHandler - [127.0.0.1]:19001: Timed out
238docker run -p 18444:19000 -d ulamlabs/bitcoind-custom-regtest:latest
239

As you can see, I exposed the image internal port 19000 as the default port for RegTestParams, 18444. From the point of view of our client, with this setup, basically it will look like as if we were running the bitcoin daemon in the host. Using your LocalTestNetParams class and providing the port 19000 as you indicated should do the trick as well.

Then, according to the feedback you provided in the question, I manually edited the daemon configuration of the bitcoin node in /root/.bitcoin/bitcoin.conf using bash and vi:

1docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli getnewaddress
2import org.bitcoinj.core.Address;
3import org.bitcoinj.core.Coin;
4import org.bitcoinj.core.NetworkParameters;
5import org.bitcoinj.core.Transaction;
6import org.bitcoinj.wallet.Wallet;
7import org.bitcoinj.wallet.listeners.WalletCoinsReceivedEventListener;
8
9public class WalletObserver {
10    public void init() {
11        final NetworkParameters netParams = NetworkParameters.fromID(NetworkParameters.ID_REGTEST);
12
13        try {
14            final Wallet wallet = Wallet.createBasic(netParams);
15
16            wallet.addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
17
18            wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
19                @Override
20                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
21                    System.out.println(&quot;Heyo!&quot;);
22                }
23            });
24        }
25        catch (Exception exception) {
26            exception.printStackTrace();
27        }
28    }
29}
30% docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.5
31068c377bab961356ad9a3919229a764aa929711c68aefd5dbd4c7c348eef3406
32    ports:
33      - &quot;51001:50001&quot;
34      - &quot;51002:50002&quot;
35      - &quot;19001:19001&quot;
36      - &quot;19000:19000&quot;
37      - &quot;28332:28332&quot;
38public class WalletObserver {
39    public void init() {
40        final LocalTestNetParams netParams = new LocalTestNetParams();
41        netParams.setPort(50001);
42        try {
43            final WalletAppKit kit = new WalletAppKit(netParams, new File(&quot;.&quot;), &quot;_minimalCryptoExchangeBtcWallet&quot;);
44            kit.setAutoSave(true);
45            kit.connectToLocalHost();
46
47            kit.startAsync();
48            kit.awaitRunning(); // I never get past this point
49            kit.peerGroup().addPeerDiscovery(new DnsDiscovery(netParams));
50            kit.wallet().addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
51
52            kit.wallet().addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
53                @Override
54                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
55                    System.out.println(&quot;Heyo!&quot;);
56                }
57            });
58        }
59        catch (Exception exception) {
60            exception.printStackTrace();
61        }
62    }
63package com.dpisarenko.minimalcryptoexchange.logic.btc;
64
65import org.bitcoinj.params.RegTestParams;
66
67public class LocalTestNetParams extends RegTestParams {
68    public void setPort(final int newPort) {
69        this.port = newPort;
70    }
71}
7222:16:34.245 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
7322:16:34.265 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
74java.net.ConnectException: Connection refused
75    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
76    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
77    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
78    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
79    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
80    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
81    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
82    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
83    at java.base/java.lang.Thread.run(Thread.java:830)
8422:16:34.267 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
8522:16:34.267 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 21.84 μs and returned 0 items from 0 discoverers
8622:16:34.269 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 1502 ms before next connect attempt to [10.10.1.218]:50001
8722:16:35.776 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
8822:16:35.778 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
89java.net.ConnectException: Connection refused
90    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
91    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
92    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
93    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
94    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
95    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
96    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
97    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
98    at java.base/java.lang.Thread.run(Thread.java:830)
9922:16:35.778 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
10022:16:35.779 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 8.752 μs and returned 0 items from 0 discoverers
101    public WalletAppKit connectToLocalHost() {
102        try {
103            InetAddress localHost = InetAddress.getLocalHost();
104            return this.setPeerNodes(new PeerAddress(this.params, localHost, this.params.getPort()));
105        } catch (UnknownHostException var2) {
106            throw new RuntimeException(var2);
107        }
108    }
109
110  node:
111    image: ulamlabs/bitcoind-custom-regtest:latest
112    network_mode: &quot;host&quot;
113minimal-crypto-exchange % docker-compose up -d
114Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
115Creating minimal-crypto-exchange_postgres_1  ... done
116Creating minimal-crypto-exchange_geth_1     ...
117Creating minimal-crypto-exchange_node_1     ... done
118Creating minimal-crypto-exchange_electrumx_1 ...
119Creating minimal-crypto-exchange_electrumx_1 ... error
120
121ERROR: for minimal-crypto-exchange_electrumx_1  Cannot start service electrumx: driver fail
122Creating minimal-crypto-exchange_geth_1      ... done
123f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
124Creating minimal-crypto-exchange_blockscout_1 ... done
125
126ERROR: for electrumx  Cannot start service electrumx: driver failed programming external connectivity on endpoint minimal-crypto-exchange_electrumx_1 (8eaa4f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
127ERROR: Encountered errors while bringing up the project.
128  electrumx:
129    image: lukechilds/electrumx:latest
130    network_mode: &quot;host&quot;
131minimal-crypto-exchange % docker-compose up -d
132minimal-crypto-exchange_postgres_1 is up-to-date
133minimal-crypto-exchange_geth_1 is up-to-date
134Recreating minimal-crypto-exchange_node_1 ...
135Recreating minimal-crypto-exchange_node_1 ... done
136Recreating minimal-crypto-exchange_electrumx_1 ...
137
138ERROR: for minimal-crypto-exchange_electrumx_1  &quot;host&quot; network_mode is incompatible with port_bindings
139
140ERROR: for electrumx  &quot;host&quot; network_mode is incompatible with port_bindings
141Traceback (most recent call last):
142  File &quot;docker-compose&quot;, line 3, in &lt;module&gt;
143  File &quot;compose/cli/main.py&quot;, line 81, in main
144  File &quot;compose/cli/main.py&quot;, line 203, in perform_command
145  File &quot;compose/metrics/decorator.py&quot;, line 18, in wrapper
146  File &quot;compose/cli/main.py&quot;, line 1186, in up
147  File &quot;compose/cli/main.py&quot;, line 1166, in up
148  File &quot;compose/project.py&quot;, line 697, in up
149  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
150  File &quot;compose/parallel.py&quot;, line 206, in producer
151  File &quot;compose/project.py&quot;, line 679, in do
152  File &quot;compose/service.py&quot;, line 579, in execute_convergence_plan
153  File &quot;compose/service.py&quot;, line 499, in _execute_convergence_recreate
154  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
155  File &quot;compose/parallel.py&quot;, line 206, in producer
156  File &quot;compose/service.py&quot;, line 494, in recreate
157  File &quot;compose/service.py&quot;, line 612, in recreate_container
158  File &quot;compose/service.py&quot;, line 330, in create_container
159  File &quot;compose/service.py&quot;, line 939, in _get_container_create_options
160  File &quot;compose/service.py&quot;, line 1014, in _get_container_host_config
161  File &quot;docker/api/container.py&quot;, line 598, in create_host_config
162  File &quot;docker/types/containers.py&quot;, line 338, in __init__
163docker.errors.InvalidArgument: &quot;host&quot; network_mode is incompatible with port_bindings
164[44262] Failed to execute script docker-compose
165  electrumx:
166    image: lukechilds/electrumx:latest
167    network_mode: host
168    links:
169      - node
170# Port settings see https://github.com/ulamlabs/bitcoind-custom-regtest
171#    ports:
172#      - &quot;51001:50001&quot;
173#      - &quot;51002:50002&quot;
174#      - &quot;19001:19001&quot;
175#      - &quot;19000:19000&quot;
176#      - &quot;28332:28332&quot;
177 % docker-compose up -d
178Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
179Creating minimal-crypto-exchange_geth_1 ...
180Creating minimal-crypto-exchange_postgres_1  ... done
181Creating minimal-crypto-exchange_node_1     ... done
182Creating minimal-crypto-exchange_electrumx_1 ... error
183Creating minimal-crypto-exchange_geth_1      ... done
184ERROR: for minimal-crypto-exchange_electrumx_1  Cannot create container for service electrumx: conflicting options: host type networking can't be used with links. This would result in undefined behavior
185Creating minimal-crypto-exchange_blockscout_1 ... done
186
187ERROR: for electrumx  Cannot create container for service electrumx: conflicting options: host type networking can't be used with links. This would result in undefined behavior
188ERROR: Encountered errors while bringing up the project.
189  node:
190    image: ulamlabs/bitcoind-custom-regtest:latest
191# For ports used by node see
192# https://github.com/ulamlabs/bitcoind-custom-regtest/blob/master/bitcoin.conf
193    ports:
194      - &quot;19001:19001&quot;
195      - &quot;19000:19000&quot;
196      - &quot;28332:28332&quot;
197  electrumx:
198    image: lukechilds/electrumx:latest
199    links:
200      - node
201# Port settings see https://github.com/ulamlabs/bitcoind-custom-regtest
202    ports:
203      - &quot;51001:50001&quot;
204      - &quot;51002:50002&quot;
205#      - &quot;19001:19001&quot;
206#      - &quot;19000:19000&quot;
207#      - &quot;28332:28332&quot;
20811:33:51.865 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [192.168.10.208]:19000: Peer died      (0 connected, 0 pending, 1 max)
20911:33:51.865 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - Not yet setting download peer because there is no clear candidate.
21011:33:51.865 [NioClientManager] DEBUG org.bitcoinj.core.BitcoinSerializer - Received 168 byte 'alert' message: 60010000000000000000000000ffffff7f00000000ffffff7ffeffff7f01ffffff7f00000000ffffff7f00ffffff7f002f555247454e543a20416c657274206b657920636f6d70726f6d697365642c2075706772616465207265717569726564004630440220653febd6410f470f6bae11cad19c48413becb1ac2c17f908fd0fd53bdc3abd5202206d0e9c96fe88d4a0f01ed9dedae2b6f9e00da94cad0fecaae66ecf689bf71b50
21111:33:51.866 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 999 ms before next connect attempt to [127.0.0.1]:19000
21211:33:51.866 [NioClientManager] DEBUG org.bitcoinj.core.Peer - Received alert from peer Peer{[192.168.10.208]:19000, version=70015, subVer=/Satoshi:0.19.1(bitcore)/, services=1033 (NETWORK, WITNESS, NETWORK_LIMITED), time=2021-11-06 11:33:52, height=5}: URGENT: Alert key compromised, upgrade required
21311:33:51.867 [NioClientManager] WARN  org.bitcoinj.net.ConnectionHandler - Error handling SelectionKey: java.nio.channels.CancelledKeyException 
214java.nio.channels.CancelledKeyException: null
215    at java.base/sun.nio.ch.SelectionKeyImpl.ensureValid(SelectionKeyImpl.java:71)
216    at java.base/sun.nio.ch.SelectionKeyImpl.readyOps(SelectionKeyImpl.java:130)
217    at java.base/java.nio.channels.SelectionKey.isWritable(SelectionKey.java:377)
218    at org.bitcoinj.net.ConnectionHandler.handleKey(ConnectionHandler.java:244)
219    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:86)
220    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
221    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
222    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
223    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
224    at java.base/java.lang.Thread.run(Thread.java:830)
22511:32:43.482 [NioClientManager] INFO  org.bitcoinj.core.Peer - Peer{[127.0.0.1]:19000, version=70015, subVer=/Satoshi:0.19.1(bitcore)/, services=1033 (NETWORK, WITNESS, NETWORK_LIMITED), time=2021-11-06 11:32:43, height=4}: Peer does not support bloom filtering.
226peerbloomfilters=1
227#13 922.4 g++: fatal error: Killed signal terminated program cc1plus
228#13 922.4 compilation terminated.
229#13 922.4 make[2]: *** [Makefile:8044: libbitcoin_server_a-init.o] Error 1
230#13 922.4 make[2]: *** Waiting for unfinished jobs....
231#13 965.8 make[2]: Leaving directory '/bitcoin-0.19.1/src'
232#13 965.8 make[1]: *** [Makefile:13765: all-recursive] Error 1
233#13 965.9 make[1]: Leaving directory '/bitcoin-0.19.1/src'
234#13 965.9 make: *** [Makefile:776: all-recursive] Error 1
235------
236executor failed running [/bin/sh -c tar -xzf *.tar.gz     &amp;&amp; cd bitcoin-${BITCOIN_VERSION}     &amp;&amp; sed -i 's/consensus.nSubsidyHalvingInterval = 150/consensus.nSubsidyHalvingInterval = 210000/g' src/chainparams.cpp     &amp;&amp; ./autogen.sh     &amp;&amp; ./configure LDFLAGS=-L`ls -d /opt/db`/lib/ CPPFLAGS=-I`ls -d /opt/db`/include/     --prefix=/opt/bitcoin     --disable-man     --disable-tests     --disable-bench     --disable-ccache     --with-gui=no     --enable-util-cli     --with-daemon     &amp;&amp; make -j4     &amp;&amp; make install     &amp;&amp; strip /opt/bitcoin/bin/bitcoin-cli     &amp;&amp; strip /opt/bitcoin/bin/bitcoind]: exit code: 2
237INFO  org.bitcoinj.core.PeerSocketHandler - [127.0.0.1]:19001: Timed out
238docker run -p 18444:19000 -d ulamlabs/bitcoind-custom-regtest:latest
239docker exec -it 0aa2e863cd9927 bash
240

And included the following configuration:

1docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli getnewaddress
2import org.bitcoinj.core.Address;
3import org.bitcoinj.core.Coin;
4import org.bitcoinj.core.NetworkParameters;
5import org.bitcoinj.core.Transaction;
6import org.bitcoinj.wallet.Wallet;
7import org.bitcoinj.wallet.listeners.WalletCoinsReceivedEventListener;
8
9public class WalletObserver {
10    public void init() {
11        final NetworkParameters netParams = NetworkParameters.fromID(NetworkParameters.ID_REGTEST);
12
13        try {
14            final Wallet wallet = Wallet.createBasic(netParams);
15
16            wallet.addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
17
18            wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
19                @Override
20                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
21                    System.out.println(&quot;Heyo!&quot;);
22                }
23            });
24        }
25        catch (Exception exception) {
26            exception.printStackTrace();
27        }
28    }
29}
30% docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.5
31068c377bab961356ad9a3919229a764aa929711c68aefd5dbd4c7c348eef3406
32    ports:
33      - &quot;51001:50001&quot;
34      - &quot;51002:50002&quot;
35      - &quot;19001:19001&quot;
36      - &quot;19000:19000&quot;
37      - &quot;28332:28332&quot;
38public class WalletObserver {
39    public void init() {
40        final LocalTestNetParams netParams = new LocalTestNetParams();
41        netParams.setPort(50001);
42        try {
43            final WalletAppKit kit = new WalletAppKit(netParams, new File(&quot;.&quot;), &quot;_minimalCryptoExchangeBtcWallet&quot;);
44            kit.setAutoSave(true);
45            kit.connectToLocalHost();
46
47            kit.startAsync();
48            kit.awaitRunning(); // I never get past this point
49            kit.peerGroup().addPeerDiscovery(new DnsDiscovery(netParams));
50            kit.wallet().addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
51
52            kit.wallet().addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
53                @Override
54                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
55                    System.out.println(&quot;Heyo!&quot;);
56                }
57            });
58        }
59        catch (Exception exception) {
60            exception.printStackTrace();
61        }
62    }
63package com.dpisarenko.minimalcryptoexchange.logic.btc;
64
65import org.bitcoinj.params.RegTestParams;
66
67public class LocalTestNetParams extends RegTestParams {
68    public void setPort(final int newPort) {
69        this.port = newPort;
70    }
71}
7222:16:34.245 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
7322:16:34.265 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
74java.net.ConnectException: Connection refused
75    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
76    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
77    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
78    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
79    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
80    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
81    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
82    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
83    at java.base/java.lang.Thread.run(Thread.java:830)
8422:16:34.267 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
8522:16:34.267 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 21.84 μs and returned 0 items from 0 discoverers
8622:16:34.269 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 1502 ms before next connect attempt to [10.10.1.218]:50001
8722:16:35.776 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
8822:16:35.778 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
89java.net.ConnectException: Connection refused
90    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
91    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
92    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
93    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
94    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
95    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
96    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
97    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
98    at java.base/java.lang.Thread.run(Thread.java:830)
9922:16:35.778 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
10022:16:35.779 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 8.752 μs and returned 0 items from 0 discoverers
101    public WalletAppKit connectToLocalHost() {
102        try {
103            InetAddress localHost = InetAddress.getLocalHost();
104            return this.setPeerNodes(new PeerAddress(this.params, localHost, this.params.getPort()));
105        } catch (UnknownHostException var2) {
106            throw new RuntimeException(var2);
107        }
108    }
109
110  node:
111    image: ulamlabs/bitcoind-custom-regtest:latest
112    network_mode: &quot;host&quot;
113minimal-crypto-exchange % docker-compose up -d
114Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
115Creating minimal-crypto-exchange_postgres_1  ... done
116Creating minimal-crypto-exchange_geth_1     ...
117Creating minimal-crypto-exchange_node_1     ... done
118Creating minimal-crypto-exchange_electrumx_1 ...
119Creating minimal-crypto-exchange_electrumx_1 ... error
120
121ERROR: for minimal-crypto-exchange_electrumx_1  Cannot start service electrumx: driver fail
122Creating minimal-crypto-exchange_geth_1      ... done
123f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
124Creating minimal-crypto-exchange_blockscout_1 ... done
125
126ERROR: for electrumx  Cannot start service electrumx: driver failed programming external connectivity on endpoint minimal-crypto-exchange_electrumx_1 (8eaa4f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
127ERROR: Encountered errors while bringing up the project.
128  electrumx:
129    image: lukechilds/electrumx:latest
130    network_mode: &quot;host&quot;
131minimal-crypto-exchange % docker-compose up -d
132minimal-crypto-exchange_postgres_1 is up-to-date
133minimal-crypto-exchange_geth_1 is up-to-date
134Recreating minimal-crypto-exchange_node_1 ...
135Recreating minimal-crypto-exchange_node_1 ... done
136Recreating minimal-crypto-exchange_electrumx_1 ...
137
138ERROR: for minimal-crypto-exchange_electrumx_1  &quot;host&quot; network_mode is incompatible with port_bindings
139
140ERROR: for electrumx  &quot;host&quot; network_mode is incompatible with port_bindings
141Traceback (most recent call last):
142  File &quot;docker-compose&quot;, line 3, in &lt;module&gt;
143  File &quot;compose/cli/main.py&quot;, line 81, in main
144  File &quot;compose/cli/main.py&quot;, line 203, in perform_command
145  File &quot;compose/metrics/decorator.py&quot;, line 18, in wrapper
146  File &quot;compose/cli/main.py&quot;, line 1186, in up
147  File &quot;compose/cli/main.py&quot;, line 1166, in up
148  File &quot;compose/project.py&quot;, line 697, in up
149  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
150  File &quot;compose/parallel.py&quot;, line 206, in producer
151  File &quot;compose/project.py&quot;, line 679, in do
152  File &quot;compose/service.py&quot;, line 579, in execute_convergence_plan
153  File &quot;compose/service.py&quot;, line 499, in _execute_convergence_recreate
154  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
155  File &quot;compose/parallel.py&quot;, line 206, in producer
156  File &quot;compose/service.py&quot;, line 494, in recreate
157  File &quot;compose/service.py&quot;, line 612, in recreate_container
158  File &quot;compose/service.py&quot;, line 330, in create_container
159  File &quot;compose/service.py&quot;, line 939, in _get_container_create_options
160  File &quot;compose/service.py&quot;, line 1014, in _get_container_host_config
161  File &quot;docker/api/container.py&quot;, line 598, in create_host_config
162  File &quot;docker/types/containers.py&quot;, line 338, in __init__
163docker.errors.InvalidArgument: &quot;host&quot; network_mode is incompatible with port_bindings
164[44262] Failed to execute script docker-compose
165  electrumx:
166    image: lukechilds/electrumx:latest
167    network_mode: host
168    links:
169      - node
170# Port settings see https://github.com/ulamlabs/bitcoind-custom-regtest
171#    ports:
172#      - &quot;51001:50001&quot;
173#      - &quot;51002:50002&quot;
174#      - &quot;19001:19001&quot;
175#      - &quot;19000:19000&quot;
176#      - &quot;28332:28332&quot;
177 % docker-compose up -d
178Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
179Creating minimal-crypto-exchange_geth_1 ...
180Creating minimal-crypto-exchange_postgres_1  ... done
181Creating minimal-crypto-exchange_node_1     ... done
182Creating minimal-crypto-exchange_electrumx_1 ... error
183Creating minimal-crypto-exchange_geth_1      ... done
184ERROR: for minimal-crypto-exchange_electrumx_1  Cannot create container for service electrumx: conflicting options: host type networking can't be used with links. This would result in undefined behavior
185Creating minimal-crypto-exchange_blockscout_1 ... done
186
187ERROR: for electrumx  Cannot create container for service electrumx: conflicting options: host type networking can't be used with links. This would result in undefined behavior
188ERROR: Encountered errors while bringing up the project.
189  node:
190    image: ulamlabs/bitcoind-custom-regtest:latest
191# For ports used by node see
192# https://github.com/ulamlabs/bitcoind-custom-regtest/blob/master/bitcoin.conf
193    ports:
194      - &quot;19001:19001&quot;
195      - &quot;19000:19000&quot;
196      - &quot;28332:28332&quot;
197  electrumx:
198    image: lukechilds/electrumx:latest
199    links:
200      - node
201# Port settings see https://github.com/ulamlabs/bitcoind-custom-regtest
202    ports:
203      - &quot;51001:50001&quot;
204      - &quot;51002:50002&quot;
205#      - &quot;19001:19001&quot;
206#      - &quot;19000:19000&quot;
207#      - &quot;28332:28332&quot;
20811:33:51.865 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [192.168.10.208]:19000: Peer died      (0 connected, 0 pending, 1 max)
20911:33:51.865 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - Not yet setting download peer because there is no clear candidate.
21011:33:51.865 [NioClientManager] DEBUG org.bitcoinj.core.BitcoinSerializer - Received 168 byte 'alert' message: 60010000000000000000000000ffffff7f00000000ffffff7ffeffff7f01ffffff7f00000000ffffff7f00ffffff7f002f555247454e543a20416c657274206b657920636f6d70726f6d697365642c2075706772616465207265717569726564004630440220653febd6410f470f6bae11cad19c48413becb1ac2c17f908fd0fd53bdc3abd5202206d0e9c96fe88d4a0f01ed9dedae2b6f9e00da94cad0fecaae66ecf689bf71b50
21111:33:51.866 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 999 ms before next connect attempt to [127.0.0.1]:19000
21211:33:51.866 [NioClientManager] DEBUG org.bitcoinj.core.Peer - Received alert from peer Peer{[192.168.10.208]:19000, version=70015, subVer=/Satoshi:0.19.1(bitcore)/, services=1033 (NETWORK, WITNESS, NETWORK_LIMITED), time=2021-11-06 11:33:52, height=5}: URGENT: Alert key compromised, upgrade required
21311:33:51.867 [NioClientManager] WARN  org.bitcoinj.net.ConnectionHandler - Error handling SelectionKey: java.nio.channels.CancelledKeyException 
214java.nio.channels.CancelledKeyException: null
215    at java.base/sun.nio.ch.SelectionKeyImpl.ensureValid(SelectionKeyImpl.java:71)
216    at java.base/sun.nio.ch.SelectionKeyImpl.readyOps(SelectionKeyImpl.java:130)
217    at java.base/java.nio.channels.SelectionKey.isWritable(SelectionKey.java:377)
218    at org.bitcoinj.net.ConnectionHandler.handleKey(ConnectionHandler.java:244)
219    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:86)
220    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
221    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
222    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
223    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
224    at java.base/java.lang.Thread.run(Thread.java:830)
22511:32:43.482 [NioClientManager] INFO  org.bitcoinj.core.Peer - Peer{[127.0.0.1]:19000, version=70015, subVer=/Satoshi:0.19.1(bitcore)/, services=1033 (NETWORK, WITNESS, NETWORK_LIMITED), time=2021-11-06 11:32:43, height=4}: Peer does not support bloom filtering.
226peerbloomfilters=1
227#13 922.4 g++: fatal error: Killed signal terminated program cc1plus
228#13 922.4 compilation terminated.
229#13 922.4 make[2]: *** [Makefile:8044: libbitcoin_server_a-init.o] Error 1
230#13 922.4 make[2]: *** Waiting for unfinished jobs....
231#13 965.8 make[2]: Leaving directory '/bitcoin-0.19.1/src'
232#13 965.8 make[1]: *** [Makefile:13765: all-recursive] Error 1
233#13 965.9 make[1]: Leaving directory '/bitcoin-0.19.1/src'
234#13 965.9 make: *** [Makefile:776: all-recursive] Error 1
235------
236executor failed running [/bin/sh -c tar -xzf *.tar.gz     &amp;&amp; cd bitcoin-${BITCOIN_VERSION}     &amp;&amp; sed -i 's/consensus.nSubsidyHalvingInterval = 150/consensus.nSubsidyHalvingInterval = 210000/g' src/chainparams.cpp     &amp;&amp; ./autogen.sh     &amp;&amp; ./configure LDFLAGS=-L`ls -d /opt/db`/lib/ CPPFLAGS=-I`ls -d /opt/db`/include/     --prefix=/opt/bitcoin     --disable-man     --disable-tests     --disable-bench     --disable-ccache     --with-gui=no     --enable-util-cli     --with-daemon     &amp;&amp; make -j4     &amp;&amp; make install     &amp;&amp; strip /opt/bitcoin/bin/bitcoin-cli     &amp;&amp; strip /opt/bitcoin/bin/bitcoind]: exit code: 2
237INFO  org.bitcoinj.core.PeerSocketHandler - [127.0.0.1]:19001: Timed out
238docker run -p 18444:19000 -d ulamlabs/bitcoind-custom-regtest:latest
239docker exec -it 0aa2e863cd9927 bash
240peerbloomfilters=1
241

After restart the container, I got a new address:

1docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli getnewaddress
2import org.bitcoinj.core.Address;
3import org.bitcoinj.core.Coin;
4import org.bitcoinj.core.NetworkParameters;
5import org.bitcoinj.core.Transaction;
6import org.bitcoinj.wallet.Wallet;
7import org.bitcoinj.wallet.listeners.WalletCoinsReceivedEventListener;
8
9public class WalletObserver {
10    public void init() {
11        final NetworkParameters netParams = NetworkParameters.fromID(NetworkParameters.ID_REGTEST);
12
13        try {
14            final Wallet wallet = Wallet.createBasic(netParams);
15
16            wallet.addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
17
18            wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
19                @Override
20                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
21                    System.out.println(&quot;Heyo!&quot;);
22                }
23            });
24        }
25        catch (Exception exception) {
26            exception.printStackTrace();
27        }
28    }
29}
30% docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.5
31068c377bab961356ad9a3919229a764aa929711c68aefd5dbd4c7c348eef3406
32    ports:
33      - &quot;51001:50001&quot;
34      - &quot;51002:50002&quot;
35      - &quot;19001:19001&quot;
36      - &quot;19000:19000&quot;
37      - &quot;28332:28332&quot;
38public class WalletObserver {
39    public void init() {
40        final LocalTestNetParams netParams = new LocalTestNetParams();
41        netParams.setPort(50001);
42        try {
43            final WalletAppKit kit = new WalletAppKit(netParams, new File(&quot;.&quot;), &quot;_minimalCryptoExchangeBtcWallet&quot;);
44            kit.setAutoSave(true);
45            kit.connectToLocalHost();
46
47            kit.startAsync();
48            kit.awaitRunning(); // I never get past this point
49            kit.peerGroup().addPeerDiscovery(new DnsDiscovery(netParams));
50            kit.wallet().addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
51
52            kit.wallet().addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
53                @Override
54                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
55                    System.out.println(&quot;Heyo!&quot;);
56                }
57            });
58        }
59        catch (Exception exception) {
60            exception.printStackTrace();
61        }
62    }
63package com.dpisarenko.minimalcryptoexchange.logic.btc;
64
65import org.bitcoinj.params.RegTestParams;
66
67public class LocalTestNetParams extends RegTestParams {
68    public void setPort(final int newPort) {
69        this.port = newPort;
70    }
71}
7222:16:34.245 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
7322:16:34.265 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
74java.net.ConnectException: Connection refused
75    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
76    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
77    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
78    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
79    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
80    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
81    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
82    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
83    at java.base/java.lang.Thread.run(Thread.java:830)
8422:16:34.267 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
8522:16:34.267 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 21.84 μs and returned 0 items from 0 discoverers
8622:16:34.269 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 1502 ms before next connect attempt to [10.10.1.218]:50001
8722:16:35.776 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
8822:16:35.778 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
89java.net.ConnectException: Connection refused
90    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
91    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
92    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
93    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
94    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
95    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
96    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
97    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
98    at java.base/java.lang.Thread.run(Thread.java:830)
9922:16:35.778 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
10022:16:35.779 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 8.752 μs and returned 0 items from 0 discoverers
101    public WalletAppKit connectToLocalHost() {
102        try {
103            InetAddress localHost = InetAddress.getLocalHost();
104            return this.setPeerNodes(new PeerAddress(this.params, localHost, this.params.getPort()));
105        } catch (UnknownHostException var2) {
106            throw new RuntimeException(var2);
107        }
108    }
109
110  node:
111    image: ulamlabs/bitcoind-custom-regtest:latest
112    network_mode: &quot;host&quot;
113minimal-crypto-exchange % docker-compose up -d
114Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
115Creating minimal-crypto-exchange_postgres_1  ... done
116Creating minimal-crypto-exchange_geth_1     ...
117Creating minimal-crypto-exchange_node_1     ... done
118Creating minimal-crypto-exchange_electrumx_1 ...
119Creating minimal-crypto-exchange_electrumx_1 ... error
120
121ERROR: for minimal-crypto-exchange_electrumx_1  Cannot start service electrumx: driver fail
122Creating minimal-crypto-exchange_geth_1      ... done
123f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
124Creating minimal-crypto-exchange_blockscout_1 ... done
125
126ERROR: for electrumx  Cannot start service electrumx: driver failed programming external connectivity on endpoint minimal-crypto-exchange_electrumx_1 (8eaa4f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
127ERROR: Encountered errors while bringing up the project.
128  electrumx:
129    image: lukechilds/electrumx:latest
130    network_mode: &quot;host&quot;
131minimal-crypto-exchange % docker-compose up -d
132minimal-crypto-exchange_postgres_1 is up-to-date
133minimal-crypto-exchange_geth_1 is up-to-date
134Recreating minimal-crypto-exchange_node_1 ...
135Recreating minimal-crypto-exchange_node_1 ... done
136Recreating minimal-crypto-exchange_electrumx_1 ...
137
138ERROR: for minimal-crypto-exchange_electrumx_1  &quot;host&quot; network_mode is incompatible with port_bindings
139
140ERROR: for electrumx  &quot;host&quot; network_mode is incompatible with port_bindings
141Traceback (most recent call last):
142  File &quot;docker-compose&quot;, line 3, in &lt;module&gt;
143  File &quot;compose/cli/main.py&quot;, line 81, in main
144  File &quot;compose/cli/main.py&quot;, line 203, in perform_command
145  File &quot;compose/metrics/decorator.py&quot;, line 18, in wrapper
146  File &quot;compose/cli/main.py&quot;, line 1186, in up
147  File &quot;compose/cli/main.py&quot;, line 1166, in up
148  File &quot;compose/project.py&quot;, line 697, in up
149  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
150  File &quot;compose/parallel.py&quot;, line 206, in producer
151  File &quot;compose/project.py&quot;, line 679, in do
152  File &quot;compose/service.py&quot;, line 579, in execute_convergence_plan
153  File &quot;compose/service.py&quot;, line 499, in _execute_convergence_recreate
154  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
155  File &quot;compose/parallel.py&quot;, line 206, in producer
156  File &quot;compose/service.py&quot;, line 494, in recreate
157  File &quot;compose/service.py&quot;, line 612, in recreate_container
158  File &quot;compose/service.py&quot;, line 330, in create_container
159  File &quot;compose/service.py&quot;, line 939, in _get_container_create_options
160  File &quot;compose/service.py&quot;, line 1014, in _get_container_host_config
161  File &quot;docker/api/container.py&quot;, line 598, in create_host_config
162  File &quot;docker/types/containers.py&quot;, line 338, in __init__
163docker.errors.InvalidArgument: &quot;host&quot; network_mode is incompatible with port_bindings
164[44262] Failed to execute script docker-compose
165  electrumx:
166    image: lukechilds/electrumx:latest
167    network_mode: host
168    links:
169      - node
170# Port settings see https://github.com/ulamlabs/bitcoind-custom-regtest
171#    ports:
172#      - &quot;51001:50001&quot;
173#      - &quot;51002:50002&quot;
174#      - &quot;19001:19001&quot;
175#      - &quot;19000:19000&quot;
176#      - &quot;28332:28332&quot;
177 % docker-compose up -d
178Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
179Creating minimal-crypto-exchange_geth_1 ...
180Creating minimal-crypto-exchange_postgres_1  ... done
181Creating minimal-crypto-exchange_node_1     ... done
182Creating minimal-crypto-exchange_electrumx_1 ... error
183Creating minimal-crypto-exchange_geth_1      ... done
184ERROR: for minimal-crypto-exchange_electrumx_1  Cannot create container for service electrumx: conflicting options: host type networking can't be used with links. This would result in undefined behavior
185Creating minimal-crypto-exchange_blockscout_1 ... done
186
187ERROR: for electrumx  Cannot create container for service electrumx: conflicting options: host type networking can't be used with links. This would result in undefined behavior
188ERROR: Encountered errors while bringing up the project.
189  node:
190    image: ulamlabs/bitcoind-custom-regtest:latest
191# For ports used by node see
192# https://github.com/ulamlabs/bitcoind-custom-regtest/blob/master/bitcoin.conf
193    ports:
194      - &quot;19001:19001&quot;
195      - &quot;19000:19000&quot;
196      - &quot;28332:28332&quot;
197  electrumx:
198    image: lukechilds/electrumx:latest
199    links:
200      - node
201# Port settings see https://github.com/ulamlabs/bitcoind-custom-regtest
202    ports:
203      - &quot;51001:50001&quot;
204      - &quot;51002:50002&quot;
205#      - &quot;19001:19001&quot;
206#      - &quot;19000:19000&quot;
207#      - &quot;28332:28332&quot;
20811:33:51.865 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [192.168.10.208]:19000: Peer died      (0 connected, 0 pending, 1 max)
20911:33:51.865 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - Not yet setting download peer because there is no clear candidate.
21011:33:51.865 [NioClientManager] DEBUG org.bitcoinj.core.BitcoinSerializer - Received 168 byte 'alert' message: 60010000000000000000000000ffffff7f00000000ffffff7ffeffff7f01ffffff7f00000000ffffff7f00ffffff7f002f555247454e543a20416c657274206b657920636f6d70726f6d697365642c2075706772616465207265717569726564004630440220653febd6410f470f6bae11cad19c48413becb1ac2c17f908fd0fd53bdc3abd5202206d0e9c96fe88d4a0f01ed9dedae2b6f9e00da94cad0fecaae66ecf689bf71b50
21111:33:51.866 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 999 ms before next connect attempt to [127.0.0.1]:19000
21211:33:51.866 [NioClientManager] DEBUG org.bitcoinj.core.Peer - Received alert from peer Peer{[192.168.10.208]:19000, version=70015, subVer=/Satoshi:0.19.1(bitcore)/, services=1033 (NETWORK, WITNESS, NETWORK_LIMITED), time=2021-11-06 11:33:52, height=5}: URGENT: Alert key compromised, upgrade required
21311:33:51.867 [NioClientManager] WARN  org.bitcoinj.net.ConnectionHandler - Error handling SelectionKey: java.nio.channels.CancelledKeyException 
214java.nio.channels.CancelledKeyException: null
215    at java.base/sun.nio.ch.SelectionKeyImpl.ensureValid(SelectionKeyImpl.java:71)
216    at java.base/sun.nio.ch.SelectionKeyImpl.readyOps(SelectionKeyImpl.java:130)
217    at java.base/java.nio.channels.SelectionKey.isWritable(SelectionKey.java:377)
218    at org.bitcoinj.net.ConnectionHandler.handleKey(ConnectionHandler.java:244)
219    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:86)
220    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
221    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
222    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
223    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
224    at java.base/java.lang.Thread.run(Thread.java:830)
22511:32:43.482 [NioClientManager] INFO  org.bitcoinj.core.Peer - Peer{[127.0.0.1]:19000, version=70015, subVer=/Satoshi:0.19.1(bitcore)/, services=1033 (NETWORK, WITNESS, NETWORK_LIMITED), time=2021-11-06 11:32:43, height=4}: Peer does not support bloom filtering.
226peerbloomfilters=1
227#13 922.4 g++: fatal error: Killed signal terminated program cc1plus
228#13 922.4 compilation terminated.
229#13 922.4 make[2]: *** [Makefile:8044: libbitcoin_server_a-init.o] Error 1
230#13 922.4 make[2]: *** Waiting for unfinished jobs....
231#13 965.8 make[2]: Leaving directory '/bitcoin-0.19.1/src'
232#13 965.8 make[1]: *** [Makefile:13765: all-recursive] Error 1
233#13 965.9 make[1]: Leaving directory '/bitcoin-0.19.1/src'
234#13 965.9 make: *** [Makefile:776: all-recursive] Error 1
235------
236executor failed running [/bin/sh -c tar -xzf *.tar.gz     &amp;&amp; cd bitcoin-${BITCOIN_VERSION}     &amp;&amp; sed -i 's/consensus.nSubsidyHalvingInterval = 150/consensus.nSubsidyHalvingInterval = 210000/g' src/chainparams.cpp     &amp;&amp; ./autogen.sh     &amp;&amp; ./configure LDFLAGS=-L`ls -d /opt/db`/lib/ CPPFLAGS=-I`ls -d /opt/db`/include/     --prefix=/opt/bitcoin     --disable-man     --disable-tests     --disable-bench     --disable-ccache     --with-gui=no     --enable-util-cli     --with-daemon     &amp;&amp; make -j4     &amp;&amp; make install     &amp;&amp; strip /opt/bitcoin/bin/bitcoin-cli     &amp;&amp; strip /opt/bitcoin/bin/bitcoind]: exit code: 2
237INFO  org.bitcoinj.core.PeerSocketHandler - [127.0.0.1]:19001: Timed out
238docker run -p 18444:19000 -d ulamlabs/bitcoind-custom-regtest:latest
239docker exec -it 0aa2e863cd9927 bash
240peerbloomfilters=1
241docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest getnewaddress
242

Let's assume that the new address is the one you provided in the question:

1docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli getnewaddress
2import org.bitcoinj.core.Address;
3import org.bitcoinj.core.Coin;
4import org.bitcoinj.core.NetworkParameters;
5import org.bitcoinj.core.Transaction;
6import org.bitcoinj.wallet.Wallet;
7import org.bitcoinj.wallet.listeners.WalletCoinsReceivedEventListener;
8
9public class WalletObserver {
10    public void init() {
11        final NetworkParameters netParams = NetworkParameters.fromID(NetworkParameters.ID_REGTEST);
12
13        try {
14            final Wallet wallet = Wallet.createBasic(netParams);
15
16            wallet.addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
17
18            wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
19                @Override
20                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
21                    System.out.println(&quot;Heyo!&quot;);
22                }
23            });
24        }
25        catch (Exception exception) {
26            exception.printStackTrace();
27        }
28    }
29}
30% docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.5
31068c377bab961356ad9a3919229a764aa929711c68aefd5dbd4c7c348eef3406
32    ports:
33      - &quot;51001:50001&quot;
34      - &quot;51002:50002&quot;
35      - &quot;19001:19001&quot;
36      - &quot;19000:19000&quot;
37      - &quot;28332:28332&quot;
38public class WalletObserver {
39    public void init() {
40        final LocalTestNetParams netParams = new LocalTestNetParams();
41        netParams.setPort(50001);
42        try {
43            final WalletAppKit kit = new WalletAppKit(netParams, new File(&quot;.&quot;), &quot;_minimalCryptoExchangeBtcWallet&quot;);
44            kit.setAutoSave(true);
45            kit.connectToLocalHost();
46
47            kit.startAsync();
48            kit.awaitRunning(); // I never get past this point
49            kit.peerGroup().addPeerDiscovery(new DnsDiscovery(netParams));
50            kit.wallet().addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
51
52            kit.wallet().addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
53                @Override
54                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
55                    System.out.println(&quot;Heyo!&quot;);
56                }
57            });
58        }
59        catch (Exception exception) {
60            exception.printStackTrace();
61        }
62    }
63package com.dpisarenko.minimalcryptoexchange.logic.btc;
64
65import org.bitcoinj.params.RegTestParams;
66
67public class LocalTestNetParams extends RegTestParams {
68    public void setPort(final int newPort) {
69        this.port = newPort;
70    }
71}
7222:16:34.245 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
7322:16:34.265 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
74java.net.ConnectException: Connection refused
75    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
76    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
77    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
78    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
79    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
80    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
81    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
82    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
83    at java.base/java.lang.Thread.run(Thread.java:830)
8422:16:34.267 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
8522:16:34.267 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 21.84 μs and returned 0 items from 0 discoverers
8622:16:34.269 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 1502 ms before next connect attempt to [10.10.1.218]:50001
8722:16:35.776 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
8822:16:35.778 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
89java.net.ConnectException: Connection refused
90    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
91    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
92    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
93    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
94    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
95    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
96    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
97    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
98    at java.base/java.lang.Thread.run(Thread.java:830)
9922:16:35.778 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
10022:16:35.779 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 8.752 μs and returned 0 items from 0 discoverers
101    public WalletAppKit connectToLocalHost() {
102        try {
103            InetAddress localHost = InetAddress.getLocalHost();
104            return this.setPeerNodes(new PeerAddress(this.params, localHost, this.params.getPort()));
105        } catch (UnknownHostException var2) {
106            throw new RuntimeException(var2);
107        }
108    }
109
110  node:
111    image: ulamlabs/bitcoind-custom-regtest:latest
112    network_mode: &quot;host&quot;
113minimal-crypto-exchange % docker-compose up -d
114Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
115Creating minimal-crypto-exchange_postgres_1  ... done
116Creating minimal-crypto-exchange_geth_1     ...
117Creating minimal-crypto-exchange_node_1     ... done
118Creating minimal-crypto-exchange_electrumx_1 ...
119Creating minimal-crypto-exchange_electrumx_1 ... error
120
121ERROR: for minimal-crypto-exchange_electrumx_1  Cannot start service electrumx: driver fail
122Creating minimal-crypto-exchange_geth_1      ... done
123f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
124Creating minimal-crypto-exchange_blockscout_1 ... done
125
126ERROR: for electrumx  Cannot start service electrumx: driver failed programming external connectivity on endpoint minimal-crypto-exchange_electrumx_1 (8eaa4f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
127ERROR: Encountered errors while bringing up the project.
128  electrumx:
129    image: lukechilds/electrumx:latest
130    network_mode: &quot;host&quot;
131minimal-crypto-exchange % docker-compose up -d
132minimal-crypto-exchange_postgres_1 is up-to-date
133minimal-crypto-exchange_geth_1 is up-to-date
134Recreating minimal-crypto-exchange_node_1 ...
135Recreating minimal-crypto-exchange_node_1 ... done
136Recreating minimal-crypto-exchange_electrumx_1 ...
137
138ERROR: for minimal-crypto-exchange_electrumx_1  &quot;host&quot; network_mode is incompatible with port_bindings
139
140ERROR: for electrumx  &quot;host&quot; network_mode is incompatible with port_bindings
141Traceback (most recent call last):
142  File &quot;docker-compose&quot;, line 3, in &lt;module&gt;
143  File &quot;compose/cli/main.py&quot;, line 81, in main
144  File &quot;compose/cli/main.py&quot;, line 203, in perform_command
145  File &quot;compose/metrics/decorator.py&quot;, line 18, in wrapper
146  File &quot;compose/cli/main.py&quot;, line 1186, in up
147  File &quot;compose/cli/main.py&quot;, line 1166, in up
148  File &quot;compose/project.py&quot;, line 697, in up
149  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
150  File &quot;compose/parallel.py&quot;, line 206, in producer
151  File &quot;compose/project.py&quot;, line 679, in do
152  File &quot;compose/service.py&quot;, line 579, in execute_convergence_plan
153  File &quot;compose/service.py&quot;, line 499, in _execute_convergence_recreate
154  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
155  File &quot;compose/parallel.py&quot;, line 206, in producer
156  File &quot;compose/service.py&quot;, line 494, in recreate
157  File &quot;compose/service.py&quot;, line 612, in recreate_container
158  File &quot;compose/service.py&quot;, line 330, in create_container
159  File &quot;compose/service.py&quot;, line 939, in _get_container_create_options
160  File &quot;compose/service.py&quot;, line 1014, in _get_container_host_config
161  File &quot;docker/api/container.py&quot;, line 598, in create_host_config
162  File &quot;docker/types/containers.py&quot;, line 338, in __init__
163docker.errors.InvalidArgument: &quot;host&quot; network_mode is incompatible with port_bindings
164[44262] Failed to execute script docker-compose
165  electrumx:
166    image: lukechilds/electrumx:latest
167    network_mode: host
168    links:
169      - node
170# Port settings see https://github.com/ulamlabs/bitcoind-custom-regtest
171#    ports:
172#      - &quot;51001:50001&quot;
173#      - &quot;51002:50002&quot;
174#      - &quot;19001:19001&quot;
175#      - &quot;19000:19000&quot;
176#      - &quot;28332:28332&quot;
177 % docker-compose up -d
178Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
179Creating minimal-crypto-exchange_geth_1 ...
180Creating minimal-crypto-exchange_postgres_1  ... done
181Creating minimal-crypto-exchange_node_1     ... done
182Creating minimal-crypto-exchange_electrumx_1 ... error
183Creating minimal-crypto-exchange_geth_1      ... done
184ERROR: for minimal-crypto-exchange_electrumx_1  Cannot create container for service electrumx: conflicting options: host type networking can't be used with links. This would result in undefined behavior
185Creating minimal-crypto-exchange_blockscout_1 ... done
186
187ERROR: for electrumx  Cannot create container for service electrumx: conflicting options: host type networking can't be used with links. This would result in undefined behavior
188ERROR: Encountered errors while bringing up the project.
189  node:
190    image: ulamlabs/bitcoind-custom-regtest:latest
191# For ports used by node see
192# https://github.com/ulamlabs/bitcoind-custom-regtest/blob/master/bitcoin.conf
193    ports:
194      - &quot;19001:19001&quot;
195      - &quot;19000:19000&quot;
196      - &quot;28332:28332&quot;
197  electrumx:
198    image: lukechilds/electrumx:latest
199    links:
200      - node
201# Port settings see https://github.com/ulamlabs/bitcoind-custom-regtest
202    ports:
203      - &quot;51001:50001&quot;
204      - &quot;51002:50002&quot;
205#      - &quot;19001:19001&quot;
206#      - &quot;19000:19000&quot;
207#      - &quot;28332:28332&quot;
20811:33:51.865 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [192.168.10.208]:19000: Peer died      (0 connected, 0 pending, 1 max)
20911:33:51.865 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - Not yet setting download peer because there is no clear candidate.
21011:33:51.865 [NioClientManager] DEBUG org.bitcoinj.core.BitcoinSerializer - Received 168 byte 'alert' message: 60010000000000000000000000ffffff7f00000000ffffff7ffeffff7f01ffffff7f00000000ffffff7f00ffffff7f002f555247454e543a20416c657274206b657920636f6d70726f6d697365642c2075706772616465207265717569726564004630440220653febd6410f470f6bae11cad19c48413becb1ac2c17f908fd0fd53bdc3abd5202206d0e9c96fe88d4a0f01ed9dedae2b6f9e00da94cad0fecaae66ecf689bf71b50
21111:33:51.866 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 999 ms before next connect attempt to [127.0.0.1]:19000
21211:33:51.866 [NioClientManager] DEBUG org.bitcoinj.core.Peer - Received alert from peer Peer{[192.168.10.208]:19000, version=70015, subVer=/Satoshi:0.19.1(bitcore)/, services=1033 (NETWORK, WITNESS, NETWORK_LIMITED), time=2021-11-06 11:33:52, height=5}: URGENT: Alert key compromised, upgrade required
21311:33:51.867 [NioClientManager] WARN  org.bitcoinj.net.ConnectionHandler - Error handling SelectionKey: java.nio.channels.CancelledKeyException 
214java.nio.channels.CancelledKeyException: null
215    at java.base/sun.nio.ch.SelectionKeyImpl.ensureValid(SelectionKeyImpl.java:71)
216    at java.base/sun.nio.ch.SelectionKeyImpl.readyOps(SelectionKeyImpl.java:130)
217    at java.base/java.nio.channels.SelectionKey.isWritable(SelectionKey.java:377)
218    at org.bitcoinj.net.ConnectionHandler.handleKey(ConnectionHandler.java:244)
219    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:86)
220    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
221    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
222    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
223    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
224    at java.base/java.lang.Thread.run(Thread.java:830)
22511:32:43.482 [NioClientManager] INFO  org.bitcoinj.core.Peer - Peer{[127.0.0.1]:19000, version=70015, subVer=/Satoshi:0.19.1(bitcore)/, services=1033 (NETWORK, WITNESS, NETWORK_LIMITED), time=2021-11-06 11:32:43, height=4}: Peer does not support bloom filtering.
226peerbloomfilters=1
227#13 922.4 g++: fatal error: Killed signal terminated program cc1plus
228#13 922.4 compilation terminated.
229#13 922.4 make[2]: *** [Makefile:8044: libbitcoin_server_a-init.o] Error 1
230#13 922.4 make[2]: *** Waiting for unfinished jobs....
231#13 965.8 make[2]: Leaving directory '/bitcoin-0.19.1/src'
232#13 965.8 make[1]: *** [Makefile:13765: all-recursive] Error 1
233#13 965.9 make[1]: Leaving directory '/bitcoin-0.19.1/src'
234#13 965.9 make: *** [Makefile:776: all-recursive] Error 1
235------
236executor failed running [/bin/sh -c tar -xzf *.tar.gz     &amp;&amp; cd bitcoin-${BITCOIN_VERSION}     &amp;&amp; sed -i 's/consensus.nSubsidyHalvingInterval = 150/consensus.nSubsidyHalvingInterval = 210000/g' src/chainparams.cpp     &amp;&amp; ./autogen.sh     &amp;&amp; ./configure LDFLAGS=-L`ls -d /opt/db`/lib/ CPPFLAGS=-I`ls -d /opt/db`/include/     --prefix=/opt/bitcoin     --disable-man     --disable-tests     --disable-bench     --disable-ccache     --with-gui=no     --enable-util-cli     --with-daemon     &amp;&amp; make -j4     &amp;&amp; make install     &amp;&amp; strip /opt/bitcoin/bin/bitcoin-cli     &amp;&amp; strip /opt/bitcoin/bin/bitcoind]: exit code: 2
237INFO  org.bitcoinj.core.PeerSocketHandler - [127.0.0.1]:19001: Timed out
238docker run -p 18444:19000 -d ulamlabs/bitcoind-custom-regtest:latest
239docker exec -it 0aa2e863cd9927 bash
240peerbloomfilters=1
241docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest getnewaddress
2422N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181
243

Then, as suggested in the Bitcoin documentation, in order to avoid an insufficient funds error, I generated 101 blocks to this address:

1docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli getnewaddress
2import org.bitcoinj.core.Address;
3import org.bitcoinj.core.Coin;
4import org.bitcoinj.core.NetworkParameters;
5import org.bitcoinj.core.Transaction;
6import org.bitcoinj.wallet.Wallet;
7import org.bitcoinj.wallet.listeners.WalletCoinsReceivedEventListener;
8
9public class WalletObserver {
10    public void init() {
11        final NetworkParameters netParams = NetworkParameters.fromID(NetworkParameters.ID_REGTEST);
12
13        try {
14            final Wallet wallet = Wallet.createBasic(netParams);
15
16            wallet.addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
17
18            wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
19                @Override
20                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
21                    System.out.println(&quot;Heyo!&quot;);
22                }
23            });
24        }
25        catch (Exception exception) {
26            exception.printStackTrace();
27        }
28    }
29}
30% docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.5
31068c377bab961356ad9a3919229a764aa929711c68aefd5dbd4c7c348eef3406
32    ports:
33      - &quot;51001:50001&quot;
34      - &quot;51002:50002&quot;
35      - &quot;19001:19001&quot;
36      - &quot;19000:19000&quot;
37      - &quot;28332:28332&quot;
38public class WalletObserver {
39    public void init() {
40        final LocalTestNetParams netParams = new LocalTestNetParams();
41        netParams.setPort(50001);
42        try {
43            final WalletAppKit kit = new WalletAppKit(netParams, new File(&quot;.&quot;), &quot;_minimalCryptoExchangeBtcWallet&quot;);
44            kit.setAutoSave(true);
45            kit.connectToLocalHost();
46
47            kit.startAsync();
48            kit.awaitRunning(); // I never get past this point
49            kit.peerGroup().addPeerDiscovery(new DnsDiscovery(netParams));
50            kit.wallet().addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
51
52            kit.wallet().addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
53                @Override
54                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
55                    System.out.println(&quot;Heyo!&quot;);
56                }
57            });
58        }
59        catch (Exception exception) {
60            exception.printStackTrace();
61        }
62    }
63package com.dpisarenko.minimalcryptoexchange.logic.btc;
64
65import org.bitcoinj.params.RegTestParams;
66
67public class LocalTestNetParams extends RegTestParams {
68    public void setPort(final int newPort) {
69        this.port = newPort;
70    }
71}
7222:16:34.245 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
7322:16:34.265 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
74java.net.ConnectException: Connection refused
75    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
76    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
77    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
78    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
79    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
80    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
81    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
82    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
83    at java.base/java.lang.Thread.run(Thread.java:830)
8422:16:34.267 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
8522:16:34.267 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 21.84 μs and returned 0 items from 0 discoverers
8622:16:34.269 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 1502 ms before next connect attempt to [10.10.1.218]:50001
8722:16:35.776 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
8822:16:35.778 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
89java.net.ConnectException: Connection refused
90    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
91    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
92    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
93    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
94    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
95    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
96    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
97    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
98    at java.base/java.lang.Thread.run(Thread.java:830)
9922:16:35.778 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
10022:16:35.779 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 8.752 μs and returned 0 items from 0 discoverers
101    public WalletAppKit connectToLocalHost() {
102        try {
103            InetAddress localHost = InetAddress.getLocalHost();
104            return this.setPeerNodes(new PeerAddress(this.params, localHost, this.params.getPort()));
105        } catch (UnknownHostException var2) {
106            throw new RuntimeException(var2);
107        }
108    }
109
110  node:
111    image: ulamlabs/bitcoind-custom-regtest:latest
112    network_mode: &quot;host&quot;
113minimal-crypto-exchange % docker-compose up -d
114Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
115Creating minimal-crypto-exchange_postgres_1  ... done
116Creating minimal-crypto-exchange_geth_1     ...
117Creating minimal-crypto-exchange_node_1     ... done
118Creating minimal-crypto-exchange_electrumx_1 ...
119Creating minimal-crypto-exchange_electrumx_1 ... error
120
121ERROR: for minimal-crypto-exchange_electrumx_1  Cannot start service electrumx: driver fail
122Creating minimal-crypto-exchange_geth_1      ... done
123f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
124Creating minimal-crypto-exchange_blockscout_1 ... done
125
126ERROR: for electrumx  Cannot start service electrumx: driver failed programming external connectivity on endpoint minimal-crypto-exchange_electrumx_1 (8eaa4f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
127ERROR: Encountered errors while bringing up the project.
128  electrumx:
129    image: lukechilds/electrumx:latest
130    network_mode: &quot;host&quot;
131minimal-crypto-exchange % docker-compose up -d
132minimal-crypto-exchange_postgres_1 is up-to-date
133minimal-crypto-exchange_geth_1 is up-to-date
134Recreating minimal-crypto-exchange_node_1 ...
135Recreating minimal-crypto-exchange_node_1 ... done
136Recreating minimal-crypto-exchange_electrumx_1 ...
137
138ERROR: for minimal-crypto-exchange_electrumx_1  &quot;host&quot; network_mode is incompatible with port_bindings
139
140ERROR: for electrumx  &quot;host&quot; network_mode is incompatible with port_bindings
141Traceback (most recent call last):
142  File &quot;docker-compose&quot;, line 3, in &lt;module&gt;
143  File &quot;compose/cli/main.py&quot;, line 81, in main
144  File &quot;compose/cli/main.py&quot;, line 203, in perform_command
145  File &quot;compose/metrics/decorator.py&quot;, line 18, in wrapper
146  File &quot;compose/cli/main.py&quot;, line 1186, in up
147  File &quot;compose/cli/main.py&quot;, line 1166, in up
148  File &quot;compose/project.py&quot;, line 697, in up
149  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
150  File &quot;compose/parallel.py&quot;, line 206, in producer
151  File &quot;compose/project.py&quot;, line 679, in do
152  File &quot;compose/service.py&quot;, line 579, in execute_convergence_plan
153  File &quot;compose/service.py&quot;, line 499, in _execute_convergence_recreate
154  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
155  File &quot;compose/parallel.py&quot;, line 206, in producer
156  File &quot;compose/service.py&quot;, line 494, in recreate
157  File &quot;compose/service.py&quot;, line 612, in recreate_container
158  File &quot;compose/service.py&quot;, line 330, in create_container
159  File &quot;compose/service.py&quot;, line 939, in _get_container_create_options
160  File &quot;compose/service.py&quot;, line 1014, in _get_container_host_config
161  File &quot;docker/api/container.py&quot;, line 598, in create_host_config
162  File &quot;docker/types/containers.py&quot;, line 338, in __init__
163docker.errors.InvalidArgument: &quot;host&quot; network_mode is incompatible with port_bindings
164[44262] Failed to execute script docker-compose
165  electrumx:
166    image: lukechilds/electrumx:latest
167    network_mode: host
168    links:
169      - node
170# Port settings see https://github.com/ulamlabs/bitcoind-custom-regtest
171#    ports:
172#      - &quot;51001:50001&quot;
173#      - &quot;51002:50002&quot;
174#      - &quot;19001:19001&quot;
175#      - &quot;19000:19000&quot;
176#      - &quot;28332:28332&quot;
177 % docker-compose up -d
178Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
179Creating minimal-crypto-exchange_geth_1 ...
180Creating minimal-crypto-exchange_postgres_1  ... done
181Creating minimal-crypto-exchange_node_1     ... done
182Creating minimal-crypto-exchange_electrumx_1 ... error
183Creating minimal-crypto-exchange_geth_1      ... done
184ERROR: for minimal-crypto-exchange_electrumx_1  Cannot create container for service electrumx: conflicting options: host type networking can't be used with links. This would result in undefined behavior
185Creating minimal-crypto-exchange_blockscout_1 ... done
186
187ERROR: for electrumx  Cannot create container for service electrumx: conflicting options: host type networking can't be used with links. This would result in undefined behavior
188ERROR: Encountered errors while bringing up the project.
189  node:
190    image: ulamlabs/bitcoind-custom-regtest:latest
191# For ports used by node see
192# https://github.com/ulamlabs/bitcoind-custom-regtest/blob/master/bitcoin.conf
193    ports:
194      - &quot;19001:19001&quot;
195      - &quot;19000:19000&quot;
196      - &quot;28332:28332&quot;
197  electrumx:
198    image: lukechilds/electrumx:latest
199    links:
200      - node
201# Port settings see https://github.com/ulamlabs/bitcoind-custom-regtest
202    ports:
203      - &quot;51001:50001&quot;
204      - &quot;51002:50002&quot;
205#      - &quot;19001:19001&quot;
206#      - &quot;19000:19000&quot;
207#      - &quot;28332:28332&quot;
20811:33:51.865 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [192.168.10.208]:19000: Peer died      (0 connected, 0 pending, 1 max)
20911:33:51.865 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - Not yet setting download peer because there is no clear candidate.
21011:33:51.865 [NioClientManager] DEBUG org.bitcoinj.core.BitcoinSerializer - Received 168 byte 'alert' message: 60010000000000000000000000ffffff7f00000000ffffff7ffeffff7f01ffffff7f00000000ffffff7f00ffffff7f002f555247454e543a20416c657274206b657920636f6d70726f6d697365642c2075706772616465207265717569726564004630440220653febd6410f470f6bae11cad19c48413becb1ac2c17f908fd0fd53bdc3abd5202206d0e9c96fe88d4a0f01ed9dedae2b6f9e00da94cad0fecaae66ecf689bf71b50
21111:33:51.866 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 999 ms before next connect attempt to [127.0.0.1]:19000
21211:33:51.866 [NioClientManager] DEBUG org.bitcoinj.core.Peer - Received alert from peer Peer{[192.168.10.208]:19000, version=70015, subVer=/Satoshi:0.19.1(bitcore)/, services=1033 (NETWORK, WITNESS, NETWORK_LIMITED), time=2021-11-06 11:33:52, height=5}: URGENT: Alert key compromised, upgrade required
21311:33:51.867 [NioClientManager] WARN  org.bitcoinj.net.ConnectionHandler - Error handling SelectionKey: java.nio.channels.CancelledKeyException 
214java.nio.channels.CancelledKeyException: null
215    at java.base/sun.nio.ch.SelectionKeyImpl.ensureValid(SelectionKeyImpl.java:71)
216    at java.base/sun.nio.ch.SelectionKeyImpl.readyOps(SelectionKeyImpl.java:130)
217    at java.base/java.nio.channels.SelectionKey.isWritable(SelectionKey.java:377)
218    at org.bitcoinj.net.ConnectionHandler.handleKey(ConnectionHandler.java:244)
219    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:86)
220    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
221    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
222    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
223    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
224    at java.base/java.lang.Thread.run(Thread.java:830)
22511:32:43.482 [NioClientManager] INFO  org.bitcoinj.core.Peer - Peer{[127.0.0.1]:19000, version=70015, subVer=/Satoshi:0.19.1(bitcore)/, services=1033 (NETWORK, WITNESS, NETWORK_LIMITED), time=2021-11-06 11:32:43, height=4}: Peer does not support bloom filtering.
226peerbloomfilters=1
227#13 922.4 g++: fatal error: Killed signal terminated program cc1plus
228#13 922.4 compilation terminated.
229#13 922.4 make[2]: *** [Makefile:8044: libbitcoin_server_a-init.o] Error 1
230#13 922.4 make[2]: *** Waiting for unfinished jobs....
231#13 965.8 make[2]: Leaving directory '/bitcoin-0.19.1/src'
232#13 965.8 make[1]: *** [Makefile:13765: all-recursive] Error 1
233#13 965.9 make[1]: Leaving directory '/bitcoin-0.19.1/src'
234#13 965.9 make: *** [Makefile:776: all-recursive] Error 1
235------
236executor failed running [/bin/sh -c tar -xzf *.tar.gz     &amp;&amp; cd bitcoin-${BITCOIN_VERSION}     &amp;&amp; sed -i 's/consensus.nSubsidyHalvingInterval = 150/consensus.nSubsidyHalvingInterval = 210000/g' src/chainparams.cpp     &amp;&amp; ./autogen.sh     &amp;&amp; ./configure LDFLAGS=-L`ls -d /opt/db`/lib/ CPPFLAGS=-I`ls -d /opt/db`/include/     --prefix=/opt/bitcoin     --disable-man     --disable-tests     --disable-bench     --disable-ccache     --with-gui=no     --enable-util-cli     --with-daemon     &amp;&amp; make -j4     &amp;&amp; make install     &amp;&amp; strip /opt/bitcoin/bin/bitcoin-cli     &amp;&amp; strip /opt/bitcoin/bin/bitcoind]: exit code: 2
237INFO  org.bitcoinj.core.PeerSocketHandler - [127.0.0.1]:19001: Timed out
238docker run -p 18444:19000 -d ulamlabs/bitcoind-custom-regtest:latest
239docker exec -it 0aa2e863cd9927 bash
240peerbloomfilters=1
241docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest getnewaddress
2422N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181
243docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest generatetoaddress 101 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 
244

I used generatetoaddress and not generate because since Bitcoin 0.19.0 the option is no longer valid.

Next, I prepared a simple Java program, based in the information you provided and this example from the Bitcoinj library documentation:

1docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli getnewaddress
2import org.bitcoinj.core.Address;
3import org.bitcoinj.core.Coin;
4import org.bitcoinj.core.NetworkParameters;
5import org.bitcoinj.core.Transaction;
6import org.bitcoinj.wallet.Wallet;
7import org.bitcoinj.wallet.listeners.WalletCoinsReceivedEventListener;
8
9public class WalletObserver {
10    public void init() {
11        final NetworkParameters netParams = NetworkParameters.fromID(NetworkParameters.ID_REGTEST);
12
13        try {
14            final Wallet wallet = Wallet.createBasic(netParams);
15
16            wallet.addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
17
18            wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
19                @Override
20                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
21                    System.out.println(&quot;Heyo!&quot;);
22                }
23            });
24        }
25        catch (Exception exception) {
26            exception.printStackTrace();
27        }
28    }
29}
30% docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.5
31068c377bab961356ad9a3919229a764aa929711c68aefd5dbd4c7c348eef3406
32    ports:
33      - &quot;51001:50001&quot;
34      - &quot;51002:50002&quot;
35      - &quot;19001:19001&quot;
36      - &quot;19000:19000&quot;
37      - &quot;28332:28332&quot;
38public class WalletObserver {
39    public void init() {
40        final LocalTestNetParams netParams = new LocalTestNetParams();
41        netParams.setPort(50001);
42        try {
43            final WalletAppKit kit = new WalletAppKit(netParams, new File(&quot;.&quot;), &quot;_minimalCryptoExchangeBtcWallet&quot;);
44            kit.setAutoSave(true);
45            kit.connectToLocalHost();
46
47            kit.startAsync();
48            kit.awaitRunning(); // I never get past this point
49            kit.peerGroup().addPeerDiscovery(new DnsDiscovery(netParams));
50            kit.wallet().addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
51
52            kit.wallet().addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
53                @Override
54                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
55                    System.out.println(&quot;Heyo!&quot;);
56                }
57            });
58        }
59        catch (Exception exception) {
60            exception.printStackTrace();
61        }
62    }
63package com.dpisarenko.minimalcryptoexchange.logic.btc;
64
65import org.bitcoinj.params.RegTestParams;
66
67public class LocalTestNetParams extends RegTestParams {
68    public void setPort(final int newPort) {
69        this.port = newPort;
70    }
71}
7222:16:34.245 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
7322:16:34.265 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
74java.net.ConnectException: Connection refused
75    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
76    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
77    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
78    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
79    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
80    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
81    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
82    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
83    at java.base/java.lang.Thread.run(Thread.java:830)
8422:16:34.267 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
8522:16:34.267 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 21.84 μs and returned 0 items from 0 discoverers
8622:16:34.269 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 1502 ms before next connect attempt to [10.10.1.218]:50001
8722:16:35.776 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
8822:16:35.778 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
89java.net.ConnectException: Connection refused
90    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
91    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
92    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
93    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
94    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
95    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
96    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
97    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
98    at java.base/java.lang.Thread.run(Thread.java:830)
9922:16:35.778 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
10022:16:35.779 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 8.752 μs and returned 0 items from 0 discoverers
101    public WalletAppKit connectToLocalHost() {
102        try {
103            InetAddress localHost = InetAddress.getLocalHost();
104            return this.setPeerNodes(new PeerAddress(this.params, localHost, this.params.getPort()));
105        } catch (UnknownHostException var2) {
106            throw new RuntimeException(var2);
107        }
108    }
109
110  node:
111    image: ulamlabs/bitcoind-custom-regtest:latest
112    network_mode: &quot;host&quot;
113minimal-crypto-exchange % docker-compose up -d
114Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
115Creating minimal-crypto-exchange_postgres_1  ... done
116Creating minimal-crypto-exchange_geth_1     ...
117Creating minimal-crypto-exchange_node_1     ... done
118Creating minimal-crypto-exchange_electrumx_1 ...
119Creating minimal-crypto-exchange_electrumx_1 ... error
120
121ERROR: for minimal-crypto-exchange_electrumx_1  Cannot start service electrumx: driver fail
122Creating minimal-crypto-exchange_geth_1      ... done
123f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
124Creating minimal-crypto-exchange_blockscout_1 ... done
125
126ERROR: for electrumx  Cannot start service electrumx: driver failed programming external connectivity on endpoint minimal-crypto-exchange_electrumx_1 (8eaa4f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
127ERROR: Encountered errors while bringing up the project.
128  electrumx:
129    image: lukechilds/electrumx:latest
130    network_mode: &quot;host&quot;
131minimal-crypto-exchange % docker-compose up -d
132minimal-crypto-exchange_postgres_1 is up-to-date
133minimal-crypto-exchange_geth_1 is up-to-date
134Recreating minimal-crypto-exchange_node_1 ...
135Recreating minimal-crypto-exchange_node_1 ... done
136Recreating minimal-crypto-exchange_electrumx_1 ...
137
138ERROR: for minimal-crypto-exchange_electrumx_1  &quot;host&quot; network_mode is incompatible with port_bindings
139
140ERROR: for electrumx  &quot;host&quot; network_mode is incompatible with port_bindings
141Traceback (most recent call last):
142  File &quot;docker-compose&quot;, line 3, in &lt;module&gt;
143  File &quot;compose/cli/main.py&quot;, line 81, in main
144  File &quot;compose/cli/main.py&quot;, line 203, in perform_command
145  File &quot;compose/metrics/decorator.py&quot;, line 18, in wrapper
146  File &quot;compose/cli/main.py&quot;, line 1186, in up
147  File &quot;compose/cli/main.py&quot;, line 1166, in up
148  File &quot;compose/project.py&quot;, line 697, in up
149  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
150  File &quot;compose/parallel.py&quot;, line 206, in producer
151  File &quot;compose/project.py&quot;, line 679, in do
152  File &quot;compose/service.py&quot;, line 579, in execute_convergence_plan
153  File &quot;compose/service.py&quot;, line 499, in _execute_convergence_recreate
154  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
155  File &quot;compose/parallel.py&quot;, line 206, in producer
156  File &quot;compose/service.py&quot;, line 494, in recreate
157  File &quot;compose/service.py&quot;, line 612, in recreate_container
158  File &quot;compose/service.py&quot;, line 330, in create_container
159  File &quot;compose/service.py&quot;, line 939, in _get_container_create_options
160  File &quot;compose/service.py&quot;, line 1014, in _get_container_host_config
161  File &quot;docker/api/container.py&quot;, line 598, in create_host_config
162  File &quot;docker/types/containers.py&quot;, line 338, in __init__
163docker.errors.InvalidArgument: &quot;host&quot; network_mode is incompatible with port_bindings
164[44262] Failed to execute script docker-compose
165  electrumx:
166    image: lukechilds/electrumx:latest
167    network_mode: host
168    links:
169      - node
170# Port settings see https://github.com/ulamlabs/bitcoind-custom-regtest
171#    ports:
172#      - &quot;51001:50001&quot;
173#      - &quot;51002:50002&quot;
174#      - &quot;19001:19001&quot;
175#      - &quot;19000:19000&quot;
176#      - &quot;28332:28332&quot;
177 % docker-compose up -d
178Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
179Creating minimal-crypto-exchange_geth_1 ...
180Creating minimal-crypto-exchange_postgres_1  ... done
181Creating minimal-crypto-exchange_node_1     ... done
182Creating minimal-crypto-exchange_electrumx_1 ... error
183Creating minimal-crypto-exchange_geth_1      ... done
184ERROR: for minimal-crypto-exchange_electrumx_1  Cannot create container for service electrumx: conflicting options: host type networking can't be used with links. This would result in undefined behavior
185Creating minimal-crypto-exchange_blockscout_1 ... done
186
187ERROR: for electrumx  Cannot create container for service electrumx: conflicting options: host type networking can't be used with links. This would result in undefined behavior
188ERROR: Encountered errors while bringing up the project.
189  node:
190    image: ulamlabs/bitcoind-custom-regtest:latest
191# For ports used by node see
192# https://github.com/ulamlabs/bitcoind-custom-regtest/blob/master/bitcoin.conf
193    ports:
194      - &quot;19001:19001&quot;
195      - &quot;19000:19000&quot;
196      - &quot;28332:28332&quot;
197  electrumx:
198    image: lukechilds/electrumx:latest
199    links:
200      - node
201# Port settings see https://github.com/ulamlabs/bitcoind-custom-regtest
202    ports:
203      - &quot;51001:50001&quot;
204      - &quot;51002:50002&quot;
205#      - &quot;19001:19001&quot;
206#      - &quot;19000:19000&quot;
207#      - &quot;28332:28332&quot;
20811:33:51.865 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [192.168.10.208]:19000: Peer died      (0 connected, 0 pending, 1 max)
20911:33:51.865 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - Not yet setting download peer because there is no clear candidate.
21011:33:51.865 [NioClientManager] DEBUG org.bitcoinj.core.BitcoinSerializer - Received 168 byte 'alert' message: 60010000000000000000000000ffffff7f00000000ffffff7ffeffff7f01ffffff7f00000000ffffff7f00ffffff7f002f555247454e543a20416c657274206b657920636f6d70726f6d697365642c2075706772616465207265717569726564004630440220653febd6410f470f6bae11cad19c48413becb1ac2c17f908fd0fd53bdc3abd5202206d0e9c96fe88d4a0f01ed9dedae2b6f9e00da94cad0fecaae66ecf689bf71b50
21111:33:51.866 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 999 ms before next connect attempt to [127.0.0.1]:19000
21211:33:51.866 [NioClientManager] DEBUG org.bitcoinj.core.Peer - Received alert from peer Peer{[192.168.10.208]:19000, version=70015, subVer=/Satoshi:0.19.1(bitcore)/, services=1033 (NETWORK, WITNESS, NETWORK_LIMITED), time=2021-11-06 11:33:52, height=5}: URGENT: Alert key compromised, upgrade required
21311:33:51.867 [NioClientManager] WARN  org.bitcoinj.net.ConnectionHandler - Error handling SelectionKey: java.nio.channels.CancelledKeyException 
214java.nio.channels.CancelledKeyException: null
215    at java.base/sun.nio.ch.SelectionKeyImpl.ensureValid(SelectionKeyImpl.java:71)
216    at java.base/sun.nio.ch.SelectionKeyImpl.readyOps(SelectionKeyImpl.java:130)
217    at java.base/java.nio.channels.SelectionKey.isWritable(SelectionKey.java:377)
218    at org.bitcoinj.net.ConnectionHandler.handleKey(ConnectionHandler.java:244)
219    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:86)
220    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
221    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
222    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
223    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
224    at java.base/java.lang.Thread.run(Thread.java:830)
22511:32:43.482 [NioClientManager] INFO  org.bitcoinj.core.Peer - Peer{[127.0.0.1]:19000, version=70015, subVer=/Satoshi:0.19.1(bitcore)/, services=1033 (NETWORK, WITNESS, NETWORK_LIMITED), time=2021-11-06 11:32:43, height=4}: Peer does not support bloom filtering.
226peerbloomfilters=1
227#13 922.4 g++: fatal error: Killed signal terminated program cc1plus
228#13 922.4 compilation terminated.
229#13 922.4 make[2]: *** [Makefile:8044: libbitcoin_server_a-init.o] Error 1
230#13 922.4 make[2]: *** Waiting for unfinished jobs....
231#13 965.8 make[2]: Leaving directory '/bitcoin-0.19.1/src'
232#13 965.8 make[1]: *** [Makefile:13765: all-recursive] Error 1
233#13 965.9 make[1]: Leaving directory '/bitcoin-0.19.1/src'
234#13 965.9 make: *** [Makefile:776: all-recursive] Error 1
235------
236executor failed running [/bin/sh -c tar -xzf *.tar.gz     &amp;&amp; cd bitcoin-${BITCOIN_VERSION}     &amp;&amp; sed -i 's/consensus.nSubsidyHalvingInterval = 150/consensus.nSubsidyHalvingInterval = 210000/g' src/chainparams.cpp     &amp;&amp; ./autogen.sh     &amp;&amp; ./configure LDFLAGS=-L`ls -d /opt/db`/lib/ CPPFLAGS=-I`ls -d /opt/db`/include/     --prefix=/opt/bitcoin     --disable-man     --disable-tests     --disable-bench     --disable-ccache     --with-gui=no     --enable-util-cli     --with-daemon     &amp;&amp; make -j4     &amp;&amp; make install     &amp;&amp; strip /opt/bitcoin/bin/bitcoin-cli     &amp;&amp; strip /opt/bitcoin/bin/bitcoind]: exit code: 2
237INFO  org.bitcoinj.core.PeerSocketHandler - [127.0.0.1]:19001: Timed out
238docker run -p 18444:19000 -d ulamlabs/bitcoind-custom-regtest:latest
239docker exec -it 0aa2e863cd9927 bash
240peerbloomfilters=1
241docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest getnewaddress
2422N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181
243docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest generatetoaddress 101 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 
244import java.io.File;
245
246import org.bitcoinj.core.Address;
247import org.bitcoinj.core.NetworkParameters;
248import org.bitcoinj.kits.WalletAppKit;
249import org.bitcoinj.params.RegTestParams;
250
251public class Kit {
252
253  public static void main(String[] args) {
254    Kit kit  = new Kit();
255    kit.run();
256  }
257
258  private synchronized void run(){
259    NetworkParameters params = RegTestParams.get();
260    WalletAppKit kit = new WalletAppKit(params, new File(&quot;.&quot;), &quot;walletappkit-example&quot;);
261    kit.connectToLocalHost();
262
263    kit.startAsync();
264    kit.awaitRunning();
265
266    kit.wallet().addWatchedAddress(Address.fromString(params, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
267
268    kit.wallet().addCoinsReceivedEventListener((wallet, tx, prevBalance, newBalance) -&gt; {
269      System.out.println(&quot;-----&gt; coins resceived: &quot; + tx.getTxId());
270    });
271
272    while (true) {
273      try {
274        this.wait(2000);
275      } catch (InterruptedException e) {
276        e.printStackTrace();
277      }
278    }
279  }
280}
281

I used a simple while loop to keep the problem running; of course, if will be probably unnecessary in an actual setup as it seems you are using Spring Boot.

Then, if you send some bitcoins to this address:

1docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli getnewaddress
2import org.bitcoinj.core.Address;
3import org.bitcoinj.core.Coin;
4import org.bitcoinj.core.NetworkParameters;
5import org.bitcoinj.core.Transaction;
6import org.bitcoinj.wallet.Wallet;
7import org.bitcoinj.wallet.listeners.WalletCoinsReceivedEventListener;
8
9public class WalletObserver {
10    public void init() {
11        final NetworkParameters netParams = NetworkParameters.fromID(NetworkParameters.ID_REGTEST);
12
13        try {
14            final Wallet wallet = Wallet.createBasic(netParams);
15
16            wallet.addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
17
18            wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
19                @Override
20                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
21                    System.out.println(&quot;Heyo!&quot;);
22                }
23            });
24        }
25        catch (Exception exception) {
26            exception.printStackTrace();
27        }
28    }
29}
30% docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.5
31068c377bab961356ad9a3919229a764aa929711c68aefd5dbd4c7c348eef3406
32    ports:
33      - &quot;51001:50001&quot;
34      - &quot;51002:50002&quot;
35      - &quot;19001:19001&quot;
36      - &quot;19000:19000&quot;
37      - &quot;28332:28332&quot;
38public class WalletObserver {
39    public void init() {
40        final LocalTestNetParams netParams = new LocalTestNetParams();
41        netParams.setPort(50001);
42        try {
43            final WalletAppKit kit = new WalletAppKit(netParams, new File(&quot;.&quot;), &quot;_minimalCryptoExchangeBtcWallet&quot;);
44            kit.setAutoSave(true);
45            kit.connectToLocalHost();
46
47            kit.startAsync();
48            kit.awaitRunning(); // I never get past this point
49            kit.peerGroup().addPeerDiscovery(new DnsDiscovery(netParams));
50            kit.wallet().addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
51
52            kit.wallet().addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
53                @Override
54                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
55                    System.out.println(&quot;Heyo!&quot;);
56                }
57            });
58        }
59        catch (Exception exception) {
60            exception.printStackTrace();
61        }
62    }
63package com.dpisarenko.minimalcryptoexchange.logic.btc;
64
65import org.bitcoinj.params.RegTestParams;
66
67public class LocalTestNetParams extends RegTestParams {
68    public void setPort(final int newPort) {
69        this.port = newPort;
70    }
71}
7222:16:34.245 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
7322:16:34.265 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
74java.net.ConnectException: Connection refused
75    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
76    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
77    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
78    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
79    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
80    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
81    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
82    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
83    at java.base/java.lang.Thread.run(Thread.java:830)
8422:16:34.267 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
8522:16:34.267 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 21.84 μs and returned 0 items from 0 discoverers
8622:16:34.269 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 1502 ms before next connect attempt to [10.10.1.218]:50001
8722:16:35.776 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
8822:16:35.778 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
89java.net.ConnectException: Connection refused
90    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
91    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
92    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
93    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
94    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
95    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
96    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
97    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
98    at java.base/java.lang.Thread.run(Thread.java:830)
9922:16:35.778 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
10022:16:35.779 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 8.752 μs and returned 0 items from 0 discoverers
101    public WalletAppKit connectToLocalHost() {
102        try {
103            InetAddress localHost = InetAddress.getLocalHost();
104            return this.setPeerNodes(new PeerAddress(this.params, localHost, this.params.getPort()));
105        } catch (UnknownHostException var2) {
106            throw new RuntimeException(var2);
107        }
108    }
109
110  node:
111    image: ulamlabs/bitcoind-custom-regtest:latest
112    network_mode: &quot;host&quot;
113minimal-crypto-exchange % docker-compose up -d
114Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
115Creating minimal-crypto-exchange_postgres_1  ... done
116Creating minimal-crypto-exchange_geth_1     ...
117Creating minimal-crypto-exchange_node_1     ... done
118Creating minimal-crypto-exchange_electrumx_1 ...
119Creating minimal-crypto-exchange_electrumx_1 ... error
120
121ERROR: for minimal-crypto-exchange_electrumx_1  Cannot start service electrumx: driver fail
122Creating minimal-crypto-exchange_geth_1      ... done
123f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
124Creating minimal-crypto-exchange_blockscout_1 ... done
125
126ERROR: for electrumx  Cannot start service electrumx: driver failed programming external connectivity on endpoint minimal-crypto-exchange_electrumx_1 (8eaa4f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
127ERROR: Encountered errors while bringing up the project.
128  electrumx:
129    image: lukechilds/electrumx:latest
130    network_mode: &quot;host&quot;
131minimal-crypto-exchange % docker-compose up -d
132minimal-crypto-exchange_postgres_1 is up-to-date
133minimal-crypto-exchange_geth_1 is up-to-date
134Recreating minimal-crypto-exchange_node_1 ...
135Recreating minimal-crypto-exchange_node_1 ... done
136Recreating minimal-crypto-exchange_electrumx_1 ...
137
138ERROR: for minimal-crypto-exchange_electrumx_1  &quot;host&quot; network_mode is incompatible with port_bindings
139
140ERROR: for electrumx  &quot;host&quot; network_mode is incompatible with port_bindings
141Traceback (most recent call last):
142  File &quot;docker-compose&quot;, line 3, in &lt;module&gt;
143  File &quot;compose/cli/main.py&quot;, line 81, in main
144  File &quot;compose/cli/main.py&quot;, line 203, in perform_command
145  File &quot;compose/metrics/decorator.py&quot;, line 18, in wrapper
146  File &quot;compose/cli/main.py&quot;, line 1186, in up
147  File &quot;compose/cli/main.py&quot;, line 1166, in up
148  File &quot;compose/project.py&quot;, line 697, in up
149  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
150  File &quot;compose/parallel.py&quot;, line 206, in producer
151  File &quot;compose/project.py&quot;, line 679, in do
152  File &quot;compose/service.py&quot;, line 579, in execute_convergence_plan
153  File &quot;compose/service.py&quot;, line 499, in _execute_convergence_recreate
154  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
155  File &quot;compose/parallel.py&quot;, line 206, in producer
156  File &quot;compose/service.py&quot;, line 494, in recreate
157  File &quot;compose/service.py&quot;, line 612, in recreate_container
158  File &quot;compose/service.py&quot;, line 330, in create_container
159  File &quot;compose/service.py&quot;, line 939, in _get_container_create_options
160  File &quot;compose/service.py&quot;, line 1014, in _get_container_host_config
161  File &quot;docker/api/container.py&quot;, line 598, in create_host_config
162  File &quot;docker/types/containers.py&quot;, line 338, in __init__
163docker.errors.InvalidArgument: &quot;host&quot; network_mode is incompatible with port_bindings
164[44262] Failed to execute script docker-compose
165  electrumx:
166    image: lukechilds/electrumx:latest
167    network_mode: host
168    links:
169      - node
170# Port settings see https://github.com/ulamlabs/bitcoind-custom-regtest
171#    ports:
172#      - &quot;51001:50001&quot;
173#      - &quot;51002:50002&quot;
174#      - &quot;19001:19001&quot;
175#      - &quot;19000:19000&quot;
176#      - &quot;28332:28332&quot;
177 % docker-compose up -d
178Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
179Creating minimal-crypto-exchange_geth_1 ...
180Creating minimal-crypto-exchange_postgres_1  ... done
181Creating minimal-crypto-exchange_node_1     ... done
182Creating minimal-crypto-exchange_electrumx_1 ... error
183Creating minimal-crypto-exchange_geth_1      ... done
184ERROR: for minimal-crypto-exchange_electrumx_1  Cannot create container for service electrumx: conflicting options: host type networking can't be used with links. This would result in undefined behavior
185Creating minimal-crypto-exchange_blockscout_1 ... done
186
187ERROR: for electrumx  Cannot create container for service electrumx: conflicting options: host type networking can't be used with links. This would result in undefined behavior
188ERROR: Encountered errors while bringing up the project.
189  node:
190    image: ulamlabs/bitcoind-custom-regtest:latest
191# For ports used by node see
192# https://github.com/ulamlabs/bitcoind-custom-regtest/blob/master/bitcoin.conf
193    ports:
194      - &quot;19001:19001&quot;
195      - &quot;19000:19000&quot;
196      - &quot;28332:28332&quot;
197  electrumx:
198    image: lukechilds/electrumx:latest
199    links:
200      - node
201# Port settings see https://github.com/ulamlabs/bitcoind-custom-regtest
202    ports:
203      - &quot;51001:50001&quot;
204      - &quot;51002:50002&quot;
205#      - &quot;19001:19001&quot;
206#      - &quot;19000:19000&quot;
207#      - &quot;28332:28332&quot;
20811:33:51.865 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [192.168.10.208]:19000: Peer died      (0 connected, 0 pending, 1 max)
20911:33:51.865 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - Not yet setting download peer because there is no clear candidate.
21011:33:51.865 [NioClientManager] DEBUG org.bitcoinj.core.BitcoinSerializer - Received 168 byte 'alert' message: 60010000000000000000000000ffffff7f00000000ffffff7ffeffff7f01ffffff7f00000000ffffff7f00ffffff7f002f555247454e543a20416c657274206b657920636f6d70726f6d697365642c2075706772616465207265717569726564004630440220653febd6410f470f6bae11cad19c48413becb1ac2c17f908fd0fd53bdc3abd5202206d0e9c96fe88d4a0f01ed9dedae2b6f9e00da94cad0fecaae66ecf689bf71b50
21111:33:51.866 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 999 ms before next connect attempt to [127.0.0.1]:19000
21211:33:51.866 [NioClientManager] DEBUG org.bitcoinj.core.Peer - Received alert from peer Peer{[192.168.10.208]:19000, version=70015, subVer=/Satoshi:0.19.1(bitcore)/, services=1033 (NETWORK, WITNESS, NETWORK_LIMITED), time=2021-11-06 11:33:52, height=5}: URGENT: Alert key compromised, upgrade required
21311:33:51.867 [NioClientManager] WARN  org.bitcoinj.net.ConnectionHandler - Error handling SelectionKey: java.nio.channels.CancelledKeyException 
214java.nio.channels.CancelledKeyException: null
215    at java.base/sun.nio.ch.SelectionKeyImpl.ensureValid(SelectionKeyImpl.java:71)
216    at java.base/sun.nio.ch.SelectionKeyImpl.readyOps(SelectionKeyImpl.java:130)
217    at java.base/java.nio.channels.SelectionKey.isWritable(SelectionKey.java:377)
218    at org.bitcoinj.net.ConnectionHandler.handleKey(ConnectionHandler.java:244)
219    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:86)
220    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
221    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
222    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
223    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
224    at java.base/java.lang.Thread.run(Thread.java:830)
22511:32:43.482 [NioClientManager] INFO  org.bitcoinj.core.Peer - Peer{[127.0.0.1]:19000, version=70015, subVer=/Satoshi:0.19.1(bitcore)/, services=1033 (NETWORK, WITNESS, NETWORK_LIMITED), time=2021-11-06 11:32:43, height=4}: Peer does not support bloom filtering.
226peerbloomfilters=1
227#13 922.4 g++: fatal error: Killed signal terminated program cc1plus
228#13 922.4 compilation terminated.
229#13 922.4 make[2]: *** [Makefile:8044: libbitcoin_server_a-init.o] Error 1
230#13 922.4 make[2]: *** Waiting for unfinished jobs....
231#13 965.8 make[2]: Leaving directory '/bitcoin-0.19.1/src'
232#13 965.8 make[1]: *** [Makefile:13765: all-recursive] Error 1
233#13 965.9 make[1]: Leaving directory '/bitcoin-0.19.1/src'
234#13 965.9 make: *** [Makefile:776: all-recursive] Error 1
235------
236executor failed running [/bin/sh -c tar -xzf *.tar.gz     &amp;&amp; cd bitcoin-${BITCOIN_VERSION}     &amp;&amp; sed -i 's/consensus.nSubsidyHalvingInterval = 150/consensus.nSubsidyHalvingInterval = 210000/g' src/chainparams.cpp     &amp;&amp; ./autogen.sh     &amp;&amp; ./configure LDFLAGS=-L`ls -d /opt/db`/lib/ CPPFLAGS=-I`ls -d /opt/db`/include/     --prefix=/opt/bitcoin     --disable-man     --disable-tests     --disable-bench     --disable-ccache     --with-gui=no     --enable-util-cli     --with-daemon     &amp;&amp; make -j4     &amp;&amp; make install     &amp;&amp; strip /opt/bitcoin/bin/bitcoin-cli     &amp;&amp; strip /opt/bitcoin/bin/bitcoind]: exit code: 2
237INFO  org.bitcoinj.core.PeerSocketHandler - [127.0.0.1]:19001: Timed out
238docker run -p 18444:19000 -d ulamlabs/bitcoind-custom-regtest:latest
239docker exec -it 0aa2e863cd9927 bash
240peerbloomfilters=1
241docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest getnewaddress
2422N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181
243docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest generatetoaddress 101 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 
244import java.io.File;
245
246import org.bitcoinj.core.Address;
247import org.bitcoinj.core.NetworkParameters;
248import org.bitcoinj.kits.WalletAppKit;
249import org.bitcoinj.params.RegTestParams;
250
251public class Kit {
252
253  public static void main(String[] args) {
254    Kit kit  = new Kit();
255    kit.run();
256  }
257
258  private synchronized void run(){
259    NetworkParameters params = RegTestParams.get();
260    WalletAppKit kit = new WalletAppKit(params, new File(&quot;.&quot;), &quot;walletappkit-example&quot;);
261    kit.connectToLocalHost();
262
263    kit.startAsync();
264    kit.awaitRunning();
265
266    kit.wallet().addWatchedAddress(Address.fromString(params, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
267
268    kit.wallet().addCoinsReceivedEventListener((wallet, tx, prevBalance, newBalance) -&gt; {
269      System.out.println(&quot;-----&gt; coins resceived: &quot; + tx.getTxId());
270    });
271
272    while (true) {
273      try {
274        this.wait(2000);
275      } catch (InterruptedException e) {
276        e.printStackTrace();
277      }
278    }
279  }
280}
281docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.00001
2820f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
283

The listener should be invoked:

1docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli getnewaddress
2import org.bitcoinj.core.Address;
3import org.bitcoinj.core.Coin;
4import org.bitcoinj.core.NetworkParameters;
5import org.bitcoinj.core.Transaction;
6import org.bitcoinj.wallet.Wallet;
7import org.bitcoinj.wallet.listeners.WalletCoinsReceivedEventListener;
8
9public class WalletObserver {
10    public void init() {
11        final NetworkParameters netParams = NetworkParameters.fromID(NetworkParameters.ID_REGTEST);
12
13        try {
14            final Wallet wallet = Wallet.createBasic(netParams);
15
16            wallet.addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
17
18            wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
19                @Override
20                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
21                    System.out.println(&quot;Heyo!&quot;);
22                }
23            });
24        }
25        catch (Exception exception) {
26            exception.printStackTrace();
27        }
28    }
29}
30% docker exec -it minimal-crypto-exchange_node_1 bitcoin-cli sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.5
31068c377bab961356ad9a3919229a764aa929711c68aefd5dbd4c7c348eef3406
32    ports:
33      - &quot;51001:50001&quot;
34      - &quot;51002:50002&quot;
35      - &quot;19001:19001&quot;
36      - &quot;19000:19000&quot;
37      - &quot;28332:28332&quot;
38public class WalletObserver {
39    public void init() {
40        final LocalTestNetParams netParams = new LocalTestNetParams();
41        netParams.setPort(50001);
42        try {
43            final WalletAppKit kit = new WalletAppKit(netParams, new File(&quot;.&quot;), &quot;_minimalCryptoExchangeBtcWallet&quot;);
44            kit.setAutoSave(true);
45            kit.connectToLocalHost();
46
47            kit.startAsync();
48            kit.awaitRunning(); // I never get past this point
49            kit.peerGroup().addPeerDiscovery(new DnsDiscovery(netParams));
50            kit.wallet().addWatchedAddress(Address.fromString(netParams, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
51
52            kit.wallet().addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
53                @Override
54                public void onCoinsReceived(final Wallet wallet, final Transaction transaction, final Coin prevBalance, final Coin newBalance) {
55                    System.out.println(&quot;Heyo!&quot;);
56                }
57            });
58        }
59        catch (Exception exception) {
60            exception.printStackTrace();
61        }
62    }
63package com.dpisarenko.minimalcryptoexchange.logic.btc;
64
65import org.bitcoinj.params.RegTestParams;
66
67public class LocalTestNetParams extends RegTestParams {
68    public void setPort(final int newPort) {
69        this.port = newPort;
70    }
71}
7222:16:34.245 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
7322:16:34.265 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
74java.net.ConnectException: Connection refused
75    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
76    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
77    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
78    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
79    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
80    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
81    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
82    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
83    at java.base/java.lang.Thread.run(Thread.java:830)
8422:16:34.267 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
8522:16:34.267 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 21.84 μs and returned 0 items from 0 discoverers
8622:16:34.269 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 1502 ms before next connect attempt to [10.10.1.218]:50001
8722:16:35.776 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Attempting connection to [10.10.1.218]:50001     (0 connected, 1 pending, 1 max)
8822:16:35.778 [NioClientManager] WARN  org.bitcoinj.net.NioClientManager - Failed to connect with exception: java.net.ConnectException: Connection refused
89java.net.ConnectException: Connection refused
90    at java.base/sun.nio.ch.Net.pollConnect(Native Method)
91    at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:579)
92    at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:820)
93    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:64)
94    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
95    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
96    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
97    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
98    at java.base/java.lang.Thread.run(Thread.java:830)
9922:16:35.778 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [10.10.1.218]:50001: Peer died      (0 connected, 0 pending, 1 max)
10022:16:35.779 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Peer discovery took 8.752 μs and returned 0 items from 0 discoverers
101    public WalletAppKit connectToLocalHost() {
102        try {
103            InetAddress localHost = InetAddress.getLocalHost();
104            return this.setPeerNodes(new PeerAddress(this.params, localHost, this.params.getPort()));
105        } catch (UnknownHostException var2) {
106            throw new RuntimeException(var2);
107        }
108    }
109
110  node:
111    image: ulamlabs/bitcoind-custom-regtest:latest
112    network_mode: &quot;host&quot;
113minimal-crypto-exchange % docker-compose up -d
114Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
115Creating minimal-crypto-exchange_postgres_1  ... done
116Creating minimal-crypto-exchange_geth_1     ...
117Creating minimal-crypto-exchange_node_1     ... done
118Creating minimal-crypto-exchange_electrumx_1 ...
119Creating minimal-crypto-exchange_electrumx_1 ... error
120
121ERROR: for minimal-crypto-exchange_electrumx_1  Cannot start service electrumx: driver fail
122Creating minimal-crypto-exchange_geth_1      ... done
123f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
124Creating minimal-crypto-exchange_blockscout_1 ... done
125
126ERROR: for electrumx  Cannot start service electrumx: driver failed programming external connectivity on endpoint minimal-crypto-exchange_electrumx_1 (8eaa4f68d0f25a0512399877bc55434513def810649e4fcf31a5a88ca3292d34): Error starting userland proxy: listen tcp4 0.0.0.0:28332: bind: address already in use
127ERROR: Encountered errors while bringing up the project.
128  electrumx:
129    image: lukechilds/electrumx:latest
130    network_mode: &quot;host&quot;
131minimal-crypto-exchange % docker-compose up -d
132minimal-crypto-exchange_postgres_1 is up-to-date
133minimal-crypto-exchange_geth_1 is up-to-date
134Recreating minimal-crypto-exchange_node_1 ...
135Recreating minimal-crypto-exchange_node_1 ... done
136Recreating minimal-crypto-exchange_electrumx_1 ...
137
138ERROR: for minimal-crypto-exchange_electrumx_1  &quot;host&quot; network_mode is incompatible with port_bindings
139
140ERROR: for electrumx  &quot;host&quot; network_mode is incompatible with port_bindings
141Traceback (most recent call last):
142  File &quot;docker-compose&quot;, line 3, in &lt;module&gt;
143  File &quot;compose/cli/main.py&quot;, line 81, in main
144  File &quot;compose/cli/main.py&quot;, line 203, in perform_command
145  File &quot;compose/metrics/decorator.py&quot;, line 18, in wrapper
146  File &quot;compose/cli/main.py&quot;, line 1186, in up
147  File &quot;compose/cli/main.py&quot;, line 1166, in up
148  File &quot;compose/project.py&quot;, line 697, in up
149  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
150  File &quot;compose/parallel.py&quot;, line 206, in producer
151  File &quot;compose/project.py&quot;, line 679, in do
152  File &quot;compose/service.py&quot;, line 579, in execute_convergence_plan
153  File &quot;compose/service.py&quot;, line 499, in _execute_convergence_recreate
154  File &quot;compose/parallel.py&quot;, line 108, in parallel_execute
155  File &quot;compose/parallel.py&quot;, line 206, in producer
156  File &quot;compose/service.py&quot;, line 494, in recreate
157  File &quot;compose/service.py&quot;, line 612, in recreate_container
158  File &quot;compose/service.py&quot;, line 330, in create_container
159  File &quot;compose/service.py&quot;, line 939, in _get_container_create_options
160  File &quot;compose/service.py&quot;, line 1014, in _get_container_host_config
161  File &quot;docker/api/container.py&quot;, line 598, in create_host_config
162  File &quot;docker/types/containers.py&quot;, line 338, in __init__
163docker.errors.InvalidArgument: &quot;host&quot; network_mode is incompatible with port_bindings
164[44262] Failed to execute script docker-compose
165  electrumx:
166    image: lukechilds/electrumx:latest
167    network_mode: host
168    links:
169      - node
170# Port settings see https://github.com/ulamlabs/bitcoind-custom-regtest
171#    ports:
172#      - &quot;51001:50001&quot;
173#      - &quot;51002:50002&quot;
174#      - &quot;19001:19001&quot;
175#      - &quot;19000:19000&quot;
176#      - &quot;28332:28332&quot;
177 % docker-compose up -d
178Creating network &quot;minimal-crypto-exchange_default&quot; with the default driver
179Creating minimal-crypto-exchange_geth_1 ...
180Creating minimal-crypto-exchange_postgres_1  ... done
181Creating minimal-crypto-exchange_node_1     ... done
182Creating minimal-crypto-exchange_electrumx_1 ... error
183Creating minimal-crypto-exchange_geth_1      ... done
184ERROR: for minimal-crypto-exchange_electrumx_1  Cannot create container for service electrumx: conflicting options: host type networking can't be used with links. This would result in undefined behavior
185Creating minimal-crypto-exchange_blockscout_1 ... done
186
187ERROR: for electrumx  Cannot create container for service electrumx: conflicting options: host type networking can't be used with links. This would result in undefined behavior
188ERROR: Encountered errors while bringing up the project.
189  node:
190    image: ulamlabs/bitcoind-custom-regtest:latest
191# For ports used by node see
192# https://github.com/ulamlabs/bitcoind-custom-regtest/blob/master/bitcoin.conf
193    ports:
194      - &quot;19001:19001&quot;
195      - &quot;19000:19000&quot;
196      - &quot;28332:28332&quot;
197  electrumx:
198    image: lukechilds/electrumx:latest
199    links:
200      - node
201# Port settings see https://github.com/ulamlabs/bitcoind-custom-regtest
202    ports:
203      - &quot;51001:50001&quot;
204      - &quot;51002:50002&quot;
205#      - &quot;19001:19001&quot;
206#      - &quot;19000:19000&quot;
207#      - &quot;28332:28332&quot;
20811:33:51.865 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - [192.168.10.208]:19000: Peer died      (0 connected, 0 pending, 1 max)
20911:33:51.865 [NioClientManager] INFO  org.bitcoinj.core.PeerGroup - Not yet setting download peer because there is no clear candidate.
21011:33:51.865 [NioClientManager] DEBUG org.bitcoinj.core.BitcoinSerializer - Received 168 byte 'alert' message: 60010000000000000000000000ffffff7f00000000ffffff7ffeffff7f01ffffff7f00000000ffffff7f00ffffff7f002f555247454e543a20416c657274206b657920636f6d70726f6d697365642c2075706772616465207265717569726564004630440220653febd6410f470f6bae11cad19c48413becb1ac2c17f908fd0fd53bdc3abd5202206d0e9c96fe88d4a0f01ed9dedae2b6f9e00da94cad0fecaae66ecf689bf71b50
21111:33:51.866 [PeerGroup Thread] INFO  org.bitcoinj.core.PeerGroup - Waiting 999 ms before next connect attempt to [127.0.0.1]:19000
21211:33:51.866 [NioClientManager] DEBUG org.bitcoinj.core.Peer - Received alert from peer Peer{[192.168.10.208]:19000, version=70015, subVer=/Satoshi:0.19.1(bitcore)/, services=1033 (NETWORK, WITNESS, NETWORK_LIMITED), time=2021-11-06 11:33:52, height=5}: URGENT: Alert key compromised, upgrade required
21311:33:51.867 [NioClientManager] WARN  org.bitcoinj.net.ConnectionHandler - Error handling SelectionKey: java.nio.channels.CancelledKeyException 
214java.nio.channels.CancelledKeyException: null
215    at java.base/sun.nio.ch.SelectionKeyImpl.ensureValid(SelectionKeyImpl.java:71)
216    at java.base/sun.nio.ch.SelectionKeyImpl.readyOps(SelectionKeyImpl.java:130)
217    at java.base/java.nio.channels.SelectionKey.isWritable(SelectionKey.java:377)
218    at org.bitcoinj.net.ConnectionHandler.handleKey(ConnectionHandler.java:244)
219    at org.bitcoinj.net.NioClientManager.handleKey(NioClientManager.java:86)
220    at org.bitcoinj.net.NioClientManager.run(NioClientManager.java:122)
221    at com.google.common.util.concurrent.AbstractExecutionThreadService$1$2.run(AbstractExecutionThreadService.java:66)
222    at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
223    at org.bitcoinj.utils.ContextPropagatingThreadFactory$1.run(ContextPropagatingThreadFactory.java:51)
224    at java.base/java.lang.Thread.run(Thread.java:830)
22511:32:43.482 [NioClientManager] INFO  org.bitcoinj.core.Peer - Peer{[127.0.0.1]:19000, version=70015, subVer=/Satoshi:0.19.1(bitcore)/, services=1033 (NETWORK, WITNESS, NETWORK_LIMITED), time=2021-11-06 11:32:43, height=4}: Peer does not support bloom filtering.
226peerbloomfilters=1
227#13 922.4 g++: fatal error: Killed signal terminated program cc1plus
228#13 922.4 compilation terminated.
229#13 922.4 make[2]: *** [Makefile:8044: libbitcoin_server_a-init.o] Error 1
230#13 922.4 make[2]: *** Waiting for unfinished jobs....
231#13 965.8 make[2]: Leaving directory '/bitcoin-0.19.1/src'
232#13 965.8 make[1]: *** [Makefile:13765: all-recursive] Error 1
233#13 965.9 make[1]: Leaving directory '/bitcoin-0.19.1/src'
234#13 965.9 make: *** [Makefile:776: all-recursive] Error 1
235------
236executor failed running [/bin/sh -c tar -xzf *.tar.gz     &amp;&amp; cd bitcoin-${BITCOIN_VERSION}     &amp;&amp; sed -i 's/consensus.nSubsidyHalvingInterval = 150/consensus.nSubsidyHalvingInterval = 210000/g' src/chainparams.cpp     &amp;&amp; ./autogen.sh     &amp;&amp; ./configure LDFLAGS=-L`ls -d /opt/db`/lib/ CPPFLAGS=-I`ls -d /opt/db`/include/     --prefix=/opt/bitcoin     --disable-man     --disable-tests     --disable-bench     --disable-ccache     --with-gui=no     --enable-util-cli     --with-daemon     &amp;&amp; make -j4     &amp;&amp; make install     &amp;&amp; strip /opt/bitcoin/bin/bitcoin-cli     &amp;&amp; strip /opt/bitcoin/bin/bitcoind]: exit code: 2
237INFO  org.bitcoinj.core.PeerSocketHandler - [127.0.0.1]:19001: Timed out
238docker run -p 18444:19000 -d ulamlabs/bitcoind-custom-regtest:latest
239docker exec -it 0aa2e863cd9927 bash
240peerbloomfilters=1
241docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest getnewaddress
2422N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181
243docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest generatetoaddress 101 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 
244import java.io.File;
245
246import org.bitcoinj.core.Address;
247import org.bitcoinj.core.NetworkParameters;
248import org.bitcoinj.kits.WalletAppKit;
249import org.bitcoinj.params.RegTestParams;
250
251public class Kit {
252
253  public static void main(String[] args) {
254    Kit kit  = new Kit();
255    kit.run();
256  }
257
258  private synchronized void run(){
259    NetworkParameters params = RegTestParams.get();
260    WalletAppKit kit = new WalletAppKit(params, new File(&quot;.&quot;), &quot;walletappkit-example&quot;);
261    kit.connectToLocalHost();
262
263    kit.startAsync();
264    kit.awaitRunning();
265
266    kit.wallet().addWatchedAddress(Address.fromString(params, &quot;2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181&quot;));
267
268    kit.wallet().addCoinsReceivedEventListener((wallet, tx, prevBalance, newBalance) -&gt; {
269      System.out.println(&quot;-----&gt; coins resceived: &quot; + tx.getTxId());
270    });
271
272    while (true) {
273      try {
274        this.wait(2000);
275      } catch (InterruptedException e) {
276        e.printStackTrace();
277      }
278    }
279  }
280}
281docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.00001
2820f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
2832021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Received a pending transaction 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26 that spends 0.00 BTC from our own wallet, and sends us 0.00001 BTC
2842021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] commitTx of 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
285...
2862021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] -&gt;pending: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
2872021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Estimated balance is now: 0.00001 BTC
288-----&gt; coins resceived: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
2892021-11-09 23:51:20.538 INFO  [NioClientManager][WalletFiles] Saving wallet; last seen block is height 165, date 2021-11-09T22:50:48Z, hash 23451521947bc5ff098c088ae0fc445becca8837d39ee8f6dd88f2c47ad5ac23
2902021-11-09 23:51:20.543 INFO  [NioClientManager][WalletFiles] Save completed in 4.736 ms
291

There is still a problem you mentioned that I haven't had the opportunity to test, and it is creating a new Docker image in which the peerbloomfilters configuration would be configured properly without modifying the actual container state. I think the compilation problem you indicated could be related to this issue, basically, that the container didn't have enough resources to perform the process. If you are using macOS and Docker for Mac, try tweaking the amount of memory available to your containers, it may be of help. A change in the base alpine image used can motivate the problem also. I will try digging into the issue as well.

Source https://stackoverflow.com/questions/69764709

QUESTION

ModuleNotFoundError: No module named 'jsonschema.compat'

Asked 2021-Nov-02 at 07:20

I have been working with the Bybit API for the last week when I encountered the title problem yesterday. I have started a new env and installed only the bybit wrapper again and the issue still arises. From what I can see I have jsonschema installed and in my env PATH. It was working a few days ago, so I do believe this to be separate from whatever API I am trying to use. Included is a picture of the response when run in an interpreter. Any help would be greatly appreciated.

ModuleNotFoundError: No module named 'jsonschema.compat' is the error that comes up.

enter image description here

ANSWER

Answered 2021-Oct-03 at 20:57

I have exactly the same problem! It was working before the release of 1.3, with the version 1.21 months a go. I found this problem to day after updateing my venv to the newest versions. Search a little more, it is a problem with the version of the jsonschema-4.0.1, go back to version 3.1.1 of jsonschema and all is running like befor, incl. the version 1.3 of bybit. Regards,

Source https://stackoverflow.com/questions/69426664

Community Discussions contain sources that include Stack Exchange Network

Tutorials and Learning Resources in Wrapper

Tutorials and Learning Resources are not available at this moment for Wrapper

Share this Page

share link

Get latest updates on Wrapper