use of com.samourai.wallet.send.MyTransactionOutPoint in project samourai-wallet-android by Samourai-Wallet.
the class APIFactory method getUtxos.
public List<UTXO> getUtxos(boolean filter) {
long amount = 0L;
for (String key : utxos.keySet()) {
// for(MyTransactionOutPoint out : utxos.get(key).getOutpoints()) {
// debug("APIFactory", "utxo:" + out.getAddress() + "," + out.getValue());
// debug("APIFactory", "utxo:" + utxos.get(key).getPath());
// amount += out.getValue().longValue();
// }
}
debug("APIFactory", "utxos by value:" + amount);
List<UTXO> unspents = new ArrayList<UTXO>();
if (filter) {
for (String key : utxos.keySet()) {
UTXO u = new UTXO();
for (MyTransactionOutPoint out : utxos.get(key).getOutpoints()) {
if (!BlockedUTXO.getInstance().contains(out.getTxHash().toString(), out.getTxOutputN())) {
u.getOutpoints().add(out);
u.setPath(utxos.get(key).getPath());
}
}
if (u.getOutpoints().size() > 0) {
unspents.add(u);
}
}
} else {
unspents.addAll(utxos.values());
}
return unspents;
}
use of com.samourai.wallet.send.MyTransactionOutPoint 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.MyTransactionOutPoint 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.MyTransactionOutPoint 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.MyTransactionOutPoint in project samourai-wallet-android by Samourai-Wallet.
the class SendActivity method markUTXOAsUnspendable.
private void markUTXOAsUnspendable(String hexTx) {
HashMap<String, Long> utxos = new HashMap<String, Long>();
for (UTXO utxo : APIFactory.getInstance(SendActivity.this).getUtxos(true)) {
for (MyTransactionOutPoint outpoint : utxo.getOutpoints()) {
utxos.put(outpoint.getTxHash().toString() + "-" + outpoint.getTxOutputN(), outpoint.getValue().longValue());
}
}
Transaction tx = new Transaction(SamouraiWallet.getInstance().getCurrentNetworkParams(), Hex.decode(hexTx));
for (TransactionInput input : tx.getInputs()) {
BlockedUTXO.getInstance().add(input.getOutpoint().getHash().toString(), (int) input.getOutpoint().getIndex(), utxos.get(input.getOutpoint().getHash().toString() + "-" + (int) input.getOutpoint().getIndex()));
}
}
Aggregations