Skip to content

Commit

Permalink
Merge pull request #274 from horizontalsystems/legacy-address-validat…
Browse files Browse the repository at this point in the history
…ion-production

Validate legacy address prefix (production)
  • Loading branch information
omurovch authored Apr 3, 2019
2 parents 71b3278 + 6aa24ad commit e41ddc8
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ class AddressConverter(private val network: Network) {
}

val bytes = Arrays.copyOfRange(data, 1, data.size)
var type = AddressType.P2PKH
if (data[0].toInt() == network.addressScriptVersion) {
type = AddressType.P2SH
val addressType = when (data[0].toInt()) {
network.addressScriptVersion -> AddressType.P2SH
network.addressVersion -> AddressType.P2PKH
else -> throw AddressFormatException("Wrong address prefix")
}

LegacyAddress(addressString, bytes, type)
LegacyAddress(addressString, bytes, addressType)
}
}

Expand Down

0 comments on commit e41ddc8

Please sign in to comment.