use of com.samourai.wallet.send.UTXO in project samourai-wallet-android by Samourai-Wallet.
the class CahootsUtil method doSTONEWALLx2_3.
//
// counterparty
//
public Cahoots doSTONEWALLx2_3(STONEWALLx2 stonewall2) throws Exception {
HashMap<String, String> utxo2Address = new HashMap<String, String>();
List<UTXO> utxos = null;
if (stonewall2.getCounterpartyAccount() == WhirlpoolMeta.getInstance(context).getWhirlpoolPostmix()) {
utxos = APIFactory.getInstance(context).getUtxosPostMix(true);
} else {
utxos = APIFactory.getInstance(context).getUtxos(true);
}
for (UTXO utxo : utxos) {
for (MyTransactionOutPoint outpoint : utxo.getOutpoints()) {
utxo2Address.put(outpoint.getTxHash().toString() + "-" + outpoint.getTxOutputN(), outpoint.getAddress());
}
}
Transaction transaction = stonewall2.getTransaction();
HashMap<String, ECKey> keyBag_A = new HashMap<String, ECKey>();
for (TransactionInput input : transaction.getInputs()) {
TransactionOutPoint outpoint = input.getOutpoint();
String key = outpoint.getHash().toString() + "-" + outpoint.getIndex();
if (utxo2Address.containsKey(key)) {
String address = utxo2Address.get(key);
ECKey eckey = SendFactory.getPrivKey(address, stonewall2.getCounterpartyAccount());
keyBag_A.put(outpoint.toString(), eckey);
}
}
STONEWALLx2 stonewall3 = new STONEWALLx2(stonewall2);
stonewall3.inc(null, null, keyBag_A);
return stonewall3;
}
use of com.samourai.wallet.send.UTXO in project samourai-wallet-android by Samourai-Wallet.
the class CahootsUtil method getCahootsValue.
public long getCahootsValue(int account) {
long ret = 0L;
List<UTXO> _utxos = getCahootsUTXO(account);
for (UTXO utxo : _utxos) {
ret += utxo.getValue();
}
return ret;
}
use of com.samourai.wallet.send.UTXO in project samourai-wallet-android by Samourai-Wallet.
the class CahootsUtil method doSTONEWALLx2_4.
//
// sender
//
public Cahoots doSTONEWALLx2_4(STONEWALLx2 stonewall3) throws Exception {
HashMap<String, String> utxo2Address = new HashMap<String, String>();
List<UTXO> utxos = null;
if (stonewall3.getAccount() == WhirlpoolMeta.getInstance(context).getWhirlpoolPostmix()) {
utxos = APIFactory.getInstance(context).getUtxosPostMix(true);
} else {
utxos = APIFactory.getInstance(context).getUtxos(true);
}
for (UTXO utxo : utxos) {
for (MyTransactionOutPoint outpoint : utxo.getOutpoints()) {
utxo2Address.put(outpoint.getTxHash().toString() + "-" + outpoint.getTxOutputN(), outpoint.getAddress());
}
}
Transaction transaction = stonewall3.getTransaction();
HashMap<String, ECKey> keyBag_B = new HashMap<String, ECKey>();
for (TransactionInput input : transaction.getInputs()) {
TransactionOutPoint outpoint = input.getOutpoint();
String key = outpoint.getHash().toString() + "-" + outpoint.getIndex();
if (utxo2Address.containsKey(key)) {
String address = utxo2Address.get(key);
ECKey eckey = SendFactory.getPrivKey(address, stonewall3.getAccount());
keyBag_B.put(outpoint.toString(), eckey);
}
}
STONEWALLx2 stonewall4 = new STONEWALLx2(stonewall3);
stonewall4.inc(null, null, keyBag_B);
return stonewall4;
}
use of com.samourai.wallet.send.UTXO in project samourai-wallet-android by Samourai-Wallet.
the class CahootsUtil method doStowaway3.
//
// receiver
//
public Cahoots doStowaway3(Stowaway stowaway2) throws Exception {
debug("CahootsUtil", "sender account (3):" + stowaway2.getAccount());
HashMap<String, String> utxo2Address = new HashMap<String, String>();
List<UTXO> utxos = APIFactory.getInstance(context).getUtxos(true);
for (UTXO utxo : utxos) {
for (MyTransactionOutPoint outpoint : utxo.getOutpoints()) {
utxo2Address.put(outpoint.getTxHash().toString() + "-" + outpoint.getTxOutputN(), outpoint.getAddress());
debug("CahootsUtil", "outpoint address:" + outpoint.getTxHash().toString() + "-" + outpoint.getTxOutputN() + "," + outpoint.getAddress());
}
}
Transaction transaction = stowaway2.getPSBT().getTransaction();
HashMap<String, ECKey> keyBag_A = new HashMap<String, ECKey>();
for (TransactionInput input : transaction.getInputs()) {
TransactionOutPoint outpoint = input.getOutpoint();
String key = outpoint.getHash().toString() + "-" + outpoint.getIndex();
if (utxo2Address.containsKey(key)) {
String address = utxo2Address.get(key);
ECKey eckey = SendFactory.getPrivKey(address, 0);
keyBag_A.put(outpoint.toString(), eckey);
}
}
Stowaway stowaway3 = new Stowaway(stowaway2);
stowaway3.inc(null, null, keyBag_A);
return stowaway3;
}
use of com.samourai.wallet.send.UTXO in project samourai-wallet-android by Samourai-Wallet.
the class UTXODetailsActivity method sendUTXOtoWhirlpool.
private void sendUTXOtoWhirlpool() {
new AlertDialog.Builder(this).setMessage("Send utxo to whirlpool").setCancelable(false).setPositiveButton(R.string.ok, (dialog, whichButton) -> {
ArrayList<UTXOCoin> list = new ArrayList<>();
list.add(utxoCoin);
String id = UUID.randomUUID().toString();
PreSelectUtil.getInstance().clear();
PreSelectUtil.getInstance().add(id, list);
if (account == WhirlpoolMeta.getInstance(getApplication()).getWhirlpoolPostmix()) {
if (!utxoCoin.path.startsWith("M/1/")) {
Snackbar.make(paynymLayout.getRootView(), R.string.only_change_utxos_allowed, Snackbar.LENGTH_LONG).show();
return;
}
}
if (utxoCoin.doNotSpend) {
Snackbar.make(paynymLayout.getRootView(), R.string.selection_contains_blocked_utxo, Snackbar.LENGTH_LONG).show();
return;
}
if (id != null) {
Intent intent = new Intent(getApplicationContext(), WhirlpoolMain.class);
intent.putExtra("preselected", id);
intent.putExtra("_account", account);
startActivity(intent);
}
}).setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
}).show();
}
Aggregations