cormorant: rbf handling and related fixes

This commit is contained in:
Craig Raw 2022-12-12 12:55:19 +02:00
parent af6bbebac4
commit 61d9ad1875
3 changed files with 15 additions and 7 deletions

View file

@ -383,10 +383,10 @@ public class BitcoindClient {
for(String txid : new HashSet<>(mempoolEntries.keySet())) {
if(forceRefresh || mempoolEntries.get(txid) == null) {
MempoolEntry mempoolEntry = getBitcoindService().getMempoolEntry(txid);
if(mempoolEntry != null) {
try {
MempoolEntry mempoolEntry = getBitcoindService().getMempoolEntry(txid);
mempoolEntries.put(txid, mempoolEntry);
} else {
} catch(JsonRpcException e) {
mempoolEntries.remove(txid);
}
}
@ -395,7 +395,14 @@ public class BitcoindClient {
private boolean isConflicted(ListTransaction listTransaction, Map<String, Boolean> conflictCache) {
if(listTransaction.confirmations() == 0 && !listTransaction.walletconflicts().isEmpty()) {
Boolean active = conflictCache.computeIfAbsent(listTransaction.txid(), txid -> getBitcoindService().getMempoolEntry(txid) != null);
Boolean active = conflictCache.computeIfAbsent(listTransaction.txid(), txid -> {
try {
getBitcoindService().getMempoolEntry(txid);
return true;
} catch(JsonRpcException e) {
return false;
}
});
if(active) {
for(String conflictedTxid : listTransaction.walletconflicts()) {

View file

@ -1,6 +1,7 @@
package com.sparrowwallet.sparrow.net.cormorant.electrum;
import com.github.arteam.simplejsonrpc.core.annotation.JsonRpcMethod;
import com.github.arteam.simplejsonrpc.core.annotation.JsonRpcOptional;
import com.github.arteam.simplejsonrpc.core.annotation.JsonRpcParam;
import com.github.arteam.simplejsonrpc.core.annotation.JsonRpcService;
@ -10,5 +11,5 @@ public interface ElectrumNotificationService {
void notifyHeaders(@JsonRpcParam("header") ElectrumBlockHeader electrumBlockHeader);
@JsonRpcMethod("blockchain.scripthash.subscribe")
void notifyScriptHash(@JsonRpcParam("scripthash") String scriptHash, @JsonRpcParam("status") String status);
void notifyScriptHash(@JsonRpcParam("scripthash") String scriptHash, @JsonRpcOptional @JsonRpcParam("status") String status);
}

View file

@ -146,9 +146,9 @@ public class ElectrumServerService {
}
@JsonRpcMethod("blockchain.transaction.get")
public String getTransaction(@JsonRpcParam("tx_hash") String tx_hash, @JsonRpcParam("verbose") @JsonRpcOptional boolean verbose) throws BitcoindIOException, TransactionNotFoundException {
public Object getTransaction(@JsonRpcParam("tx_hash") String tx_hash, @JsonRpcParam("verbose") @JsonRpcOptional boolean verbose) throws BitcoindIOException, TransactionNotFoundException {
try {
return bitcoindClient.getBitcoindService().getRawTransaction(tx_hash, verbose).toString();
return bitcoindClient.getBitcoindService().getRawTransaction(tx_hash, verbose);
} catch(JsonRpcException e) {
throw new TransactionNotFoundException(e.getErrorMessage());
} catch(IllegalStateException e) {