mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 23:29:12 +01:00
kernel: Add function for copying block data to C header
This adds a function for streaming bytes into a user-owned data structure. Use it in the tests for verifying the implementation of the validation interface's `BlockChecked` method.
This commit is contained in:
@@ -967,6 +967,17 @@ const btck_Transaction* btck_block_get_transaction_at(const btck_Block* block, s
|
||||
return btck_Transaction::ref(&btck_Block::get(block)->vtx[index]);
|
||||
}
|
||||
|
||||
int btck_block_to_bytes(const btck_Block* block, btck_WriteBytes writer, void* user_data)
|
||||
{
|
||||
try {
|
||||
WriterStream ws{writer, user_data};
|
||||
ws << TX_WITH_WITNESS(*btck_Block::get(block));
|
||||
return 0;
|
||||
} catch (...) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
void btck_block_destroy(btck_Block* block)
|
||||
{
|
||||
delete block;
|
||||
|
||||
Reference in New Issue
Block a user