mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 13:16:44 +00:00
cormorant: rbf handling and related fixes
This commit is contained in:
parent
af6bbebac4
commit
61d9ad1875
3 changed files with 15 additions and 7 deletions
|
@ -383,10 +383,10 @@ public class BitcoindClient {
|
||||||
|
|
||||||
for(String txid : new HashSet<>(mempoolEntries.keySet())) {
|
for(String txid : new HashSet<>(mempoolEntries.keySet())) {
|
||||||
if(forceRefresh || mempoolEntries.get(txid) == null) {
|
if(forceRefresh || mempoolEntries.get(txid) == null) {
|
||||||
|
try {
|
||||||
MempoolEntry mempoolEntry = getBitcoindService().getMempoolEntry(txid);
|
MempoolEntry mempoolEntry = getBitcoindService().getMempoolEntry(txid);
|
||||||
if(mempoolEntry != null) {
|
|
||||||
mempoolEntries.put(txid, mempoolEntry);
|
mempoolEntries.put(txid, mempoolEntry);
|
||||||
} else {
|
} catch(JsonRpcException e) {
|
||||||
mempoolEntries.remove(txid);
|
mempoolEntries.remove(txid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -395,7 +395,14 @@ public class BitcoindClient {
|
||||||
|
|
||||||
private boolean isConflicted(ListTransaction listTransaction, Map<String, Boolean> conflictCache) {
|
private boolean isConflicted(ListTransaction listTransaction, Map<String, Boolean> conflictCache) {
|
||||||
if(listTransaction.confirmations() == 0 && !listTransaction.walletconflicts().isEmpty()) {
|
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) {
|
if(active) {
|
||||||
for(String conflictedTxid : listTransaction.walletconflicts()) {
|
for(String conflictedTxid : listTransaction.walletconflicts()) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.sparrowwallet.sparrow.net.cormorant.electrum;
|
package com.sparrowwallet.sparrow.net.cormorant.electrum;
|
||||||
|
|
||||||
import com.github.arteam.simplejsonrpc.core.annotation.JsonRpcMethod;
|
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.JsonRpcParam;
|
||||||
import com.github.arteam.simplejsonrpc.core.annotation.JsonRpcService;
|
import com.github.arteam.simplejsonrpc.core.annotation.JsonRpcService;
|
||||||
|
|
||||||
|
@ -10,5 +11,5 @@ public interface ElectrumNotificationService {
|
||||||
void notifyHeaders(@JsonRpcParam("header") ElectrumBlockHeader electrumBlockHeader);
|
void notifyHeaders(@JsonRpcParam("header") ElectrumBlockHeader electrumBlockHeader);
|
||||||
|
|
||||||
@JsonRpcMethod("blockchain.scripthash.subscribe")
|
@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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,9 +146,9 @@ public class ElectrumServerService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonRpcMethod("blockchain.transaction.get")
|
@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 {
|
try {
|
||||||
return bitcoindClient.getBitcoindService().getRawTransaction(tx_hash, verbose).toString();
|
return bitcoindClient.getBitcoindService().getRawTransaction(tx_hash, verbose);
|
||||||
} catch(JsonRpcException e) {
|
} catch(JsonRpcException e) {
|
||||||
throw new TransactionNotFoundException(e.getErrorMessage());
|
throw new TransactionNotFoundException(e.getErrorMessage());
|
||||||
} catch(IllegalStateException e) {
|
} catch(IllegalStateException e) {
|
||||||
|
|
Loading…
Reference in a new issue