Skip to content

Commit f15a541

Browse files
Squashed 'libbitcoinkernel-sys/bitcoin/' changes from b04e178cd3ca..53258393b2b6
53258393b2b6 change install directory for kernel ee2e1fa622e0 kernel/blockreader REVERT: b04e178cd3ca change install directory for kernel REVERT: 36bba0408321 kernel/blockreader git-subtree-dir: libbitcoinkernel-sys/bitcoin git-subtree-split: 53258393b2b69188dcfdaa32dc610cbb5ed22187
1 parent 1cefdda commit f15a541

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

src/kernel/bitcoinkernel.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ typedef struct kernel_ScriptPubkey kernel_ScriptPubkey;
123123
*/
124124
typedef struct kernel_TransactionOutput kernel_TransactionOutput;
125125

126+
/**
127+
* Opaque data structure for holding a transaction input.
128+
*/
129+
130+
typedef struct kernel_TransactionInput kernel_TransactionInput;
131+
132+
126133
/**
127134
* Opaque data structure for holding a logging connection.
128135
*

src/kernel/blockreader/blockreader.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ const CBlock* cast_const_block_pointer(const kernel_BlockPointer* block_pointer)
4949
return reinterpret_cast<const CBlock*>(block_pointer);
5050
}
5151

52+
const CTransaction* cast_const_transaction(const kernel_Transaction* transaction)
53+
{
54+
return reinterpret_cast<const CTransaction*>(transaction);
55+
}
56+
5257
kernel_blockreader_IBDStatus cast_ibd_status(IBDStatus status)
5358
{
5459
switch (status) {
@@ -394,5 +399,19 @@ const kernel_Transaction* kernel_block_pointer_get_transaction(const kernel_Bloc
394399
return reinterpret_cast<const kernel_Transaction*>(block->vtx[index].get());
395400
}
396401

402+
uint32_t kernel_transaction_get_transaction_input_count(const kernel_Transaction * _transaction)
403+
{
404+
const auto* transaction = cast_const_transaction(_transaction);
405+
return transaction->vin.size();
406+
}
407+
408+
const kernel_TransactionInput* kernel_transaction_get_transaction_input(const kernel_Transaction* _transaction, size_t index)
409+
{
410+
const auto* transaction = cast_const_transaction(_transaction);
411+
if (index >= transaction->vin.size()) {
412+
return nullptr;
413+
}
414+
return reinterpret_cast<const kernel_TransactionInput*>(&transaction->vin[index]);
415+
}
397416

398417
} // extern "C"

src/kernel/blockreader/blockreader.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,11 @@ BITCOINKERNEL_API kernel_BlockPointer* BITCOINKERNEL_WARN_UNUSED_RESULT kernel_b
107107

108108
BITCOINKERNEL_API uint32_t BITCOINKERNEL_WARN_UNUSED_RESULT kernel_block_pointer_get_transaction_count(const kernel_BlockPointer* block_pointer) BITCOINKERNEL_ARG_NONNULL(1);
109109

110-
BITCOINKERNEL_API kernel_Transaction* BITCOINKERNEL_WARN_UNUSED_RESULT kernel_block_pointer_get_transaction(const kernel_BlockPointer* block_pointer, size_t index) BITCOINKERNEL_ARG_NONNULL(1);
110+
BITCOINKERNEL_API const kernel_Transaction* BITCOINKERNEL_WARN_UNUSED_RESULT kernel_block_pointer_get_transaction(const kernel_BlockPointer* block_pointer, size_t index) BITCOINKERNEL_ARG_NONNULL(1);
111+
112+
BITCOINKERNEL_API uint32_t BITCOINKERNEL_WARN_UNUSED_RESULT kernel_transaction_get_transaction_input_count(const kernel_Transaction* transaction) BITCOINKERNEL_ARG_NONNULL(1);
113+
114+
BITCOINKERNEL_API const kernel_TransactionInput* BITCOINKERNEL_WARN_UNUSED_RESULT kernel_transaction_get_transaction_input(const kernel_Transaction*, size_t index) BITCOINKERNEL_ARG_NONNULL(1);
111115

112116
#ifdef __cplusplus
113117
}

0 commit comments

Comments
 (0)