Package com.github.katenachain
Class Transactor
- java.lang.Object
-
- com.github.katenachain.Transactor
-
public class Transactor extends Object
Transactor provides helper methods to hide the complexity of Tx creation, signature and API dialog.
-
-
Constructor Summary
Constructors Constructor Description Transactor(String apiUrl)Transactor constructor.Transactor(String apiUrl, String chainId, String companyChainId, PrivateKey txSigner)Transactor constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StringformatBcid(String companyChainId, String uuid)concatenates a company chain id and a uuid into a bcid.TxgetTx(TxData txData)signs a tx data and returns a new tx ready to be sent.byte[]getTxDataState(String chainId, Date nonceTime, TxData txData)returns the sorted and marshaled json representation of a TxData ready to be signed.TxWrapperretrieveCertificate(String companyChainId, String uuid)fetches the API to find the corresponding tx and return a tx wrapper.TxWrappersretrieveCertificatesHistory(String companyChainId, String uuid)fetches the API to find the corresponding txs and returns tx wrappers or an error.TxWrappersretrieveSecrets(String companyChainId, String uuid)fetches the API to find the corresponding txs and returns tx wrappers.TxStatussendCertificateEd25519V1(String uuid, PublicKey signer, byte[] signature)creates a CertificateEd25519 (V1), wraps in a tx and sends it to the API.TxStatussendCertificateRawV1(String uuid, byte[] value)creates a CertificateRaw (V1), wraps in a tx and sends it to the API.TxStatussendSecretNaclBoxV1(String uuid, PublicKey sender, byte[] nonce, byte[] content)creates a SecretNaclBox (V1), wraps in a tx and sends it to the API.
-
-
-
Constructor Detail
-
Transactor
public Transactor(String apiUrl, String chainId, String companyChainId, PrivateKey txSigner)
Transactor constructor.- Parameters:
apiUrl- StringchainId- StringcompanyChainId- StringtxSigner- PrivateKey
-
Transactor
public Transactor(String apiUrl)
Transactor constructor.- Parameters:
apiUrl- String
-
-
Method Detail
-
sendCertificateRawV1
public TxStatus sendCertificateRawV1(String uuid, byte[] value) throws Exception
creates a CertificateRaw (V1), wraps in a tx and sends it to the API.- Parameters:
uuid- Stringvalue- byte[]- Returns:
- TxStatus tx status
- Throws:
Exception- the exception
-
sendCertificateEd25519V1
public TxStatus sendCertificateEd25519V1(String uuid, PublicKey signer, byte[] signature) throws Exception
creates a CertificateEd25519 (V1), wraps in a tx and sends it to the API.- Parameters:
uuid- Stringsigner- PublicKeysignature- byte[]- Returns:
- TxStatus tx status
- Throws:
Exception- the exception
-
retrieveCertificate
public TxWrapper retrieveCertificate(String companyChainId, String uuid) throws IOException
fetches the API to find the corresponding tx and return a tx wrapper.- Parameters:
companyChainId- Stringuuid- String- Returns:
- TxWrapper tx wrapper
- Throws:
IOException- the io exception
-
retrieveCertificatesHistory
public TxWrappers retrieveCertificatesHistory(String companyChainId, String uuid) throws IOException
fetches the API to find the corresponding txs and returns tx wrappers or an error.- Parameters:
companyChainId- Stringuuid- String- Returns:
- TxWrappers tx wrappers
- Throws:
IOException- the io exception
-
sendSecretNaclBoxV1
public TxStatus sendSecretNaclBoxV1(String uuid, PublicKey sender, byte[] nonce, byte[] content) throws Exception
creates a SecretNaclBox (V1), wraps in a tx and sends it to the API.- Parameters:
uuid- Stringsender- io.katena.crypto.Nacl.PublicKeynonce- byte[]content- byte[]- Returns:
- TxStatus tx status
- Throws:
Exception- the exception
-
retrieveSecrets
public TxWrappers retrieveSecrets(String companyChainId, String uuid) throws IOException
fetches the API to find the corresponding txs and returns tx wrappers.- Parameters:
companyChainId- Stringuuid- String- Returns:
- TxWrappers tx wrappers
- Throws:
IOException- the io exception
-
getTx
public Tx getTx(TxData txData) throws Exception
signs a tx data and returns a new tx ready to be sent.- Parameters:
txData- TxData- Returns:
- Tx tx
- Throws:
Exception- the exception
-
getTxDataState
public byte[] getTxDataState(String chainId, Date nonceTime, TxData txData)
returns the sorted and marshaled json representation of a TxData ready to be signed.- Parameters:
chainId- StringnonceTime- DatetxData- TxData- Returns:
- byte[] byte [ ]
-
-