-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
495 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Build & Test | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '11' | ||
distribution: 'temurin' | ||
- name: Build | ||
run: mvn package | ||
- name: Test | ||
run: mvn test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Publish to Maven Central | ||
|
||
on: | ||
release: | ||
types: [created] | ||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Java | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '11' | ||
distribution: 'adopt' | ||
server-id: ossrh | ||
server-username: MAVEN_USERNAME | ||
server-password: MAVEN_PASSWORD | ||
gpg-private-key: ${{ secrets.GPG_SECRET_KEY }} | ||
gpg-passphrase: MAVEN_GPG_PASSPHRASE | ||
- name: build artifact | ||
run: mvn clean package | ||
- name: Publish to the Maven Central Repository | ||
run: mvn --no-transfer-progress --batch-mode deploy | ||
env: | ||
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} | ||
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} | ||
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_SECRET_KEY_PASSWORD }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
out/* | ||
|
||
# Maven | ||
target/ | ||
pom.xml.tag | ||
pom.xml.releaseBackup | ||
pom.xml.versionsBackup | ||
pom.xml.next | ||
release.properties | ||
dependency-reduced-pom.xml | ||
buildNumber.properties | ||
.mvn/timing.properties | ||
# https://github.com/takari/maven-wrapper#usage-without-binary-jar | ||
.mvn/wrapper/maven-wrapper.jar | ||
build | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
<project> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.sol4k</groupId> | ||
<artifactId>utilities</artifactId> | ||
<version>0.1.0</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>utilities</name> | ||
<description>sol4k utilities library</description> | ||
<url>https://github.com/sol4k/utilities</url> | ||
|
||
<licenses> | ||
<license> | ||
<name>Apache License, Version 2.0</name> | ||
<url>https://www.apache.org/licenses/LICENSE-2.0</url> | ||
</license> | ||
</licenses> | ||
|
||
<developers> | ||
<developer> | ||
<name>Sasha Shpota</name> | ||
<email>[email protected]</email> | ||
<organization>sol4k</organization> | ||
<organizationUrl>https://github.com/sol4k</organizationUrl> | ||
</developer> | ||
</developers> | ||
|
||
<scm> | ||
<connection>scm:git:git://github.com/sol4k/utilities.git</connection> | ||
<developerConnection>scm:git:ssh://github.com:sol4k/utilities.git</developerConnection> | ||
<url>https://github.com/sol4k/utilities/tree/main</url> | ||
</scm> | ||
|
||
|
||
<properties> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.13.1</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-javadoc-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>attach-javadoc</id> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-source-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>attach-source</id> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-clean-plugin</artifactId> | ||
<version>3.1.0</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>3.2.0</version> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.sonatype.plugins</groupId> | ||
<artifactId>nexus-staging-maven-plugin</artifactId> | ||
<version>1.6.7</version> | ||
<extensions>true</extensions> | ||
<configuration> | ||
<serverId>ossrh</serverId> | ||
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl> | ||
<autoReleaseAfterClose>true</autoReleaseAfterClose> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-gpg-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>sign-artifacts</id> | ||
<phase>verify</phase> | ||
<goals> | ||
<goal>sign</goal> | ||
</goals> | ||
<configuration> | ||
<gpgArguments> | ||
<arg>--pinentry-mode</arg> | ||
<arg>loopback</arg> | ||
</gpgArguments> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<distributionManagement> | ||
<repository> | ||
<id>ossrh</id> | ||
<name>Central Repository OSSRH</name> | ||
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url> | ||
</repository> | ||
</distributionManagement> | ||
</project> |
118 changes: 118 additions & 0 deletions
118
src/main/java/org/sol4k/utilities/AddressFormatException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
/* | ||
* Copyright 2011 Google Inc. | ||
* Copyright 2015 Andreas Schildbach | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.sol4k.utilities; | ||
|
||
|
||
@SuppressWarnings("serial") | ||
public class AddressFormatException extends IllegalArgumentException { | ||
public AddressFormatException() { | ||
super(); | ||
} | ||
|
||
public AddressFormatException(String message) { | ||
super(message); | ||
} | ||
|
||
/** | ||
* This exception is thrown by {@link Base58} when you try to decode data and a character isn't valid. | ||
* You shouldn't allow the user to proceed in this case. | ||
*/ | ||
public static class InvalidCharacter extends AddressFormatException { | ||
public final char character; | ||
public final int position; | ||
|
||
public InvalidCharacter(char character, int position) { | ||
super("Invalid character '" + Character.toString(character) + "' at position " + position); | ||
this.character = character; | ||
this.position = position; | ||
} | ||
} | ||
|
||
/** | ||
* This exception is thrown by {@link Base58} when you try to decode data and the data isn't of the right size. | ||
* You shouldn't allow the user to proceed in this case. | ||
*/ | ||
public static class InvalidDataLength extends AddressFormatException { | ||
public InvalidDataLength() { | ||
super(); | ||
} | ||
|
||
public InvalidDataLength(String message) { | ||
super(message); | ||
} | ||
} | ||
|
||
/** | ||
* This exception is thrown by {@link Base58} when you try to decode data and the checksum isn't valid. | ||
* You shouldn't allow the user to proceed in this case. | ||
*/ | ||
public static class InvalidChecksum extends AddressFormatException { | ||
public InvalidChecksum() { | ||
super("Checksum does not validate"); | ||
} | ||
|
||
public InvalidChecksum(String message) { | ||
super(message); | ||
} | ||
} | ||
|
||
/** | ||
* This exception is thrown by {@code SegwitAddress} when you try to decode data and the witness version doesn't | ||
* match the Bech32 encoding as per BIP350. You shouldn't allow the user to proceed in this case. | ||
*/ | ||
public static class UnexpectedWitnessVersion extends AddressFormatException { | ||
public UnexpectedWitnessVersion() { | ||
super("Unexpected witness version"); | ||
} | ||
|
||
public UnexpectedWitnessVersion(String message) { | ||
super(message); | ||
} | ||
} | ||
|
||
/** | ||
* This exception is thrown by the {@code EncodedPrivateKey} hierarchy of classes when you try and decode an | ||
* address or private key with an invalid prefix (version header or human-readable part). You shouldn't allow the | ||
* user to proceed in this case. | ||
*/ | ||
public static class InvalidPrefix extends AddressFormatException { | ||
public InvalidPrefix() { | ||
super(); | ||
} | ||
|
||
public InvalidPrefix(String message) { | ||
super(message); | ||
} | ||
} | ||
|
||
/** | ||
* This exception is thrown by the {@code EncodedPrivateKey} hierarchy of classes when you try and decode an | ||
* address with a prefix (version header or human-readable part) that used by another network (usually: mainnet vs | ||
* testnet). You shouldn't allow the user to proceed in this case as they are trying to send money across different | ||
* chains, an operation that is guaranteed to destroy the money. | ||
*/ | ||
public static class WrongNetwork extends InvalidPrefix { | ||
public WrongNetwork(int versionHeader) { | ||
super("Version code of address did not match acceptable versions for network: " + versionHeader); | ||
} | ||
|
||
public WrongNetwork(String hrp) { | ||
super("Human readable part of address did not match acceptable HRPs for network: " + hrp); | ||
} | ||
} | ||
} |
Oops, something went wrong.