Skip to content

Commit f352cab

Browse files
feat: remove OP_RETURN feature
1 parent d0f0bdf commit f352cab

File tree

6 files changed

+76
-115
lines changed

6 files changed

+76
-115
lines changed

app/src/main/java/org/bitcoindevkit/devkitwallet/domain/Wallet.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class Wallet private constructor(
5454
return walletSecrets
5555
}
5656

57-
fun createTransaction(recipientList: List<Recipient>, feeRate: FeeRate, opReturnMsg: String?): Psbt {
57+
fun createTransaction(recipientList: List<Recipient>, feeRate: FeeRate): Psbt {
5858
// technique 1 for adding a list of recipients to the TxBuilder
5959
// var txBuilder = TxBuilder()
6060
// for (recipient in recipientList) {

app/src/main/java/org/bitcoindevkit/devkitwallet/presentation/ui/components/NeutralButton.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import androidx.compose.ui.unit.dp
1919
import org.bitcoindevkit.devkitwallet.presentation.theme.DevkitWalletColors
2020

2121
@Composable
22-
fun NeutralButton(text: String, enabled: Boolean, modifier: Modifier? = null, onClick: () -> Unit) {
22+
fun NeutralButton(text: String, enabled: Boolean = true, modifier: Modifier? = null, onClick: () -> Unit) {
2323
Button(
2424
onClick = onClick,
2525
colors =

app/src/main/java/org/bitcoindevkit/devkitwallet/presentation/ui/components/TransactionCards.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ fun PendingTransactionCard(details: TxDetails, navController: NavController) {
8080
color = DevkitWalletColors.accent1,
8181
shape = RoundedCornerShape(16.dp)
8282
).clickable {
83-
viewTransaction(
84-
navController = navController,
85-
txid = details.txid
86-
)
83+
// viewTransaction(
84+
// navController = navController,
85+
// txid = details.txid
86+
// )
8787
},
8888
verticalAlignment = Alignment.CenterVertically,
8989
horizontalArrangement = Arrangement.Absolute.SpaceBetween

app/src/main/java/org/bitcoindevkit/devkitwallet/presentation/ui/screens/wallet/SendScreen.kt

Lines changed: 70 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ package org.bitcoindevkit.devkitwallet.presentation.ui.screens.wallet
88
import android.content.Context
99
import android.widget.Toast
1010
import androidx.compose.foundation.background
11+
import androidx.compose.foundation.border
12+
import androidx.compose.foundation.clickable
1113
import androidx.compose.foundation.layout.Arrangement
14+
import androidx.compose.foundation.layout.Box
1215
import androidx.compose.foundation.layout.Column
1316
import androidx.compose.foundation.layout.Row
1417
import androidx.compose.foundation.layout.Spacer
@@ -27,6 +30,7 @@ import androidx.compose.material3.BottomSheetScaffoldState
2730
import androidx.compose.material3.Button
2831
import androidx.compose.material3.ButtonDefaults
2932
import androidx.compose.material3.ExperimentalMaterial3Api
33+
import androidx.compose.material3.Icon
3034
import androidx.compose.material3.OutlinedTextField
3135
import androidx.compose.material3.OutlinedTextFieldDefaults
3236
import androidx.compose.material3.Switch
@@ -43,22 +47,27 @@ import androidx.compose.runtime.rememberCoroutineScope
4347
import androidx.compose.runtime.saveable.rememberSaveable
4448
import androidx.compose.ui.Alignment
4549
import androidx.compose.ui.Modifier
50+
import androidx.compose.ui.draw.clip
4651
import androidx.compose.ui.draw.shadow
4752
import androidx.compose.ui.graphics.Color
4853
import androidx.compose.ui.platform.LocalContext
54+
import androidx.compose.ui.semantics.Role
4955
import androidx.compose.ui.text.TextStyle
5056
import androidx.compose.ui.text.style.TextAlign
5157
import androidx.compose.ui.unit.dp
5258
import androidx.compose.ui.unit.sp
5359
import androidx.constraintlayout.compose.ConstraintLayout
5460
import androidx.constraintlayout.compose.Dimension
5561
import androidx.navigation.NavController
62+
import com.composables.icons.lucide.Lucide
63+
import com.composables.icons.lucide.UserRoundMinus
64+
import com.composables.icons.lucide.UserRoundPlus
5665
import kotlinx.coroutines.CoroutineScope
5766
import kotlinx.coroutines.launch
5867
import org.bitcoindevkit.devkitwallet.presentation.navigation.HomeScreen
5968
import org.bitcoindevkit.devkitwallet.presentation.theme.DevkitWalletColors
60-
import org.bitcoindevkit.devkitwallet.presentation.theme.quattroRegular
6169
import org.bitcoindevkit.devkitwallet.presentation.theme.standardText
70+
import org.bitcoindevkit.devkitwallet.presentation.ui.components.NeutralButton
6271
import org.bitcoindevkit.devkitwallet.presentation.ui.components.SecondaryScreensAppBar
6372
import org.bitcoindevkit.devkitwallet.presentation.viewmodels.SendViewModel
6473
import org.bitcoindevkit.devkitwallet.presentation.viewmodels.mvi.Recipient
@@ -79,10 +88,7 @@ internal fun SendScreen(navController: NavController, sendViewModel: SendViewMod
7988
val recipientList: MutableList<Recipient> = remember { mutableStateListOf(Recipient(address = "", amount = 0u)) }
8089
val feeRate: MutableState<String> = rememberSaveable { mutableStateOf("") }
8190
val (showDialog, setShowDialog) = rememberSaveable { mutableStateOf(false) }
82-
8391
val sendAll: MutableState<Boolean> = remember { mutableStateOf(false) }
84-
val rbfDisabled: MutableState<Boolean> = remember { mutableStateOf(false) }
85-
val opReturnMsg: MutableState<String?> = remember { mutableStateOf(null) }
8692

8793
val bottomSheetScaffoldState: BottomSheetScaffoldState = rememberBottomSheetScaffoldState()
8894

@@ -94,7 +100,7 @@ internal fun SendScreen(navController: NavController, sendViewModel: SendViewMod
94100
)
95101
},
96102
sheetShape = RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp),
97-
sheetContent = { AdvancedOptions(sendAll, opReturnMsg, recipientList) },
103+
sheetContent = { AdvancedOptions(sendAll, recipientList) },
98104
sheetContainerColor = DevkitWalletColors.primaryDark,
99105
scaffoldState = bottomSheetScaffoldState,
100106
sheetPeekHeight = 0.dp,
@@ -124,14 +130,12 @@ internal fun SendScreen(navController: NavController, sendViewModel: SendViewMod
124130
transactionType = if (sendAll.value) TransactionType.SEND_ALL else TransactionType.STANDARD
125131
)
126132
TransactionFeeInput(feeRate = feeRate)
127-
MoreOptions(coroutineScope = coroutineScope, bottomSheetScaffoldState = bottomSheetScaffoldState)
128133
Dialog(
129134
recipientList = recipientList,
130135
feeRate = feeRate,
131136
showDialog = showDialog,
132137
setShowDialog = setShowDialog,
133138
transactionType = if (sendAll.value) TransactionType.SEND_ALL else TransactionType.STANDARD,
134-
opReturnMsg = opReturnMsg.value,
135139
context = context,
136140
onAction = onAction
137141
)
@@ -144,6 +148,7 @@ internal fun SendScreen(navController: NavController, sendViewModel: SendViewMod
144148
end.linkTo(parent.end)
145149
}.padding(bottom = 32.dp)
146150
) {
151+
MoreOptions(coroutineScope = coroutineScope, bottomSheetScaffoldState = bottomSheetScaffoldState)
147152
Button(
148153
onClick = { setShowDialog(true) },
149154
colors = ButtonDefaults.buttonColors(DevkitWalletColors.accent2),
@@ -155,11 +160,7 @@ internal fun SendScreen(navController: NavController, sendViewModel: SendViewMod
155160
.shadow(elevation = 4.dp, shape = RoundedCornerShape(16.dp))
156161
) {
157162
Text(
158-
text = "broadcast transaction",
159-
fontSize = 14.sp,
160-
fontFamily = quattroRegular,
161-
textAlign = TextAlign.Center,
162-
lineHeight = 28.sp,
163+
text = "Broadcast transaction",
163164
)
164165
}
165166
}
@@ -170,27 +171,13 @@ internal fun SendScreen(navController: NavController, sendViewModel: SendViewMod
170171
@Composable
171172
internal fun AdvancedOptions(
172173
sendAll: MutableState<Boolean>,
173-
opReturnMsg: MutableState<String?>,
174174
recipientList: MutableList<Recipient>,
175175
) {
176176
Column(
177177
modifier = Modifier
178178
.fillMaxWidth()
179179
.padding(horizontal = 16.dp, vertical = 8.dp)
180180
) {
181-
Row(
182-
Modifier
183-
.fillMaxWidth()
184-
.padding(bottom = 8.dp),
185-
horizontalArrangement = Arrangement.Center
186-
) {
187-
Text(
188-
text = "Advanced Options",
189-
color = DevkitWalletColors.white,
190-
fontSize = 18.sp,
191-
)
192-
}
193-
194181
Row(
195182
verticalAlignment = Alignment.CenterVertically,
196183
horizontalArrangement = Arrangement.SpaceBetween,
@@ -221,77 +208,72 @@ internal fun AdvancedOptions(
221208
)
222209
}
223210

224-
Row(verticalAlignment = Alignment.CenterVertically) {
225-
OutlinedTextField(
226-
modifier = Modifier
227-
.padding(vertical = 8.dp)
228-
.weight(0.5f),
229-
value = opReturnMsg.value ?: "",
230-
onValueChange = {
231-
opReturnMsg.value = it
232-
},
233-
label = {
234-
Text(
235-
text = "Optional OP_RETURN message",
236-
color = DevkitWalletColors.white,
237-
)
238-
},
239-
singleLine = true,
240-
textStyle = TextStyle(color = DevkitWalletColors.white),
241-
colors = OutlinedTextFieldDefaults.colors(
242-
cursorColor = DevkitWalletColors.accent1,
243-
focusedBorderColor = DevkitWalletColors.accent1,
244-
unfocusedBorderColor = DevkitWalletColors.white
245-
),
246-
)
247-
}
248-
249211
Row(
250-
Modifier
251-
.fillMaxWidth()
252-
.padding(vertical = 4.dp),
253-
horizontalArrangement = Arrangement.Center
212+
Modifier.fillMaxWidth(),
213+
horizontalArrangement = Arrangement.SpaceBetween,
214+
verticalAlignment = Alignment.CenterVertically
254215
) {
255216
Text(
256217
text = "Number of Recipients",
257218
style = standardText
258219
)
259-
}
260-
261-
Row(
262-
Modifier.fillMaxWidth(),
263-
horizontalArrangement = Arrangement.SpaceBetween,
264-
verticalAlignment = Alignment.CenterVertically
265-
) {
266-
Button(
267-
onClick = {
268-
if (recipientList.size > 1) {
269-
recipientList.removeLast()
270-
}
271-
},
272-
enabled = !sendAll.value,
273-
colors = ButtonDefaults.buttonColors(DevkitWalletColors.accent2),
274-
shape = RoundedCornerShape(16.dp),
275-
modifier = Modifier.width(70.dp)
276-
) {
277-
Text(text = "-")
278-
}
279-
280220
Text(
281221
text = "${recipientList.size}",
282-
color = DevkitWalletColors.white,
283-
fontSize = 18.sp,
222+
style = standardText
284223
)
285224

286-
Button(
287-
onClick = { recipientList.add(Recipient("", 0u)) },
288-
enabled = !sendAll.value,
289-
colors = ButtonDefaults.buttonColors(DevkitWalletColors.accent1),
290-
shape = RoundedCornerShape(16.dp),
291-
modifier = Modifier.width(70.dp)
225+
Row(
226+
verticalAlignment = Alignment.CenterVertically,
227+
horizontalArrangement = Arrangement.spacedBy((-1).dp),
228+
modifier = Modifier.padding(top = 4.dp)
292229
) {
293-
Text(text = "+")
230+
val startShape = RoundedCornerShape(topStart = 6.dp, bottomStart = 6.dp)
231+
val endShape = RoundedCornerShape(topEnd = 6.dp, bottomEnd = 6.dp)
232+
Box(
233+
Modifier
234+
.clip(startShape)
235+
.border(2.dp, Color.White, startShape)
236+
.clickable(role = Role.Button) {
237+
recipientList.add(Recipient("", 0u))
238+
}.padding(horizontal = 12.dp, vertical = 10.dp)
239+
) {
240+
Icon(Lucide.UserRoundPlus, tint = DevkitWalletColors.white, contentDescription = null)
241+
}
242+
Box(
243+
Modifier
244+
.clip(endShape)
245+
.border(2.dp, Color.White, endShape)
246+
.clickable(role = Role.Button) {
247+
if (recipientList.size > 1) {
248+
recipientList.removeLast()
249+
}
250+
}.padding(horizontal = 12.dp, vertical = 10.dp)
251+
) {
252+
Icon(Lucide.UserRoundMinus, tint = DevkitWalletColors.white, contentDescription = null)
253+
}
294254
}
255+
// Button(
256+
// onClick = {
257+
// if (recipientList.size > 1) {
258+
// recipientList.removeLast()
259+
// }
260+
// },
261+
// enabled = !sendAll.value,
262+
// colors = ButtonDefaults.buttonColors(DevkitWalletColors.accent2),
263+
// shape = RoundedCornerShape(16.dp),
264+
// modifier = Modifier.width(70.dp)
265+
// ) {
266+
// Text(text = "-")
267+
// }
268+
// Button(
269+
// onClick = { recipientList.add(Recipient("", 0u)) },
270+
// enabled = !sendAll.value,
271+
// colors = ButtonDefaults.buttonColors(DevkitWalletColors.accent1),
272+
// shape = RoundedCornerShape(16.dp),
273+
// modifier = Modifier.width(70.dp)
274+
// ) {
275+
// Text(text = "+")
276+
// }
295277
}
296278

297279
Spacer(modifier = Modifier.height(32.dp))
@@ -447,29 +429,15 @@ private fun TransactionFeeInput(feeRate: MutableState<String>) {
447429
fun MoreOptions(coroutineScope: CoroutineScope, bottomSheetScaffoldState: BottomSheetScaffoldState) {
448430
Column(
449431
horizontalAlignment = Alignment.CenterHorizontally,
450-
modifier = Modifier
451-
.padding(vertical = 8.dp)
452-
.background(DevkitWalletColors.secondary)
453432
) {
454-
Button(
433+
NeutralButton(
434+
text = "Advanced options",
455435
onClick = {
456436
coroutineScope.launch {
457437
bottomSheetScaffoldState.bottomSheetState.expand()
458438
}
459439
},
460-
colors = ButtonDefaults.buttonColors(Color.Transparent),
461-
modifier = Modifier
462-
.height(60.dp)
463-
.fillMaxWidth(fraction = 0.9f)
464-
.padding(vertical = 8.dp)
465-
) {
466-
Text(
467-
text = "advanced options",
468-
style = standardText,
469-
textAlign = TextAlign.Center,
470-
lineHeight = 28.sp,
471-
)
472-
}
440+
)
473441
}
474442
}
475443

@@ -480,7 +448,6 @@ private fun Dialog(
480448
showDialog: Boolean,
481449
setShowDialog: (Boolean) -> Unit,
482450
transactionType: TransactionType,
483-
opReturnMsg: String?,
484451
context: Context,
485452
onAction: (SendScreenAction) -> Unit,
486453
) {
@@ -490,9 +457,6 @@ private fun Dialog(
490457
if (feeRate.value.isNotEmpty()) {
491458
confirmationText += "Fee Rate : ${feeRate.value.toULong()}"
492459
}
493-
if (!opReturnMsg.isNullOrEmpty()) {
494-
confirmationText += "OP_RETURN Message : $opReturnMsg"
495-
}
496460
AlertDialog(
497461
containerColor = DevkitWalletColors.primaryLight,
498462
onDismissRequest = {},
@@ -517,7 +481,6 @@ private fun Dialog(
517481
recipients = recipientList,
518482
feeRate = feeRate.value.toULong(),
519483
transactionType = transactionType,
520-
opReturnMsg = opReturnMsg
521484
)
522485
onAction(SendScreenAction.Broadcast(txDataBundle))
523486
setShowDialog(false)

app/src/main/java/org/bitcoindevkit/devkitwallet/presentation/viewmodels/SendViewModel.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ internal class SendViewModel(private val wallet: Wallet) : ViewModel() {
3232
wallet.createTransaction(
3333
recipientList = txInfo.recipients,
3434
feeRate = FeeRate.fromSatPerVb(txInfo.feeRate),
35-
opReturnMsg = txInfo.opReturnMsg
3635
)
3736
// TransactionType.SEND_ALL -> Wallet.createSendAllTransaction(recipientList[0].address, FeeRate.fromSatPerVb(feeRate), rbfEnabled, opReturnMsg)
3837
TransactionType.SEND_ALL -> throw NotImplementedError("Send all not implemented")

app/src/main/java/org/bitcoindevkit/devkitwallet/presentation/viewmodels/mvi/MviSendScreen.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ data class TxDataBundle(
1717
val recipients: List<Recipient>,
1818
val feeRate: ULong,
1919
val transactionType: TransactionType,
20-
val opReturnMsg: String? = null,
2120
)
2221

2322
data class Recipient(var address: String, var amount: ULong)

0 commit comments

Comments
 (0)