Skip to content

Commit 76b0afd

Browse files
Squashed 'libbitcoinkernel-sys/bitcoin/' changes from 53258393b2b6..deb632faf686
deb632faf686 change install directory for kernel 0b72a1b3471c kernel/blockreader REVERT: 53258393b2b6 change install directory for kernel REVERT: ee2e1fa622e0 kernel/blockreader git-subtree-dir: libbitcoinkernel-sys/bitcoin git-subtree-split: deb632faf686660240e48535dcb216d470071445
1 parent f15a541 commit 76b0afd

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

src/kernel/bitcoinkernel.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ typedef struct kernel_TransactionOutput kernel_TransactionOutput;
129129

130130
typedef struct kernel_TransactionInput kernel_TransactionInput;
131131

132+
/**
133+
* Opaque data structure for holding a transaction outpoint.
134+
*/
135+
136+
typedef struct kernel_TransactionOutPoint kernel_TransactionOutPoint;
132137

133138
/**
134139
* Opaque data structure for holding a logging connection.

src/kernel/blockreader/blockreader.cpp

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ const CTransaction* cast_const_transaction(const kernel_Transaction* transaction
5454
return reinterpret_cast<const CTransaction*>(transaction);
5555
}
5656

57+
const CTxIn* cast_const_transaction_input(const kernel_TransactionInput* input)
58+
{
59+
return reinterpret_cast<const CTxIn*>(input);
60+
}
61+
62+
const COutPoint* cast_const_transaction_out_point(const kernel_TransactionOutPoint* out_point)
63+
{
64+
return reinterpret_cast<const COutPoint*>(out_point);
65+
}
66+
5767
kernel_blockreader_IBDStatus cast_ibd_status(IBDStatus status)
5868
{
5969
switch (status) {
@@ -399,7 +409,7 @@ const kernel_Transaction* kernel_block_pointer_get_transaction(const kernel_Bloc
399409
return reinterpret_cast<const kernel_Transaction*>(block->vtx[index].get());
400410
}
401411

402-
uint32_t kernel_transaction_get_transaction_input_count(const kernel_Transaction * _transaction)
412+
uint32_t kernel_transaction_get_transaction_input_count(const kernel_Transaction* _transaction)
403413
{
404414
const auto* transaction = cast_const_transaction(_transaction);
405415
return transaction->vin.size();
@@ -414,4 +424,28 @@ const kernel_TransactionInput* kernel_transaction_get_transaction_input(const ke
414424
return reinterpret_cast<const kernel_TransactionInput*>(&transaction->vin[index]);
415425
}
416426

427+
const kernel_TransactionOutPoint* kernel_transaction_input_get_out_point(const kernel_TransactionInput* _input)
428+
{
429+
const auto* input = cast_const_transaction_input(_input);
430+
return reinterpret_cast<const kernel_TransactionOutPoint*>(&input->prevout);
431+
}
432+
433+
const kernel_BlockHash* kernel_transaction_out_point_get_hash(const kernel_TransactionOutPoint* _out_point)
434+
{
435+
const auto* out_point = cast_const_transaction_out_point(_out_point);
436+
437+
auto* block_hash = new kernel_BlockHash{};
438+
std::memcpy(block_hash->hash, out_point->hash.begin(), sizeof(block_hash));
439+
440+
return block_hash;
441+
}
442+
443+
uint32_t kernel_transaction_out_point_get_index(const kernel_TransactionOutPoint* _out_point)
444+
{
445+
const auto* input = cast_const_transaction_out_point(_out_point);
446+
447+
return input->n;
448+
}
449+
450+
417451
} // extern "C"

src/kernel/blockreader/blockreader.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ BITCOINKERNEL_API uint32_t BITCOINKERNEL_WARN_UNUSED_RESULT kernel_transaction_g
113113

114114
BITCOINKERNEL_API const kernel_TransactionInput* BITCOINKERNEL_WARN_UNUSED_RESULT kernel_transaction_get_transaction_input(const kernel_Transaction*, size_t index) BITCOINKERNEL_ARG_NONNULL(1);
115115

116+
BITCOINKERNEL_API const kernel_TransactionOutPoint* BITCOINKERNEL_WARN_UNUSED_RESULT kernel_transaction_input_get_out_point(const kernel_TransactionInput* input) BITCOINKERNEL_ARG_NONNULL(1);
117+
118+
BITCOINKERNEL_API const kernel_BlockHash* BITCOINKERNEL_WARN_UNUSED_RESULT kernel_transaction_out_point_get_hash(const kernel_TransactionOutPoint* out_point) BITCOINKERNEL_ARG_NONNULL(1);
119+
120+
BITCOINKERNEL_API uint32_t BITCOINKERNEL_WARN_UNUSED_RESULT kernel_transaction_outpoint_get_index(const kernel_TransactionOutPoint*)
121+
116122
#ifdef __cplusplus
117123
}
118124
#endif

0 commit comments

Comments
 (0)