2020 05 11 bech32 addr tostring (#1413)

* Make Bech32Address.toString actually print the string representation not the object one

* Remove Bech32Address.toString all together and use the super class definition

* Add test case

* Run scalafmt
This commit is contained in:
Chris Stewart 2020-05-11 10:59:36 -05:00 committed by GitHub
parent d4c4ec3311
commit 65f21acbf8
3 changed files with 11 additions and 21 deletions

View File

@ -1,7 +1,7 @@
package org.bitcoins.core.protocol
import org.bitcoins.testkit.core.gen.AddressGenerator
import org.bitcoins.testkit.util.BitcoinSUnitTest
import org.bitcoins.testkit.util.{BitcoinSUnitTest, TestUtil}
import scala.util.{Failure, Success}
@ -25,4 +25,9 @@ class AddressTest extends BitcoinSUnitTest {
}
}
}
it must "serialize a bech32 address correctly" in {
TestUtil.bech32Address.toString must be(
"bcrt1qq6w6pu6zq90az9krn53zlkvgyzkyeglzukyepf")
}
}

View File

@ -112,9 +112,6 @@ sealed abstract class Bech32Address extends BitcoinAddress {
def expandHrp: Vector[UInt5] = {
Bech32.hrpExpand(hrp)
}
override def toString: String = "Bech32Address(" + value + ")"
}
object Bech32Address extends AddressFactory[Bech32Address] {

View File

@ -4,26 +4,13 @@ import org.bitcoins.core.crypto.BaseTxSigComponent
import org.bitcoins.core.currency.CurrencyUnits
import org.bitcoins.core.number.UInt32
import org.bitcoins.core.policy.Policy
import org.bitcoins.core.protocol.BitcoinAddress
import org.bitcoins.core.protocol.script.{
EmptyScriptPubKey,
P2SHScriptSignature,
ScriptPubKey,
ScriptSignature
}
import org.bitcoins.core.protocol.transaction.{
Transaction,
TransactionInput,
TransactionOutput
}
import org.bitcoins.core.protocol.{Bech32Address, BitcoinAddress}
import org.bitcoins.core.protocol.script.{EmptyScriptPubKey, P2SHScriptSignature, ScriptPubKey, ScriptSignature}
import org.bitcoins.core.protocol.transaction.{Transaction, TransactionInput, TransactionOutput}
import org.bitcoins.core.script.PreExecutionScriptProgram
import org.bitcoins.core.script.bitwise.{OP_EQUAL, OP_EQUALVERIFY}
import org.bitcoins.core.script.constant._
import org.bitcoins.core.script.crypto.{
OP_CHECKMULTISIG,
OP_CHECKSIG,
OP_HASH160
}
import org.bitcoins.core.script.crypto.{OP_CHECKMULTISIG, OP_CHECKSIG, OP_HASH160}
import org.bitcoins.core.script.stack.OP_DUP
import org.bitcoins.core.serializers.script.RawScriptPubKeyParser
import org.bitcoins.core.serializers.transaction.RawTransactionInputParser
@ -35,6 +22,7 @@ object TestUtil {
def testBitcoinAddress = BitcoinAddress("n3p1ct69ao3qxWvEvzLhLtWG2zJGTjN3EV")
def testP2SHAddress = BitcoinAddress("2MzYbQdkSVp5wVyMRp6A5PHPuQNHpiaTbCj")
val bech32Address: Bech32Address = Bech32Address.fromString("bcrt1qq6w6pu6zq90az9krn53zlkvgyzkyeglzukyepf").get
def bitcoinAddress = BitcoinAddress("1C4kYhyLftmkn48YarSoLupxHfYFo8kp64")
def multiSigAddress = BitcoinAddress("342ftSRCvFHfCeFFBuz4xwbeqnDw6BGUey")