modify get bcc transaction size is to large
MODIFY
bither-android/AndroidManifest.xml
bither-android/AndroidManifest.xml
xmlns:tools="http://schemas.android.com/tools"
package="net.bither"
android:installLocation="internalOnly"
- android:versionCode="170"
- android:versionName="1.7.0">
+ android:versionCode="171"
+ android:versionName="1.7.1">
<uses-sdk
android:minSdkVersion="9"

MODIFY
bither-android/src/net/bither/activity/hot/SplitBCCHDAccountMonitoredSendActivity.java
bither-android/src/net/bither/activity/hot/SplitBCCHDAccountMonitoredSendActivity.java
@@ -30,6 +30,7 @@ import net.bither.ui.base.dialog.DialogHdSendConfirm;
import org.json.JSONObject;
import java.util.ArrayList;
+import java.util.List;
/**
* Created by ltq on 2017/7/29.
@@ -39,7 +40,7 @@ public class SplitBCCHDAccountMonitoredSendActivity extends SplitBCCSendActivity
.SendConfirmListener {
private long btcAmount;
private String toAddress;
- private Tx tx;
+ private List<Tx> txs;
static {
CompleteTransactionRunnable.registerTxBuilderExceptionMessages();
@@ -103,15 +104,14 @@ public class SplitBCCHDAccountMonitoredSendActivity extends SplitBCCSendActivity
}
private void send() {
- this.tx = null;
+ this.txs = null;
HDAccount account = (HDAccount) address;
try {
- tx = account.newForkTx(toAddress, btcAmount);
- tx.setBtc(false);
+ txs = account.newForkTx(toAddress, btcAmount);
} catch (Exception e) {
e.printStackTrace();
btcAmount = 0;
- tx = null;
+ txs = null;
String msg = getString(R.string.send_failed);
if (e instanceof KeyCrypterException || e instanceof MnemonicException
.MnemonicLengthException) {
@@ -131,7 +131,7 @@ public class SplitBCCHDAccountMonitoredSendActivity extends SplitBCCSendActivity
});
}
- if (this.tx != null) {
+ if (this.txs != null) {
runOnUiThread(new Runnable() {
@Override
public void run() {
@@ -166,13 +166,13 @@ public class SplitBCCHDAccountMonitoredSendActivity extends SplitBCCSendActivity
if (dp.isShowing()) {
dp.dismiss();
}
- new DialogHdSendConfirm(this, toAddress, tx, false, this).show();
+ new DialogHdSendConfirm(this, toAddress, txs, this).show();
}
@Override
public void onConfirm() {
Intent intent = new Intent(this, UnsignedTxQrCodeActivity.class);
- intent.putExtra(BitherSetting.INTENT_REF.QR_CODE_STRING, QRCodeTxTransport.getHDAccountMonitoredUnsignedTx(tx, toAddress, (HDAccount) address));
+ intent.putExtra(BitherSetting.INTENT_REF.QR_CODE_STRING, QRCodeTxTransport.getBccHDAccountMonitoredUnsignedTx(txs, toAddress, (HDAccount) address));
intent.putExtra(BitherSetting.INTENT_REF.TITLE_STRING, getString(R.string
.unsigned_transaction_qr_code_title));
startActivityForResult(intent, BitherSetting.INTENT_REF.SIGN_TX_REQUEST_CODE);
@@ -192,12 +192,30 @@ public class SplitBCCHDAccountMonitoredSendActivity extends SplitBCCSendActivity
@Override
public void run() {
String[] array = QRCodeUtil.splitString(qr);
+ int insCount = 0;
+ for (Tx tx : txs) {
+ insCount += tx.getIns().size();
+ }
+ boolean success = insCount == array.length;
+ if (success) {
+ int strIndex = 0;
+ for (int i = 0; i < txs.size(); i++) {
+ Tx tx = txs.get(i);
ArrayList<byte[]> sigs = new ArrayList<byte[]>();
- for (String s : array) {
+ for (int j = 0; j < tx.getIns().size(); j++) {
+ String s = array[strIndex + j];
sigs.add(Utils.hexStringToByteArray(replaceSignHashOfString(s)));
}
tx.signWithSignatures(sigs);
- if (tx.verifySignatures()) {
+ if (!tx.verifySignatures()) {
+ success = false;
+ break;
+ }
+ strIndex += tx.getIns().size();
+ }
+ }
+
+ if (success) {
runOnUiThread(new Runnable() {
@Override
public void run() {
@@ -232,47 +250,43 @@ public class SplitBCCHDAccountMonitoredSendActivity extends SplitBCCSendActivity
if (!dp.isShowing()) {
dp.show();
}
+
new Thread() {
@Override
public void run() {
- boolean success = false;
+ String errorMsg = null;
+ for (final Tx tx: txs) {
try {
String raw = Utils.bytesToHexString(tx.bitcoinSerialize());
BccBroadCastApi bccBroadCastApi = new BccBroadCastApi(raw);
bccBroadCastApi.handleHttpPost();
JSONObject jsonObject = new JSONObject(bccBroadCastApi.getResult());
boolean result = jsonObject.getInt("result") == 1 ? true : false;
- if (result) {
- saveIsObtainBcc();
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- DropdownMessage.showDropdownMessage(SplitBCCHDAccountMonitoredSendActivity.this,R.string.send_success);
- }
- });
- success = true;
- } else {
+ if (!result) {
final JSONObject jsonObj = jsonObject.getJSONObject("error");
final int code = jsonObj.getInt("code");
final String message = jsonObj.getString("message");
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- DropdownMessage.showDropdownMessage(SplitBCCHDAccountMonitoredSendActivity.this,String.valueOf(code) + message);
- }
- });
- success = false;
+ errorMsg = String.valueOf(code) + message;
}
} catch (Exception e) {
e.printStackTrace();
+ errorMsg = getString(R.string.send_failed);
}
- if (success) {
+
+ if (errorMsg != null) {
+ break;
+ }
+ }
+
+ if (errorMsg == null) {
+ saveIsObtainBcc();
runOnUiThread(new Runnable() {
@Override
public void run() {
if (dp.isShowing()) {
dp.dismiss();
}
+ DropdownMessage.showDropdownMessage(SplitBCCHDAccountMonitoredSendActivity.this, R.string.send_success);
}
});
btnSend.postDelayed(new Runnable() {
@@ -284,14 +298,14 @@ public class SplitBCCHDAccountMonitoredSendActivity extends SplitBCCSendActivity
}
},1000);
} else {
+ final String finalErrorMsg = errorMsg;
runOnUiThread(new Runnable() {
@Override
public void run() {
if (dp.isShowing()) {
dp.dismiss();
}
- DropdownMessage.showDropdownMessage(SplitBCCHDAccountMonitoredSendActivity
- .this, R.string.send_failed);
+ DropdownMessage.showDropdownMessage(SplitBCCHDAccountMonitoredSendActivity.this, finalErrorMsg);
btnSend.setEnabled(true);
}
});

MODIFY
bither-android/src/net/bither/activity/hot/SplitBCCHDAccountSendActivity.java
bither-android/src/net/bither/activity/hot/SplitBCCHDAccountSendActivity.java
@@ -25,6 +25,8 @@ import net.bither.ui.base.dialog.DialogHdSendConfirm;
import org.json.JSONObject;
+import java.util.List;
+
/**
* Created by ltq on 2017/7/28.
*/
@@ -34,7 +36,7 @@ public class SplitBCCHDAccountSendActivity extends SplitBCCSendActivity implemen
private long btcAmount;
private String toAddress;
- private Tx tx;
+ private List<Tx> txs;
static {
CompleteTransactionRunnable.registerTxBuilderExceptionMessages();
@@ -89,15 +91,15 @@ public class SplitBCCHDAccountSendActivity extends SplitBCCSendActivity implemen
}
private void send() {
- tx = null;
+ txs = null;
HDAccount account = (HDAccount) address;
SecureCharSequence password = new SecureCharSequence(etPassword.getText());
try {
- tx = account.newForkTx(etAddress.getText().toString().trim(), btcAmount, password);
+ txs = account.newForkTx(etAddress.getText().toString().trim(), btcAmount, password);
} catch (Exception e) {
e.printStackTrace();
btcAmount = 0;
- tx = null;
+ txs = null;
String msg = getString(R.string.send_failed);
if (e instanceof KeyCrypterException || e instanceof MnemonicException
.MnemonicLengthException) {
@@ -118,7 +120,7 @@ public class SplitBCCHDAccountSendActivity extends SplitBCCSendActivity implemen
} finally {
password.wipe();
}
- if (tx != null) {
+ if (txs != null) {
runOnUiThread(new Runnable() {
@Override
public void run() {
@@ -153,7 +155,7 @@ public class SplitBCCHDAccountSendActivity extends SplitBCCSendActivity implemen
if (dp.isShowing()) {
dp.dismiss();
}
- new DialogHdSendConfirm(this, toAddress, tx, false, this).show();
+ new DialogHdSendConfirm(this, toAddress, txs, this).show();
}
@Override
@@ -161,10 +163,12 @@ public class SplitBCCHDAccountSendActivity extends SplitBCCSendActivity implemen
if (!dp.isShowing()) {
dp.show();
}
+
new Thread() {
@Override
public void run() {
- boolean success = false;
+ String errorMsg = null;
+ for (final Tx tx: txs) {
try {
String raw = Utils.bytesToHexString(tx.bitcoinSerialize());
BccBroadCastApi bccBroadCastApi = new BccBroadCastApi(raw);
@@ -175,33 +179,27 @@ public class SplitBCCHDAccountSendActivity extends SplitBCCSendActivity implemen
final JSONObject jsonObj = jsonObject.getJSONObject("error");
final int code = jsonObj.getInt("code");
final String message = jsonObj.getString("message");
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- DropdownMessage.showDropdownMessage(SplitBCCHDAccountSendActivity.this,String.valueOf(code) + message);
- }
- });
- success = false;
- } else {
- saveIsObtainBcc();
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- DropdownMessage.showDropdownMessage(SplitBCCHDAccountSendActivity.this,R.string.send_success);
- }
- });
- success = true;
+ errorMsg = String.valueOf(code) + message;
}
} catch (Exception e) {
e.printStackTrace();
+ errorMsg = getString(R.string.send_failed);
+ }
+
+ if (errorMsg != null) {
+ break;
+ }
}
- if (success) {
+
+ if (errorMsg == null) {
+ saveIsObtainBcc();
runOnUiThread(new Runnable() {
@Override
public void run() {
if (dp.isShowing()) {
dp.dismiss();
}
+ DropdownMessage.showDropdownMessage(SplitBCCHDAccountSendActivity.this, R.string.send_success);
}
});
btnSend.postDelayed(new Runnable() {
@@ -213,14 +211,15 @@ public class SplitBCCHDAccountSendActivity extends SplitBCCSendActivity implemen
}
},1000);
} else {
+ final String finalErrorMsg = errorMsg;
runOnUiThread(new Runnable() {
@Override
public void run() {
if (dp.isShowing()) {
dp.dismiss();
}
- DropdownMessage.showDropdownMessage(SplitBCCHDAccountSendActivity.this, R
- .string.send_failed);
+ DropdownMessage.showDropdownMessage(SplitBCCHDAccountSendActivity.this, finalErrorMsg);
+ btnSend.setEnabled(true);
}
});
}

MODIFY
bither-android/src/net/bither/activity/hot/SplitBCCSendActivity.java
bither-android/src/net/bither/activity/hot/SplitBCCSendActivity.java
@@ -42,6 +42,7 @@ import net.bither.ui.base.keyboard.EntryKeyboardView;
import net.bither.ui.base.keyboard.password.PasswordEntryKeyboardView;
import net.bither.ui.base.listener.IBackClickListener;
import net.bither.util.InputParser;
+import net.bither.util.LogUtil;
import org.json.JSONObject;
@@ -52,7 +53,7 @@ import java.util.List;
*/
public class SplitBCCSendActivity extends SwipeRightActivity implements EntryKeyboardView
- .EntryKeyboardViewListener,CommitTransactionThread.CommitTransactionListener {
+ .EntryKeyboardViewListener {
protected int addressPosition;
protected Address address;
@@ -66,7 +67,7 @@ public class SplitBCCSendActivity extends SwipeRightActivity implements EntryKey
protected DialogRCheck dp;
private PasswordEntryKeyboardView kvPassword;
private View vKeyboardContainer;
- private Tx tx;
+ private List<Tx> txs;
private long btcAmount;
@Override
@@ -136,47 +137,43 @@ public class SplitBCCSendActivity extends SwipeRightActivity implements EntryKey
if (!dp.isShowing()) {
dp.show();
}
+
new Thread() {
@Override
public void run() {
- boolean success = false;
+ String errorMsg = null;
+ for (final Tx tx: txs) {
try {
String raw = Utils.bytesToHexString(tx.bitcoinSerialize());
BccBroadCastApi bccBroadCastApi = new BccBroadCastApi(raw);
bccBroadCastApi.handleHttpPost();
JSONObject jsonObject = new JSONObject(bccBroadCastApi.getResult());
boolean result = jsonObject.getInt("result") == 1 ? true : false;
- if (result) {
- success = true;
- saveIsObtainBcc();
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- DropdownMessage.showDropdownMessage(SplitBCCSendActivity.this,R.string.send_success);
- }
- });
- } else {
+ if (!result) {
final JSONObject jsonObj = jsonObject.getJSONObject("error");
final int code = jsonObj.getInt("code");
final String message = jsonObj.getString("message");
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- DropdownMessage.showDropdownMessage(SplitBCCSendActivity.this,String.valueOf(code) + message);
- }
- });
- success = false;
+ errorMsg = String.valueOf(code) + message;
}
} catch (Exception e) {
e.printStackTrace();
+ errorMsg = getString(R.string.send_failed);
}
- if (success) {
+
+ if (errorMsg != null) {
+ break;
+ }
+ }
+
+ if (errorMsg == null) {
+ saveIsObtainBcc();
runOnUiThread(new Runnable() {
@Override
public void run() {
if (dp.isShowing()) {
dp.dismiss();
}
+ DropdownMessage.showDropdownMessage(SplitBCCSendActivity.this, R.string.send_success);
}
});
btnSend.postDelayed(new Runnable() {
@@ -188,14 +185,15 @@ public class SplitBCCSendActivity extends SwipeRightActivity implements EntryKey
}
},1000);
} else {
+ final String finalErrorMsg = errorMsg;
runOnUiThread(new Runnable() {
@Override
public void run() {
if (dp.isShowing()) {
dp.dismiss();
}
- DropdownMessage.showDropdownMessage(SplitBCCSendActivity.this, R
- .string.send_failed);
+ DropdownMessage.showDropdownMessage(SplitBCCSendActivity.this, finalErrorMsg);
+ btnSend.setEnabled(true);
}
});
}
@@ -209,22 +207,6 @@ public class SplitBCCSendActivity extends SwipeRightActivity implements EntryKey
}
};
- @Override
- public void onCommitTransactionSuccess(Tx tx) {
- Intent intent = getIntent();
- if (tx != null) {
- intent.putExtra(SelectAddressToSendActivity.INTENT_EXTRA_TRANSACTION,
- tx.getHashAsString());
- }
- setResult(RESULT_OK, intent);
- finish();
- }
-
- @Override
- public void onCommitTransactionFailed() {
- DropdownMessage.showDropdownMessage(SplitBCCSendActivity.this, R.string.send_failed);
- }
-
private View.OnClickListener sendClick = new View.OnClickListener() {
@Override
@@ -240,9 +222,9 @@ public class SplitBCCSendActivity extends SwipeRightActivity implements EntryKey
if (!dp.isShowing()) {
dp.show();
}
- if (msg.obj != null && msg.obj instanceof Tx) {
- tx = (Tx) msg.obj;
- RCheckRunnable run = new RCheckRunnable(address, tx);
+ if (msg.obj != null && msg.obj instanceof List) {
+ txs = (List<Tx>) msg.obj;
+ RCheckRunnable run = new RCheckRunnable(address, txs);
run.setHandler(rcheckHandler);
new Thread(run).start();
} else {
@@ -276,8 +258,8 @@ public class SplitBCCSendActivity extends SwipeRightActivity implements EntryKey
public void handleMessage(Message msg) {
switch (msg.what) {
case HandlerMessage.MSG_SUCCESS:
- if (msg.obj != null && msg.obj instanceof Tx) {
- final Tx tx = (Tx) msg.obj;
+ if (msg.obj != null && msg.obj instanceof List) {
+ final List<Tx> txs = (List<Tx>) msg.obj;
if (!dp.isShowing()) {
dp.show();
}
@@ -285,9 +267,7 @@ public class SplitBCCSendActivity extends SwipeRightActivity implements EntryKey
@Override
public void run() {
dp.dismiss();
- DialogHdSendConfirm dialog = new DialogHdSendConfirm(SplitBCCSendActivity.this,toAddress,
- tx,false,sendConfirmListener);
- dialog.show();
+ new DialogHdSendConfirm(SplitBCCSendActivity.this, toAddress, txs, sendConfirmListener).show();
dp.setWait();
}
}, 800);

MODIFY
bither-android/src/net/bither/activity/hot/SplitBccColdWalletSendActivity.java
bither-android/src/net/bither/activity/hot/SplitBccColdWalletSendActivity.java
@@ -30,6 +30,7 @@ import net.bither.util.InputParser;
import org.json.JSONObject;
import java.util.ArrayList;
+import java.util.List;
/**
* Created by ltq on 2017/7/29.
@@ -39,7 +40,7 @@ public class SplitBccColdWalletSendActivity extends SplitBCCSendActivity {
private long btcAmount;
private String toAddress;
- public Tx tx;
+ public List<Tx> txs;
private boolean needConfirm = true;
private int kSignTypeLength = 2;
private int kCompressPubKeyLength = 68;
@@ -110,11 +111,12 @@ public class SplitBccColdWalletSendActivity extends SplitBCCSendActivity {
String addressCannotBtParsed = getString(R.string.address_cannot_be_parsed);
Intent intent = new Intent(SplitBccColdWalletSendActivity.this,
UnsignedTxQrCodeActivity.class);
+
intent.putExtra(BitherSetting.INTENT_REF.QR_CODE_STRING,
- QRCodeTxTransport.getPresignTxString(tx, toAddress, addressCannotBtParsed, QRCodeTxTransport.NO_HDM_INDEX));
+ QRCodeTxTransport.getBccPresignTxString(txs, toAddress, addressCannotBtParsed));
if (Utils.isEmpty(toAddress)) {
intent.putExtra(BitherSetting.INTENT_REF.OLD_QR_CODE_STRING,
- QRCodeTxTransport.oldGetPreSignString(tx, addressCannotBtParsed));
+ QRCodeTxTransport.oldGetBccPreSignString(txs, addressCannotBtParsed));
} else {
intent.putExtra(BitherSetting.INTENT_REF.QR_CODE_HAS_CHANGE_ADDRESS_STRING
, true);
@@ -139,15 +141,11 @@ public class SplitBccColdWalletSendActivity extends SplitBCCSendActivity {
if (dp.isShowing()) {
dp.dismiss();
}
- if (msg.obj != null && msg.obj instanceof Tx) {
- Tx smgTx = (Tx) msg.obj;
- tx = smgTx;
- tx.setBtc(false);
+ if (msg.obj != null && msg.obj instanceof List) {
+ List<Tx> smgTx = (List<Tx>) msg.obj;
+ txs = smgTx;
if (needConfirm) {
- DialogHdSendConfirm dialog = new DialogHdSendConfirm
- (SplitBccColdWalletSendActivity.this, toAddress,tx, false,
- sendConfirmListener);
- dialog.show();
+ new DialogHdSendConfirm(SplitBccColdWalletSendActivity.this, toAddress, txs, sendConfirmListener).show();
} else {
sendConfirmListener.onConfirm();
}
@@ -179,28 +177,6 @@ public class SplitBccColdWalletSendActivity extends SplitBCCSendActivity {
}
};
- @Override
- public void onCommitTransactionSuccess(Tx tx) {
- needConfirm = true;
- if (dp.isShowing()) {
- dp.dismiss();
- }
- Intent intent = getIntent();
- if (tx != null) {
- intent.putExtra(SelectAddressToSendActivity.INTENT_EXTRA_TRANSACTION,
- tx.getHashAsString());
- }
- setResult(RESULT_OK, intent);
- finish();
- }
-
- @Override
- public void onCommitTransactionFailed() {
- needConfirm = true;
- btnSend.setEnabled(true);
- DropdownMessage.showDropdownMessage(SplitBccColdWalletSendActivity.this, R.string.send_failed);
- }
-
private void send() {
try {
CompleteTransactionRunnable completeRunnable = new
@@ -224,47 +200,43 @@ public class SplitBccColdWalletSendActivity extends SplitBCCSendActivity {
if (!dp.isShowing()) {
dp.show();
}
+
new Thread() {
@Override
public void run() {
- boolean success = false;
+ String errorMsg = null;
+ for (final Tx tx: txs) {
try {
String raw = Utils.bytesToHexString(tx.bitcoinSerialize());
BccBroadCastApi bccBroadCastApi = new BccBroadCastApi(raw);
bccBroadCastApi.handleHttpPost();
JSONObject jsonObject = new JSONObject(bccBroadCastApi.getResult());
boolean result = jsonObject.getInt("result") == 1 ? true : false;
- if (result) {
- saveIsObtainBcc();
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- DropdownMessage.showDropdownMessage(SplitBccColdWalletSendActivity.this,R.string.send_success);
- }
- });
- success = true;
- } else {
+ if (!result) {
final JSONObject jsonObj = jsonObject.getJSONObject("error");
final int code = jsonObj.getInt("code");
final String message = jsonObj.getString("message");
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- DropdownMessage.showDropdownMessage(SplitBccColdWalletSendActivity.this,String.valueOf(code) + message);
- }
- });
- success = false;
+ errorMsg = String.valueOf(code) + message;
}
} catch (Exception e) {
e.printStackTrace();
+ errorMsg = getString(R.string.send_failed);
}
- if (success) {
+
+ if (errorMsg != null) {
+ break;
+ }
+ }
+
+ if (errorMsg == null) {
+ saveIsObtainBcc();
runOnUiThread(new Runnable() {
@Override
public void run() {
if (dp.isShowing()) {
dp.dismiss();
}
+ DropdownMessage.showDropdownMessage(SplitBccColdWalletSendActivity.this, R.string.send_success);
}
});
btnSend.postDelayed(new Runnable() {
@@ -276,14 +248,14 @@ public class SplitBccColdWalletSendActivity extends SplitBCCSendActivity {
}
},1000);
} else {
+ final String finalErrorMsg = errorMsg;
runOnUiThread(new Runnable() {
@Override
public void run() {
if (dp.isShowing()) {
dp.dismiss();
}
- DropdownMessage.showDropdownMessage(SplitBccColdWalletSendActivity
- .this, R.string.send_failed);
+ DropdownMessage.showDropdownMessage(SplitBccColdWalletSendActivity.this, finalErrorMsg);
btnSend.setEnabled(true);
}
});
@@ -338,11 +310,20 @@ public class SplitBccColdWalletSendActivity extends SplitBCCSendActivity {
btnSend.postDelayed(new Runnable() {
@Override
public void run() {
- boolean success;
String[] array = QRCodeUtil.splitString(qr);
+ int insCount = 0;
+ for (Tx tx : txs) {
+ insCount += tx.getIns().size();
+ }
+ boolean success = insCount == array.length;
+ if (success) {
+ int strIndex = 0;
+ for (int i = 0; i < txs.size(); i++) {
+ Tx tx = txs.get(i);
ArrayList<byte[]> compressSigs = new ArrayList<byte[]>();
ArrayList<byte[]> uncompressedSigs = new ArrayList<byte[]>();
- for (String s : array) {
+ for (int j = 0; j < tx.getIns().size(); j++) {
+ String s = array[strIndex + j];
compressSigs.add(Utils.hexStringToByteArray(replaceSignHashOfString(s, kCompressPubKeyLength)));
uncompressedSigs.add(Utils.hexStringToByteArray(replaceSignHashOfString(s, kUncompressedPubKeyLength)));
}
@@ -350,7 +331,15 @@ public class SplitBccColdWalletSendActivity extends SplitBCCSendActivity {
if (!tx.verifySignatures()) {
tx.signWithSignatures(uncompressedSigs);
}
- if (tx.verifySignatures()) {
+ if (!tx.verifySignatures()) {
+ success = false;
+ break;
+ }
+ strIndex += tx.getIns().size();
+ }
+ }
+
+ if (success) {
runOnUiThread(new Runnable() {
@Override
public void run() {

MODIFY
bither-android/src/net/bither/runnable/CompleteTransactionRunnable.java
bither-android/src/net/bither/runnable/CompleteTransactionRunnable.java
@@ -28,6 +28,8 @@ import net.bither.bitherj.exception.TxBuilderException;
import net.bither.bitherj.utils.Utils;
import net.bither.util.LogUtil;
+import java.util.List;
+
public class CompleteTransactionRunnable extends BaseRunnable {
private Address wallet;
@@ -124,6 +126,49 @@ public class CompleteTransactionRunnable extends BaseRunnable {
@Override
public void run() {
obtainMessage(HandlerMessage.MSG_PREPARE);
+ if (isBtc) {
+ signTx();
+ } else {
+ signBccTxs();
+ }
+ }
+
+ private void signBccTxs() {
+ try {
+ List<Tx> txs = wallet.buildBccTx(amount, toAddress, changeAddress);
+ if (txs == null) {
+ obtainMessage(HandlerMessage.MSG_FAILURE, BitherApplication.mContext.getString(R
+ .string.send_failed));
+ return;
+ }
+ if (toSign) {
+ for (Tx tx: txs) {
+ wallet.signTx(tx, password, isBtc);
+ if (!tx.verifySignatures()) {
+ obtainMessage(HandlerMessage.MSG_FAILURE, getMessageFromException(null));
+ return;
+ }
+ }
+ if (password != null) {
+ password.wipe();
+ }
+ }
+ obtainMessage(HandlerMessage.MSG_SUCCESS, txs);
+ } catch (Exception e) {
+ if (password != null) {
+ password.wipe();
+ }
+ if (e instanceof HDMSignUserCancelExcetion) {
+ obtainMessage(HandlerMessage.MSG_FAILURE);
+ return;
+ }
+ e.printStackTrace();
+ String msg = getMessageFromException(e);
+ obtainMessage(HandlerMessage.MSG_FAILURE, msg);
+ }
+ }
+
+ private void signTx() {
try {
Tx tx = wallet.buildTx(amount, toAddress, changeAddress, isBtc);
if (tx == null) {
@@ -148,11 +193,9 @@ public class CompleteTransactionRunnable extends BaseRunnable {
password.wipe();
}
if (!tx.verifySignatures()) {
- LogUtil.w("SignTransaction", "sign transaction failed");
obtainMessage(HandlerMessage.MSG_FAILURE, getMessageFromException(null));
return;
}
- LogUtil.i("SignTransaction", "sign transaction success");
}
obtainMessage(HandlerMessage.MSG_SUCCESS, tx);
} catch (Exception e) {

MODIFY
bither-android/src/net/bither/runnable/RCheckRunnable.java
bither-android/src/net/bither/runnable/RCheckRunnable.java
@@ -21,21 +21,33 @@ package net.bither.runnable;
import net.bither.bitherj.core.Address;
import net.bither.bitherj.core.Tx;
+import java.util.List;
+
/**
* Created by songchenwen on 14-10-20.
*/
public class RCheckRunnable extends BaseRunnable {
private Address address;
private Tx tx;
+ private List<Tx> txs;
public RCheckRunnable(Address address, Tx tx) {
this.address = address;
this.tx = tx;
}
+ public RCheckRunnable(Address address, List<Tx> txs) {
+ this.address = address;
+ this.txs = txs;
+ }
+
@Override
public void run() {
obtainMessage(HandlerMessage.MSG_PREPARE);
+ if (tx != null) {
obtainMessage(HandlerMessage.MSG_SUCCESS, tx);
+ } else if (txs != null) {
+ obtainMessage(HandlerMessage.MSG_SUCCESS, txs);
+ }
}
}

MODIFY
bither-android/src/net/bither/ui/base/dialog/DialogHdSendConfirm.java
bither-android/src/net/bither/ui/base/dialog/DialogHdSendConfirm.java
@@ -30,6 +30,8 @@ import net.bither.preference.AppSharedPreference;
import net.bither.util.UnitUtilWrapper;
import net.bither.util.WalletUtils;
+import java.util.List;
+
/**
* Created by songchenwen on 15/4/17.
*/
@@ -81,6 +83,35 @@ public class DialogHdSendConfirm extends CenterDialog implements DialogInterface
tvFee.setText(UnitUtilWrapper.formatValueWithBold(tx.getFee()));
}
+ public DialogHdSendConfirm(Context context, String toAddress, List<Tx> txs, SendConfirmListener listener) {
+ super(context);
+ this.listener = listener;
+ setOnDismissListener(this);
+ setContentView(R.layout.dialog_send_confirm);
+ TextView tvAddress = (TextView) findViewById(R.id.tv_address);
+ TextView tvBtc = (TextView) findViewById(R.id.tv_btc);
+ TextView tvFee = (TextView) findViewById(R.id.tv_fee);
+ TextView tvSymbol = (TextView) findViewById(R.id.tv_symbol);
+ TextView tvFeeSymbol = (TextView) findViewById(R.id.tv_fee_symbol);
+ View llChange = findViewById(R.id.ll_change);
+ TextView tvSymbolChange = (TextView) findViewById(R.id.tv_symbol_change);
+ tvSymbol.setText(BitherSetting.BCC);
+ tvFeeSymbol.setText(BitherSetting.BCC);
+ tvSymbolChange.setText(BitherSetting.BCC);
+ findViewById(R.id.btn_cancel).setOnClickListener(this);
+ findViewById(R.id.btn_ok).setOnClickListener(this);
+ llChange.setVisibility(View.GONE);
+ tvAddress.setText(WalletUtils.formatHash(toAddress, 4, 24));
+ long amount = 0;
+ long fee = 0;
+ for (Tx tx: txs) {
+ amount += tx.amountSentToAddress(toAddress);
+ fee += tx.getFee();
+ }
+ tvBtc.setText(UnitUtilWrapper.formatValueWithBold(amount));
+ tvFee.setText(UnitUtilWrapper.formatValueWithBold(fee));
+ }
+
@Override
public void onDismiss(DialogInterface dialog) {
if (listener != null) {

MODIFY
bitherj
bitherj
-Subproject commit d21c9bf558f5971b0f392c5579ea357ffa10dbc1
+Subproject commit 79e06bd12f0fa390370e5b443242ccf652afdf49

modify get bcc transaction size is to large