Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
deBeauvoir
samourai-wallet-android
Commits
8676d68d
Verified
Commit
8676d68d
authored
Dec 02, 2021
by
Sarath
⚔
Browse files
Improved tx0 from utxos list
parent
0384b399
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
27 deletions
+51
-27
app/src/main/java/com/samourai/wallet/utxos/UTXOSActivity.java
...rc/main/java/com/samourai/wallet/utxos/UTXOSActivity.java
+50
-26
app/src/main/res/values/strings.xml
app/src/main/res/values/strings.xml
+1
-1
No files found.
app/src/main/java/com/samourai/wallet/utxos/UTXOSActivity.java
View file @
8676d68d
...
...
@@ -56,8 +56,12 @@ import com.samourai.wallet.utxos.models.UTXOCoin;
import
com.samourai.wallet.utxos.models.UTXOCoinSegment
;
import
com.samourai.wallet.whirlpool.WhirlpoolHome
;
import
com.samourai.wallet.whirlpool.WhirlpoolMeta
;
import
com.samourai.wallet.whirlpool.fragments.WhirlPoolLoaderDialog
;
import
com.samourai.wallet.widgets.ItemDividerDecorator
;
import
com.samourai.whirlpool.client.wallet.AndroidWhirlpoolWalletService
;
import
com.samourai.whirlpool.client.wallet.WhirlpoolUtils
;
import
com.samourai.whirlpool.client.wallet.WhirlpoolWallet
;
import
com.samourai.whirlpool.client.wallet.beans.WhirlpoolUtxo
;
import
org.bitcoinj.core.Address
;
import
org.bitcoinj.crypto.MnemonicException
;
...
...
@@ -690,44 +694,35 @@ public class UTXOSActivity extends SamouraiActivity implements ActionMode.Callba
String
id
=
getPreSelected
();
if
(
account
==
WhirlpoolMeta
.
getInstance
(
getApplicationContext
()).
getWhirlpoolPostmix
())
{
if
(
PreSelectUtil
.
getInstance
().
getPreSelected
(
id
).
size
()
!=
1
)
{
Snackbar
.
make
(
utxoList
,
R
.
string
.
only_a_single_
change_
utxo_may
,
Snackbar
.
LENGTH_LONG
).
show
();
Snackbar
.
make
(
utxoList
,
R
.
string
.
only_a_single_utxo_may
,
Snackbar
.
LENGTH_LONG
).
show
();
return
false
;
}
boolean
blockedExist
=
false
,
receiveExist
=
false
;
boolean
blockedExist
=
false
;
for
(
UTXOCoin
coin
:
PreSelectUtil
.
getInstance
().
getPreSelected
(
id
))
{
if
(
coin
.
doNotSpend
)
{
blockedExist
=
true
;
break
;
}
if
(!
coin
.
path
.
startsWith
(
"M/1/"
))
{
receiveExist
=
true
;
}
}
if
(
receiveExist
)
{
Snackbar
.
make
(
utxoList
,
R
.
string
.
only_a_single_change_utxo_may
,
Snackbar
.
LENGTH_LONG
).
show
();
return
false
;
}
if
(
blockedExist
)
{
Snackbar
.
make
(
utxoList
,
R
.
string
.
selection_contains_blocked_utxo
,
Snackbar
.
LENGTH_LONG
).
show
();
return
false
;
}
}
new
MaterialAlertDialogBuilder
(
this
)
.
setMessage
(
"Send selected utxo's to whirlpool"
)
.
setCancelable
(
false
)
.
setPositiveButton
(
R
.
string
.
ok
,
(
dialog
,
whichButton
)
->
{
if
(
id
!=
null
)
{
Intent
intent
=
new
Intent
(
UTXOSActivity
.
this
,
WhirlpoolHome
.
class
);
intent
.
putExtra
(
"preselected"
,
id
);
intent
.
putExtra
(
"_account"
,
account
);
startActivity
(
intent
);
}
})
.
setNegativeButton
(
R
.
string
.
cancel
,
(
dialogInterface
,
i
)
->
{
})
.
show
();
WhirlpoolWallet
wallet
=
AndroidWhirlpoolWalletService
.
getInstance
().
getWhirlpoolWalletOrNull
();
if
(
wallet
==
null
||
!
wallet
.
isStarted
())
{
WhirlPoolLoaderDialog
whirlPoolLoaderDialog
=
new
WhirlPoolLoaderDialog
();
whirlPoolLoaderDialog
.
show
(
getSupportFragmentManager
(),
whirlPoolLoaderDialog
.
getTag
());
whirlPoolLoaderDialog
.
setOnInitComplete
(()
->
{
sendToWhirlpool
(
wallet
,
id
);
});
}
else
{
sendToWhirlpool
(
wallet
,
id
);
}
}
else
{
sendToWhirlpool
(
null
,
id
);
}
break
;
}
case
R
.
id
.
utxo_details_action_send
:
{
...
...
@@ -774,6 +769,35 @@ public class UTXOSActivity extends SamouraiActivity implements ActionMode.Callba
return
false
;
}
private
void
sendToWhirlpool
(
WhirlpoolWallet
wallet
,
String
id
)
{
if
(
wallet
!=
null
){
List
<
UTXOCoin
>
utxoCoins
=
PreSelectUtil
.
getInstance
().
getPreSelected
(
id
);
for
(
UTXOCoin
coin:
utxoCoins
)
{
WhirlpoolUtxo
utxo
=
wallet
.
getUtxoSupplier
().
findUtxo
(
coin
.
hash
,
coin
.
idx
);
try
{
wallet
.
mixStop
(
utxo
);
}
catch
(
Exception
ex
){
//no-op
}
}
}
new
MaterialAlertDialogBuilder
(
this
)
.
setMessage
(
"Send selected utxo's to whirlpool"
)
.
setCancelable
(
false
)
.
setPositiveButton
(
R
.
string
.
ok
,
(
dialog
,
whichButton
)
->
{
if
(
id
!=
null
)
{
Intent
intent
=
new
Intent
(
UTXOSActivity
.
this
,
WhirlpoolHome
.
class
);
intent
.
putExtra
(
"preselected"
,
id
);
intent
.
putExtra
(
"_account"
,
account
);
startActivity
(
intent
);
}
})
.
setNegativeButton
(
R
.
string
.
cancel
,
(
dialogInterface
,
i
)
->
{
})
.
show
();
}
@Override
public
void
onDestroyActionMode
(
ActionMode
mode
)
{
toolbarActionMode
=
null
;
...
...
app/src/main/res/values/strings.xml
View file @
8676d68d
...
...
@@ -727,7 +727,7 @@
<string
name=
"change_from_postmix"
>
Change from postmix spend
</string>
<string
name=
"selection_contains_blocked_utxo"
>
Your selection contains blocked utxos. please remove and try again.
</string>
<string
name=
"only_single_utxo_may_selected"
>
Only a single utxo may be selected for direct spend from post-mix.
</string>
<string
name=
"only_a_single_
change_
utxo_may"
>
Only a single
change
utxo may be selected for direct Whirlpooling from post-mix.
</string>
<string
name=
"only_a_single_utxo_may"
>
Only a single utxo may be selected for direct Whirlpooling from post-mix.
</string>
<string
name=
"only_change_utxos_allowed"
>
Only change utxo\'s allowed
</string>
<string
name=
"utxo_is_marked_as_blocked"
>
utxo is marked as blocked
</string>
<string-array
name=
"address_types"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment