Search in sources :

Example 1 with CahootsType

use of com.samourai.wallet.cahoots.CahootsType in project sparrow by sparrowwallet.

the class CounterpartyController method startCounterpartyMeetingReceive.

private void startCounterpartyMeetingReceive() {
    Soroban soroban = AppServices.getSorobanServices().getSoroban(walletId);
    SparrowCahootsWallet counterpartyCahootsWallet = soroban.getCahootsWallet(wallet, 1);
    try {
        SorobanCahootsService sorobanMeetingService = soroban.getSorobanCahootsService(counterpartyCahootsWallet);
        sorobanMeetingService.receiveMeetingRequest(TIMEOUT_MS).subscribeOn(Schedulers.io()).observeOn(JavaFxScheduler.platform()).subscribe(requestMessage -> {
            String code = requestMessage.getSender();
            CahootsType cahootsType = requestMessage.getType();
            PaymentCode paymentCodeInitiator = new PaymentCode(code);
            updateMixPartner(paymentCodeInitiator, cahootsType);
            Boolean accepted = (Boolean) Platform.enterNestedEventLoop(meetingAccepted);
            sorobanMeetingService.sendMeetingResponse(paymentCodeInitiator, requestMessage, accepted).subscribeOn(Schedulers.io()).observeOn(JavaFxScheduler.platform()).subscribe(responseMessage -> {
                if (accepted) {
                    startCounterpartyCollaboration(counterpartyCahootsWallet, paymentCodeInitiator, cahootsType);
                    followPaymentCode(paymentCodeInitiator);
                }
            }, error -> {
                log.error("Error sending meeting response", error);
                mixingPartner.setVisible(false);
            });
        }, error -> {
            log.error("Failed to receive meeting request", error);
            mixingPartner.setVisible(false);
        });
    } catch (Exception e) {
        log.error("Error sending meeting response", e);
    }
}
Also used : PaymentCode(com.samourai.wallet.bip47.rpc.PaymentCode) CahootsType(com.samourai.wallet.cahoots.CahootsType) SorobanCahootsService(com.samourai.soroban.client.cahoots.SorobanCahootsService) PSBTParseException(com.sparrowwallet.drongo.psbt.PSBTParseException)

Aggregations

SorobanCahootsService (com.samourai.soroban.client.cahoots.SorobanCahootsService)1 PaymentCode (com.samourai.wallet.bip47.rpc.PaymentCode)1 CahootsType (com.samourai.wallet.cahoots.CahootsType)1 PSBTParseException (com.sparrowwallet.drongo.psbt.PSBTParseException)1