From 4810eff433ade89dafe7724544f3b938df4f2f99 Mon Sep 17 00:00:00 2001 From: KirillPamPam Date: Wed, 13 Nov 2024 17:59:50 +0400 Subject: [PATCH] Remove extra bitcoin unspent fields (#593) --- .../upstream/bitcoin/data/EsploraUnspent.kt | 4 ---- .../bitcoin/data/EsploraUnspentDeserializer.kt | 4 ---- .../upstream/bitcoin/EsploraClientSpec.groovy | 13 +++++++------ 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/bitcoin/data/EsploraUnspent.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/bitcoin/data/EsploraUnspent.kt index 76ed11773..461a6af8c 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/bitcoin/data/EsploraUnspent.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/bitcoin/data/EsploraUnspent.kt @@ -15,12 +15,8 @@ */ package io.emeraldpay.dshackle.upstream.bitcoin.data -import java.time.Instant - data class EsploraUnspent( val txid: String, val vout: Int, val value: Long, - val timestamp: Instant, - val height: Long, ) diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/bitcoin/data/EsploraUnspentDeserializer.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/bitcoin/data/EsploraUnspentDeserializer.kt index 71ad6af57..34d14852e 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/bitcoin/data/EsploraUnspentDeserializer.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/bitcoin/data/EsploraUnspentDeserializer.kt @@ -19,18 +19,14 @@ import com.fasterxml.jackson.core.JsonParser import com.fasterxml.jackson.databind.DeserializationContext import com.fasterxml.jackson.databind.JsonDeserializer import com.fasterxml.jackson.databind.JsonNode -import java.time.Instant class EsploraUnspentDeserializer : JsonDeserializer() { override fun deserialize(jp: JsonParser, ctxt: DeserializationContext): EsploraUnspent { val node: JsonNode = jp.readValueAsTree() - val status = node.get("status") return EsploraUnspent( node.get("txid").asText(), node.get("vout").asInt(), node.get("value").asLong(), - Instant.ofEpochSecond(status.get("block_time").asLong()), - status.get("block_height").asLong(), ) } } diff --git a/src/test/groovy/io/emeraldpay/dshackle/upstream/bitcoin/EsploraClientSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/upstream/bitcoin/EsploraClientSpec.groovy index 6e32bace1..ea686f168 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/upstream/bitcoin/EsploraClientSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/upstream/bitcoin/EsploraClientSpec.groovy @@ -1,5 +1,7 @@ package io.emeraldpay.dshackle.upstream.bitcoin +import io.emeraldpay.dshackle.upstream.bitcoin.data.EsploraUnspent + /** * Copyright (c) 2020 EmeraldPay, Inc * @@ -15,7 +17,7 @@ package io.emeraldpay.dshackle.upstream.bitcoin * See the License for the specific language governing permissions and * limitations under the License. */ -import io.emeraldpay.dshackle.upstream.bitcoin.data.EsploraUnspent + import org.bitcoinj.core.Address import org.bitcoinj.params.MainNetParams import org.bitcoinj.params.TestNet3Params @@ -27,7 +29,6 @@ import reactor.test.StepVerifier import spock.lang.Specification import java.time.Duration -import java.time.Instant class EsploraClientSpec extends Specification { @@ -62,13 +63,13 @@ class EsploraClientSpec extends Specification { .expectNextMatches { list -> def ok = list.size() == 14 if (!ok) println("invalid size") - ok = ok && list[0] == new EsploraUnspent("002eba7d9e8081afc687e1c3fa7b6a6451713b75bc91432d441bb1e7e1511c5c", 0, 105524, Instant.ofEpochSecond(1599808442), 647721) + ok = ok && list[0] == new EsploraUnspent("002eba7d9e8081afc687e1c3fa7b6a6451713b75bc91432d441bb1e7e1511c5c", 0, 105524) if (!ok) println("invalid 0") - ok = ok && list[1] == new EsploraUnspent("1ee3cb3833b1e499e7f8babb1100c4aa0b4273f655036561d84dd72a5b197258", 0, 5248, Instant.ofEpochSecond(1600114632), 648312) + ok = ok && list[1] == new EsploraUnspent("1ee3cb3833b1e499e7f8babb1100c4aa0b4273f655036561d84dd72a5b197258", 0, 5248) if (!ok) println("invalid 1") - ok = ok && list[12] == new EsploraUnspent("311d0d1d4eea6ee37d57954cd1002898bef64885d8e438afbbd7fe4fdc6e08de", 2250, 22978, Instant.ofEpochSecond(1599018027), 646382) + ok = ok && list[12] == new EsploraUnspent("311d0d1d4eea6ee37d57954cd1002898bef64885d8e438afbbd7fe4fdc6e08de", 2250, 22978) if (!ok) println("invalid 12") - ok = ok && list[13] == new EsploraUnspent("230317b8fdf1ae85f5fbdc49ca90851b1728c2d9432b2738d3fe1c6f68f046e4", 11, 8642, Instant.ofEpochSecond(1599273442), 646777) + ok = ok && list[13] == new EsploraUnspent("230317b8fdf1ae85f5fbdc49ca90851b1728c2d9432b2738d3fe1c6f68f046e4", 11, 8642) if (!ok) println("invalid 13") ok }