Repository navigation
kernel: expose witness stack and scriptSig for btck_TransactionInput - #35380
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35380. ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste |
|
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
There was a problem hiding this comment.
Concept ACK, seems useful to expose.
Small motivation nit:
Without access to it, kernel API callers cannot extract the sender key from these input types which is a requirement for silent payments scanning.
Callers can, but they have to parse the entire transaction, so exposing these functions obviously makes that easier and less error-prone.
| * @param[in] transaction_input Non-null. | ||
| * @return The number of witness stack items. | ||
| */ | ||
| BITCOINKERNEL_API size_t btck_transaction_input_get_witness_stack_num_items( |
There was a problem hiding this comment.
nit: we use _count for similar functions, so would stay consistent with btck_transaction_input_count_witness_stack_items
There was a problem hiding this comment.
Done. Updated in 34897f3
| Transaction segwit_tx{hex_string_to_byte_vec("010000000001011f97548fbbe7a0db7588a66e18d803d0089315aa7d4cc28360b6ec50ef36718a0100000000ffffffff02df1776000000000017a9146c002a686959067f4866b8fb493ad7970290ab728757d29f0000000000220020701a8d401c84fb13e6baf169d59684e17abd9fa216c8cc5b9fc63d622ff8c58d04004730440220565d170eed95ff95027a69b313758450ba84a01224e1f7f130dda46e94d13f8602207bdd20e307f062594022f12ed5017bbf4a055a06aea91c10110a0e3bb23117fc014730440220647d2dc5b15f60bc37dc42618a370b2a1490293f9e5c8464f53ec4fe1dfe067302203598773895b4b16d37485cbe21b337f4e4b650739880098c592553add7dd4355016952210375e00eb72e29da82b89367947f29ef34afb75e8654f6ea368e0acdfd92976b7c2103a1b26313f430c4b15bb1fdce663207659d8cac749a0e53d70eff01874496feff2103c96d495bfdd5ba4145e3e046fee45e84a8a48ad05bd8dbb395c011a32cf9f88053ae00000000")}; | ||
| TransactionInputView segwit_input = segwit_tx.GetInput(0); | ||
| BOOST_CHECK_EQUAL(segwit_input.GetWitnessStackNumItems(), 4); | ||
| BOOST_CHECK_EQUAL(segwit_input.GetWitnessStackItem(0).size(), 0); |
There was a problem hiding this comment.
Would be better to test full equality rather than just the size
There was a problem hiding this comment.
Updated the tests in 34897f3
| * @param[in] index Index of the witness stack item. | ||
| * @param[in] writer Non-null, function pointer for writing bytes. | ||
| * @param[in] user_data Nullable, passed back through the writer callback. | ||
| * @return 0 on success, -1 if the index is out of bounds. |
There was a problem hiding this comment.
Depending on the writer impl, -1 can also indicate that writing failed. As a general pattern, I wonder if it makes sense to wholesale return the writer error code. Alternatively we could catch the writer error code, log it, and then returning a pre-defined writer error code, so we get e.g. 0 on success, -1 on out of bounds, and -2 on write failure?
f09656e to
f196825
Compare
Updated the title and description to clarify motivation and reflect both commits. |
|
Concept ACK |
|
Concept ACK |
| return btck_transaction_input_count_witness_stack_items(impl()); | ||
| } | ||
|
|
||
| std::vector<std::byte> GetWitnessStackItem(size_t index) const |
There was a problem hiding this comment.
I think this could crash the program when an invalid index is passed?
test
BOOST_CHECK_THROW(segwit_input.GetWitnessStackItem(4), std::out_of_range);output Log
unknown location:0: fatal error: in "btck_transaction_input": signal: SIGABRT (application abort requested)
I think the cause might be here at L318 - L320:
L318 - L320
if (to_bytes(object, write, &user_data) != 0) {
std::rethrow_exception(user_data.exception);
}When passing an index out of bounds, the C API returns -1, and the user_data.exception remains nullptr. Passing nullptr to std::rethrow_exception results in undefined behaviour (UB). Probably add a bounds check here?
diff
if (to_bytes(object, write, &user_data) != 0) {
if (user_data.exception) std::rethrow_exception(user_data.exception);
throw std::runtime_error("Kernel API call failed");
}f196825 to
a398cd8
Compare
|
Double checking myself. Looking at src/validation.cpp:3869-L3871 And src/core_io.cpp:463-464 I don't think valid usage would ever reach an unverified index given the count function is available, so |
sedited
left a comment
There was a problem hiding this comment.
I would drop the description in the commit message of what the witness data is needed for. There are many use cases for this, and I don't think enumerating them is useful.
| @@ -8,6 +8,7 @@ | |||
| #include <kernel/bitcoinkernel.h> | |||
|
|
|||
| #include <array> | |||
| #include <cassert> | |||
There was a problem hiding this comment.
I think this include must be from a prior revision. Can you remove it?
| @@ -586,6 +587,27 @@ class TransactionInputApi | |||
| { | |||
| return btck_transaction_input_get_sequence(impl()); | |||
| } | |||
|
|
|||
| size_t GetWitnessStackNumItems() const | |||
There was a problem hiding this comment.
I think this should be called CountWitnessStackItems.
a398cd8 to
46a4654
Compare
|
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
7af5abc to
269e39b
Compare
sedited
left a comment
There was a problem hiding this comment.
ACK 269e39b2dc41f99f6184120f648f5ab3c1c93b7d
musaHaruna
left a comment
There was a problem hiding this comment.
Concept ACK
I don't think valid usage would ever reach an unverified index given the count function is available, so assert feels more appropriate here?
Looking at the code through the lenses of a newbie, While assert(index < stack.size()); prevents Undefined Behavior by stopping execution immediately, and usage (like in validation.cpp or core_io.cpp) safely guards indices, I don't think it's ideal for the shared library, because the endpoint is consumed by external runtimes and language bindings (Go, Rust, JS) via FFI, we cannot guarantee valid usage from the caller.
More importantly, in production Release builds where NDEBUG is defined, this assert will be completely stripped out. If an external caller does pass an invalid index by mistake, it will lead to undefined behavior or a segmentation fault via stack[index].
Would it make sense to perform a runtime bounds check instead?
int btck_transaction_input_get_witness_stack_item(const btck_TransactionInput* input, size_t index, btck_WriteBytes writer, void* user_data)
{
const std::vector<std::vector<unsigned char>>& stack{btck_TransactionInput::get(input).scriptWitness.stack};
if (index >= stack.size()) {
return -1;
}
return writer(stack[index].data(), stack[index].size(), user_data);
}Then the C++ wrapper utility (write_bytes) could handle non-exception failures, as suggested by @yuvicc:
if (to_bytes(object, write, &user_data) != 0) {
if (user_data.exception) std::rethrow_exception(user_data.exception);
throw std::runtime_error("Kernel API call failed");
}That would also allow the proposed unit test to pass:
BOOST_CHECK_THROW(segwit_input.GetWitnessStackItem(4), std::out_of_range);| @@ -320,6 +320,36 @@ std::vector<std::byte> write_bytes(const T* object, int (*to_bytes)(const T*, bt | |||
| return bytes; | |||
| } | |||
|
|
|||
| template <typename T> | |||
| std::vector<std::byte> write_bytes(const T* object, size_t index, int (*to_bytes)(const T*, size_t, btck_WriteBytes, void*)) | |||
There was a problem hiding this comment.
In your previous approach (c6d532414406cff5d31819e10adbf04042a65746) you, just used a Ctx wrapper. Any reason you changed it to this overload? I thought the wrapper was quite elegant? The new approach is a lot of unnecessary duplication.
(nit: if you update, Item seems like a more helpful name than Ctx.)
git diff on fa221030ac
diff --git a/src/kernel/bitcoinkernel_wrapper.h b/src/kernel/bitcoinkernel_wrapper.h
index d6b06d3c13..3bfd4a48ac 100644
--- a/src/kernel/bitcoinkernel_wrapper.h
+++ b/src/kernel/bitcoinkernel_wrapper.h
@@ -320,36 +320,6 @@ std::vector<std::byte> write_bytes(const T* object, int (*to_bytes)(const T*, bt
return bytes;
}
-template <typename T>
-std::vector<std::byte> write_bytes(const T* object, size_t index, int (*to_bytes)(const T*, size_t, btck_WriteBytes, void*))
-{
- std::vector<std::byte> bytes;
- struct UserData {
- std::vector<std::byte>* bytes;
- std::exception_ptr exception;
- };
- UserData user_data = UserData{.bytes = &bytes, .exception = nullptr};
-
- constexpr auto const write = +[](const void* buffer, size_t len, void* user_data) -> int {
- auto& data = *reinterpret_cast<UserData*>(user_data);
- auto& bytes = *data.bytes;
- try {
- auto const* first = static_cast<const std::byte*>(buffer);
- auto const* last = first + len;
- bytes.insert(bytes.end(), first, last);
- return 0;
- } catch (...) {
- data.exception = std::current_exception();
- return -1;
- }
- };
-
- if (to_bytes(object, index, write, &user_data) != 0) {
- std::rethrow_exception(user_data.exception);
- }
- return bytes;
-}
-
template <typename CType>
class View
{
@@ -614,7 +584,11 @@ public:
std::vector<std::byte> Item(size_t index) const
{
- return write_bytes(impl(), index, btck_witness_stack_get_item);
+ struct Item { const btck_WitnessStack* stack; size_t index; };
+ Item ctx{impl(), index};
+ return write_bytes(&ctx, +[](const Item* item, btck_WriteBytes w, void* ud) {
+ return btck_witness_stack_get_item(item->stack, item->index, w, ud);
+ });
}
MAKE_RANGE_METHOD(Items, Derived, &WitnessStackApi<Derived>::Count, &WitnessStackApi<Derived>::Item, *static_cast<const Derived*>(this))
There was a problem hiding this comment.
Thanks! I was considering consistency with the other write_bytes calls but I agree about duplication that the overload creates. Reducing the duplication would require refactoring write_bytes itself, though I felt that would be of scope for this PR. I'll revert to the Ctx wrapper.
| return btck_witness_stack_count(impl()); | ||
| } | ||
|
|
||
| std::vector<std::byte> Item(size_t index) const |
There was a problem hiding this comment.
nit: quite a few naming inconsistencies wrt other functions, e.g. typically we prefix getters here with Get. Also btck_witness_stack_get_item_at and btck_witness_stack_count_items.
|
|
||
| int btck_transaction_input_get_script_sig(const btck_TransactionInput* input, btck_WriteBytes writer, void* user_data) | ||
| { | ||
| return writer(btck_TransactionInput::get(input).scriptSig.data(), btck_TransactionInput::get(input).scriptSig.size(), user_data); |
There was a problem hiding this comment.
nit: would create a const auto& script_sig{btck_TransactionInput::get(input).scriptSig}; here
| * @param[in] user_data Nullable, passed back through the writer callback. | ||
| * @return The return value of the writer. Aborts if index is out of bounds. | ||
| */ | ||
| BITCOINKERNEL_API int BITCOINKERNEL_WARN_UNUSED_RESULT btck_transaction_input_get_witness_stack_item( |
There was a problem hiding this comment.
I like the btck_WitnessStack approach.
meta-nit: would suggest to either post a link to an alternative branch if you don't want to update the PR branch yet as you're looking for feedback, or update the PR branch with a properly rebased version, this is kind of the worst of both worlds.
fa22103 to
d6cc918
Compare
|
Concept ACK |
stickies-v
left a comment
There was a problem hiding this comment.
ACK d6cc918c482f16b2caa1e8c56f449136f3aa41f4
meta-nit: people can already see the PR edit history by clicking on the "edited" link. For new reviewers, and our git tree (PR description gets included in the merge commit) just reflecting the current status rather than a full historical record is more straightforward.
| std::vector<std::byte> GetItem(size_t index) const | ||
| { | ||
| struct Item { const btck_WitnessStack* stack; size_t index; }; | ||
| Item ctx{impl(), index}; |
There was a problem hiding this comment.
nit
| Item ctx{impl(), index}; | |
| Item item{impl(), index}; |
| * @param[in] index Index of the item in the witness stack. | ||
| * @param[in] writer Non-null, function pointer for writing bytes. | ||
| * @param[in] user_data Nullable, passed back through the writer callback. | ||
| * @return The return value of the writer. Aborts if index is out of bounds. |
There was a problem hiding this comment.
nit: would be more appropriately documented as a @pre, e.g. @pre index < btck_witness_stack_count_items(witness_stack)
There was a problem hiding this comment.
Done, I agree with the use of @pre though I dropped it from #34885 since it would have been the first use in bitcoinkernel.h and other functions with similar assert-on-OOB behavior don't document it that way. Noting it here in case it's worth aligning across the file.
There was a problem hiding this comment.
nit
| * Holds information on the @ref btck_TransactionOutPoint, @ref btck_WitnessStack and script_sig held within. |
| Transaction segwit_tx{hex_string_to_byte_vec("010000000001011f97548fbbe7a0db7588a66e18d803d0089315aa7d4cc28360b6ec50ef36718a0100000000ffffffff02df1776000000000017a9146c002a686959067f4866b8fb493ad7970290ab728757d29f0000000000220020701a8d401c84fb13e6baf169d59684e17abd9fa216c8cc5b9fc63d622ff8c58d04004730440220565d170eed95ff95027a69b313758450ba84a01224e1f7f130dda46e94d13f8602207bdd20e307f062594022f12ed5017bbf4a055a06aea91c10110a0e3bb23117fc014730440220647d2dc5b15f60bc37dc42618a370b2a1490293f9e5c8464f53ec4fe1dfe067302203598773895b4b16d37485cbe21b337f4e4b650739880098c592553add7dd4355016952210375e00eb72e29da82b89367947f29ef34afb75e8654f6ea368e0acdfd92976b7c2103a1b26313f430c4b15bb1fdce663207659d8cac749a0e53d70eff01874496feff2103c96d495bfdd5ba4145e3e046fee45e84a8a48ad05bd8dbb395c011a32cf9f88053ae00000000")}; | ||
| TransactionInputView segwit_input = segwit_tx.GetInput(0); | ||
| WitnessStackView ws = segwit_input.GetWitnessStack(); | ||
| BOOST_CHECK_EQUAL(ws.CountItems(), 4); |
There was a problem hiding this comment.
Can you add a CheckRange(ws.Items(), ws.CountItems());?
There was a problem hiding this comment.
CheckRange calls .get() on each element and Items() returns std::vector<std::byte>, which has no .get(), so it won't pass CI as is.
There was a problem hiding this comment.
another meta comment: before pushing, always make sure that the code compiles locally for you, and that the unit and functional tests pass
There was a problem hiding this comment.
Noted, sorry about that. My local build and test scripts were configured improperly, and it looked like it was passing locally. Fixed the configuration issue on my end.
d6cc918 to
0277cbb
Compare
Thanks & Done, updated the description to reflect the current state. |
|
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
0277cbb to
6667dc4
Compare
musaHaruna
left a comment
There was a problem hiding this comment.
ACK 6667dc
The new approach of introducing a btck_WitnessStack type looks cleaner than adding more witness-specific functions to btck_TransactionInput. I think this is a more appropriate abstraction for the witness stack.
| * @param[in] writer Non-null, function pointer for writing bytes. | ||
| * @param[in] user_data Nullable, passed back through the writer callback. | ||
| * @return The return value of the writer. | ||
| * @pre index < btck_witness_stack_count_items(witness_stack) |
There was a problem hiding this comment.
Nit: Incase a need to push arises again, this can be aligned
| * @pre index < btck_witness_stack_count_items(witness_stack) | |
| * @pre index < btck_witness_stack_count_items(witness_stack) |
…ig for btck_TransactionInput 2129e97 kernel: expose scriptSig for btck_TransactionInput (Peter Zafonte) 9a7a217 kernel: expose witness stack for btck_TransactionInput (Peter Zafonte) Pull request description: Silent payments scanning needs the public key from every input. For SegWit inputs it is in the witness stack. For P2PKH inputs it is in scriptSig. Without these new functions, callers must deserialize the raw transaction themselves to reach that data, which is difficult and error-prone. Introduces a `btck_WitnessStack` type and adds the following functions: **Witness stack:** `btck_transaction_input_get_witness_stack`: returns a non-owning `const btck_WitnessStack* `view `btck_witness_stack_count_items `: item count `btck_witness_stack_get_item_at `: single item by index via btck_WriteBytes `btck_witness_stack_copy` / `btck_witness_stack_destroy`: lifecycle for owned copies **scriptSig:** `btck_transaction_input_get_script_sig`: full scriptSig via btck_WriteBytes All functions are exposed in the C++ wrapper via `WitnessStackView`, `WitnessStack`, and `WitnessStackApi` , and `GetScriptSig()`. ACKs for top commit: sedited: ACK 2129e97 musaHaruna: ACK [6667dc](bitcoin/bitcoin@2129e97) stickies-v: ACK 2129e97 Tree-SHA512: b5e9d32ec87a5f5a9fea5652ed69737eae1d1f9cfb777544b96d703bbd057c114e0b7afae4e9e9d09b8b546694b14fb923b747c04a8f0211ab6caa015d06967d
…d9ec7f3d4 70d9ec7f3d4 Merge bitcoin/bitcoin#34538: net: advertise -externalip addresses 7bff765d514 Merge bitcoin/bitcoin#35639: external_signer: validate fingerprint from enumerate response 773b1c9aa58 Merge bitcoin/bitcoin#35572: coins: make cursor iteration DB-only 8d9e4f8dbd8 Merge bitcoin/bitcoin#35633: wallet: avoid call bumpfeediscount with negative values c4216e885a6 Merge bitcoin/bitcoin#35723: fuzz: Drop unnecessary mutexes 240d5f743aa fuzz: Drop unnecessary mutexes cf0368fb76e Merge bitcoin/bitcoin#35720: ipc: Update libmultiprocess subtree and drop fuzz test workaround 2d4065d1fe4 Merge bitcoin/bitcoin#35718: ci: Update lint container dependencies 8d9fbf76664 Merge bitcoin/bitcoin#35380: kernel: expose witness stack and scriptSig for btck_TransactionInput fab8eeed82c fuzz: clang-format LIMITED_WHILE fa0d777ce2a fuzz: Clang-format LIMITED_WHILE like while fa1a9bde5a6 fuzz: Remove unused workaround after fix in libmultiprocess byte-span serializer fa55385ab36 fuzz: Use LIMITED_WHILE over for-loop with consumed size integral fa911d815db Merge commit '6d5f753921578eefdd3fce64cfc8ee7951b6cbc4' into HEAD 6d5f7539215 Squashed 'src/ipc/libmultiprocess/' changes from 28e056576a..e8de5c7b68 900a7785bf5 ci: use Ubuntu 26.04 for lint container 058a73a0aea ci: use uv 11.x 14f4ddcb554 ci: mypy 2.3.0 54e1a95a12e Merge bitcoin/bitcoin#35719: ci: disable Qt build in OpenBSD cross job b0e09511586 ci: disable Qt build in OpenBSD cross job 734c34bafda Merge bitcoin/bitcoin#35427: depends: Build `qt` and `qrencode` packages on OpenBSD ee61b11a9e7 Merge bitcoin/bitcoin#35200: node: smooth oversized `dbcache` warnings e3554bf361f Merge bitcoin/bitcoin#35579: wallet: reserve walletrescan before checking wallet is at the tip 11ae4265522 Merge bitcoin/bitcoin#35715: cmake: Fix WITH_EXTERNAL_LIBMULTIPROCESS + BUILD_FUZZ_BINARY e544413c0de Merge bitcoin/bitcoin#32763: wallet: Replace CWalletTx::mapValue and vOrderForm with explicit class members fe1cb6e40d7 Merge bitcoin/bitcoin#35690: wallet: Introduce WalletError with machine-readable error code 441f3114f57 Merge bitcoin/bitcoin#35659: Clarify supported *BSD releases and drop outdated workarounds 0399df827c6 Merge bitcoin/bitcoin#35708: depends: capnp 1.5.0 1ab1fdd4696 Merge bitcoin/bitcoin#35705: bench: replace CreateMockableWalletDatabase with MakeInMemoryWalletDatabase db35b9238fc ipc # build: Fix fuzz target CMakeLists.txt for external libmultiprocess d18fec892e2 Merge bitcoin/bitcoin#35698: doc: Update enum class constant naming style guide a2e4cd7ad2a depends: capnp 1.5.0 7508ac319d9 bench: replace CreateMockableWalletDatabase with MakeInMemoryWalletDatabase 907e284e303 Merge bitcoin/bitcoin#35701: test: Remove `mock_process.cpp` c8459b6bdcd Merge bitcoin/bitcoin#35568: txospenderindex: disable bloom filters to optimize disk usage 63c5f9d22c0 test: Remove `mock_process.cpp` ef101b04a8d Merge bitcoin/bitcoin#35655: wallet: Use in-memory SQLite for temporary wallet in exportwatchonlywallet b6becf3534c Merge bitcoin/bitcoin#35684: Update libmultiprocess subtree to add `max_connections` option 930f25050f7 Merge bitcoin/bitcoin#35700: doc: archive release notes for v29.4 9b2b3f4ec6f doc: archive release notes for v29.4 297fd1489bb Merge bitcoin/bitcoin#35412: ci: add NetBSD Clang cross job e314869066b Merge bitcoin/bitcoin#35695: Remove myself as security contact e3d67a5eae5 Merge bitcoin/bitcoin#35691: chainparams: delete my DNS seed a8223bb4e62 wallet: Introduce WalletError with machine-readable error code fad5809cb92 doc: Update enum class constant naming style guide 7d8137c1417 Merge bitcoin/bitcoin#34897: indexes: Don't commit ahead of the flushed chainstate 629df81e4c6 Remove myself as security contact d164a043426 node: smooth oversized `-dbcache` warnings d9080639804 chainparams: delete my DNS seed e9ed898a0da validation: Don't use m_chain.Tip() in FlushStateToDisk 3679f1ecf5e index: Don't commit ahead of the flushed chainstate 65735728a5a index: Remove return value from Commit() 09c06960c6a validation: track last flushed block 13c02b5466d test: add test for index commits ahead of the last flushed block c43b7a1115f ci: add netBSD cross CI job 699c21aea47 depends: add netbsd_LDFLAGS 777d23f25c7 test: add regression test for in-memory SQLiteDatabase reopen d1e7f8c986f wallet: use in-memory SQLite for temporary wallet in exportwatchonlywallet ee43743f126 wallet: store m_additional_flags in SQLiteDatabase to fix reopen path a9d1b652f32 Merge commit '707d0ded84563386f770ec17970834c65f8fa938' into pr/subtree-12 707d0ded845 Squashed 'src/ipc/libmultiprocess/' changes from 16bf05dea02..28e056576a3 6667dc4eec7 kernel: expose scriptSig for btck_TransactionInput e6de3a2d3c7 kernel: expose witness stack for btck_TransactionInput 3ae3a94f2bd wallet: avoid call bumpfeediscount with negative values dab7f2c984b test: cover -externalip/onlynet interaction in functional test 657a5aa3f3d test: cover -externalip bypassing -onlynet 8c87e32bd39 net: let -externalip bypass -onlynet f4af02e827b net: add an add_even_if_unreachable argument to AddLocal 2bab6bc73f2 refactor: Drop support for FreeBSD < 14 91b5c8a07c6 refactor: Remove FreeBSD-specific workaround 56701ff6d5c doc: Clarify supported *BSD releases 6d0ea4cf5bd doc: add release notes a2b1c86903a txospenderindex: disable bloom filters to optimize disk usage 4c9de7d5b32 external_signer: validate fingerprint from enumerate response fed3cf6f0ed wallet: Replace CWalletTx's vOrderForm with specific fields 4f8823e8e11 wallet: Drop vOrderForm from CommitTransaction 9e62e4b1f34 test: slow down rescaning process a2b0bfcd854 wallet: Drop mapValue from CWalletTx cb99864c91c wallet: Throw if unknown entry is found in mapValue 98d5cdae663 wallet: Make CWalletTx "replaces_txid" and "replaced_by_txid" member variables 7ef8a6efc2a wallet: Make CWalletTx "comment" and "to" member variables 2155e913d3e wallet: Make CWalletTx "from" and "message" member variables c6ba98dcc8a wallet: Drop mapValue from CommitTransaction 00abb174a80 wallet: Pass comment and comment_to to CommitTransaction 1a219a37a21 wallet: Pass replaces_txid to CommitTransaction outside of mapValue 72db4accbf5 coins: drop stale cursor null checks 3d2f2d8de09 coins: pass UTXO stats view by reference 35aedb28236 coins: drop cursor from base view c6fbe2f66cf coins: pass DB view to cursor users 336f5a738b3 wallet: reserve walletrescan before checking wallet is at the tip a54ec373a69 depends: Build `qt` and `qrencode` packages for OpenBSD hosts git-subtree-dir: libbitcoinkernel-sys/bitcoin git-subtree-split: 70d9ec7f3d452789d04dce81dc02db0b3b778bb5
…ig for btck_TransactionInput
6667dc4eec7b458893920eb7f8631bdf2467c046 kernel: expose scriptSig for btck_TransactionInput (Peter Zafonte)
e6de3a2d3c78d5b72f57bd6a5d711fed97ca70c1 kernel: expose witness stack for btck_TransactionInput (Peter Zafonte)
Pull request description:
Silent payments scanning needs the public key from every input. For SegWit inputs it is in the witness stack. For P2PKH inputs it is in scriptSig. Without these new functions, callers must deserialize the raw transaction themselves to reach that data, which is difficult and error-prone.
Introduces a `btck_WitnessStack` type and adds the following functions:
**Witness stack:**
`btck_transaction_input_get_witness_stack`: returns a non-owning `const btck_WitnessStack* `view
`btck_witness_stack_count_items `: item count
`btck_witness_stack_get_item_at `: single item by index via btck_WriteBytes
`btck_witness_stack_copy` / `btck_witness_stack_destroy`: lifecycle for owned copies
**scriptSig:**
`btck_transaction_input_get_script_sig`: full scriptSig via btck_WriteBytes
All functions are exposed in the C++ wrapper via `WitnessStackView`, `WitnessStack`, and `WitnessStackApi` , and `GetScriptSig()`.
ACKs for top commit:
sedited:
ACK 6667dc4eec7b458893920eb7f8631bdf2467c046
musaHaruna:
ACK [6667dc](bitcoin/bitcoin@6667dc4)
stickies-v:
ACK 6667dc4eec7b458893920eb7f8631bdf2467c046
Tree-SHA512: b5e9d32ec87a5f5a9fea5652ed69737eae1d1f9cfb777544b96d703bbd057c114e0b7afae4e9e9d09b8b546694b14fb923b747c04a8f0211ab6caa015d06967d
Silent payments scanning needs the public key from every input. For SegWit inputs it is in the witness stack. For P2PKH inputs it is in scriptSig. Without these new functions, callers must deserialize the raw transaction themselves to reach that data, which is difficult and error-prone.
Introduces a
btck_WitnessStacktype and adds the following functions:Witness stack:
btck_transaction_input_get_witness_stack: returns a non-owningconst btck_WitnessStack*viewbtck_witness_stack_count_items: item countbtck_witness_stack_get_item_at: single item by index via btck_WriteBytesbtck_witness_stack_copy/btck_witness_stack_destroy: lifecycle for owned copiesscriptSig:
btck_transaction_input_get_script_sig: full scriptSig via btck_WriteBytesAll functions are exposed in the C++ wrapper via
WitnessStackView,WitnessStack, andWitnessStackApi, andGetScriptSig().