Commit 6bf46fdb authored by Rocky Rococo's avatar Rocky Rococo
Browse files

Squashed commit of the following:

commit 614cc7f9479a43db088a5fb3ca04e2a340a5e352
Author: TDevD <dev@samouraiwallet.com>
Date:   Wed Sep 22 15:06:35 2021 +0200

    0.99.97a

commit 26e971703da1cb883011faaa2e362daccb961fc5
Author: TDevD <dev@samouraiwallet.com>
Date:   Wed Sep 22 14:54:16 2021 +0200

    bump version name

commit 07f43147db959396c8d9c75f15b4cb5e386e75de
Author: TDevD <dev@samouraiwallet.com>
Date:   Wed Sep 22 12:46:09 2021 +0200

    bump version name

commit 775b537751589c21f3242847514c6adcbf09b84f
Author: TDevD <dev@samouraiwallet.com>
Date:   Sat Sep 18 13:57:40 2021 +0200

    bump staging

commit 1fb6e89ea688f56cb9a7b92e25cf9306fc328aca
Author: TDevD <dev@samouraiwallet.com>
Date:   Sat Sep 18 13:45:03 2021 +0200

    check for Dojo like-type

commit be4aae7834ca09dec0a1f73adba33fa60cfa0588
Author: TDevD <dev@samouraiwallet.com>
Date:   Wed Sep 15 16:44:21 2021 +0200

    v0.99.97

commit 77c4e8a7de00e69c21fa9a82f0f89444384343c9
Author: TDevD <dev@samouraiwallet.com>
Date:   Wed Sep 15 10:21:31 2021 +0200

    bump version

commit 339eb7de620cc1888438394bcdd0f9e2c5c52e5a
Author: TDevD <dev@samouraiwallet.com>
Date:   Sun Sep 5 10:05:00 2021 +0200

    Dojo like-type outputs

commit 2d37d0ee885f26e5fe77a914af5f03f15ec8c371
Author: TDevD <dev@samouraiwallet.com>
Date:   Sun Sep 5 10:04:27 2021 +0200

    read Dojo version number

commit ca3c87968b991052c2f2c3761df7601cd192c732
Author: TDevD <dev@samouraiwallet.com>
Date:   Sat Aug 21 09:18:34 2021 +0200

    use boolean for xpubpostxreg metadata

commit 179af9bb6287aa30710c80de27e5abe25cebcbc3
Author: TDevD <dev@samouraiwallet.com>
Date:   Thu Aug 19 18:51:41 2021 +0200

    xpubpostxreg metadata

commit 356bab1443d1aed38ccf8ff7a7cf823eb25de562
Merge: dbc2a566 5c12dc86
Author: TDevD <dev@samouraiwallet.com>
Date:   Thu Aug 19 15:12:15 2021 +0200

    Merge branch 'postmix_change' into staging

commit dbc2a56666acc4a4e5282d6a06498afd6ac49a1d
Merge: 55af74a3 f1e424c3
Author: TDevD <dev@samouraiwallet.com>
Date:   Thu Aug 19 15:10:27 2021 +0200

    Merge branch 'staging' of https://code.samourai.io/wallet/samourai-wallet-android into staging

commit 5c12dc869e4d67b988eee12a026e56f504f71bab
Author: TDevD <dev@samouraiwallet.com>
Date:   Thu Aug 19 15:09:58 2021 +0200

    Post-mix like type change

commit f1e424c3
Merge: 25acb4d1 81f86af2
Author: T Dev. D <dev@samouraiwallet.com>
Date:   Thu Aug 19 13:09:19 2021 +0000

    Merge branch 'staging' into 'staging'

    Update support links

    See merge request wallet/samourai-wallet-android!456

commit 81f86af2
Merge: 73d79ae4 e7591dfe
Author: Crazyk031 <crazyk@samourai.io>
Date:   Wed Aug 18 20:59:45 2021 -0700

    Merge branch 'staging' of code.samourai.io:Crazyk031/samourai-wallet-android into staging
    Merge

commit e7591dfe
Author: Crazyk031 <crazyk@samourai.io>
Date:   Wed Aug 18 05:16:18 2021 +0000

    Update samourai.api, app/src/main/java/com/samourai/wallet/home/BalanceActivity.java files

commit 73d79ae4
Author: Crazyk031 <crazyk@samourai.io>
Date:   Tue Aug 17 21:49:24 2021 -0700

    Change support links & email

commit 9b13869c
Author: Crazyk031 <crazyk@samourai.io>
Date:   Mon Aug 16 22:05:58 2021 -0700

    Change support links & email

commit 55af74a32ed1b0cd3ddcbba3261dd141b5e5673c
Author: TDevD <dev@samouraiwallet.com>
Date:   Sat Aug 7 09:53:52 2021 +0200

    Local receive indexes

commit 25acb4d1
Author: TDevD <dev@samouraiwallet.com>
Date:   Sat Aug 7 09:50:57 2021 +0200

    NewPoolActivity: use same fee as tx0FeeTarget

commit 42a6352e
Author: TDevD <dev@samouraiwallet.com>
Date:   Sat Aug 7 09:05:10 2021 +0200

    PayloadUtil: fix spacing

commit 43c0c771
Author: TDevD <dev@samouraiwallet.com>
Date:   Thu Aug 5 15:23:33 2021 +0200

    bump staging

commit 2722b90d
Merge: 7881e404 3ad3d3a0
Author: T Dev. D <dev@samouraiwallet.com>
Date:   Thu Aug 5 13:15:45 2021 +0000

    Merge branch 'develop' into 'staging'

    updated french version

    See merge request wallet/samourai-wallet-android!454

commit 3ad3d3a0
Author: deBeauvoir <sh2201@gmail.com>
Date:   Tue Jul 27 09:37:16 2021 +0200

    updated french version
parent 7881e404
......@@ -11,8 +11,8 @@ android {
applicationId 'com.samourai.wallet'
minSdkVersion 21
targetSdkVersion 30
versionCode 184
versionName "0.99.96j"
versionCode 187
versionName "0.99.97a"
// Enabling multidex support.
multiDexEnabled true
}
......@@ -57,19 +57,19 @@ android {
applicationId 'com.samourai.wallet'
minSdkVersion 21
targetSdkVersion 30
versionCode 184
versionName "0.99.96j"
versionCode 187
versionName "0.99.97a"
resValue "string", "app_name", "Samourai"
resValue "string", "version_name", "0.99.96j"
resValue "string", "version_name", "0.99.97a"
}
staging {
applicationId 'com.samourai.wallet.staging'
minSdkVersion 21
targetSdkVersion 30
versionCode 184
versionName "0.99.96j"
versionCode 187
versionName "0.99.97a"
resValue "string", "app_name", "Samourai Staging"
resValue "string", "version_name", "0.99.96j"
resValue "string", "version_name", "0.99.97a"
}
}
testOptions {
......
......@@ -138,6 +138,16 @@ public class AddressCalcActivity extends SamouraiActivity {
segwitAddress = new SegwitAddress(hd_addr.getECKey(), SamouraiWallet.getInstance().getCurrentNetworkParams());
}
else if(spType.getSelectedItemPosition() == 6) {
segwitAddress = null;
chain = 1;
hd_addr = BIP84Util.getInstance(AddressCalcActivity.this).getWallet().getAccountAt(WhirlpoolMeta.getInstance(AddressCalcActivity.this).getWhirlpoolPostmix()).getChain(chain).getAddressAt(index);
}
else if(spType.getSelectedItemPosition() == 7) {
chain = 1;
hd_addr = BIP84Util.getInstance(AddressCalcActivity.this).getWallet().getAccountAt(WhirlpoolMeta.getInstance(AddressCalcActivity.this).getWhirlpoolPostmix()).getChain(chain).getAddressAt(index);
segwitAddress = new SegwitAddress(hd_addr.getECKey(), SamouraiWallet.getInstance().getCurrentNetworkParams());
}
else if(spType.getSelectedItemPosition() == 8) {
hd_addr = BIP84Util.getInstance(AddressCalcActivity.this).getWallet().getAccountAt(WhirlpoolMeta.getInstance(AddressCalcActivity.this).getWhirlpoolBadBank()).getChain(chain).getAddressAt(index);
segwitAddress = new SegwitAddress(hd_addr.getECKey(), SamouraiWallet.getInstance().getCurrentNetworkParams());
}
......@@ -148,13 +158,13 @@ public class AddressCalcActivity extends SamouraiActivity {
final ECKey ecKey;
final String strAddress;
if(spType.getSelectedItemPosition() == 2) {
if(spType.getSelectedItemPosition() == 2 || spType.getSelectedItemPosition() == 6) {
ecKey = hd_addr.getECKey();
strAddress = hd_addr.getAddressString();
}
else {
ecKey = segwitAddress.getECKey();
if(spType.getSelectedItemPosition() == 0) {
if(spType.getSelectedItemPosition() == 0 || spType.getSelectedItemPosition() == 7) {
strAddress = segwitAddress.getAddressAsString();
}
else {
......
......@@ -633,7 +633,7 @@ public class ReceiveActivity extends AppCompatActivity {
}
private void doSupport() {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://support.samourai.io/section/7-receiving-bitcoin"));
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://docs.samourai.io/wallet/usage#receive-1"));
startActivity(intent);
}
......
......@@ -2313,6 +2313,16 @@ public class APIFactory {
info("APIFactory", "XPUB:" + args.toString());
args.append("&at=");
args.append(getAccessToken());
if(DojoUtil.getInstance(context).getDojoParams() == null) {
if(PrefsUtil.getInstance(context).getValue(PrefsUtil.XPUBPOSTXREG, false) == false) {
args.append("&importPostmixLikeTypeChange=1");
}
}
else {
if(DojoUtil.getInstance(context).isLikeType() && PrefsUtil.getInstance(context).getValue(PrefsUtil.XPUBPOSTXREG, false) == false) {
args.append("&importPostmixLikeTypeChange=1");
}
}
response = WebUtil.getInstance(context).postURL(_url + "wallet?", args.toString());
info("APIFactory", "XPUB response:" + response);
}
......@@ -2321,6 +2331,16 @@ public class APIFactory {
args.put("active", StringUtils.join(xpubs, "|"));
info("APIFactory", "XPUB:" + args.toString());
args.put("at", getAccessToken());
if(DojoUtil.getInstance(context).getDojoParams() == null) {
if(PrefsUtil.getInstance(context).getValue(PrefsUtil.XPUBPOSTXREG, false) == false) {
args.put("importPostmixLikeTypeChange", "1");
}
}
else {
if(DojoUtil.getInstance(context).isLikeType() && PrefsUtil.getInstance(context).getValue(PrefsUtil.XPUBPOSTXREG, false) == false) {
args.put("importPostmixLikeTypeChange", "1");
}
}
response = WebUtil.getInstance(context).tor_postURL(_url + "wallet", args);
info("APIFactory", "XPUB response:" + response);
}
......@@ -2526,6 +2546,16 @@ public class APIFactory {
if(isWellFormedMultiAddr(jsonObject)) {
try {
PayloadUtil.getInstance(context).serializeMultiAddrMix(jsonObject);
if(DojoUtil.getInstance(context).getDojoParams() == null) {
if(PrefsUtil.getInstance(context).getValue(PrefsUtil.XPUBPOSTXREG, false) == false) {
PrefsUtil.getInstance(context).setValue(PrefsUtil.XPUBPOSTXREG, true);
}
}
else {
if(DojoUtil.getInstance(context).isLikeType() && PrefsUtil.getInstance(context).getValue(PrefsUtil.XPUBPOSTXREG, false) == false) {
PrefsUtil.getInstance(context).setValue(PrefsUtil.XPUBPOSTXREG, true);
}
}
}
catch(Exception e) {
;
......@@ -2576,12 +2606,13 @@ public class APIFactory {
String path = null;
try {
String address = Bech32Util.getInstance().getAddressFromScript(script);
String address = outDict.getString("addr");
if(outDict.has("xpub")) {
JSONObject xpubObj = (JSONObject)outDict.get("xpub");
path = (String)xpubObj.get("path");
String m = (String)xpubObj.get("m");
unspentPaths.put(address, path);
if(m.equals(BIP84Util.getInstance(context).getWallet().getAccountAt(WhirlpoolMeta.getInstance(context).getWhirlpoolPostmix()).xpubstr())) {
unspentBIP84PostMix.put(address, WhirlpoolMeta.getInstance(context).getWhirlpoolPostmix());
......
......@@ -1027,7 +1027,7 @@ public class BalanceActivity extends SamouraiActivity {
}
private void doSupport() {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://support.samourai.io/"));
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://samouraiwallet.com/support"));
startActivity(intent);
}
......
......@@ -18,6 +18,7 @@ public class DojoUtil {
private static DojoUtil instance = null;
private static final String TAG = "DojoUtil";
private static Context context = null;
private static String dojoVersion = null;
private DojoUtil() { ; }
......@@ -109,6 +110,39 @@ public class DojoUtil {
}
public String getDojoVersion() {
return dojoVersion;
}
public void setDojoVersion(String version) {
dojoVersion = version;
}
public boolean isLikeType() {
if(dojoParams == null || dojoVersion == null) {
return false;
}
// version 1.11.x
String[] s = dojoVersion.split(".");
try {
if(s.length >= 1 && Integer.parseInt(s[0]) > 1) {
return true;
}
else if(s.length >= 2 && Integer.parseInt(s[0]) == 1 && Integer.parseInt(s[1]) >= 11){
return true;
}
else {
return false;
}
}
catch(NumberFormatException nfe) {
return false;
}
}
public String getVersion(String data) {
if(!isValidPairingPayload(data)) {
......
......@@ -31,6 +31,7 @@ import com.samourai.wallet.util.AddressFactory;
import com.samourai.wallet.util.AppUtil;
import com.samourai.wallet.util.BatchSendUtil;
import com.samourai.wallet.util.CharSequenceX;
import com.samourai.wallet.util.LocalReceiveIndexes;
import com.samourai.wallet.util.PrefsUtil;
import com.samourai.wallet.util.SIMUtil;
import com.samourai.wallet.util.SendAddressUtil;
......@@ -314,7 +315,7 @@ public class PayloadUtil {
meta.put("device_model", Build.MODEL == null ? "" : Build.MODEL);
meta.put("device_product", Build.PRODUCT == null ? "" : Build.PRODUCT);
meta.put("prev_balance", APIFactory.getInstance(context).getXpubBalance()- BlockedUTXO.getInstance().getTotalValueBlocked0());
meta.put("prev_balance", APIFactory.getInstance(context).getXpubBalance() - BlockedUTXO.getInstance().getTotalValueBlocked0());
meta.put("sent_tos", SendAddressUtil.getInstance().toJSON());
meta.put("sent_tos_from_bip47", SentToFromBIP47Util.getInstance().toJSON());
meta.put("batch_send", BatchSendUtil.getInstance().toJSON());
......@@ -365,6 +366,8 @@ public class PayloadUtil {
meta.put("paynym_featured_v1", PrefsUtil.getInstance(context).getValue(PrefsUtil.PAYNYM_FEATURED_SEGWIT, false));
meta.put("user_offline", AppUtil.getInstance(context).isUserOfflineMode());
meta.put("is_sat", PrefsUtil.getInstance(context).getValue(PrefsUtil.IS_SAT, false));
meta.put("localIndexes", LocalReceiveIndexes.getInstance(context).toJSON());
meta.put("xpubpostxreg", PrefsUtil.getInstance(context).getValue(PrefsUtil.XPUBPOSTREG, false));
if(DojoUtil.getInstance(context).getDojoParams() != null) {
meta.put("dojo", DojoUtil.getInstance(context).toJSON());
......@@ -700,6 +703,12 @@ public class PayloadUtil {
if(meta.has("is_sat")) {
PrefsUtil.getInstance(context).setValue(PrefsUtil.IS_SAT, meta.getBoolean("is_sat"));
}
if(meta.has("localIndexes")) {
LocalReceiveIndexes.getInstance(context).fromJSON((JSONObject) meta.get("localIndexes"));
}
if(meta.has("xpubpostxreg")) {
PrefsUtil.getInstance(context).setValue(PrefsUtil.XPUBPOSTXREG, meta.getBoolean("xpubpostxreg"));
}
}
}
......
......@@ -237,7 +237,7 @@ class PayNymHome : SamouraiActivity() {
}
private fun doSupport() {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://support.samourai.io/section/32-paynym"))
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://docs.samourai.io/wallet/usage#paynym-1"))
startActivity(intent)
}
......
......@@ -554,7 +554,7 @@ class PayNymDetailsActivity : SamouraiActivity() {
.setMessage(message)
.setCancelable(false)
.setPositiveButton(R.string.help) { _, _ ->
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse("https://support.samourai.io/article/58-connecting-to-a-paynym-contact"))
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse("https://docs.samourai.io/wallet/usage#follow-paynyms"))
startActivity(browserIntent)
}
.setNegativeButton(R.string.close) { dialog, _ -> dialog.dismiss() }
......
......@@ -60,7 +60,9 @@ import com.samourai.wallet.cahoots.CahootsType;
import com.samourai.wallet.cahoots.psbt.PSBTUtil;
import com.samourai.wallet.fragments.CameraFragmentBottomSheet;
import com.samourai.wallet.fragments.PaynymSelectModalFragment;
import com.samourai.wallet.hd.HD_Address;
import com.samourai.wallet.hd.HD_WalletFactory;
import com.samourai.wallet.network.dojo.DojoUtil;
import com.samourai.wallet.payload.PayloadUtil;
import com.samourai.wallet.paynym.paynymDetails.PayNymDetailsActivity;
import com.samourai.wallet.ricochet.RicochetActivity;
......@@ -95,6 +97,7 @@ import org.apache.commons.lang3.SerializationUtils;
import org.apache.commons.lang3.tuple.Triple;
import org.bitcoinj.core.Address;
import org.bitcoinj.core.Coin;
import org.bitcoinj.core.ECKey;
import org.bitcoinj.core.Transaction;
import org.bitcoinj.core.TransactionOutput;
import org.bitcoinj.script.Script;
......@@ -1194,13 +1197,18 @@ public class SendActivity extends SamouraiActivity {
address = strDestinationBTCAddress == null ? toAddressEditText.getText().toString().trim() : strDestinationBTCAddress;
if (account == WhirlpoolMeta.getInstance(SendActivity.this).getWhirlpoolPostmix()) {
changeType = 84;
} else if (PrefsUtil.getInstance(SendActivity.this).getValue(PrefsUtil.USE_LIKE_TYPED_CHANGE, true) == false) {
boolean useLikeType = PrefsUtil.getInstance(SendActivity.this).getValue(PrefsUtil.USE_LIKE_TYPED_CHANGE, true);
if (DojoUtil.getInstance(SendActivity.this).getDojoParams() != null && !DojoUtil.getInstance(SendActivity.this).isLikeType()) {
useLikeType = false;
}
if (!useLikeType) {
changeType = 84;
} else if (FormatsUtil.getInstance().isValidBech32(address) || Address.fromBase58(SamouraiWallet.getInstance().getCurrentNetworkParams(), address).isP2SHAddress()) {
}
else if (FormatsUtil.getInstance().isValidBech32(address) || Address.fromBase58(SamouraiWallet.getInstance().getCurrentNetworkParams(), address).isP2SHAddress()) {
changeType = FormatsUtil.getInstance().isValidBech32(address) ? 84 : 49;
} else {
}
else {
changeType = 44;
}
......@@ -1209,11 +1217,14 @@ public class SendActivity extends SamouraiActivity {
if (account == WhirlpoolMeta.getInstance(SendActivity.this).getWhirlpoolPostmix()) {
change_index = idxBIP84PostMixInternal;
} else if (changeType == 84) {
}
else if (changeType == 84) {
change_index = idxBIP84Internal;
} else if (changeType == 49) {
}
else if (changeType == 49) {
change_index = idxBIP49Internal;
} else {
}
else {
change_index = idxBIP44Internal;
}
......@@ -1855,16 +1866,32 @@ public class SendActivity extends SamouraiActivity {
if (_change > 0L) {
if (SPEND_TYPE == SPEND_SIMPLE) {
if (account == WhirlpoolMeta.getInstance(SendActivity.this).getWhirlpoolPostmix()) {
String change_address = BIP84Util.getInstance(SendActivity.this).getAddressAt(WhirlpoolMeta.getInstance(SendActivity.this).getWhirlpoolPostmix(), AddressFactory.CHANGE_CHAIN, AddressFactory.getInstance(SendActivity.this).getHighestPostChangeIdx()).getBech32AsString();
receivers.put(change_address, BigInteger.valueOf(_change));
} else if (changeType == 84) {
String change_address = BIP84Util.getInstance(SendActivity.this).getAddressAt(AddressFactory.CHANGE_CHAIN, BIP84Util.getInstance(SendActivity.this).getWallet().getAccount(0).getChange().getAddrIdx()).getBech32AsString();
if(changeType == 44) {
HD_Address hd_addr = BIP84Util.getInstance(SendActivity.this).getWallet().getAccountAt(WhirlpoolMeta.getInstance(SendActivity.this).getWhirlpoolPostmix()).getChain(AddressFactory.CHANGE_CHAIN).getAddressAt(change_index);
String change_address = hd_addr.getAddressString();
receivers.put(change_address, BigInteger.valueOf(_change));
}
else if(changeType == 49) {
HD_Address hd_addr = BIP84Util.getInstance(SendActivity.this).getWallet().getAccountAt(WhirlpoolMeta.getInstance(SendActivity.this).getWhirlpoolPostmix()).getChain(AddressFactory.CHANGE_CHAIN).getAddressAt(change_index);
SegwitAddress segwitAddress = new SegwitAddress(hd_addr.getECKey(), SamouraiWallet.getInstance().getCurrentNetworkParams());
String change_address = segwitAddress.getAddressAsString();
receivers.put(change_address, BigInteger.valueOf(_change));
}
else {
String change_address = BIP84Util.getInstance(SendActivity.this).getAddressAt(WhirlpoolMeta.getInstance(SendActivity.this).getWhirlpoolPostmix(), AddressFactory.CHANGE_CHAIN, change_index).getBech32AsString();
receivers.put(change_address, BigInteger.valueOf(_change));
}
}
else if (changeType == 84) {
String change_address = BIP84Util.getInstance(SendActivity.this).getAddressAt(AddressFactory.CHANGE_CHAIN, change_index).getBech32AsString();
receivers.put(change_address, BigInteger.valueOf(_change));
} else if (changeType == 49) {
String change_address = BIP49Util.getInstance(SendActivity.this).getAddressAt(AddressFactory.CHANGE_CHAIN, BIP49Util.getInstance(SendActivity.this).getWallet().getAccount(0).getChange().getAddrIdx()).getAddressAsString();
}
else if (changeType == 49) {
String change_address = BIP49Util.getInstance(SendActivity.this).getAddressAt(AddressFactory.CHANGE_CHAIN, change_index).getAddressAsString();
receivers.put(change_address, BigInteger.valueOf(_change));
} else {
String change_address = HD_WalletFactory.getInstance(SendActivity.this).get().getAccount(0).getChange().getAddressAt(HD_WalletFactory.getInstance(SendActivity.this).get().getAccount(0).getChange().getAddrIdx()).getAddressString();
}
else {
String change_address = HD_WalletFactory.getInstance(SendActivity.this).get().getAccount(0).getChange().getAddressAt(change_index).getAddressString();
receivers.put(change_address, BigInteger.valueOf(_change));
}
......@@ -2035,13 +2062,16 @@ public class SendActivity extends SamouraiActivity {
if (account == WhirlpoolMeta.getInstance(SendActivity.this).getWhirlpoolPostmix()) {
String change_address = BIP84Util.getInstance(SendActivity.this).getAddressAt(WhirlpoolMeta.getInstance(SendActivity.this).getWhirlpoolPostmix(), AddressFactory.CHANGE_CHAIN, AddressFactory.getInstance(SendActivity.this).getHighestPostChangeIdx()).getBech32AsString();
_receivers.put(change_address, BigInteger.valueOf(_change));
} else if (changeType == 84) {
}
else if (changeType == 84) {
String change_address = BIP84Util.getInstance(SendActivity.this).getAddressAt(AddressFactory.CHANGE_CHAIN, BIP84Util.getInstance(SendActivity.this).getWallet().getAccount(0).getChange().getAddrIdx()).getBech32AsString();
_receivers.put(change_address, BigInteger.valueOf(_change));
} else if (changeType == 49) {
}
else if (changeType == 49) {
String change_address = BIP49Util.getInstance(SendActivity.this).getAddressAt(AddressFactory.CHANGE_CHAIN, BIP49Util.getInstance(SendActivity.this).getWallet().getAccount(0).getChange().getAddrIdx()).getAddressAsString();
_receivers.put(change_address, BigInteger.valueOf(_change));
} else {
}
else {
String change_address = HD_WalletFactory.getInstance(SendActivity.this).get().getAccount(0).getChange().getAddressAt(HD_WalletFactory.getInstance(SendActivity.this).get().getAccount(0).getChange().getAddrIdx()).getAddressString();
_receivers.put(change_address, BigInteger.valueOf(_change));
}
......@@ -2449,7 +2479,7 @@ public class SendActivity extends SamouraiActivity {
}
private void doSupport() {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://support.samourai.io/section/8-sending-bitcoin"));
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://docs.samourai.io/wallet/usage#send-1"));
startActivity(intent);
}
......
......@@ -14,6 +14,7 @@ import com.samourai.wallet.bip47.rpc.PaymentCode;
import com.samourai.wallet.bip69.BIP69OutputComparator;
import com.samourai.wallet.hd.HD_Address;
import com.samourai.wallet.hd.HD_WalletFactory;
import com.samourai.wallet.network.dojo.DojoUtil;
import com.samourai.wallet.segwit.BIP49Util;
import com.samourai.wallet.segwit.BIP84Util;
import com.samourai.wallet.segwit.SegwitAddress;
......@@ -435,7 +436,11 @@ public class SendFactory {
int changeType = 84;
int mixedType = 84;
if(PrefsUtil.getInstance(context).getValue(PrefsUtil.USE_LIKE_TYPED_CHANGE, true) == true) {
boolean useLikeType = PrefsUtil.getInstance(context).getValue(PrefsUtil.USE_LIKE_TYPED_CHANGE, true);
if (DojoUtil.getInstance(context).getDojoParams() != null && !DojoUtil.getInstance(context).isLikeType()) {
useLikeType = false;
}
if(useLikeType) {
//
// inputs are pre-grouped by type
// type of address for change must match type of address for inputs
......@@ -683,7 +688,12 @@ public class SendFactory {
private String getChangeAddress(int type, int account) {
if(type != 44 || PrefsUtil.getInstance(context).getValue(PrefsUtil.USE_LIKE_TYPED_CHANGE, true) == false) {
boolean useLikeType = PrefsUtil.getInstance(context).getValue(PrefsUtil.USE_LIKE_TYPED_CHANGE, true);
if (DojoUtil.getInstance(context).getDojoParams() != null && !DojoUtil.getInstance(context).isLikeType()) {
useLikeType = false;
}
if(type != 44 || !useLikeType) {
;
}
else {
......@@ -691,10 +701,33 @@ public class SendFactory {
}
if(account == WhirlpoolMeta.getInstance(context).getWhirlpoolPostmix()) {
int idx = AddressFactory.getInstance(context).getHighestPostChangeIdx();
String change_address = BIP84Util.getInstance(context).getAddressAt(WhirlpoolMeta.getInstance(context).getWhirlpoolPostmix(), AddressFactory.CHANGE_CHAIN, idx).getBech32AsString();
AddressFactory.getInstance(context).setHighestPostChangeIdx(idx + 1);
return change_address;
if((type == 44 || type == 49) && useLikeType) {
debug("SendFactory", "change index:" + idx);
if(type == 49) {
HD_Address hd_addr = BIP84Util.getInstance(context).getWallet().getAccountAt(WhirlpoolMeta.getInstance(context).getWhirlpoolPostmix()).getChain(AddressFactory.CHANGE_CHAIN).getAddressAt(idx);
SegwitAddress segwitAddress = new SegwitAddress(hd_addr.getECKey(), SamouraiWallet.getInstance().getCurrentNetworkParams());
String change_address = segwitAddress.getAddressAsString();
AddressFactory.getInstance(context).setHighestPostChangeIdx(idx + 1);
return change_address;
}
else {
HD_Address hd_addr = BIP84Util.getInstance(context).getWallet().getAccountAt(WhirlpoolMeta.getInstance(context).getWhirlpoolPostmix()).getChain(AddressFactory.CHANGE_CHAIN).getAddressAt(idx);
String change_address = hd_addr.getAddressString();
AddressFactory.getInstance(context).setHighestPostChangeIdx(idx + 1);
return change_address;
}
}
else {
String change_address = BIP84Util.getInstance(context).getAddressAt(WhirlpoolMeta.getInstance(context).getWhirlpoolPostmix(), AddressFactory.CHANGE_CHAIN, idx).getBech32AsString();
AddressFactory.getInstance(context).setHighestPostChangeIdx(idx + 1);
return change_address;
}
}
else if(type == 84) {
String change_address = BIP84Util.getInstance(context).getAddressAt(AddressFactory.CHANGE_CHAIN, BIP84Util.getInstance(context).getWallet().getAccount(account).getChange().getAddrIdx()).getBech32AsString();
......@@ -737,17 +770,31 @@ public class SendFactory {
ecKey = addr.getECKey();
}
else if(Address.fromBase58(SamouraiWallet.getInstance().getCurrentNetworkParams(), address).isP2SHAddress()) {
debug("SendFactory", "address type:" + "bip49");
HD_Address addr = BIP49Util.getInstance(context).getWallet().getAccount(0).getChain(Integer.parseInt(s[1])).getAddressAt(Integer.parseInt(s[2]));
ecKey = addr.getECKey();
if(account == WhirlpoolMeta.getInstance(context).getWhirlpoolPostmix()) {
debug("SendFactory", "address type:" + "post-mix p2sh");
HD_Address addr = BIP84Util.getInstance(context).getWallet().getAccountAt(WhirlpoolMeta.getInstance(context).getWhirlpoolPostmix()).getChain(Integer.parseInt(s[1])).getAddressAt(Integer.parseInt(s[2]));
ecKey = addr.getECKey();
}
else {
debug("SendFactory", "address type:" + "bip49");
HD_Address addr = BIP49Util.getInstance(context).getWallet().getAccount(0).getChain(Integer.parseInt(s[1])).getAddressAt(Integer.parseInt(s[2]));
ecKey = addr.getECKey();
}
}
else {
debug("SendFactory", "address type:" + "bip44");
int account_no = APIFactory.getInstance(context).getUnspentAccounts().get(address);
HD_Address hd_address = AddressFactory.getInstance(context).get(account_no, Integer.parseInt(s[1]), Integer.parseInt(s[2]));
String strPrivKey = hd_address.getPrivateKeyString();
DumpedPrivateKey pk = new DumpedPrivateKey(SamouraiWallet.getInstance().getCurrentNetworkParams(), strPrivKey);
ecKey = pk.getKey();
if(account == WhirlpoolMeta.getInstance(context).getWhirlpoolPostmix()) {
debug("SendFactory", "address type:" + "post-mix p2pkh");
HD_Address hd_addr = BIP84Util.getInstance(context).getWallet().getAccountAt(WhirlpoolMeta.getInstance(context).getWhirlpoolPostmix()).getChain(Integer.parseInt(s[1])).getAddressAt(Integer.parseInt(s[2]));
ecKey = hd_addr.getECKey();
}
else {
debug("SendFactory", "address type:" + "bip44");
int account_no = APIFactory.getInstance(context).getUnspentAccounts().get(address);
HD_Address hd_address = AddressFactory.getInstance(context).get(account_no, Integer.parseInt(s[1]), Integer.parseInt(s[2]));
String strPrivKey = hd_address.getPrivateKeyString();
DumpedPrivateKey pk = new DumpedPrivateKey(SamouraiWallet.getInstance().getCurrentNetworkParams(), strPrivKey);
ecKey = pk.getKey();
}
}
}
else {
......
......@@ -420,7 +420,7 @@ class BatchSpendActivity : SamouraiActivity() {
}
private fun doSupport() {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://support.samourai.io/section/8-sending-bitcoin")))
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://docs.samourai.io/en/wallet/features/batch-spend")))
}
......
......@@ -131,6 +131,18 @@ class SettingsDetailsFragment(private val key: String?) : PreferenceFragmentComp
true
}
val zpubPostXPref = findPreference("zpub_post_x") as Preference?
zpubPostXPref!!.onPreferenceClickListener = Preference.OnPreferenceClickListener {
getXPUB(44, WhirlpoolMeta.getInstance(requireContext()).whirlpoolPostmix)
true
}
val zpubPostYPref = findPreference("zpub_post_y") as Preference?
zpubPostYPref!!.onPreferenceClickListener = Preference.OnPreferenceClickListener {
getXPUB(49, WhirlpoolMeta.getInstance(requireContext()).whirlpoolPostmix)
true
}
val zpubBadBankPref = findPreference("zpub_badbank") as Preference?
zpubBadBankPref!!.onPreferenceClickListener = Preference.OnPreferenceClickListener {
getXPUB(84, WhirlpoolMeta.getInstance(requireContext()).whirlpoolBadBank)
......@@ -474,17 +486,31 @@ class SettingsDetailsFragment(private val key: String?) : PreferenceFragmentComp
private fun getXPUB(purpose: Int, account: Int) {
var xpub = ""
when (purpose) {
49 -> xpub = BIP49Util.getInstance(requireContext()).wallet.getAccount(account).ypubstr()
84 -> xpub = BIP84Util.getInstance(requireContext()).wallet.getAccountAt(account).zpubstr()
else -> try {
xpub = HD_WalletFactory.getInstance(requireContext()).get().getAccount(account).xpubstr()
} catch (ioe: IOException) {
ioe.printStackTrace()
Toast.makeText(requireContext(), "HD wallet error", Toast.LENGTH_SHORT).show()
} catch (mle: MnemonicLengthException) {