mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-30 07:43:48 +02:00
kernel: Add API function for getting a tx input's nSequence
This commit is contained in:
@@ -697,6 +697,11 @@ const btck_TransactionOutPoint* btck_transaction_input_get_out_point(const btck_
|
||||
return btck_TransactionOutPoint::ref(&btck_TransactionInput::get(input).prevout);
|
||||
}
|
||||
|
||||
uint32_t btck_transaction_input_get_sequence(const btck_TransactionInput* input)
|
||||
{
|
||||
return btck_TransactionInput::get(input).nSequence;
|
||||
}
|
||||
|
||||
void btck_transaction_input_destroy(btck_TransactionInput* input)
|
||||
{
|
||||
delete input;
|
||||
|
||||
@@ -1514,6 +1514,15 @@ BITCOINKERNEL_API btck_TransactionInput* BITCOINKERNEL_WARN_UNUSED_RESULT btck_t
|
||||
BITCOINKERNEL_API const btck_TransactionOutPoint* BITCOINKERNEL_WARN_UNUSED_RESULT btck_transaction_input_get_out_point(
|
||||
const btck_TransactionInput* transaction_input) BITCOINKERNEL_ARG_NONNULL(1);
|
||||
|
||||
/**
|
||||
* @brief Get a transaction input's nSequence value.
|
||||
*
|
||||
* @param[in] transaction_input Non-null.
|
||||
* @return The nSequence value.
|
||||
*/
|
||||
BITCOINKERNEL_API uint32_t BITCOINKERNEL_WARN_UNUSED_RESULT btck_transaction_input_get_sequence(
|
||||
const btck_TransactionInput* transaction_input) BITCOINKERNEL_ARG_NONNULL(1);
|
||||
|
||||
/**
|
||||
* Destroy the transaction input.
|
||||
*/
|
||||
|
||||
@@ -551,6 +551,11 @@ public:
|
||||
{
|
||||
return OutPointView{btck_transaction_input_get_out_point(impl())};
|
||||
}
|
||||
|
||||
uint32_t GetSequence() const
|
||||
{
|
||||
return btck_transaction_input_get_sequence(impl());
|
||||
}
|
||||
};
|
||||
|
||||
class TransactionInputView : public View<btck_TransactionInput>, public TransactionInputApi<TransactionInputView>
|
||||
|
||||
@@ -404,6 +404,8 @@ BOOST_AUTO_TEST_CASE(btck_transaction_tests)
|
||||
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 input{tx.GetInput(0)};
|
||||
BOOST_CHECK_EQUAL(input.GetSequence(), 0xfffffffe);
|
||||
auto output{tx.GetOutput(tx.CountOutputs() - 1)};
|
||||
BOOST_CHECK_EQUAL(output.Amount(), 42130042);
|
||||
auto script_pubkey{output.GetScriptPubkey()};
|
||||
|
||||
Reference in New Issue
Block a user