ITransaction methods and callbacks

From Bytecoin Wiki
Jump to: navigation, search

Contents

ITransaction

ITransaction interface is a composition of two other interfaces: ITransactionReader and ITransactionWriter. For detailed explanation on multisignature usage see Multisignature API.


ITransactionReader

ITransactionReader is an interface used to obtain low-level transaction information: outputs, inputs, etc.

Method Method description Parameters Parameters description Return value Return value description
getTransactionHash Returns transaction hash Crypto::Hash Transaction hash
getTransactionPrefixHash Returns transaction prefix hash Crypto::Hash Transaction prefix hash
getTransactionPublicKey Returns transaction public key Crypto::PublicKey Transaction public key
getUnlockTime Returns transaction unlock time uint64_t Unlock time
getPaymentId Gets payment id from extra Crypto::Hash& paymentId Reference to object to receive payment id bool True if payment id is present and was successfully retrieved
getExtraNonce Gets extra nonce from transaction extra field BinaryArray& nonce Reference to object to receive nonce bool True if extra nonce is present and was successfully retrieved
getExtra Returns transaction extra BinaryArray Transaction extra
getInputCount Retuns number of transaction inputs size_t Number of transaction inputs
getInputTotalAmount Returns total amount (sum) of inputs uint64_t Total amount (sum) of inputs
getInputType Returns input type size_t index Input index in transaction TransactionTypes::InputType Input type
getInput Gets information for the specified key input size_t index Input index void
KeyInput& input Reference to object to receive input information
getInput Gets information for the specified multisignature input size_t index Input index void
MultisignatureInput& input Reference to object to receive input information
getOutputCount Returns number of transaction outputs size_t Number of transaction outputs
getOutputTotalAmount Returns total amount (sum) of outputs uint64_t Total amount (sum) of outputs
getOutputType Returns output type size_t index Output index in transaction TransactionTypes::OutputType Output type
getOutput Gets information for the specified key output size_t index Output index void
KeyOutput& output Reference to object to receive output information
uint64_t& amount Reference to variable to receive output amount
getOutput Gets information for the specified multisignature output size_t index Output index void
MultisignatureOutput& output Reference to object to receive output information
uint64_t& amount Reference to variable to receive output amount
getRequiredSignaturesCount Returns required signatures count for the specified input size_t inputIndex Input index in transaction size_t Required number of signatures fo the input
findOutputsToAccount Finds all outputs to the specified account const AccountPublicAddress& addr Receiver's account bool True if at least one output to the specified view key is found
const Crypto::SecretKey& viewSecretKey Receiver's view secret key
std::vector<uint32_t>& outs Vector to receive found output indexes
uint64_t& outputAmount Total amount of found outputs
validateInputs Validates transaction inputs bool Result of the validation
validateOutputs Validates transaction outputs bool Result of the validation
validateSignatures Validates transaction outputs signatures. Does not cryptographically checks them, just validates that number of signatures is correct. bool Result of the validation
getTransactionData Returns serialized transaction as binary block BinaryArray Serialized transaction


ITransactionWriter

ITransactionWriter is an interface which allows you to create a custom transaction, providing full control on inputs and outputs.

Method Method description Parameters Parameters description Return value Return value description
setUnlockTime Sets transaction unlock time uint64_t unlockTime Unlock time: unix time or number of blocks void
setPaymentId Sets payment id const Crypto::Hash& paymentId Payment id void
setExtraNonce Sets extra nonce const BinaryArray& nonce Extra nonce void
appendExtra Appends given binary block to transaction extra field const BinaryArray& extraData Extra data to append void
addInput Adds key input const KeyInput& input Input information size_t Input index in transaction
addInput Adds multisignature input const MultisignatureInput& input Input information size_t Input index in transaction
addInput Adds key input (helper method) const AccountKeys& senderKeys Sender's keys (spend and view key pairs) size_t Input index in transaction
const TransactionTypes::InputKeyInfo& info Input information
KeyPair& ephKeys Generated ephemeral keys to be used to sign this input
addOutput Adds output to the specified address uint64_t amount Amount of money size_t Output index in transaction
const AccountPublicAddress& to Receiver's address
addOutput Adds multisignature output uint64_t amount Amount of money size_t Output index in transaction
const std::vector<AccountPublicAddress>& to Receivers addresses
uint32_t requiredSignatures Required number of signatures to spend this output
getTransactionSecretKey Gets transaction secret key, if available. The secret key is present only in newly generated transactions. It is not preserved during serialization, so it is client's duty to save secret key, if needed. Crypto::SecretKey& key Reference object receiving the value bool true if the key successfully retrieved
setTransactionSecretKey Sets transaction secret key. The key should match transaction public key. Wrong key would be rejected. const Crypto::SecretKey& key Secret key void
signInputKey Signs key input size_t input Input index void
const TransactionTypes::InputKeyInfo& info Input information
const KeyPair& ephKeys Ephemeral key pair
signInputMultisignature Signs multisignature input size_t input Input index void
const Crypto::PublicKey& sourceTransactionKey Public key of the transaction containing multisignature output
size_t outputIndex4 Output index in source transaction
const AccountKeys& accountKeys Account keys to be used for signing

TransactionTypes

Additional data types used in ITransaction interface

namespace TransactionTypes {
  
  enum class InputType : uint8_t { Invalid, Key, Multisignature, Generating };
  enum class OutputType : uint8_t { Invalid, Key, Multisignature };

  struct GlobalOutput {
    Crypto::PublicKey targetKey;
    uint32_t outputIndex;
  };

  typedef std::vector<GlobalOutput> GlobalOutputsContainer;

  struct OutputKeyInfo {
    Crypto::PublicKey transactionPublicKey;
    size_t transactionIndex;
    size_t outputInTransaction;
  };

  struct InputKeyInfo {
    uint64_t amount;
    GlobalOutputsContainer outputs;
    OutputKeyInfo realOutput;
  };
}

Personal tools
Namespaces

Variants
Actions
Navigation
Tools