Skip to content

Commit

Permalink
Android: Moved signSchnorr() into a function; using canBroadcast() in…
Browse files Browse the repository at this point in the history
…stead of string comparison; fixed an issue with status text wrapping.
  • Loading branch information
Aldin-SXR committed Jun 9, 2021
1 parent 8a2c0d6 commit 5610e65
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
Expand Up @@ -136,7 +136,7 @@ class ColdLoadDialog : AlertDialogFragment() {
// Check if the transaction can be processed by this wallet or not
val txInfo = daemonModel.wallet!!.callAttr("get_tx_info", tx)

if (txInfo["amount"] == null && txInfo["status"].toString() != "Signed") {
if (txInfo["amount"] == null && !canBroadcast(tx)) {
idTxStatus.setText(R.string.transaction_unrelated)
} else {
idTxStatus.setText(txInfo["status"].toString())
Expand Down Expand Up @@ -172,11 +172,9 @@ fun canBroadcast(tx: PyObject): Boolean {
*/
class SignPasswordDialog : PasswordDialog<PyObject>() {
val coldLoadDialog by lazy { targetFragment as ColdLoadDialog }
// Schnorr signing is supported by standard and imported private key wallets.
val signSchnorr = daemonModel.walletType in listOf("standard", "imported_privkey")

val tx by lazy { libTransaction.callAttr("Transaction", arguments!!.getString("tx"),
Kwarg("sign_schnorr", signSchnorr)) }
Kwarg("sign_schnorr", signSchnorr())) }
val wallet = daemonModel.wallet!!

override fun onPassword(password: String): PyObject {
Expand Down
Expand Up @@ -210,10 +210,8 @@ class SendDialog : TaskLauncherDialog<Unit>() {
val inputs = wallet.callAttr("get_spendable_coins", null, daemonModel.config,
Kwarg("isInvoice", pr != null))
return try {
// Schnorr signing is supported by standard and imported private key wallets.
val signSchnorr = daemonModel.walletType in listOf("standard", "imported_privkey")
TxResult(wallet.callAttr("make_unsigned_transaction", inputs, outputs,
daemonModel.config, Kwarg("sign_schnorr", signSchnorr)),
daemonModel.config, Kwarg("sign_schnorr", signSchnorr())),
isDummy)
} catch (e: PyException) {
TxResult(if (e.message!!.startsWith("NotEnoughFunds"))
Expand Down
Expand Up @@ -258,3 +258,11 @@ fun baseDecode(s: String, base: Int): String {
return libBitcoin.callAttr("base_decode", s, null, base)
.callAttr("hex").toString()
}

/**
* Decide whether to use Schnorr signatures.
* Schnorr signing is supported by standard and imported private key wallets.
*/
fun signSchnorr(): Boolean {
return daemonModel.walletType in listOf("standard", "imported_privkey")
}
5 changes: 4 additions & 1 deletion android/app/src/main/res/layout/load.xml
Expand Up @@ -71,12 +71,15 @@
<TextView
android:id="@+id/idTxStatus"
style="@style/Medium"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginTop="6dp"
android:layout_marginEnd="24dp"
android:singleLine="false"
android:text="@string/empty"
android:visibility="visible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/idStatusLabel"
app:layout_constraintTop_toBottomOf="@+id/etTransaction" />

Expand Down

0 comments on commit 5610e65

Please sign in to comment.