MCPcopy Create free account
hub / github.com/citp/BlockSci / getSpendingInputPointer

Method getSpendingInputPointer

src/chain/output.cpp:59–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57 }
58
59 ranges::optional<InputPointer> Output::getSpendingInputPointer() const {
60 auto index = getSpendingTxIndex();
61 if (index) {
62 auto rawTx = access->getChain().getTx(*index);
63 auto spentOutNums = access->getChain().getSpentOutputNumbers(*index);
64 for (uint16_t i = 0; i < rawTx->inputCount; i++) {
65 const auto &input = rawTx->getInput(i);
66 auto spentOutNum = spentOutNums[i];
67 if (OutputPointer{input.getLinkedTxNum(), spentOutNum} == pointer) {
68 return InputPointer{*index, i};
69 }
70 }
71 throw std::runtime_error("Whoopsie. Something went terribly wrong");
72 } else {
73 return ranges::nullopt;
74 }
75 }
76
77 BlockHeight Output::getBlockHeight() const {
78 if (blockHeight == -1) {

Callers

nothing calls this directly

Calls 3

getSpendingTxIndexFunction · 0.85
getTxMethod · 0.80
getSpentOutputNumbersMethod · 0.80

Tested by

no test coverage detected