diff --git a/build.gradle.kts b/build.gradle.kts index 57beadb8..c31b223b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -12,7 +12,7 @@ plugins { val currentOs = org.gradle.internal.os.OperatingSystem.current() group = "fr.acinq.bitcoin" -version = "0.14.0-SNASPHOT" +version = "0.14.0-SNAPSHOT" repositories { google() diff --git a/src/commonMain/kotlin/fr/acinq/bitcoin/Bitcoin.kt b/src/commonMain/kotlin/fr/acinq/bitcoin/Bitcoin.kt index 7c50a591..ea1f97dc 100644 --- a/src/commonMain/kotlin/fr/acinq/bitcoin/Bitcoin.kt +++ b/src/commonMain/kotlin/fr/acinq/bitcoin/Bitcoin.kt @@ -30,12 +30,12 @@ public sealed class AddressToPublicKeyScriptResult { public abstract val result: List? - public val isSuccess: Boolean = result != null + public fun isSuccess(): Boolean = result != null - public val isFailure: Boolean = !isSuccess + public fun isFailure(): Boolean = !isSuccess() public data class Success(val script: List) : AddressToPublicKeyScriptResult() { - override val result: List? = script + override val result: List = script } public sealed class Failure : AddressToPublicKeyScriptResult() { @@ -61,11 +61,11 @@ public sealed class AddressToPublicKeyScriptResult { public sealed class AddressFromPublicKeyScriptResult { public abstract val result: String? - public val isSuccess: Boolean = result != null - public val isFailure: Boolean = !isSuccess + public fun isSuccess(): Boolean = result != null + public fun isFailure(): Boolean = !isSuccess() public data class Success(val address: String) : AddressFromPublicKeyScriptResult() { - override val result: String? = address + override val result: String = address } public sealed class Failure : AddressFromPublicKeyScriptResult() { @@ -95,7 +95,7 @@ public object Bitcoin { /** * @param pub public key * @param chainHash chain hash (i.e. hash of the genesic block of the chain we're on) - * @return the p2swh-of-p2pkh address for this key). It is a Base58 address that is compatible with most bitcoin wallets + * @return the p2swh-of-p2pkh address for this key. It is a Base58 address that is compatible with most bitcoin wallets */ @JvmStatic public fun computeP2ShOfP2WpkhAddress(pub: PublicKey, chainHash: ByteVector32): String = pub.p2shOfP2wpkhAddress(chainHash) @@ -105,9 +105,9 @@ public object Bitcoin { /** * @param pub public key - * @param chainHash chain hash (i.e. hash of the genesic block of the chain we're on) + * @param chainHash chain hash (i.e. hash of the genesis block of the chain we're on) * @return the BIP84 address for this key (i.e. the p2wpkh address for this key). It is a Bech32 address that will be - * understood only by native sewgit wallets + * understood only by native segwit wallets */ @JvmStatic public fun computeP2WpkhAddress(pub: PublicKey, chainHash: ByteVector32): String = pub.p2wpkhAddress(chainHash) @@ -117,7 +117,7 @@ public object Bitcoin { /** * Compute an address from a public key script - * @param chainHash chain hash (i.e. hash of the genesic block of the chain we're on) + * @param chainHash chain hash (i.e. hash of the genesis block of the chain we're on) * @param pubkeyScript public key script */ @JvmStatic diff --git a/src/commonMain/kotlin/fr/acinq/bitcoin/ScriptElt.kt b/src/commonMain/kotlin/fr/acinq/bitcoin/ScriptElt.kt index 98551a3c..734c1d79 100644 --- a/src/commonMain/kotlin/fr/acinq/bitcoin/ScriptElt.kt +++ b/src/commonMain/kotlin/fr/acinq/bitcoin/ScriptElt.kt @@ -422,7 +422,7 @@ public data class OP_PUSHDATA(@JvmField val data: ByteVector, @JvmField val opCo @JvmStatic public fun isMinimal(data: ByteArray, code: Int): Boolean { return when { - data.size == 0 -> code == OP_0.code + data.isEmpty() -> code == OP_0.code data.size == 1 && data[0] >= 1 && data[0] <= 16 -> code == (OP_1.code).plus(data[0] - 1) data.size == 1 && data[0] == 0x81.toByte() -> code == OP_1NEGATE.code data.size <= 75 -> code == data.size diff --git a/src/commonTest/kotlin/fr/acinq/bitcoin/BitcoinTestsCommon.kt b/src/commonTest/kotlin/fr/acinq/bitcoin/BitcoinTestsCommon.kt index 2490e8ed..6f92ada5 100644 --- a/src/commonTest/kotlin/fr/acinq/bitcoin/BitcoinTestsCommon.kt +++ b/src/commonTest/kotlin/fr/acinq/bitcoin/BitcoinTestsCommon.kt @@ -40,9 +40,9 @@ class BitcoinTestsCommon { assertEquals(address(Script.pay2wpkh(pub), it).result, computeP2WpkhAddress(pub, it)) assertEquals(address(Script.pay2sh(Script.pay2wpkh(pub)), it).result, computeP2ShOfP2WpkhAddress(pub, it)) // all these chain hashes are invalid - assertTrue(address(Script.pay2pkh(pub), it.reversed()).isFailure) - assertTrue(address(Script.pay2wpkh(pub), it.reversed()).isFailure) - assertTrue(address(Script.pay2sh(Script.pay2wpkh(pub)), it.reversed()).isFailure) + assertTrue(address(Script.pay2pkh(pub), it.reversed()).isFailure()) + assertTrue(address(Script.pay2wpkh(pub), it.reversed()).isFailure()) + assertTrue(address(Script.pay2sh(Script.pay2wpkh(pub)), it.reversed()).isFailure()) } listOf(