@@ -249,6 +249,22 @@ typedef struct btck_Coin btck_Coin;
249249 */
250250typedef struct btck_BlockHash btck_BlockHash;
251251
252+ /* *
253+ * Opaque data structure for holding a transaction input.
254+ *
255+ * Holds information on the @ref btck_TransactionOutPoint held within.
256+ */
257+ typedef struct btck_TransactionInput btck_TransactionInput;
258+
259+ /* *
260+ * Opaque data structure for holding a transaction out point.
261+ *
262+ * Holds the txid and output index it is pointing to.
263+ */
264+ typedef struct btck_TransactionOutPoint btck_TransactionOutPoint;
265+
266+ typedef struct btck_Txid btck_Txid;
267+
252268/* * Current sync state passed to tip changed callbacks. */
253269typedef uint8_t btck_SynchronizationState;
254270#define btck_SynchronizationState_INIT_REINDEX ((btck_SynchronizationState)(0 ))
@@ -498,6 +514,18 @@ BITCOINKERNEL_API size_t BITCOINKERNEL_WARN_UNUSED_RESULT btck_transaction_count
498514BITCOINKERNEL_API const btck_TransactionOutput* BITCOINKERNEL_WARN_UNUSED_RESULT btck_transaction_get_output_at (
499515 const btck_Transaction* transaction, size_t output_index) BITCOINKERNEL_ARG_NONNULL(1 );
500516
517+ /* *
518+ * @brief Get the transaction input at the provided index. The returned
519+ * transaction input is not owned and depends on the lifetime of the
520+ * transaction.
521+ *
522+ * @param[in] transaction Non-null.
523+ * @param[in] input_index The index of the transaction input to be retrieved.
524+ * @return The transaction input
525+ */
526+ BITCOINKERNEL_API const btck_TransactionInput* BITCOINKERNEL_WARN_UNUSED_RESULT btck_transaction_get_input_at (
527+ const btck_Transaction* transaction, size_t input_index) BITCOINKERNEL_ARG_NONNULL(1 );
528+
501529/* *
502530 * @brief Get the number of inputs of a transaction.
503531 *
@@ -507,6 +535,16 @@ BITCOINKERNEL_API const btck_TransactionOutput* BITCOINKERNEL_WARN_UNUSED_RESULT
507535BITCOINKERNEL_API size_t BITCOINKERNEL_WARN_UNUSED_RESULT btck_transaction_count_inputs (
508536 const btck_Transaction* transaction) BITCOINKERNEL_ARG_NONNULL(1 );
509537
538+ /* *
539+ * @brief Get the txid of a transaction. The returned txid is not owned and
540+ * depends on the lifetime of the transaction.
541+ *
542+ * @param[in] transaction Non-null.
543+ * @return The txid.
544+ */
545+ BITCOINKERNEL_API const btck_Txid* BITCOINKERNEL_WARN_UNUSED_RESULT btck_transaction_get_txid (
546+ const btck_Transaction* transaction) BITCOINKERNEL_ARG_NONNULL(1 );
547+
510548/* *
511549 * Destroy the transaction.
512550 */
@@ -1313,6 +1351,119 @@ BITCOINKERNEL_API void btck_transaction_spent_outputs_destroy(btck_TransactionSp
13131351
13141352// /@}
13151353
1354+ /* * @name Transaction Input
1355+ * Functions for working with transaction inputs.
1356+ */
1357+ // /@{
1358+
1359+ /* *
1360+ * @brief Copy a transaction input.
1361+ *
1362+ * @param[in] transaction_input Non-null.
1363+ * @return The copied transaction input.
1364+ */
1365+ BITCOINKERNEL_API btck_TransactionInput* BITCOINKERNEL_WARN_UNUSED_RESULT btck_transaction_input_copy (
1366+ const btck_TransactionInput* transaction_input) BITCOINKERNEL_ARG_NONNULL(1 );
1367+
1368+ /* *
1369+ * @brief Get the transaction out point. The returned transaction out point is
1370+ * not owned and depends on the lifetime of the transaction.
1371+ *
1372+ * @param[in] transaction_input Non-null.
1373+ * @return The transaction out point.
1374+ */
1375+ BITCOINKERNEL_API const btck_TransactionOutPoint* BITCOINKERNEL_WARN_UNUSED_RESULT btck_transaction_input_get_out_point (
1376+ const btck_TransactionInput* transaction_input) BITCOINKERNEL_ARG_NONNULL(1 );
1377+
1378+ /* *
1379+ * Destroy the transaction input.
1380+ */
1381+ BITCOINKERNEL_API void btck_transaction_input_destroy (btck_TransactionInput* transaction_input);
1382+
1383+ // /@}
1384+
1385+ /* * @name Transaction Out Point
1386+ * Functions for working with transaction out points.
1387+ */
1388+ // /@{
1389+
1390+ /* *
1391+ * @brief Copy a transaction out point.
1392+ *
1393+ * @param[in] transaction_out_point Non-null.
1394+ * @return The copied transaction out point.
1395+ */
1396+ BITCOINKERNEL_API btck_TransactionOutPoint* BITCOINKERNEL_WARN_UNUSED_RESULT btck_transaction_out_point_copy (
1397+ const btck_TransactionOutPoint* transaction_out_point) BITCOINKERNEL_ARG_NONNULL(1 );
1398+
1399+ /* *
1400+ * @brief Get the output position from the transaction out point.
1401+ *
1402+ * @param[in] transaction_out_point Non-null.
1403+ * @return The output index.
1404+ */
1405+ BITCOINKERNEL_API uint32_t BITCOINKERNEL_WARN_UNUSED_RESULT btck_transaction_out_point_get_index (
1406+ const btck_TransactionOutPoint* transaction_out_point) BITCOINKERNEL_ARG_NONNULL(1 );
1407+
1408+ /* *
1409+ * @brief Get the txid from the transaction out point. The returned txid is
1410+ * not owned and depends on the lifetime of the transaction out point.
1411+ *
1412+ * @param[in] transaction_out_point Non-null.
1413+ * @return The txid.
1414+ */
1415+ BITCOINKERNEL_API const btck_Txid* BITCOINKERNEL_WARN_UNUSED_RESULT btck_transaction_out_point_get_txid (
1416+ const btck_TransactionOutPoint* transaction_out_point) BITCOINKERNEL_ARG_NONNULL(1 );
1417+
1418+ /* *
1419+ * Destroy the transaction out point.
1420+ */
1421+ BITCOINKERNEL_API void btck_transaction_out_point_destroy (btck_TransactionOutPoint* transaction_out_point);
1422+
1423+ // /@}
1424+
1425+ /* * @name Txid
1426+ * Functions for working with txids.
1427+ */
1428+ // /@{
1429+
1430+ /* *
1431+ * @brief Copy a txid.
1432+ *
1433+ * @param[in] txid Non-null.
1434+ * @return The copied txid.
1435+ */
1436+ BITCOINKERNEL_API btck_Txid* BITCOINKERNEL_WARN_UNUSED_RESULT btck_txid_copy (
1437+ const btck_Txid* txid) BITCOINKERNEL_ARG_NONNULL(1 );
1438+
1439+ /* *
1440+ * @brief Check if two txids are equal.
1441+ *
1442+ * @param[in] txid1 Non-null.
1443+ * @param[in] txid2 Non-null.
1444+ * @return 0 if the txid is not equal.
1445+ */
1446+ BITCOINKERNEL_API int BITCOINKERNEL_WARN_UNUSED_RESULT btck_txid_equals (
1447+ const btck_Txid* txid1, const btck_Txid* txid2) BITCOINKERNEL_ARG_NONNULL(1 , 2 );
1448+
1449+ /* *
1450+ * @brief Serializes the txid to bytes.
1451+ *
1452+ * @param[in] txid Non-null.
1453+ * @param[out] output The serialized txid.
1454+ */
1455+ BITCOINKERNEL_API void btck_txid_to_bytes (
1456+ const btck_Txid* txid, unsigned char output[32 ]) BITCOINKERNEL_ARG_NONNULL(1 , 2 );
1457+
1458+ /* *
1459+ * Destroy the txid.
1460+ */
1461+ BITCOINKERNEL_API void btck_txid_destroy (btck_Txid* txid);
1462+
1463+ // /@}
1464+
1465+ // /@}
1466+
13161467/* * @name Coin
13171468 * Functions for working with coins.
13181469 */
@@ -1328,7 +1479,8 @@ BITCOINKERNEL_API btck_Coin* BITCOINKERNEL_WARN_UNUSED_RESULT btck_coin_copy(
13281479 const btck_Coin* coin) BITCOINKERNEL_ARG_NONNULL(1 );
13291480
13301481/* *
1331- * @brief Returns the height of the block that contains the coin's prevout.
1482+ * @brief Returns the block height where the transaction that
1483+ * created this coin was included in.
13321484 *
13331485 * @param[in] coin Non-null.
13341486 * @return The block height of the coin.
0 commit comments