upgrade to whirlpool 1.0.0-beta10

This commit is contained in:
zeroleak 2024-03-11 02:12:56 +01:00
parent 249a01c208
commit da74089969
6 changed files with 32 additions and 30 deletions

View file

@ -124,7 +124,7 @@ dependencies {
exclude group: 'org.slf4j'
}
implementation('com.sparrowwallet.bokmakierie:bokmakierie:1.0')
implementation('io.samourai.code.whirlpool:whirlpool-client:1.0.0-beta4')
implementation('io.samourai.code.whirlpool:whirlpool-client:1.0.0-beta10')
implementation('io.samourai.code.wallet:java-http-client:2.0.0-beta3')
implementation('io.reactivex.rxjava2:rxjava:2.2.15')
implementation('io.reactivex.rxjava2:rxjavafx:2.2.2')

View file

@ -330,20 +330,18 @@ public class CounterpartyController extends SorobanController {
}
}
};
sorobanWalletCounterparty.counterparty(cahootsContext, initiatorPaymentCode, onProgress)
.subscribeOn(Schedulers.io())
.observeOn(JavaFxScheduler.platform())
.subscribe(cahoots -> {
// cahoots success
}, error -> {
log.error("Error creating mix transaction", error);
String cutFrom = "Exception: ";
int index = error.getMessage().lastIndexOf(cutFrom);
String msg = index < 0 ? error.getMessage() : error.getMessage().substring(index + cutFrom.length());
msg = msg.replace("#Cahoots", "mix transaction");
step3Desc.setText(msg);
sorobanProgressLabel.setVisible(false);
});
try {
// TODO run in background thread?
Cahoots result = sorobanWalletCounterparty.counterparty(cahootsContext, initiatorPaymentCode, onProgress);
} catch (Exception error) {
log.error("Error creating mix transaction", error);
String cutFrom = "Exception: ";
int index = error.getMessage().lastIndexOf(cutFrom);
String msg = index < 0 ? error.getMessage() : error.getMessage().substring(index + cutFrom.length());
msg = msg.replace("#Cahoots", "mix transaction");
step3Desc.setText(msg);
sorobanProgressLabel.setVisible(false);
}
} catch(Exception e) {
log.error("Error creating mix transaction", e);
sorobanProgressLabel.setText(e.getMessage());

View file

@ -494,17 +494,16 @@ public class InitiatorController extends SorobanController {
};
SorobanWalletService sorobanWalletService = soroban.getSorobanWalletService();
sorobanProgressLabel.setText("Waiting for mix partner...");
sorobanWalletService.getSorobanWalletInitiator(cahootsWallet).meetAndInitiate(cahootsContext, paymentCodeCounterparty, listener)
.subscribeOn(Schedulers.io())
.observeOn(JavaFxScheduler.platform())
.subscribe(sorobanResponse -> {
}, error -> {
log.error("Error receiving meeting response", error);
step2Desc.setText(getErrorMessage(error));
sorobanProgressLabel.setVisible(false);
meetingFail.setVisible(true);
requestUserAttention();
});
try {
// TODO run in background thread?
Cahoots result = sorobanWalletService.getSorobanWalletInitiator(cahootsWallet).meetAndInitiate(cahootsContext, paymentCodeCounterparty, listener);
} catch (Exception error){
log.error("Error receiving meeting response", error);
step2Desc.setText(getErrorMessage(error));
sorobanProgressLabel.setVisible(false);
meetingFail.setVisible(true);
requestUserAttention();
}
}, error -> {
log.error("Could not retrieve payment code", error);
if(error.getMessage().endsWith("404")) {

View file

@ -52,7 +52,7 @@ public class SparrowDataSource extends AbstractDataSource {
super(whirlpoolWallet, bip44w, walletStateSupplier, dataSourceConfig);
this.seenBackend = computeSeenBackend(whirlpoolWallet.getConfig());
this.pushTx = computePushTx();
this.utxoSupplier = new SparrowUtxoSupplier(whirlpoolWallet, walletSupplier, utxoConfigSupplier, dataSourceConfig);
this.utxoSupplier = new SparrowUtxoSupplier(walletSupplier, utxoConfigSupplier, dataSourceConfig);
}
private ISeenBackend computeSeenBackend(WhirlpoolWalletConfig whirlpoolWalletConfig) {

View file

@ -5,6 +5,8 @@ import com.samourai.wallet.api.backend.seenBackend.SeenResponse;
import com.samourai.wallet.httpClient.IHttpClient;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
public class SparrowSeenBackend implements ISeenBackend {
private IHttpClient httpClient;
@ -15,7 +17,11 @@ public class SparrowSeenBackend implements ISeenBackend {
@Override
public SeenResponse seen(Collection<String> addresses) throws Exception {
return null; // TODO implement: check if each address already received funds
Map<String,Boolean> map = new LinkedHashMap<>();
for (String address : addresses) {
map.put(address, seen(address));
}
return new SeenResponse(map);
}
@Override

View file

@ -26,11 +26,10 @@ public class SparrowUtxoSupplier extends BasicUtxoSupplier {
private static final Logger log = LoggerFactory.getLogger(SparrowUtxoSupplier.class);
public SparrowUtxoSupplier(
WhirlpoolWallet whirlpoolWallet,
WalletSupplier walletSupplier,
UtxoConfigSupplier utxoConfigSupplier,
DataSourceConfig dataSourceConfig) {
super(whirlpoolWallet, walletSupplier, utxoConfigSupplier, dataSourceConfig);
super(walletSupplier, utxoConfigSupplier, dataSourceConfig);
}
@Override