mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-23 20:35:02 +02:00
kernel: Add API function for getting a tx's nLockTime
This commit is contained in:
@@ -533,6 +533,11 @@ const btck_TransactionInput* btck_transaction_get_input_at(const btck_Transactio
|
||||
return btck_TransactionInput::ref(&btck_Transaction::get(transaction)->vin[input_index]);
|
||||
}
|
||||
|
||||
uint32_t btck_transaction_get_locktime(const btck_Transaction* transaction)
|
||||
{
|
||||
return btck_Transaction::get(transaction)->nLockTime;
|
||||
}
|
||||
|
||||
const btck_Txid* btck_transaction_get_txid(const btck_Transaction* transaction)
|
||||
{
|
||||
return btck_Txid::ref(&btck_Transaction::get(transaction)->GetHash());
|
||||
|
||||
@@ -576,6 +576,15 @@ BITCOINKERNEL_API const btck_TransactionInput* BITCOINKERNEL_WARN_UNUSED_RESULT
|
||||
BITCOINKERNEL_API size_t BITCOINKERNEL_WARN_UNUSED_RESULT btck_transaction_count_inputs(
|
||||
const btck_Transaction* transaction) BITCOINKERNEL_ARG_NONNULL(1);
|
||||
|
||||
/**
|
||||
* @brief Get a transaction's nLockTime value.
|
||||
*
|
||||
* @param[in] transaction Non-null.
|
||||
* @return The nLockTime value.
|
||||
*/
|
||||
BITCOINKERNEL_API uint32_t BITCOINKERNEL_WARN_UNUSED_RESULT btck_transaction_get_locktime(
|
||||
const btck_Transaction* transaction) BITCOINKERNEL_ARG_NONNULL(1);
|
||||
|
||||
/**
|
||||
* @brief Get the txid of a transaction. The returned txid is not owned and
|
||||
* depends on the lifetime of the transaction.
|
||||
|
||||
@@ -596,6 +596,11 @@ public:
|
||||
return TransactionInputView{btck_transaction_get_input_at(impl(), index)};
|
||||
}
|
||||
|
||||
uint32_t GetLocktime() const
|
||||
{
|
||||
return btck_transaction_get_locktime(impl());
|
||||
}
|
||||
|
||||
TxidView Txid() const
|
||||
{
|
||||
return TxidView{btck_transaction_get_txid(impl())};
|
||||
|
||||
@@ -401,6 +401,7 @@ BOOST_AUTO_TEST_CASE(btck_transaction_tests)
|
||||
|
||||
BOOST_CHECK_EQUAL(tx.CountOutputs(), 2);
|
||||
BOOST_CHECK_EQUAL(tx.CountInputs(), 1);
|
||||
BOOST_CHECK_EQUAL(tx.GetLocktime(), 510826);
|
||||
auto broken_tx_data{std::span<std::byte>{tx_data.begin(), tx_data.begin() + 10}};
|
||||
BOOST_CHECK_THROW(Transaction{broken_tx_data}, std::runtime_error);
|
||||
auto output{tx.GetOutput(tx.CountOutputs() - 1)};
|
||||
|
||||
Reference in New Issue
Block a user