From 27f4b3b3aee2ff4023e8ad25c15d68a646e19dbf Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Wed, 24 Feb 2021 13:39:35 +0200 Subject: [PATCH] add signet support --- README.md | 6 +++--- drongo | 2 +- src/main/java/com/sparrowwallet/sparrow/MainApp.java | 5 +++++ .../java/com/sparrowwallet/sparrow/net/ElectrumServer.java | 3 +++ .../java/com/sparrowwallet/sparrow/io/ElectrumTest.java | 4 ++-- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 6ba61942..fdf72b78 100644 --- a/README.md +++ b/README.md @@ -45,10 +45,10 @@ Usage: sparrow [options] Show usage --network, -n Network to use - Possible Values: [mainnet, testnet, regtest] + Possible Values: [mainnet, testnet, regtest, signet] ``` -As a fallback, the network (mainnet, testnet or regtest) can also be set using an environment variable `SPARROW_NETWORK`. For example: +As a fallback, the network (mainnet, testnet, regtest or signet) can also be set using an environment variable `SPARROW_NETWORK`. For example: `export SPARROW_NETWORK=testnet` @@ -64,7 +64,7 @@ OSX | ~/.sparrow Linux | ~/.sparrow Windows | %APPDATA%/Sparrow -Testnet and regtest configurations (along with their wallets) are stored in subfolders to allow easy switching between networks. +Testnet, regtest and signet configurations (along with their wallets) are stored in subfolders to allow easy switching between networks. ## Reporting Issues diff --git a/drongo b/drongo index fe91063e..08acfe5b 160000 --- a/drongo +++ b/drongo @@ -1 +1 @@ -Subproject commit fe91063e8fa5acb967907c6e1f65b21e7bca0375 +Subproject commit 08acfe5ba16ed54ebbdcb8177cea88e4c53bda77 diff --git a/src/main/java/com/sparrowwallet/sparrow/MainApp.java b/src/main/java/com/sparrowwallet/sparrow/MainApp.java index 88f2fac3..7284eb2a 100644 --- a/src/main/java/com/sparrowwallet/sparrow/MainApp.java +++ b/src/main/java/com/sparrowwallet/sparrow/MainApp.java @@ -142,6 +142,11 @@ public class MainApp extends Application { Network.set(Network.TESTNET); } + File signetFlag = new File(Storage.getSparrowHome(), "network-" + Network.SIGNET.getName()); + if(signetFlag.exists()) { + Network.set(Network.SIGNET); + } + if(Network.get() != Network.MAINNET) { getLogger().info("Using " + Network.get() + " configuration"); } diff --git a/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java b/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java index 3e98c3b2..59fcd77e 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java @@ -632,6 +632,9 @@ public class ElectrumServer { Map targetBlocksFeeRatesSats = new TreeMap<>(); for(Integer target : targetBlocksFeeRatesBtcKb.keySet()) { long minFeeRateSatsKb = (long)(targetBlocksFeeRatesBtcKb.get(target) * Transaction.SATOSHIS_PER_BITCOIN); + if(minFeeRateSatsKb < 0) { + minFeeRateSatsKb = 1000; + } targetBlocksFeeRatesSats.put(target, minFeeRateSatsKb / 1000d); } diff --git a/src/test/java/com/sparrowwallet/sparrow/io/ElectrumTest.java b/src/test/java/com/sparrowwallet/sparrow/io/ElectrumTest.java index 63e4a800..7e481081 100644 --- a/src/test/java/com/sparrowwallet/sparrow/io/ElectrumTest.java +++ b/src/test/java/com/sparrowwallet/sparrow/io/ElectrumTest.java @@ -59,7 +59,7 @@ public class ElectrumTest extends IoTest { Assert.assertEquals(PolicyType.MULTI, wallet.getPolicyType()); Assert.assertEquals(ScriptType.P2SH_P2WSH, wallet.getScriptType()); Assert.assertEquals(2, wallet.getDefaultPolicy().getNumSignaturesRequired()); - Assert.assertEquals("sh(wsh(sortedmulti(2,coldcard6ba6cfd0,coldcard747b698e,coldcard7bb026be,coldcard0f056943)))", wallet.getDefaultPolicy().getMiniscript().getScript()); + Assert.assertEquals("sh(wsh(sortedmulti(2,coldcard6ba6cfd,coldcard747b698,coldcard7bb026b,coldcard0f05694)))", wallet.getDefaultPolicy().getMiniscript().getScript()); Assert.assertEquals("6ba6cfd0", wallet.getKeystores().get(0).getKeyDerivation().getMasterFingerprint()); Assert.assertEquals("m/48'/1'/0'/1'", wallet.getKeystores().get(0).getKeyDerivation().getDerivationPath()); Assert.assertEquals("tpubDFcrvj5n7gyatVbr8dHCUfHT4CGvL8hREBjtxc4ge7HZgqNuPhFimPRtVg6fRRwfXiQthV9EBjNbwbpgV2VoQeL1ZNXoAWXxP2L9vMtRjax", wallet.getKeystores().get(0).getExtendedPublicKey().toString()); @@ -82,7 +82,7 @@ public class ElectrumTest extends IoTest { Assert.assertEquals(PolicyType.MULTI, wallet.getPolicyType()); Assert.assertEquals(ScriptType.P2SH_P2WSH, wallet.getScriptType()); Assert.assertEquals(2, wallet.getDefaultPolicy().getNumSignaturesRequired()); - Assert.assertEquals("sh(wsh(sortedmulti(2,coldcard6ba6cfd0,coldcard747b698e,coldcard7bb026be,coldcard0f056943)))", wallet.getDefaultPolicy().getMiniscript().getScript()); + Assert.assertEquals("sh(wsh(sortedmulti(2,coldcard6ba6cfd,coldcard747b698,coldcard7bb026b,coldcard0f05694)))", wallet.getDefaultPolicy().getMiniscript().getScript()); Assert.assertEquals("6ba6cfd0", wallet.getKeystores().get(0).getKeyDerivation().getMasterFingerprint()); Assert.assertEquals("m/48'/1'/0'/1'", wallet.getKeystores().get(0).getKeyDerivation().getDerivationPath()); Assert.assertEquals("tpubDFcrvj5n7gyatVbr8dHCUfHT4CGvL8hREBjtxc4ge7HZgqNuPhFimPRtVg6fRRwfXiQthV9EBjNbwbpgV2VoQeL1ZNXoAWXxP2L9vMtRjax", wallet.getKeystores().get(0).getExtendedPublicKey().toString());