ripple/BRRippleTransaction.c
/*
 * Serialize the transaction
 *
 * @return serializedTransaction  valid BRRippleSerializedTransaction handle OR
 *                                NULL if unable to serialize
 */
Serialize the transaction
@return serializedTransaction  valid BRRippleSerializedTransaction handle OR
NULL if unable to serialize
Serialize the transaction @return serializedTransaction valid BRRippleSerializedTransaction handle OR NULL if unable to serialize
static BRRippleSerializedTransaction
rippleTransactionSerializeImpl (BRRippleTransaction transaction,
                            uint8_t *signature, int sig_length)
{
    assert(transaction);
    assert(transaction->transactionType == RIPPLE_TX_TYPE_PAYMENT);
    BRRippleField fields[11];
    transaction->fee = calculateFee(transaction);
    int num_fields = setFieldInfo(fields, transaction, signature, sig_length);
    BRRippleSerializedTransaction signedBytes = NULL;
    int size = rippleSerialize(fields, num_fields, 0, 0);
    if (size > 0) {
        signedBytes = calloc(1, sizeof(struct BRRippleSerializedTransactionRecord));
        signedBytes->size = size + 512; 
        signedBytes->buffer = calloc(1, signedBytes->size);
        signedBytes->size = rippleSerialize(fields, num_fields, signedBytes->buffer, signedBytes->size);
        if (0 == signedBytes->size) {
            rippleSerializedTransactionRecordFree(&signedBytes);
            signedBytes = NULL;
        }
    }
    return signedBytes;
}
static BRRippleSerializedTransaction rippleTransactionSerializeImpl ( BRRippleTransaction transaction , uint8_t * signature , int sig_length ) { assert ( transaction ) ; assert ( transaction -> transactionType == RIPPLE_TX_TYPE_PAYMENT ) ; BRRippleField fields [ 11 ] ; transaction -> fee = calculateFee ( transaction ) ; int num_fields = setFieldInfo ( fields , transaction , signature , sig_length ) ; BRRippleSerializedTransaction signedBytes = NULL ; int size = rippleSerialize ( fields , num_fields , 0 , 0 ) ; if ( size > 0 ) { signedBytes = calloc ( 1 , sizeof ( struct BRRippleSerializedTransactionRecord ) ) ; signedBytes -> size = size + 512 ; signedBytes -> buffer = calloc ( 1 , signedBytes -> size ) ; signedBytes -> size = rippleSerialize ( fields , num_fields , signedBytes -> buffer , signedBytes -> size ) ; if ( 0 == signedBytes -> size ) { rippleSerializedTransactionRecordFree ( & signedBytes ) ; signedBytes = NULL ; } } return signedBytes ; }
Serialize the transaction
 @return serializedTransaction  valid BRRippleSerializedTransaction handle OR
                                NULL if unable to serialize
Serialize the transaction @return serializedTransaction valid BRRippleSerializedTransaction handle OR NULL if unable to serialize
// NOTE - the address fields will hold a BRRippleAddress pointer BUT // they are owned by the the transaction or transfer so we don't need // to worry about the memory. // I guess we will be sending back something // TODO validate the serialized bytes // Allocate an extra 512 bytes for safety // Something bad happened - free memory and set pointer to NULL // LOG somewhere ???