Package org.symbol.sdk.facade
Interface BlockchainFacade<TTransaction extends CatbufferType,TDescriptor extends TypedDescriptor,TKeyPair extends KeyPair>
- Type Parameters:
TTransaction- Transaction model type.TDescriptor- Typed transaction-descriptor type.TKeyPair- Key-pair type.
public interface BlockchainFacade<TTransaction extends CatbufferType,TDescriptor extends TypedDescriptor,TKeyPair extends KeyPair>
- BlockchainFacade
- Blockchain-agnostic surface shared by
SymbolFacadeand : build, sign, hash and verify transactions through a single handle. The transaction, typed-descriptor and key-pair types stay chain-specific, so passing another chain's transaction or key pair is a compile error; a key pair enters the wildcard world through the facade (createKeyPair(org.symbol.sdk.CryptoTypes.PrivateKey),bip32NodeToKeyPair(org.symbol.sdk.Bip32.Bip32Node),Account.keyPair()). Each facade also exposes chain-specific methods (e.g. Symbol's embedded-transaction and cosignature helpers) outside this contract.A facade obtained from
FacadeFactory.create(java.lang.String, java.lang.String)is typedBlockchainFacade<?, ?, ?>; the transaction-typed methods are then called from a generic capture-helper method, where the wildcard is fixed to a consistent type:BlockchainFacade<?, ?, ?> facade = FacadeFactory.create(chainName, "testnet"); transfer(facade, json, privateKey); static <T extends CatbufferType, D extends TypedDescriptor, K extends KeyPair> void transfer( BlockchainFacade<T, D, K> facade, String json, CryptoTypes.PrivateKey privateKey) { Account<T, K> account = facade.createAccount(privateKey); T transaction = facade.createTransactionFromJson(json, account.publicKey(), 100, 3600); CryptoTypes.Signature signature = facade.signTransaction(account.keyPair(), transaction); facade.verifyTransaction(transaction, signature); }
-
Method Summary
Modifier and TypeMethodDescriptionGets the BIP32 curve name used by this blockchain.bip32NodeToKeyPair(Bip32.Bip32Node bip32Node) Derives a key pair from a BIP32 node using this blockchain's derivation rules.int[]bip32Path(int accountId) Builds a BIP32 derivation path for an account.createAccount(CryptoTypes.PrivateKey privateKey) Creates an account from a private key.createAddress(String address) Parses an address from its canonical string form.createKeyPair(CryptoTypes.PrivateKey privateKey) Creates a key pair from a private key.createPublicAccount(CryptoTypes.PublicKey publicKey) Creates a public account from a public key.createTransactionFromJson(String json, CryptoTypes.PublicKey signerPublicKey, long fee, long deadlineSeconds) Creates a transaction from a JSON descriptor.createTransactionFromTypedDescriptor(TDescriptor typedDescriptor, CryptoTypes.PublicKey signerPublicKey, long fee, long deadlineSeconds) Creates a transaction from a typed descriptor.createVerifier(CryptoTypes.PublicKey publicKey) Creates a verifier around a public key.deriveSharedKey(TKeyPair keyPair, CryptoTypes.PublicKey otherPublicKey) Derives a shared encryption key between one of this blockchain's key pairs and another party's public key.byte[]extractSigningPayload(TTransaction transaction) Extracts the signing payload of a transaction.hashTransaction(TTransaction transaction) Hashes a transaction.Network<?, ?> network()Gets the network this facade is bound to.now()Gets the current network timestamp.signTransaction(TKeyPair keyPair, TTransaction transaction) Signs a transaction with this blockchain's key-pair type — the type parameter makes a foreign chain's key pair a compile error.booleanverifyTransaction(TTransaction transaction, CryptoTypes.Signature signature) Verifies a transaction signature.
-
Method Details
-
network
Network<?,?> network()- BlockchainFacade.network
- Gets the network this facade is bound to.
- Returns:
- Network.
-
now
NetworkTimestamp.Base now()- BlockchainFacade.now
- Gets the current network timestamp.
- Returns:
- Network timestamp.
-
bip32CurveName
String bip32CurveName()- BlockchainFacade.bip32CurveName
- Gets the BIP32 curve name used by this blockchain.
- Returns:
- BIP32 curve name.
-
bip32Path
int[] bip32Path(int accountId) - BlockchainFacade.bip32Path
- Builds a BIP32 derivation path for an account.
- Parameters:
accountId- Account id.- Returns:
- BIP32 path components.
-
bip32NodeToKeyPair
- BlockchainFacade.bip32NodeToKeyPair
- Derives a key pair from a BIP32 node using this blockchain's derivation rules.
- Parameters:
bip32Node- BIP32 node.- Returns:
- Key pair.
-
createKeyPair
- BlockchainFacade.createKeyPair
- Creates a key pair from a private key.
- Parameters:
privateKey- Private key.- Returns:
- Key pair.
-
createVerifier
- BlockchainFacade.createVerifier
- Creates a verifier around a public key.
- Parameters:
publicKey- Signer public key.- Returns:
- Verifier.
-
createAddress
- BlockchainFacade.createAddress
- Parses an address from its canonical string form.
- Parameters:
address- Address string.- Returns:
- Address.
-
createPublicAccount
- BlockchainFacade.createPublicAccount
- Creates a public account from a public key.
- Parameters:
publicKey- Account public key.- Returns:
- Public account.
-
createAccount
- BlockchainFacade.createAccount
- Creates an account from a private key.
- Parameters:
privateKey- Account private key.- Returns:
- Account.
-
createTransactionFromTypedDescriptor
TTransaction createTransactionFromTypedDescriptor(TDescriptor typedDescriptor, CryptoTypes.PublicKey signerPublicKey, long fee, long deadlineSeconds) - BlockchainFacade.createTransactionFromTypedDescriptor
- Creates a transaction from a typed descriptor.
- Parameters:
typedDescriptor- Typed transaction descriptor.signerPublicKey- Signer public key.fee- Fee — a per-byte fee multiplier for Symbol, an absolute fee for NEM.deadlineSeconds- Relative deadline in seconds.- Returns:
- Transaction.
-
createTransactionFromJson
TTransaction createTransactionFromJson(String json, CryptoTypes.PublicKey signerPublicKey, long fee, long deadlineSeconds) - BlockchainFacade.createTransactionFromJson
- Creates a transaction from a JSON descriptor.
- Parameters:
json- JSON transaction descriptor.signerPublicKey- Signer public key.fee- Fee — a per-byte fee multiplier for Symbol, an absolute fee for NEM.deadlineSeconds- Relative deadline in seconds.- Returns:
- Transaction.
-
hashTransaction
- BlockchainFacade.hashTransaction
- Hashes a transaction.
- Parameters:
transaction- Transaction.- Returns:
- Transaction hash.
-
extractSigningPayload
- BlockchainFacade.extractSigningPayload
- Extracts the signing payload of a transaction.
- Parameters:
transaction- Transaction.- Returns:
- Signing payload bytes.
-
signTransaction
- BlockchainFacade.signTransaction
- Signs a transaction with this blockchain's key-pair type — the type parameter makes a foreign chain's key pair a compile error.
- Parameters:
keyPair- Signer key pair.transaction- Transaction.- Returns:
- Signature.
-
verifyTransaction
- BlockchainFacade.verifyTransaction
- Verifies a transaction signature.
- Parameters:
transaction- Transaction.signature- Signature.- Returns:
- true if the signature is valid, false otherwise.
-