Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. // TODO: imports and functions goes here
  2. export const myblockchainCodec: TxCodec = {
  3.  
  4. /** these are the bytes we create to add a signature;
  5. * they often include nonce and chainID */
  6. bytesToSign: (unsigned: UnsignedTransaction, nonce: Nonce): SigningJob => {
  7. // TODO: write your unsigned transaction serialization recipe
  8. return {
  9. bytes, /** the serialized transaction */
  10. prehashType /** your crypto flawor from PrehashType: Sha256, Sha512, Keccak256 */
  11. };
  12. },
  13.  
  14. /** bytesToPost includes the raw transaction appended with the various signatures */
  15. bytesToPost: (signed: SignedTransaction): PostableBytes => {
  16. // TODO: write your signed transaction serialization recipe
  17. return mySignedTxSerializedBytes as PostableBytes;
  18. },
  19.  
  20. /** identifier is usually some sort of hash of bytesToPost, chain-dependent */
  21. identifier: (signed: SignedTransaction): TransactionId => {
  22. // TODO: generate your transaction id
  23. return myTransactionId as TransactionId;
  24. },
  25.  
  26. /** parseBytes will recover bytes from the blockchain into a format we can use */
  27. parseBytes: (bytes: PostableBytes, chainId: ChainId): SignedTransaction => {
  28. // TODO: deserialize your transaction bytes into the readable components
  29. return myHumanReadTransaction as SignedTransaction;
  30. },
  31.  
  32. /** chain-dependent way to calculate address from a public key */
  33. identityToAddress: (identity: PublicIdentity): Address => {
  34. // TODO: logic to get from public key to blockchain address
  35. return myAddressFromPubKey as Address;
  36. },
  37.  
  38. /** chain-dependent validation of address */
  39. isValidAddress: (address: string): boolean => {
  40. // TODO: logic to validate an address
  41. return myAddressValidationBoolean;
  42. },
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement