Skip to content

Commit 669bbe9

Browse files
committed
Update version to 5.3.12: Remove Bitcoin.com socket, and fix the Blockchain.info socket.
1 parent b9b1a9d commit 669bbe9

File tree

8 files changed

+21
-72
lines changed

8 files changed

+21
-72
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Other features include:
2121
Why accept Bitcoin Cash?
2222
- Say goodbye to credit card fees! Bitcoin Cash costs absolutely nothing to receive
2323
- Customers pay less than a penny in transaction fees to send
24-
- No registration is required to accept BCH. Just download a free, open-source wallet, like the official Bitcoin.com Bitcoin Wallet
24+
- No registration is required to accept BCH. Just download a free wallet like the official Bitcoin.com Bitcoin Wallet
2525
- No one can freeze your wallet
2626
- No one can seize your funds
2727
- No one can block your payments

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ android {
1616
applicationId "com.bitcoin.merchant.app"
1717
minSdkVersion 21
1818
targetSdkVersion 30
19-
versionCode 50311
20-
versionName "5.3.11"
19+
versionCode 50312
20+
versionName "5.3.12"
2121
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2222
}
2323
buildTypes {

app/src/main/java/com/bitcoin/merchant/app/MainActivity.kt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import com.bitcoin.merchant.app.model.Analytics
2727
import com.bitcoin.merchant.app.network.PaymentReceived
2828
import com.bitcoin.merchant.app.network.websocket.TxWebSocketHandler
2929
import com.bitcoin.merchant.app.network.websocket.WebSocketListener
30-
import com.bitcoin.merchant.app.network.websocket.impl.bitcoincom.BitcoinComSocketHandler
3130
import com.bitcoin.merchant.app.network.websocket.impl.blockchaininfo.BlockchainInfoSocketSocketHandler
3231
import com.bitcoin.merchant.app.screens.dialogs.DialogHelper
3332
import com.bitcoin.merchant.app.screens.features.ToolbarAwareFragment
@@ -51,14 +50,12 @@ open class MainActivity : AppCompatActivity(), WebSocketListener {
5150
val app: CashRegisterApplication
5251
get() = application as CashRegisterApplication
5352

54-
lateinit var bitcoinDotComSocket: TxWebSocketHandler
5553
lateinit var blockchainDotInfoSocket: TxWebSocketHandler
5654

5755
private val receiver: BroadcastReceiver = object : BroadcastReceiver() {
5856
override fun onReceive(context: Context, intent: Intent) {
5957
if (Action.SUBSCRIBE_TO_ADDRESS == intent.action) {
6058
println("Subscribed to address!")
61-
bitcoinDotComSocket.subscribeToAddress(intent.getStringExtra("address"))
6259
blockchainDotInfoSocket.subscribeToAddress(intent.getStringExtra("address"))
6360
}
6461
}
@@ -81,13 +78,6 @@ open class MainActivity : AppCompatActivity(), WebSocketListener {
8178
}
8279

8380
fun restartSocketsWhenNeeded() {
84-
if (!this::bitcoinDotComSocket.isInitialized || !bitcoinDotComSocket.isConnected) {
85-
if (this::bitcoinDotComSocket.isInitialized)
86-
bitcoinDotComSocket.stop()
87-
bitcoinDotComSocket = BitcoinComSocketHandler()
88-
bitcoinDotComSocket.setListener(this)
89-
bitcoinDotComSocket.start()
90-
}
9181
if (!this::blockchainDotInfoSocket.isInitialized || !blockchainDotInfoSocket.isConnected) {
9282
if (this::blockchainDotInfoSocket.isInitialized)
9383
blockchainDotInfoSocket.stop()

app/src/main/java/com/bitcoin/merchant/app/model/PaymentTarget.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ data class PaymentTarget(val type: Type, val target: String) {
5252
if (Xpub.isValid(value))
5353
return PaymentTarget(Type.XPUB, value)
5454
if (AddressUtil.isValidLegacy(value))
55-
return PaymentTarget(Type.ADDRESS, value)
55+
return PaymentTarget(Type.ADDRESS, AddressUtil.toCashAddress(value))
5656
if (AddressUtil.isValidCashAddr(value))
57-
return PaymentTarget(Type.ADDRESS, AddressUtil.toLegacyAddress(value))
57+
return PaymentTarget(Type.ADDRESS, value)
5858
if (isApiKey(value))
5959
return PaymentTarget(Type.API_KEY, value)
6060
return PaymentTarget(Type.INVALID, "")

app/src/main/java/com/bitcoin/merchant/app/network/websocket/impl/bitcoincom/BitcoinComSocketHandler.java

Lines changed: 0 additions & 52 deletions
This file was deleted.

app/src/main/java/com/bitcoin/merchant/app/screens/PaymentRequestFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ class PaymentRequestFragment : ToolbarAwareFragment() {
482482
object : CountDownTimer(1000, 1000) {
483483
override fun onTick(millisUntilFinished: Long) {
484484
if (isAdded) {
485-
updateConnectionStatus(activity.bitcoinDotComSocket.isConnected)
485+
updateConnectionStatus(activity.blockchainDotInfoSocket.isConnected)
486486
}
487487
}
488488

app/src/main/java/com/bitcoin/merchant/app/util/AddressUtil.kt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,20 @@ object AddressUtil {
2525
}
2626
}
2727

28-
fun toCashAddress(legacy: String): String {
29-
return CashAddressFactory.create().getFromBase58(MainNetParams.get(), legacy).toString()
28+
fun toCashAddress(address: String): String {
29+
return if(isValidLegacy(address)) {
30+
CashAddressFactory.create().getFromBase58(MainNetParams.get(), address).toString()
31+
} else {
32+
CashAddressFactory.create().getFromFormattedAddress(MainNetParams.get(), address).toString()
33+
}
3034
}
3135

3236
fun toLegacyAddress(address: String): String {
33-
return CashAddressFactory.create().getFromFormattedAddress(MainNetParams.get(), address).toBase58()
37+
return if(isValidCashAddr(address)) {
38+
CashAddressFactory.create().getFromFormattedAddress(MainNetParams.get(), address).toBase58()
39+
} else {
40+
CashAddressFactory.create().getFromBase58(MainNetParams.get(), address).toBase58()
41+
}
3442
}
3543

3644
fun toSimpleLedgerAddress(address: String): String {

app/src/main/java/com/bitcoin/merchant/app/util/Settings.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ object Settings {
4242
}
4343

4444
fun getPaymentTarget(context: Context): PaymentTarget {
45-
val value = PrefsUtil.getInstance(context).getValue(PrefsUtil.MERCHANT_KEY_MERCHANT_RECEIVER, "")
45+
var value = PrefsUtil.getInstance(context).getValue(PrefsUtil.MERCHANT_KEY_MERCHANT_RECEIVER, "")
46+
if(AddressUtil.isValidLegacy(value)) {
47+
value = AddressUtil.toCashAddress(value)
48+
}
4649
return PaymentTarget.parse(value)
4750
}
4851

0 commit comments

Comments
 (0)