| 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) { |
nothing calls this directly
no test coverage detected