mirror of
https://github.com/sparrowwallet/hummingbird.git
synced 2024-12-26 10:06:45 +00:00
v1.4 get cryptoaccount from ur registry
This commit is contained in:
parent
096c09f070
commit
7ad7545749
4 changed files with 24 additions and 3 deletions
21
README.md
21
README.md
|
@ -11,7 +11,7 @@ It contains both the classes to represent a UR, and a UR encoder and decoder to
|
||||||
Hummingbird is hosted in Maven Central and can be added as a dependency with the following:
|
Hummingbird is hosted in Maven Central and can be added as a dependency with the following:
|
||||||
|
|
||||||
```
|
```
|
||||||
implementation('com.sparrowwallet:hummingbird:1.3')
|
implementation('com.sparrowwallet:hummingbird:1.4')
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
@ -49,6 +49,25 @@ while(true) {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Hummingbird also includes a type registry to assist with decoding from CBOR to POJOs:
|
||||||
|
|
||||||
|
```java
|
||||||
|
RegistryType urRegistryType = ur.getRegistryType();
|
||||||
|
if(urRegistryType.equals(RegistryType.CRYPTO_PSBT)) {
|
||||||
|
CryptoPSBT cryptoPSBT = (CryptoPSBT)ur.decodeFromRegistry();
|
||||||
|
} else if(urRegistryType.equals(RegistryType.CRYPTO_ADDRESS)) {
|
||||||
|
CryptoAddress cryptoAddress = (CryptoAddress)ur.decodeFromRegistry();
|
||||||
|
} else if(urRegistryType.equals(RegistryType.CRYPTO_HDKEY)) {
|
||||||
|
CryptoHDKey cryptoHDKey = (CryptoHDKey)ur.decodeFromRegistry();
|
||||||
|
} else if(urRegistryType.equals(RegistryType.CRYPTO_OUTPUT)) {
|
||||||
|
CryptoOutput cryptoOutput = (CryptoOutput)ur.decodeFromRegistry();
|
||||||
|
} else if(urRegistryType.equals(RegistryType.CRYPTO_ACCOUNT)) {
|
||||||
|
CryptoAccount cryptoAccount = (CryptoAccount)ur.decodeFromRegistry();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
See `RegistryType.java` for the full list of supported types and their POJO implementation classes where available.
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
||||||
Hummingbird has a thorough testsuite ported from URKit. The tests can be run with:
|
Hummingbird has a thorough testsuite ported from URKit. The tests can be run with:
|
||||||
|
|
|
@ -16,7 +16,7 @@ apply plugin: 'com.bmuschko.nexus'
|
||||||
|
|
||||||
archivesBaseName = 'hummingbird'
|
archivesBaseName = 'hummingbird'
|
||||||
group 'com.sparrowwallet'
|
group 'com.sparrowwallet'
|
||||||
version '1.3'
|
version '1.4'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|
|
@ -74,6 +74,8 @@ public class UR {
|
||||||
return CryptoOutput.fromCbor(item);
|
return CryptoOutput.fromCbor(item);
|
||||||
} else if(registryType == RegistryType.CRYPTO_PSBT) {
|
} else if(registryType == RegistryType.CRYPTO_PSBT) {
|
||||||
return CryptoPSBT.fromCbor(item);
|
return CryptoPSBT.fromCbor(item);
|
||||||
|
} else if(registryType == RegistryType.CRYPTO_ACCOUNT) {
|
||||||
|
return CryptoAccount.fromCbor(item);
|
||||||
}
|
}
|
||||||
} catch(CborException e) {
|
} catch(CborException e) {
|
||||||
throw new InvalidCBORException(e.getMessage());
|
throw new InvalidCBORException(e.getMessage());
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class CryptoAddress {
|
||||||
|
|
||||||
public static CryptoAddress fromCbor(DataItem item) {
|
public static CryptoAddress fromCbor(DataItem item) {
|
||||||
CryptoCoinInfo info = null;
|
CryptoCoinInfo info = null;
|
||||||
Type type = null;
|
Type type = Type.P2PKH;
|
||||||
byte[] data = null;
|
byte[] data = null;
|
||||||
|
|
||||||
Map map = (Map)item;
|
Map map = (Map)item;
|
||||||
|
|
Loading…
Reference in a new issue