| 799 | } |
| 800 | |
| 801 | static bool deep_enough(u32 maxheight, const struct utxo *utxo, |
| 802 | u32 current_blockheight) |
| 803 | { |
| 804 | if (utxo->close_info |
| 805 | && utxo->close_info->option_anchors) { |
| 806 | /* BOLT #3: |
| 807 | * If `option_anchors` applies to the commitment transaction, the |
| 808 | * `to_remote` output is encumbered by a one block csv lock. |
| 809 | */ |
| 810 | if (!utxo->blockheight) |
| 811 | return false; |
| 812 | |
| 813 | u32 csv_free = *utxo->blockheight + utxo->close_info->csv - 1; |
| 814 | assert(csv_free >= *utxo->blockheight); |
| 815 | |
| 816 | if (csv_free > current_blockheight) |
| 817 | return false; |
| 818 | } |
| 819 | |
| 820 | bool immature = utxo_is_immature(utxo, current_blockheight); |
| 821 | if (immature) |
| 822 | return false; |
| 823 | |
| 824 | /* If we require confirmations check that we have a |
| 825 | * confirmation height and that it is below the required |
| 826 | * maxheight (current_height - minconf) */ |
| 827 | if (maxheight == 0) |
| 828 | return true; |
| 829 | if (!utxo->blockheight) |
| 830 | return false; |
| 831 | return *utxo->blockheight <= maxheight; |
| 832 | } |
| 833 | |
| 834 | /* FIXME: Make this wallet_find_utxos, and branch and bound and I've |
| 835 | * left that to @niftynei to do, who actually read the paper! */ |
no test coverage detected