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
by java-native-access java
6675 NOASSERTION
Java Native Access
by serialport typescript
5146 MIT
Access serial ports with JavaScript. Linux, OSX and Windows. Welcome your robotic JavaScript overlords. Better yet, program them!
by eddiezane ruby
2795 MIT
A friendly wrapper for launchctl
by KeepSafe java
2474 Apache-2.0
A robust native library loader for Android.
by pyserial python
2386 NOASSERTION
Python serial port access library
by rust-lang c++
2298 BSD-3-Clause
Automatically generates Rust FFI bindings to C (and some C++) libraries.
by jeelabs c
2255 NOASSERTION
esp8266 wifi-serial bridge, outbound TCP, and arduino/AVR/LPC/NXP programmer
by classgraph java
2206 MIT
An uber-fast parallelized Java classpath scanner and module scanner.
by ahupp python
2030 NOASSERTION
A python wrapper for libmagic
Trending New libraries in Wrapper
by fzyzcjy rust
1054 MIT
High-level memory-safe binding generator for Flutter/Dart <-> Rust
by sebastianbergmann php
504 NOASSERTION
Library for counting the lines of code in PHP source code
by getditto rust
460 MIT
Write safer FFI code in Rust without polluting it with unsafe code
by lcodecorex c
422 MIT
Fighting against force-stop kill process on Android with binder ioctl / Android高级保活
by COLOR-SKY python
365 MIT
Source code of my project ID:INVADED(WINDOWED)
by gonzalezreal swift
304 MIT
A convenient way to handle default values with Swift Codable types
by areebbeigh python
204 Apache-2.0
Backend code repository for CodeInterview
by u2takey go
196 Apache-2.0
golang binding for ffmpeg
by larksuite rust
195 MIT
A Rust crate that exposes FFmpeg's power as much as possible.
Top Authors in Wrapper
1
10 Libraries
110
2
8 Libraries
388
3
7 Libraries
79
4
5 Libraries
1061
5
5 Libraries
14
6
5 Libraries
30
7
4 Libraries
22
8
4 Libraries
94
9
4 Libraries
21
10
4 Libraries
61
1
10 Libraries
110
2
8 Libraries
388
3
7 Libraries
79
4
5 Libraries
1061
5
5 Libraries
14
6
5 Libraries
30
7
4 Libraries
22
8
4 Libraries
94
9
4 Libraries
21
10
4 Libraries
61
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 <module 'pandas.core.internals.blocks'>
"Cannot read properties of undefined (reading 'pathname')" 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:02I 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 = "${rootProject.buildDir}/${project.name}"
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 = "${rootProject.buildDir}/${project.name}"
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:09It 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 = "${rootProject.buildDir}/${project.name}"
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.
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:01I'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> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
6 > 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> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
6 > 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 = "30.0.0"
16 minSdkVersion = 21
17 compileSdkVersion = 30
18 targetSdkVersion = 30
19 supportLibVersion = "28.0.0"
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("$rootDir/../node_modules/react-native/android")
39 }
40 maven {
41 // Android JSC is installed from npm
42 url("$rootDir/../node_modules/jsc-android/dist")
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> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
6 > 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 = "30.0.0"
16 minSdkVersion = 21
17 compileSdkVersion = 30
18 targetSdkVersion = 30
19 supportLibVersion = "28.0.0"
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("$rootDir/../node_modules/react-native/android")
39 }
40 maven {
41 // Android JSC is installed from npm
42 url("$rootDir/../node_modules/jsc-android/dist")
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:03The 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> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
6 > 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 = "30.0.0"
16 minSdkVersion = 21
17 compileSdkVersion = 30
18 targetSdkVersion = 30
19 supportLibVersion = "28.0.0"
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("$rootDir/../node_modules/react-native/android")
39 }
40 maven {
41 // Android JSC is installed from npm
42 url("$rootDir/../node_modules/jsc-android/dist")
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 = "2.6.0"
58 // Force WorkManager 2.6.0 for transitive dependency
59 implementation("androidx.work:work-runtime-ktx:$work_version") {
60 force = true
61 }
62}
63
This should fix it.
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:48please, I'm learning a VueJS 3 and I have probably begineer problem. I have warn in browser developer console like this one:
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<template>
3 <div class="wrapper">
4 <section v-for="(item, index) in items" :key="index" class="box">
5 <ItemProperties class="infobox-item-properties" :info="item.properties" />
6 </section>
7 </div>
8</template>
9<script>
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</script>
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<template>
3 <div class="wrapper">
4 <section v-for="(item, index) in items" :key="index" class="box">
5 <ItemProperties class="infobox-item-properties" :info="item.properties" />
6 </section>
7 </div>
8</template>
9<script>
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</script>
26<template>
27 <div class="infobox-item-property" v-for="(object, index) in info" :key="index">
28 <span class="infobox-item-title">{{ object.name }}:</span>
29 <span v-if="object.type === 'rating'">
30 <span v-for="(v, k) in object.value" :key="k">{{ object.icon }}</span>
31 </span>
32 <span v-else>
33 <span>{{ object.value }}</span>
34 </span>
35 </div>
36</template>
37
38<script>
39export default {
40 props: {
41 info: {
42 type: Array,
43 required: false,
44 default: () => [
45 {
46 name: '',
47 value: '',
48 type: 'string',
49 icon: '',
50 },
51 ],
52 },
53 },
54}
55</script>
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<template>
3 <div class="wrapper">
4 <section v-for="(item, index) in items" :key="index" class="box">
5 <ItemProperties class="infobox-item-properties" :info="item.properties" />
6 </section>
7 </div>
8</template>
9<script>
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</script>
26<template>
27 <div class="infobox-item-property" v-for="(object, index) in info" :key="index">
28 <span class="infobox-item-title">{{ object.name }}:</span>
29 <span v-if="object.type === 'rating'">
30 <span v-for="(v, k) in object.value" :key="k">{{ object.icon }}</span>
31 </span>
32 <span v-else>
33 <span>{{ object.value }}</span>
34 </span>
35 </div>
36</template>
37
38<script>
39export default {
40 props: {
41 info: {
42 type: Array,
43 required: false,
44 default: () => [
45 {
46 name: '',
47 value: '',
48 type: 'string',
49 icon: '',
50 },
51 ],
52 },
53 },
54}
55</script>
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:32The 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<template>
3 <div class="wrapper">
4 <section v-for="(item, index) in items" :key="index" class="box">
5 <ItemProperties class="infobox-item-properties" :info="item.properties" />
6 </section>
7 </div>
8</template>
9<script>
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</script>
26<template>
27 <div class="infobox-item-property" v-for="(object, index) in info" :key="index">
28 <span class="infobox-item-title">{{ object.name }}:</span>
29 <span v-if="object.type === 'rating'">
30 <span v-for="(v, k) in object.value" :key="k">{{ object.icon }}</span>
31 </span>
32 <span v-else>
33 <span>{{ object.value }}</span>
34 </span>
35 </div>
36</template>
37
38<script>
39export default {
40 props: {
41 info: {
42 type: Array,
43 required: false,
44 default: () => [
45 {
46 name: '',
47 value: '',
48 type: 'string',
49 icon: '',
50 },
51 ],
52 },
53 },
54}
55</script>
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<template>
73 <div>
74 <section v-for="(item, index) in items" :key="index" class="box">
75 ...
76 </section>
77 </div>
78</template>
79
QUESTION
AttributeError: Can't get attribute 'new_block' on <module 'pandas.core.internals.blocks'>
Asked 2022-Feb-25 at 13:18I 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 = "/tmp/db")
2conn = sqlite3.connect("/tmp/db/simple_db.sqlite")
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["bounds_north"]) >= lat) &
14 (np.array(pdf["bounds_south"]) <= lat) &
15 (np.array(pdf['bounds_west']) <= lng) &
16 (np.array(pdf['bounds_east']) >= lng) ]
17 if len(out):
18 min_index = np.argmin( (np.array(out["lat"]) - lat)**2 + (np.array(out["lng"]) - lng)**2)
19 zip_ = str(out["zipcode"].iloc[min_index])
20 else:
21 zip_ = 'bad'
22 return zip_
23
24df = df.withColumn('zipcode', get_zip_b(col("latitude"),col("longitude")))
25
Below is the traceback, where line 102, in get_zip_b refers to pdf = brd_pdf.value
:
1search = SearchEngine(db_file_dir = "/tmp/db")
2conn = sqlite3.connect("/tmp/db/simple_db.sqlite")
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["bounds_north"]) >= lat) &
14 (np.array(pdf["bounds_south"]) <= lat) &
15 (np.array(pdf['bounds_west']) <= lng) &
16 (np.array(pdf['bounds_east']) >= lng) ]
17 if len(out):
18 min_index = np.argmin( (np.array(out["lat"]) - lat)**2 + (np.array(out["lng"]) - lng)**2)
19 zip_ = str(out["zipcode"].iloc[min_index])
20 else:
21 zip_ = 'bad'
22 return zip_
23
24df = df.withColumn('zipcode', get_zip_b(col("latitude"),col("longitude")))
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 "/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/worker.py", line 605, in main
27 process()
28 File "/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/worker.py", line 597, in process
29 serializer.dump_stream(out_iter, outfile)
30 File "/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/serializers.py", line 223, in dump_stream
31 self.serializer.dump_stream(self._batched(iterator), stream)
32 File "/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/serializers.py", line 141, in dump_stream
33 for obj in iterator:
34 File "/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/serializers.py", line 212, in _batched
35 for item in iterator:
36 File "/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/worker.py", line 450, in mapper
37 result = tuple(f(*[a[o] for o in arg_offsets]) for (arg_offsets, f) in udfs)
38 File "/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/worker.py", line 450, in <genexpr>
39 result = tuple(f(*[a[o] for o in arg_offsets]) for (arg_offsets, f) in udfs)
40 File "/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/worker.py", line 90, in <lambda>
41 return lambda *a: f(*a)
42 File "/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/util.py", line 121, in wrapper
43 return f(*args, **kwargs)
44 File "/mnt/var/lib/hadoop/steps/s-1IBFS0SYWA19Z/Mobile_ID_process_center.py", line 102, in get_zip_b
45 File "/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/broadcast.py", line 146, in value
46 self._value = self.load_from_path(self._path)
47 File "/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/broadcast.py", line 123, in load_from_path
48 return self.load(f)
49 File "/mnt/yarn/usercache/hadoop/appcache/application_1627867699893_0001/container_1627867699893_0001_01_000009/pyspark.zip/pyspark/broadcast.py", line 129, in load
50 return pickle.load(file)
51AttributeError: Can't get attribute 'new_block' on <module 'pandas.core.internals.blocks' from '/mnt/miniconda/lib/python3.9/site-packages/pandas/core/internals/blocks.py'>
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:53I 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.
QUESTION
"Cannot read properties of undefined (reading 'pathname')" when testing pages in the v6 React Router
Asked 2022-Feb-03 at 00:48When 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 = () => {
2 const history = createMemoryHistory();
3 const wrapper = render(
4 <Router history={history}>
5 <MyPage />
6 </Router>
7 );
8 return { ...wrapper, history };
9}
10
This worked fine up to v5.3, but after upgrading to v6 I get:
1const renderInRouter = () => {
2 const history = createMemoryHistory();
3 const wrapper = render(
4 <Router history={history}>
5 <MyPage />
6 </Router>
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 = () => {
2 const history = createMemoryHistory();
3 const wrapper = render(
4 <Router history={history}>
5 <MyPage />
6 </Router>
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<Location> | 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 = () => {
2 const history = createMemoryHistory();
3 const wrapper = render(
4 <Router history={history}>
5 <MyPage />
6 </Router>
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<Location> | string;
24 navigationType?: NavigationType;
25 navigator: Navigator;
26 static?: boolean;
27}
28{
29 "name": "router6-demo",
30 "version": "1.0.0",
31 "description": "",
32 "main": "index.js",
33 "scripts": {
34 "test": "jest"
35 },
36 "jest": {
37 "testEnvironment": "jsdom"
38 },
39 "babel": {
40 "presets": [
41 "@babel/preset-react"
42 ]
43 },
44 "keywords": [],
45 "author": "",
46 "license": "ISC",
47 "devDependencies": {
48 "@babel/preset-react": "^7.16.0",
49 "@testing-library/react": "^12.1.2",
50 "jest": "^27.3.1",
51 "react": "^17.0.2",
52 "react-dom": "^17.0.2",
53 "react-router-dom": "^6.0.0"
54 }
55}
56
57
index.test.js
:
1const renderInRouter = () => {
2 const history = createMemoryHistory();
3 const wrapper = render(
4 <Router history={history}>
5 <MyPage />
6 </Router>
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<Location> | string;
24 navigationType?: NavigationType;
25 navigator: Navigator;
26 static?: boolean;
27}
28{
29 "name": "router6-demo",
30 "version": "1.0.0",
31 "description": "",
32 "main": "index.js",
33 "scripts": {
34 "test": "jest"
35 },
36 "jest": {
37 "testEnvironment": "jsdom"
38 },
39 "babel": {
40 "presets": [
41 "@babel/preset-react"
42 ]
43 },
44 "keywords": [],
45 "author": "",
46 "license": "ISC",
47 "devDependencies": {
48 "@babel/preset-react": "^7.16.0",
49 "@testing-library/react": "^12.1.2",
50 "jest": "^27.3.1",
51 "react": "^17.0.2",
52 "react-dom": "^17.0.2",
53 "react-router-dom": "^6.0.0"
54 }
55}
56
57const { render } = require("@testing-library/react");
58const { createMemoryHistory } = require("history");
59const React = require("react");
60const { Router } = require("react-router-dom");
61
62it("used to work", () => {
63 render(
64 <Router history={createMemoryHistory()}></Router>
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:28React 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 = () => {
2 const history = createMemoryHistory();
3 const wrapper = render(
4 <Router history={history}>
5 <MyPage />
6 </Router>
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<Location> | string;
24 navigationType?: NavigationType;
25 navigator: Navigator;
26 static?: boolean;
27}
28{
29 "name": "router6-demo",
30 "version": "1.0.0",
31 "description": "",
32 "main": "index.js",
33 "scripts": {
34 "test": "jest"
35 },
36 "jest": {
37 "testEnvironment": "jsdom"
38 },
39 "babel": {
40 "presets": [
41 "@babel/preset-react"
42 ]
43 },
44 "keywords": [],
45 "author": "",
46 "license": "ISC",
47 "devDependencies": {
48 "@babel/preset-react": "^7.16.0",
49 "@testing-library/react": "^12.1.2",
50 "jest": "^27.3.1",
51 "react": "^17.0.2",
52 "react-dom": "^17.0.2",
53 "react-router-dom": "^6.0.0"
54 }
55}
56
57const { render } = require("@testing-library/react");
58const { createMemoryHistory } = require("history");
59const React = require("react");
60const { Router } = require("react-router-dom");
61
62it("used to work", () => {
63 render(
64 <Router history={createMemoryHistory()}></Router>
65 );
66});
67export declare type Navigator = Omit<History, "action" | "location" | "back" | "forward" | "listen" | "block">;
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 = () => {
2 const history = createMemoryHistory();
3 const wrapper = render(
4 <Router history={history}>
5 <MyPage />
6 </Router>
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<Location> | string;
24 navigationType?: NavigationType;
25 navigator: Navigator;
26 static?: boolean;
27}
28{
29 "name": "router6-demo",
30 "version": "1.0.0",
31 "description": "",
32 "main": "index.js",
33 "scripts": {
34 "test": "jest"
35 },
36 "jest": {
37 "testEnvironment": "jsdom"
38 },
39 "babel": {
40 "presets": [
41 "@babel/preset-react"
42 ]
43 },
44 "keywords": [],
45 "author": "",
46 "license": "ISC",
47 "devDependencies": {
48 "@babel/preset-react": "^7.16.0",
49 "@testing-library/react": "^12.1.2",
50 "jest": "^27.3.1",
51 "react": "^17.0.2",
52 "react-dom": "^17.0.2",
53 "react-router-dom": "^6.0.0"
54 }
55}
56
57const { render } = require("@testing-library/react");
58const { createMemoryHistory } = require("history");
59const React = require("react");
60const { Router } = require("react-router-dom");
61
62it("used to work", () => {
63 render(
64 <Router history={createMemoryHistory()}></Router>
65 );
66});
67export declare type Navigator = Omit<History, "action" | "location" | "back" | "forward" | "listen" | "block">;
68const { render } = require("@testing-library/react");
69const { createMemoryHistory } = require("history");
70const React = require("react");
71const { Router } = require("react-router-dom");
72
73it("works", () => {
74 const history = createMemoryHistory();
75 render(
76 <Router location={history.location} navigator={history}></Router>
77 );
78});
79
QUESTION
pymongo [SSL: CERTIFICATE_VERIFY_FAILED]: certificate has expired on Mongo Atlas
Asked 2022-Jan-29 at 22:03I 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 "c:\users\admin\appdata\local\programs\python\python39\lib\threading.py", line 973, in _bootstrap_inner
4 self.run()
5 File "c:\users\admin\appdata\local\programs\python\python39\lib\threading.py", line 910, in run
6 self._target(*self._args, **self._kwargs)
7 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
8 fn(*args, **kwargs)
9 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\core\management\commands\runserver.py", line 121, in inner_run
10 self.check_migrations()
11 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\core\management\base.py", line 486, in check_migrations
12 executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
13 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\migrations\executor.py", line 18, in __init__
14 self.loader = MigrationLoader(self.connection)
15 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\migrations\loader.py", line 53, in __init__
16 self.build_graph()
17 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\migrations\loader.py", line 220, in build_graph
18 self.applied_migrations = recorder.applied_migrations()
19 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\migrations\recorder.py", line 77, in applied_migrations
20 if self.has_table():
21 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\migrations\recorder.py", line 56, in has_table
22 tables = self.connection.introspection.table_names(cursor)
23 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\backends\base\introspection.py", line 52, in table_names
24 return get_names(cursor)
25 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\backends\base\introspection.py", line 47, in get_names
26 return sorted(ti.name for ti in self.get_table_list(cursor)
27 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\djongo\introspection.py", line 47, in get_table_list
28 for c in cursor.db_conn.list_collection_names()
29 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\database.py", line 880, in list_collection_names
30 for result in self.list_collections(session=session, **kwargs)]
31 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\database.py", line 842, in list_collections
32 return self.__client._retryable_read(
33 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\mongo_client.py", line 1514, in _retryable_read
34 server = self._select_server(
35 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\mongo_client.py", line 1346, in _select_server
36 server = topology.select_server(server_selector)
37 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\topology.py", line 244, in select_server
38 return random.choice(self.select_servers(selector,
39 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\topology.py", line 202, in select_servers
40 server_descriptions = self._select_servers_loop(
41 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\topology.py", 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: <TopologyDescription id: 6155f0c9148b07ff5851a1b3, topology_type: ReplicaSetNoPrimary, servers: [<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)')>, <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)')>, <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)')>]>
44
I am using djongo as the database engine
1Exception in thread django-main-thread:
2Traceback (most recent call last):
3 File "c:\users\admin\appdata\local\programs\python\python39\lib\threading.py", line 973, in _bootstrap_inner
4 self.run()
5 File "c:\users\admin\appdata\local\programs\python\python39\lib\threading.py", line 910, in run
6 self._target(*self._args, **self._kwargs)
7 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
8 fn(*args, **kwargs)
9 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\core\management\commands\runserver.py", line 121, in inner_run
10 self.check_migrations()
11 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\core\management\base.py", line 486, in check_migrations
12 executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
13 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\migrations\executor.py", line 18, in __init__
14 self.loader = MigrationLoader(self.connection)
15 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\migrations\loader.py", line 53, in __init__
16 self.build_graph()
17 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\migrations\loader.py", line 220, in build_graph
18 self.applied_migrations = recorder.applied_migrations()
19 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\migrations\recorder.py", line 77, in applied_migrations
20 if self.has_table():
21 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\migrations\recorder.py", line 56, in has_table
22 tables = self.connection.introspection.table_names(cursor)
23 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\backends\base\introspection.py", line 52, in table_names
24 return get_names(cursor)
25 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\backends\base\introspection.py", line 47, in get_names
26 return sorted(ti.name for ti in self.get_table_list(cursor)
27 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\djongo\introspection.py", line 47, in get_table_list
28 for c in cursor.db_conn.list_collection_names()
29 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\database.py", line 880, in list_collection_names
30 for result in self.list_collections(session=session, **kwargs)]
31 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\database.py", line 842, in list_collections
32 return self.__client._retryable_read(
33 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\mongo_client.py", line 1514, in _retryable_read
34 server = self._select_server(
35 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\mongo_client.py", line 1346, in _select_server
36 server = topology.select_server(server_selector)
37 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\topology.py", line 244, in select_server
38 return random.choice(self.select_servers(selector,
39 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\topology.py", line 202, in select_servers
40 server_descriptions = self._select_servers_loop(
41 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\topology.py", 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: <TopologyDescription id: 6155f0c9148b07ff5851a1b3, topology_type: ReplicaSetNoPrimary, servers: [<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)')>, <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)')>, <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)')>]>
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&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 "c:\users\admin\appdata\local\programs\python\python39\lib\threading.py", line 973, in _bootstrap_inner
4 self.run()
5 File "c:\users\admin\appdata\local\programs\python\python39\lib\threading.py", line 910, in run
6 self._target(*self._args, **self._kwargs)
7 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
8 fn(*args, **kwargs)
9 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\core\management\commands\runserver.py", line 121, in inner_run
10 self.check_migrations()
11 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\core\management\base.py", line 486, in check_migrations
12 executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
13 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\migrations\executor.py", line 18, in __init__
14 self.loader = MigrationLoader(self.connection)
15 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\migrations\loader.py", line 53, in __init__
16 self.build_graph()
17 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\migrations\loader.py", line 220, in build_graph
18 self.applied_migrations = recorder.applied_migrations()
19 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\migrations\recorder.py", line 77, in applied_migrations
20 if self.has_table():
21 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\migrations\recorder.py", line 56, in has_table
22 tables = self.connection.introspection.table_names(cursor)
23 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\backends\base\introspection.py", line 52, in table_names
24 return get_names(cursor)
25 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\django\db\backends\base\introspection.py", line 47, in get_names
26 return sorted(ti.name for ti in self.get_table_list(cursor)
27 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\djongo\introspection.py", line 47, in get_table_list
28 for c in cursor.db_conn.list_collection_names()
29 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\database.py", line 880, in list_collection_names
30 for result in self.list_collections(session=session, **kwargs)]
31 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\database.py", line 842, in list_collections
32 return self.__client._retryable_read(
33 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\mongo_client.py", line 1514, in _retryable_read
34 server = self._select_server(
35 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\mongo_client.py", line 1346, in _select_server
36 server = topology.select_server(server_selector)
37 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\topology.py", line 244, in select_server
38 return random.choice(self.select_servers(selector,
39 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\topology.py", line 202, in select_servers
40 server_descriptions = self._select_servers_loop(
41 File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\pymongo\topology.py", 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: <TopologyDescription id: 6155f0c9148b07ff5851a1b3, topology_type: ReplicaSetNoPrimary, servers: [<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)')>, <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)')>, <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)')>]>
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&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:57This 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.
QUESTION
How to set max-height of dropdown selection area?
Asked 2022-Jan-21 at 05:26In 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}<select onfocus='this.size=10;' onblur='this.size=1;' onchange='this.size=1; this.blur();'>
4 <option>1</option>
5 <option>2</option>
6 <option>3</option>
7 <option>4</option>
8 <option>5</option>
9 <option>6</option>
10 <option>7</option>
11 <option>8</option>
12 <option>9</option>
13 <option>10</option>
14 <option>11</option>
15 <option>12</option>
16 <option>13</option>
17 <option>14</option>
18 <option>15</option>
19 <option>16</option>
20 <option>17</option>
21 <option>18</option>
22 <option>19</option>
23 <option>20</option>
24 <option>21</option>
25</select>
26<div>Popular Tags:</div>
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}<select onfocus='this.size=10;' onblur='this.size=1;' onchange='this.size=1; this.blur();'>
4 <option>1</option>
5 <option>2</option>
6 <option>3</option>
7 <option>4</option>
8 <option>5</option>
9 <option>6</option>
10 <option>7</option>
11 <option>8</option>
12 <option>9</option>
13 <option>10</option>
14 <option>11</option>
15 <option>12</option>
16 <option>13</option>
17 <option>14</option>
18 <option>15</option>
19 <option>16</option>
20 <option>17</option>
21 <option>18</option>
22 <option>19</option>
23 <option>20</option>
24 <option>21</option>
25</select>
26<div>Popular Tags:</div>.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:00Unfortunately, you cannot chant the height of a dropdown list (while using <select>
).
It is confirmed here.
you can build it yourself using div
s & v-for
(assuming you get the list from an outsource) and then you can style it as you wish.
apologies for barring bad news.
QUESTION
How do I get details of a veracode vulnerability report?
Asked 2022-Jan-07 at 21:46How 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
, andprototype
.
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:46Ok, 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
Have someone post an issue against your library suggesting that its
mapObjIndexed
function is subject to the prototype pollution vulnerability.Respond to say that you don't think the user has demonstrated that well-known vulnerability, but that you will dig deeper.
Write a detailed post described what that vulnerability means and demonstrate that the library is not in fact subject to it, or or at least that the example supplied does not demonstrate it.
Carry on a short conversation with interested parties explaining the point more thoroughly and responding to objections.
Leave the issue open for a while so the original reporter can argue the point and respond. 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
, andprototype
.and eventually learn that this is due to a report from the software security company Veracode.
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.
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.
- 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.
- 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.
- 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.
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.
- 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.
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.
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.
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.
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.
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'sObject.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?
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.
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.
- 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 61Receive 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.
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:39I 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, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
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("Heyo!");
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, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
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("Heyo!");
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.
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, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
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("Heyo!");
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 - "51001:50001"
34 - "51002:50002"
35 - "19001:19001"
36 - "19000:19000"
37 - "28332:28332"
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, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
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("Heyo!");
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 - "51001:50001"
34 - "51002:50002"
35 - "19001:19001"
36 - "19000:19000"
37 - "28332:28332"
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("."), "_minimalCryptoExchangeBtcWallet");
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, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
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("Heyo!");
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, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
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("Heyo!");
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 - "51001:50001"
34 - "51002:50002"
35 - "19001:19001"
36 - "19000:19000"
37 - "28332:28332"
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("."), "_minimalCryptoExchangeBtcWallet");
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, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
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("Heyo!");
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, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
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("Heyo!");
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 - "51001:50001"
34 - "51002:50002"
35 - "19001:19001"
36 - "19000:19000"
37 - "28332:28332"
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("."), "_minimalCryptoExchangeBtcWallet");
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, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
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("Heyo!");
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, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
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("Heyo!");
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 - "51001:50001"
34 - "51002:50002"
35 - "19001:19001"
36 - "19000:19000"
37 - "28332:28332"
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("."), "_minimalCryptoExchangeBtcWallet");
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, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
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("Heyo!");
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, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
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("Heyo!");
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 - "51001:50001"
34 - "51002:50002"
35 - "19001:19001"
36 - "19000:19000"
37 - "28332:28332"
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("."), "_minimalCryptoExchangeBtcWallet");
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, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
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("Heyo!");
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: "host"
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, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
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("Heyo!");
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 - "51001:50001"
34 - "51002:50002"
35 - "19001:19001"
36 - "19000:19000"
37 - "28332:28332"
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("."), "_minimalCryptoExchangeBtcWallet");
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, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
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("Heyo!");
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: "host"
113minimal-crypto-exchange % docker-compose up -d
114Creating network "minimal-crypto-exchange_default" 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, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
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("Heyo!");
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 - "51001:50001"
34 - "51002:50002"
35 - "19001:19001"
36 - "19000:19000"
37 - "28332:28332"
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("."), "_minimalCryptoExchangeBtcWallet");
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, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
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("Heyo!");
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: "host"
113minimal-crypto-exchange % docker-compose up -d
114Creating network "minimal-crypto-exchange_default" 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: "host"
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, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
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("Heyo!");
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 - "51001:50001"
34 - "51002:50002"
35 - "19001:19001"
36 - "19000:19000"
37 - "28332:28332"
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("."), "_minimalCryptoExchangeBtcWallet");
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, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
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("Heyo!");
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: "host"
113minimal-crypto-exchange % docker-compose up -d
114Creating network "minimal-crypto-exchange_default" 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: "host"
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 "host" network_mode is incompatible with port_bindings
139
140ERROR: for electrumx "host" network_mode is incompatible with port_bindings
141Traceback (most recent call last):
142 File "docker-compose", line 3, in <module>
143 File "compose/cli/main.py", line 81, in main
144 File "compose/cli/main.py", line 203, in perform_command
145 File "compose/metrics/decorator.py", line 18, in wrapper
146 File "compose/cli/main.py", line 1186, in up
147 File "compose/cli/main.py", line 1166, in up
148 File "compose/project.py", line 697, in up
149 File "compose/parallel.py", line 108, in parallel_execute
150 File "compose/parallel.py", line 206, in producer
151 File "compose/project.py", line 679, in do
152 File "compose/service.py", line 579, in execute_convergence_plan
153 File "compose/service.py", line 499, in _execute_convergence_recreate
154 File "compose/parallel.py", line 108, in parallel_execute
155 File "compose/parallel.py", line 206, in producer
156 File "compose/service.py", line 494, in recreate
157 File "compose/service.py", line 612, in recreate_container
158 File "compose/service.py", line 330, in create_container
159 File "compose/service.py", line 939, in _get_container_create_options
160 File "compose/service.py", line 1014, in _get_container_host_config
161 File "docker/api/container.py", line 598, in create_host_config
162 File "docker/types/containers.py", line 338, in __init__
163docker.errors.InvalidArgument: "host" 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, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
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("Heyo!");
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 - "51001:50001"
34 - "51002:50002"
35 - "19001:19001"
36 - "19000:19000"
37 - "28332:28332"
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("."), "_minimalCryptoExchangeBtcWallet");
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, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
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("Heyo!");
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: "host"
113minimal-crypto-exchange % docker-compose up -d
114Creating network "minimal-crypto-exchange_default" 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: "host"
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 "host" network_mode is incompatible with port_bindings
139
140ERROR: for electrumx "host" network_mode is incompatible with port_bindings
141Traceback (most recent call last):
142 File "docker-compose", line 3, in <module>
143 File "compose/cli/main.py", line 81, in main
144 File "compose/cli/main.py", line 203, in perform_command
145 File "compose/metrics/decorator.py", line 18, in wrapper
146 File "compose/cli/main.py", line 1186, in up
147 File "compose/cli/main.py", line 1166, in up
148 File "compose/project.py", line 697, in up
149 File "compose/parallel.py", line 108, in parallel_execute
150 File "compose/parallel.py", line 206, in producer
151 File "compose/project.py", line 679, in do
152 File "compose/service.py", line 579, in execute_convergence_plan
153 File "compose/service.py", line 499, in _execute_convergence_recreate
154 File "compose/parallel.py", line 108, in parallel_execute
155 File "compose/parallel.py", line 206, in producer
156 File "compose/service.py", line 494, in recreate
157 File "compose/service.py", line 612, in recreate_container
158 File "compose/service.py", line 330, in create_container
159 File "compose/service.py", line 939, in _get_container_create_options
160 File "compose/service.py", line 1014, in _get_container_host_config
161 File "docker/api/container.py", line 598, in create_host_config
162 File "docker/types/containers.py", line 338, in __init__
163docker.errors.InvalidArgument: "host" 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# - "51001:50001"
173# - "51002:50002"
174# - "19001:19001"
175# - "19000:19000"
176# - "28332:28332"
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, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
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("Heyo!");
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 - "51001:50001"
34 - "51002:50002"
35 - "19001:19001"
36 - "19000:19000"
37 - "28332:28332"
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("."), "_minimalCryptoExchangeBtcWallet");
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, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
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("Heyo!");
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: "host"
113minimal-crypto-exchange % docker-compose up -d
114Creating network "minimal-crypto-exchange_default" 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: "host"
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 "host" network_mode is incompatible with port_bindings
139
140ERROR: for electrumx "host" network_mode is incompatible with port_bindings
141Traceback (most recent call last):
142 File "docker-compose", line 3, in <module>
143 File "compose/cli/main.py", line 81, in main
144 File "compose/cli/main.py", line 203, in perform_command
145 File "compose/metrics/decorator.py", line 18, in wrapper
146 File "compose/cli/main.py", line 1186, in up
147 File "compose/cli/main.py", line 1166, in up
148 File "compose/project.py", line 697, in up
149 File "compose/parallel.py", line 108, in parallel_execute
150 File "compose/parallel.py", line 206, in producer
151 File "compose/project.py", line 679, in do
152 File "compose/service.py", line 579, in execute_convergence_plan
153 File "compose/service.py", line 499, in _execute_convergence_recreate
154 File "compose/parallel.py", line 108, in parallel_execute
155 File "compose/parallel.py", line 206, in producer
156 File "compose/service.py", line 494, in recreate
157 File "compose/service.py", line 612, in recreate_container
158 File "compose/service.py", line 330, in create_container
159 File "compose/service.py", line 939, in _get_container_create_options
160 File "compose/service.py", line 1014, in _get_container_host_config
161 File "docker/api/container.py", line 598, in create_host_config
162 File "docker/types/containers.py", line 338, in __init__
163docker.errors.InvalidArgument: "host" 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# - "51001:50001"
173# - "51002:50002"
174# - "19001:19001"
175# - "19000:19000"
176# - "28332:28332"
177 % docker-compose up -d
178Creating network "minimal-crypto-exchange_default" 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, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
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("Heyo!");
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 - "51001:50001"
34 - "51002:50002"
35 - "19001:19001"
36 - "19000:19000"
37 - "28332:28332"
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("."), "_minimalCryptoExchangeBtcWallet");
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, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
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("Heyo!");
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: "host"
113minimal-crypto-exchange % docker-compose up -d
114Creating network "minimal-crypto-exchange_default" 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: "host"
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 "host" network_mode is incompatible with port_bindings
139
140ERROR: for electrumx "host" network_mode is incompatible with port_bindings
141Traceback (most recent call last):
142 File "docker-compose", line 3, in <module>
143 File "compose/cli/main.py", line 81, in main
144 File "compose/cli/main.py", line 203, in perform_command
145 File "compose/metrics/decorator.py", line 18, in wrapper
146 File "compose/cli/main.py", line 1186, in up
147 File "compose/cli/main.py", line 1166, in up
148 File "compose/project.py", line 697, in up
149 File "compose/parallel.py", line 108, in parallel_execute
150 File "compose/parallel.py", line 206, in producer
151 File "compose/project.py", line 679, in do
152 File "compose/service.py", line 579, in execute_convergence_plan
153 File "compose/service.py", line 499, in _execute_convergence_recreate
154 File "compose/parallel.py", line 108, in parallel_execute
155 File "compose/parallel.py", line 206, in producer
156 File "compose/service.py", line 494, in recreate
157 File "compose/service.py", line 612, in recreate_container
158 File "compose/service.py", line 330, in create_container
159 File "compose/service.py", line 939, in _get_container_create_options
160 File "compose/service.py", line 1014, in _get_container_host_config
161 File "docker/api/container.py", line 598, in create_host_config
162 File "docker/types/containers.py", line 338, in __init__
163docker.errors.InvalidArgument: "host" 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# - "51001:50001"
173# - "51002:50002"
174# - "19001:19001"
175# - "19000:19000"
176# - "28332:28332"
177 % docker-compose up -d
178Creating network "minimal-crypto-exchange_default" 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 - "19001:19001"
195 - "19000:19000"
196 - "28332:28332"
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 - "51001:50001"
204 - "51002:50002"
205# - "19001:19001"
206# - "19000:19000"
207# - "28332:28332"
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, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
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("Heyo!");
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 - "51001:50001"
34 - "51002:50002"
35 - "19001:19001"
36 - "19000:19000"
37 - "28332:28332"
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("."), "_minimalCryptoExchangeBtcWallet");
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, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
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("Heyo!");
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: "host"
113minimal-crypto-exchange % docker-compose up -d
114Creating network "minimal-crypto-exchange_default" 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: "host"
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 "host" network_mode is incompatible with port_bindings
139
140ERROR: for electrumx "host" network_mode is incompatible with port_bindings
141Traceback (most recent call last):
142 File "docker-compose", line 3, in <module>
143 File "compose/cli/main.py", line 81, in main
144 File "compose/cli/main.py", line 203, in perform_command
145 File "compose/metrics/decorator.py", line 18, in wrapper
146 File "compose/cli/main.py", line 1186, in up
147 File "compose/cli/main.py", line 1166, in up
148 File "compose/project.py", line 697, in up
149 File "compose/parallel.py", line 108, in parallel_execute
150 File "compose/parallel.py", line 206, in producer
151 File "compose/project.py", line 679, in do
152 File "compose/service.py", line 579, in execute_convergence_plan
153 File "compose/service.py", line 499, in _execute_convergence_recreate
154 File "compose/parallel.py", line 108, in parallel_execute
155 File "compose/parallel.py", line 206, in producer
156 File "compose/service.py", line 494, in recreate
157 File "compose/service.py", line 612, in recreate_container
158 File "compose/service.py", line 330, in create_container
159 File "compose/service.py", line 939, in _get_container_create_options
160 File "compose/service.py", line 1014, in _get_container_host_config
161 File "docker/api/container.py", line 598, in create_host_config
162 File "docker/types/containers.py", line 338, in __init__
163docker.errors.InvalidArgument: "host" 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# - "51001:50001"
173# - "51002:50002"
174# - "19001:19001"
175# - "19000:19000"
176# - "28332:28332"
177 % docker-compose up -d
178Creating network "minimal-crypto-exchange_default" 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 - "19001:19001"
195 - "19000:19000"
196 - "28332:28332"
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 - "51001:50001"
204 - "51002:50002"
205# - "19001:19001"
206# - "19000:19000"
207# - "28332:28332"
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, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
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("Heyo!");
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 - "51001:50001"
34 - "51002:50002"
35 - "19001:19001"
36 - "19000:19000"
37 - "28332:28332"
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("."), "_minimalCryptoExchangeBtcWallet");
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, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
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("Heyo!");
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: "host"
113minimal-crypto-exchange % docker-compose up -d
114Creating network "minimal-crypto-exchange_default" 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: "host"
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 "host" network_mode is incompatible with port_bindings
139
140ERROR: for electrumx "host" network_mode is incompatible with port_bindings
141Traceback (most recent call last):
142 File "docker-compose", line 3, in <module>
143 File "compose/cli/main.py", line 81, in main
144 File "compose/cli/main.py", line 203, in perform_command
145 File "compose/metrics/decorator.py", line 18, in wrapper
146 File "compose/cli/main.py", line 1186, in up
147 File "compose/cli/main.py", line 1166, in up
148 File "compose/project.py", line 697, in up
149 File "compose/parallel.py", line 108, in parallel_execute
150 File "compose/parallel.py", line 206, in producer
151 File "compose/project.py", line 679, in do
152 File "compose/service.py", line 579, in execute_convergence_plan
153 File "compose/service.py", line 499, in _execute_convergence_recreate
154 File "compose/parallel.py", line 108, in parallel_execute
155 File "compose/parallel.py", line 206, in producer
156 File "compose/service.py", line 494, in recreate
157 File "compose/service.py", line 612, in recreate_container
158 File "compose/service.py", line 330, in create_container
159 File "compose/service.py", line 939, in _get_container_create_options
160 File "compose/service.py", line 1014, in _get_container_host_config
161 File "docker/api/container.py", line 598, in create_host_config
162 File "docker/types/containers.py", line 338, in __init__
163docker.errors.InvalidArgument: "host" 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# - "51001:50001"
173# - "51002:50002"
174# - "19001:19001"
175# - "19000:19000"
176# - "28332:28332"
177 % docker-compose up -d
178Creating network "minimal-crypto-exchange_default" 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 - "19001:19001"
195 - "19000:19000"
196 - "28332:28332"
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 - "51001:50001"
204 - "51002:50002"
205# - "19001:19001"
206# - "19000:19000"
207# - "28332:28332"
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, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
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("Heyo!");
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 - "51001:50001"
34 - "51002:50002"
35 - "19001:19001"
36 - "19000:19000"
37 - "28332:28332"
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("."), "_minimalCryptoExchangeBtcWallet");
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, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
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("Heyo!");
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: "host"
113minimal-crypto-exchange % docker-compose up -d
114Creating network "minimal-crypto-exchange_default" 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: "host"
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 "host" network_mode is incompatible with port_bindings
139
140ERROR: for electrumx "host" network_mode is incompatible with port_bindings
141Traceback (most recent call last):
142 File "docker-compose", line 3, in <module>
143 File "compose/cli/main.py", line 81, in main
144 File "compose/cli/main.py", line 203, in perform_command
145 File "compose/metrics/decorator.py", line 18, in wrapper
146 File "compose/cli/main.py", line 1186, in up
147 File "compose/cli/main.py", line 1166, in up
148 File "compose/project.py", line 697, in up
149 File "compose/parallel.py", line 108, in parallel_execute
150 File "compose/parallel.py", line 206, in producer
151 File "compose/project.py", line 679, in do
152 File "compose/service.py", line 579, in execute_convergence_plan
153 File "compose/service.py", line 499, in _execute_convergence_recreate
154 File "compose/parallel.py", line 108, in parallel_execute
155 File "compose/parallel.py", line 206, in producer
156 File "compose/service.py", line 494, in recreate
157 File "compose/service.py", line 612, in recreate_container
158 File "compose/service.py", line 330, in create_container
159 File "compose/service.py", line 939, in _get_container_create_options
160 File "compose/service.py", line 1014, in _get_container_host_config
161 File "docker/api/container.py", line 598, in create_host_config
162 File "docker/types/containers.py", line 338, in __init__
163docker.errors.InvalidArgument: "host" 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# - "51001:50001"
173# - "51002:50002"
174# - "19001:19001"
175# - "19000:19000"
176# - "28332:28332"
177 % docker-compose up -d
178Creating network "minimal-crypto-exchange_default" 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 - "19001:19001"
195 - "19000:19000"
196 - "28332:28332"
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 - "51001:50001"
204 - "51002:50002"
205# - "19001:19001"
206# - "19000:19000"
207# - "28332:28332"
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, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
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("Heyo!");
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 - "51001:50001"
34 - "51002:50002"
35 - "19001:19001"
36 - "19000:19000"
37 - "28332:28332"
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("."), "_minimalCryptoExchangeBtcWallet");
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, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
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("Heyo!");
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: "host"
113minimal-crypto-exchange % docker-compose up -d
114Creating network "minimal-crypto-exchange_default" 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: "host"
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 "host" network_mode is incompatible with port_bindings
139
140ERROR: for electrumx "host" network_mode is incompatible with port_bindings
141Traceback (most recent call last):
142 File "docker-compose", line 3, in <module>
143 File "compose/cli/main.py", line 81, in main
144 File "compose/cli/main.py", line 203, in perform_command
145 File "compose/metrics/decorator.py", line 18, in wrapper
146 File "compose/cli/main.py", line 1186, in up
147 File "compose/cli/main.py", line 1166, in up
148 File "compose/project.py", line 697, in up
149 File "compose/parallel.py", line 108, in parallel_execute
150 File "compose/parallel.py", line 206, in producer
151 File "compose/project.py", line 679, in do
152 File "compose/service.py", line 579, in execute_convergence_plan
153 File "compose/service.py", line 499, in _execute_convergence_recreate
154 File "compose/parallel.py", line 108, in parallel_execute
155 File "compose/parallel.py", line 206, in producer
156 File "compose/service.py", line 494, in recreate
157 File "compose/service.py", line 612, in recreate_container
158 File "compose/service.py", line 330, in create_container
159 File "compose/service.py", line 939, in _get_container_create_options
160 File "compose/service.py", line 1014, in _get_container_host_config
161 File "docker/api/container.py", line 598, in create_host_config
162 File "docker/types/containers.py", line 338, in __init__
163docker.errors.InvalidArgument: "host" 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# - "51001:50001"
173# - "51002:50002"
174# - "19001:19001"
175# - "19000:19000"
176# - "28332:28332"
177 % docker-compose up -d
178Creating network "minimal-crypto-exchange_default" 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 - "19001:19001"
195 - "19000:19000"
196 - "28332:28332"
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 - "51001:50001"
204 - "51002:50002"
205# - "19001:19001"
206# - "19000:19000"
207# - "28332:28332"
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 && cd bitcoin-${BITCOIN_VERSION} && sed -i 's/consensus.nSubsidyHalvingInterval = 150/consensus.nSubsidyHalvingInterval = 210000/g' src/chainparams.cpp && ./autogen.sh && ./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 && make -j4 && make install && strip /opt/bitcoin/bin/bitcoin-cli && 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, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
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("Heyo!");
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 - "51001:50001"
34 - "51002:50002"
35 - "19001:19001"
36 - "19000:19000"
37 - "28332:28332"
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("."), "_minimalCryptoExchangeBtcWallet");
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, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));
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("Heyo!");
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: "host"
113minimal-crypto-exchange % docker-compose up -d
114Creating network "minimal-crypto-exchange_default" 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: "host"
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 "host" network_mode is incompatible with port_bindings
139
140ERROR: for electrumx "host" network_mode is incompatible with port_bindings
141Traceback (most recent call last):
142 File "docker-compose", line 3, in <module>
143 File "compose/cli/main.py", line 81, in main
144 File "compose/cli/main.py", line 203, in perform_command
145 File "compose/metrics/decorator.py", line 18, in wrapper
146 File "compose/cli/main.py", line 1186, in up
147 File "compose/cli/main.py", line 1166, in up
148 File "compose/project.py", line 697, in up
149 File "compose/parallel.py", line 108, in parallel_execute
150 File "compose/parallel.py", line 206, in producer
151 File "compose/project.py", line 679, in do
152 File "compose/service.py", line 579, in execute_convergence_plan
153 File "compose/service.py", line 499, in _execute_convergence_recreate
154 File "compose/parallel.py", line 108, in parallel_execute
155 File "compose/parallel.py", line 206, in producer
156 File "compose/service.py", line 494, in recreate
157 File "compose/service.py", line 612, in recreate_container
158 File "compose/service.py", line 330, in create_container
159 File "compose/service.py", line 939, in _get_container_create_options
160 File "compose/service.py", line 1014, in _get_container_host_config
161 File "docker/api/container.py", line 598, in create_host_config
162 File "docker/types/containers.py", line 338, in __init__
163docker.errors.InvalidArgument: "host" 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# - "51001:50001"
173# - "51002:50002"
174# - "19001:19001"
175# - "19000:19000"
176# - "28332:28332"
177 % docker-compose up -d
178Creating network "minimal-crypto-exchange_default" 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 - "19001:19001"
195 - "19000:19000"
196 - "28332:28332"
197 electrumx:
198 image: lukechilds/electrumx:latest
199 links: