You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
110 lines
4.4 KiB
110 lines
4.4 KiB
![]()
10 years ago
|
/*
|
||
![]()
7 years ago
|
* This file is part of the TREZOR project, https://trezor.io/
|
||
![]()
10 years ago
|
*
|
||
|
* Copyright (C) 2014 Pavol Rusnak <stick@satoshilabs.com>
|
||
|
*
|
||
|
* This library is free software: you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||
|
* the Free Software Foundation, either version 3 of the License, or
|
||
|
* (at your option) any later version.
|
||
|
*
|
||
|
* This library is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU Lesser General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Lesser General Public License
|
||
|
* along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*/
|
||
|
|
||
|
#ifndef __TRANSACTION_H__
|
||
|
#define __TRANSACTION_H__
|
||
|
|
||
|
#include <stdbool.h>
|
||
|
#include <stdint.h>
|
||
|
#include "bip32.h"
|
||
![]()
7 years ago
|
#include "coins.h"
|
||
![]()
7 years ago
|
#include "hasher.h"
|
||
![]()
6 years ago
|
#include "messages-bitcoin.pb.h"
|
||
![]()
5 years ago
|
#include "sha2.h"
|
||
![]()
10 years ago
|
|
||
![]()
6 years ago
|
#define TX_OVERWINTERED 0x80000000
|
||
|
|
||
![]()
10 years ago
|
typedef struct {
|
||
![]()
5 years ago
|
uint32_t inputs_len;
|
||
|
uint32_t outputs_len;
|
||
![]()
10 years ago
|
|
||
![]()
5 years ago
|
uint32_t version;
|
||
|
uint32_t version_group_id;
|
||
|
uint32_t lock_time;
|
||
|
uint32_t expiry;
|
||
|
bool is_segwit;
|
||
|
bool is_decred;
|
||
![]()
10 years ago
|
|
||
![]()
5 years ago
|
uint32_t have_inputs;
|
||
|
uint32_t have_outputs;
|
||
![]()
8 years ago
|
|
||
![]()
5 years ago
|
bool overwintered;
|
||
|
uint32_t extra_data_len;
|
||
|
uint32_t extra_data_received;
|
||
![]()
8 years ago
|
|
||
![]()
5 years ago
|
uint32_t size;
|
||
![]()
10 years ago
|
|
||
![]()
5 years ago
|
Hasher hasher;
|
||
![]()
10 years ago
|
} TxStruct;
|
||
|
|
||
![]()
5 years ago
|
bool compute_address(const CoinInfo *coin, InputScriptType script_type,
|
||
|
const HDNode *node, bool has_multisig,
|
||
|
const MultisigRedeemScriptType *multisig,
|
||
|
char address[MAX_ADDR_SIZE]);
|
||
|
uint32_t compile_script_sig(uint32_t address_type, const uint8_t *pubkeyhash,
|
||
|
uint8_t *out);
|
||
|
uint32_t compile_script_multisig(const CoinInfo *coin,
|
||
|
const MultisigRedeemScriptType *multisig,
|
||
|
uint8_t *out);
|
||
|
uint32_t compile_script_multisig_hash(const CoinInfo *coin,
|
||
|
const MultisigRedeemScriptType *multisig,
|
||
|
uint8_t *hash);
|
||
|
uint32_t serialize_script_sig(const uint8_t *signature, uint32_t signature_len,
|
||
|
const uint8_t *pubkey, uint32_t pubkey_len,
|
||
|
uint8_t sighash, uint8_t *out);
|
||
|
uint32_t serialize_script_multisig(const CoinInfo *coin,
|
||
|
const MultisigRedeemScriptType *multisig,
|
||
|
uint8_t sighash, uint8_t *out);
|
||
|
int compile_output(const CoinInfo *coin, const HDNode *root, TxOutputType *in,
|
||
|
TxOutputBinType *out, bool needs_confirm);
|
||
![]()
8 years ago
|
|
||
![]()
6 years ago
|
uint32_t tx_prevout_hash(Hasher *hasher, const TxInputType *input);
|
||
![]()
7 years ago
|
uint32_t tx_script_hash(Hasher *hasher, uint32_t size, const uint8_t *data);
|
||
![]()
6 years ago
|
uint32_t tx_sequence_hash(Hasher *hasher, const TxInputType *input);
|
||
![]()
5 years ago
|
uint32_t tx_output_hash(Hasher *hasher, const TxOutputBinType *output,
|
||
|
bool decred);
|
||
![]()
8 years ago
|
uint32_t tx_serialize_script(uint32_t size, const uint8_t *data, uint8_t *out);
|
||
![]()
8 years ago
|
|
||
![]()
8 years ago
|
uint32_t tx_serialize_footer(TxStruct *tx, uint8_t *out);
|
||
![]()
5 years ago
|
uint32_t tx_serialize_input(TxStruct *tx, const TxInputType *input,
|
||
|
uint8_t *out);
|
||
|
uint32_t tx_serialize_output(TxStruct *tx, const TxOutputBinType *output,
|
||
|
uint8_t *out);
|
||
|
uint32_t tx_serialize_decred_witness(TxStruct *tx, const TxInputType *input,
|
||
|
uint8_t *out);
|
||
![]()
10 years ago
|
|
||
![]()
5 years ago
|
void tx_init(TxStruct *tx, uint32_t inputs_len, uint32_t outputs_len,
|
||
|
uint32_t version, uint32_t lock_time, uint32_t expiry,
|
||
|
uint32_t extra_data_len, HasherType hasher_sign, bool overwintered,
|
||
|
uint32_t version_group_id);
|
||
![]()
8 years ago
|
uint32_t tx_serialize_header_hash(TxStruct *tx);
|
||
![]()
6 years ago
|
uint32_t tx_serialize_input_hash(TxStruct *tx, const TxInputType *input);
|
||
|
uint32_t tx_serialize_output_hash(TxStruct *tx, const TxOutputBinType *output);
|
||
![]()
5 years ago
|
uint32_t tx_serialize_extra_data_hash(TxStruct *tx, const uint8_t *data,
|
||
|
uint32_t datalen);
|
||
|
uint32_t tx_serialize_decred_witness_hash(TxStruct *tx,
|
||
|
const TxInputType *input);
|
||
![]()
10 years ago
|
void tx_hash_final(TxStruct *t, uint8_t *hash, bool reverse);
|
||
|
|
||
![]()
6 years ago
|
uint32_t tx_input_weight(const CoinInfo *coin, const TxInputType *txinput);
|
||
|
uint32_t tx_output_weight(const CoinInfo *coin, const TxOutputType *txoutput);
|
||
|
uint32_t tx_decred_witness_weight(const TxInputType *txinput);
|
||
![]()
10 years ago
|
|
||
|
#endif
|