public void sendPop(View view) { try { if (txidToProve == null) { Toast.makeText(this, R.string.pop_no_transaction_selected, Toast.LENGTH_LONG).show(); } WalletAccount account = _mbwManager.getSelectedAccount(); final UnsignedTransaction unsignedPop = account.createUnsignedPop(txidToProve, popRequest.getN()); _mbwManager.runPinProtectedFunction( PopActivity.this, new Runnable() { @Override public void run() { disableButtons(); SignTransactionActivity.callMe( PopActivity.this, _mbwManager.getSelectedAccount().getId(), false, unsignedPop, SIGN_TRANSACTION_REQUEST_CODE); } }); } catch (Exception e) { Toast.makeText(this, "An internal error occurred:" + e.getMessage(), Toast.LENGTH_LONG) .show(); } }
private long getPaymentAmountSatoshis(TransactionSummary transactionSummary) { long amountSatoshis = transactionSummary.value; if (amountSatoshis < 0) { amountSatoshis = -amountSatoshis; } TransactionDetails transactionDetails = _mbwManager.getSelectedAccount().getTransactionDetails(transactionSummary.txid); amountSatoshis -= getFee(transactionDetails); return amountSatoshis; }
@Override protected void onCreate(Bundle savedInstanceState) { this.requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); setContentView(R.layout.pop_activity); _mbwManager = MbwManager.getInstance(getApplication()); if (savedInstanceState != null) { popRequest = (PopRequest) savedInstanceState.getSerializable("popRequest"); txidToProve = (Sha256Hash) savedInstanceState.getSerializable("txidToProve"); updateUi(_mbwManager.getSelectedAccount().getTransactionSummary(txidToProve)); return; } popRequest = (PopRequest) getIntent().getSerializableExtra("popRequest"); if (popRequest == null) { finish(); } Sha256Hash userSelectedTransaction = (Sha256Hash) getIntent().getSerializableExtra("selectedTransactionToProve"); TransactionSummary txToProve; if (userSelectedTransaction != null) { txidToProve = userSelectedTransaction; txToProve = _mbwManager.getSelectedAccount().getTransactionSummary(txidToProve); } else { // Get history ordered by block height descending List<TransactionSummary> transactionHistory = _mbwManager.getSelectedAccount().getTransactionHistory(0, 10000); TransactionSummary matchingTransaction = findFirstMatchingTransaction(popRequest, transactionHistory); if (matchingTransaction == null) { launchSelectTransactionActivity(); return; } txidToProve = matchingTransaction.txid; txToProve = matchingTransaction; } updateUi(txToProve); }