Search in sources :

Example 31 with MyTransactionOutPoint

use of com.samourai.wallet.send.MyTransactionOutPoint in project samourai-wallet-android by Samourai-Wallet.

the class AndroidWhirlpoolDataService method toUnspentOutput.

private UnspentResponse.UnspentOutput toUnspentOutput(UTXO utxo) {
    UnspentResponse.UnspentOutput u = new UnspentResponse.UnspentOutput();
    MyTransactionOutPoint o = utxo.getOutpoints().iterator().next();
    u.addr = o.getAddress();
    u.confirmations = o.getConfirmations();
    // TODO ?
    u.script = null;
    u.tx_hash = o.getTxHash().toString();
    u.tx_output_n = o.getTxOutputN();
    u.value = o.getValue().value;
    u.xpub = new UnspentResponse.UnspentOutput.Xpub();
    u.xpub.path = utxo.getPath();
    return u;
}
Also used : MyTransactionOutPoint(com.samourai.wallet.send.MyTransactionOutPoint) UnspentResponse(com.samourai.wallet.api.backend.beans.UnspentResponse)

Example 32 with MyTransactionOutPoint

use of com.samourai.wallet.send.MyTransactionOutPoint in project sparrow by sparrowwallet.

the class SparrowCahootsWallet method addUtxo.

public void addUtxo(WalletNode node, BlockTransaction blockTransaction, int index) {
    if (node.getWallet().getScriptType() != ScriptType.P2WPKH) {
        return;
    }
    UnspentOutput unspentOutput = Whirlpool.getUnspentOutput(node, blockTransaction, index);
    MyTransactionOutPoint myTransactionOutPoint = unspentOutput.computeOutpoint(getParams());
    CahootsUtxo cahootsUtxo;
    if (node.getWallet().isBip47()) {
        try {
            String strPaymentCode = node.getWallet().getKeystores().get(0).getExternalPaymentCode().toString();
            HD_Address hdAddress = getBip47Wallet().getAccount(getBip47Account()).addressAt(node.getIndex());
            PaymentAddress paymentAddress = Bip47UtilJava.getInstance().getPaymentAddress(new PaymentCode(strPaymentCode), 0, hdAddress, getParams());
            cahootsUtxo = new CahootsUtxo(myTransactionOutPoint, node.getDerivationPath(), paymentAddress.getReceiveECKey());
        } catch (Exception e) {
            throw new IllegalStateException("Cannot add BIP47 UTXO", e);
        }
    } else {
        HD_Address hdAddress = getBip84Wallet().getAddressAt(account, unspentOutput);
        cahootsUtxo = new CahootsUtxo(myTransactionOutPoint, node.getDerivationPath(), hdAddress.getECKey());
    }
    addUtxo(account, cahootsUtxo);
}
Also used : PaymentCode(com.samourai.wallet.bip47.rpc.PaymentCode) HD_Address(com.samourai.wallet.hd.HD_Address) MyTransactionOutPoint(com.samourai.wallet.send.MyTransactionOutPoint) UnspentOutput(com.samourai.wallet.api.backend.beans.UnspentOutput) PaymentAddress(com.samourai.wallet.bip47.rpc.PaymentAddress) CahootsUtxo(com.samourai.wallet.cahoots.CahootsUtxo)

Aggregations

MyTransactionOutPoint (com.samourai.wallet.send.MyTransactionOutPoint)32 UTXO (com.samourai.wallet.send.UTXO)28 HashMap (java.util.HashMap)19 ArrayList (java.util.ArrayList)18 Transaction (org.bitcoinj.core.Transaction)16 BlockedUTXO (com.samourai.wallet.send.BlockedUTXO)12 IOException (java.io.IOException)12 BigInteger (java.math.BigInteger)12 ECKey (org.bitcoinj.core.ECKey)12 TransactionOutPoint (org.bitcoinj.core.TransactionOutPoint)12 MnemonicException (org.bitcoinj.crypto.MnemonicException)11 JSONException (org.json.JSONException)11 JSONObject (org.json.JSONObject)11 TransactionInput (org.bitcoinj.core.TransactionInput)10 Script (org.bitcoinj.script.Script)9 Intent (android.content.Intent)8 SegwitAddress (com.samourai.wallet.segwit.SegwitAddress)8 AlertDialog (android.app.AlertDialog)7 DecryptionException (com.samourai.wallet.crypto.DecryptionException)7 DialogInterface (android.content.DialogInterface)6