Search in sources :

Example 1 with CahootsUtxo

use of com.samourai.wallet.cahoots.CahootsUtxo 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

UnspentOutput (com.samourai.wallet.api.backend.beans.UnspentOutput)1 PaymentAddress (com.samourai.wallet.bip47.rpc.PaymentAddress)1 PaymentCode (com.samourai.wallet.bip47.rpc.PaymentCode)1 CahootsUtxo (com.samourai.wallet.cahoots.CahootsUtxo)1 HD_Address (com.samourai.wallet.hd.HD_Address)1 MyTransactionOutPoint (com.samourai.wallet.send.MyTransactionOutPoint)1