@@ -68,6 +68,7 @@ import (
6868
6969 "github.com/BitBoxSwiss/bitbox-wallet-app/backend/bridgecommon"
7070 btctypes "github.com/BitBoxSwiss/bitbox-wallet-app/backend/coins/btc/types"
71+ "github.com/BitBoxSwiss/bitbox-wallet-app/backend/devices/bitbox02/simulator"
7172 "github.com/BitBoxSwiss/bitbox-wallet-app/backend/devices/usb"
7273 "github.com/BitBoxSwiss/bitbox-wallet-app/backend/mobileserver"
7374 "github.com/BitBoxSwiss/bitbox-wallet-app/util/logging"
@@ -109,6 +110,14 @@ func setOnline(isReachable bool) {
109110 bridgecommon .SetOnline (isReachable )
110111}
111112
113+ func deviceInfos () []usb.DeviceInfo {
114+ testDeviceInfo := simulator .TestDeviceInfo ()
115+ if testDeviceInfo != nil {
116+ return []usb.DeviceInfo {testDeviceInfo }
117+ }
118+ return usb .DeviceInfos ()
119+ }
120+
112121//export serve
113122func serve (
114123 cppHeapFreeFn C.cppHeapFree ,
@@ -121,6 +130,8 @@ func serve(
121130 log := logging .Get ().WithGroup ("server" )
122131 log .WithField ("args" , os .Args ).Info ("Started Qt application" )
123132 testnet := flag .Bool ("testnet" , false , "activate testnets" )
133+ simulatorPort := flag .Int ("simulatorPort" , 15423 , "port for the BitBox02 simulator" )
134+ useSimulator := flag .Bool ("simulator" , false , "use the BitBox02 simulator. It implies --testnet." )
124135
125136 if runtime .GOOS == "darwin" {
126137 // eat "-psn_xxxx" on Mac, which is passed when starting an app from Finder for the first time.
@@ -146,12 +157,17 @@ func serve(
146157 }
147158 }
148159
160+ if * useSimulator {
161+ simulator .Init (* simulatorPort )
162+ }
163+
149164 // Capture C string early to avoid potential use when it's already popped
150165 // from the stack.
151166 nativeLocale := C .GoString (preferredLocale )
152167
153168 bridgecommon .Serve (
154169 * testnet ,
170+ * useSimulator ,
155171 gapLimits ,
156172 & nativeCommunication {
157173 respond : func (queryID int , response string ) {
@@ -171,7 +187,7 @@ func serve(
171187 defer C .free (unsafe .Pointer (cText ))
172188 C .notifyUser (notifyUserFn , cText )
173189 },
174- DeviceInfosFunc : usb . DeviceInfos ,
190+ DeviceInfosFunc : deviceInfos ,
175191 SystemOpenFunc : system .Open ,
176192 UsingMobileDataFunc : func () bool { return false },
177193 NativeLocaleFunc : func () string { return nativeLocale },
0 commit comments