update readme

This commit is contained in:
Craig Raw 2021-04-13 17:32:30 +02:00
parent bb5d5488ed
commit 327f0490e2
2 changed files with 11 additions and 1 deletions

View file

@ -50,20 +50,25 @@ while(true) {
}
```
Hummingbird also includes a type registry to assist with decoding from CBOR to POJOs:
Hummingbird also includes a type registry to assist with encoding and decoding from CBOR to and from POJOs:
```java
RegistryType urRegistryType = ur.getRegistryType();
if(urRegistryType.equals(RegistryType.CRYPTO_PSBT)) {
CryptoPSBT cryptoPSBT = (CryptoPSBT)ur.decodeFromRegistry();
UR cryptoPSBTUR = cryptoPSBT.toUR();
} else if(urRegistryType.equals(RegistryType.CRYPTO_ADDRESS)) {
CryptoAddress cryptoAddress = (CryptoAddress)ur.decodeFromRegistry();
UR cryptoAddressUR = cryptoAddress.toUR();
} else if(urRegistryType.equals(RegistryType.CRYPTO_HDKEY)) {
CryptoHDKey cryptoHDKey = (CryptoHDKey)ur.decodeFromRegistry();
UR cryptoHDKeyUR = cryptoHDKey.toUR();
} else if(urRegistryType.equals(RegistryType.CRYPTO_OUTPUT)) {
CryptoOutput cryptoOutput = (CryptoOutput)ur.decodeFromRegistry();
UR cryptoOutputUR = cryptoOutput.toUR();
} else if(urRegistryType.equals(RegistryType.CRYPTO_ACCOUNT)) {
CryptoAccount cryptoAccount = (CryptoAccount)ur.decodeFromRegistry();
UR cryptoAccountUR = cryptoAccount.toUR();
}
```

View file

@ -16,6 +16,11 @@ public class CryptoCoinInfo extends RegistryItem {
this.network = network;
}
public CryptoCoinInfo(Type type, Network network) {
this.type = (type != null ? type.ordinal() : null);
this.network = (network != null ? network.ordinal() : null);
}
public Type getType() {
return type == null ? Type.BITCOIN : Type.values()[type];
}