BOLT #2: * 3. if (and only if) `option_shutdown_anysegwit` is negotiated: * * `OP_1` through `OP_16` inclusive, followed by a single * push of 2 to 40 bytes * (witness program versions 1 through 16) */
| 35 | * (witness program versions 1 through 16) |
| 36 | */ |
| 37 | static bool is_valid_witnessprog(const u8 *scriptpubkey, size_t scriptpubkey_len) |
| 38 | { |
| 39 | size_t pushlen; |
| 40 | |
| 41 | if (scriptpubkey_len < 2) |
| 42 | return false; |
| 43 | |
| 44 | switch (scriptpubkey[0]) { |
| 45 | case OP_1: |
| 46 | case OP_2: |
| 47 | case OP_3: |
| 48 | case OP_4: |
| 49 | case OP_5: |
| 50 | case OP_6: |
| 51 | case OP_7: |
| 52 | case OP_8: |
| 53 | case OP_9: |
| 54 | case OP_10: |
| 55 | case OP_11: |
| 56 | case OP_12: |
| 57 | case OP_13: |
| 58 | case OP_14: |
| 59 | case OP_15: |
| 60 | case OP_16: |
| 61 | break; |
| 62 | default: |
| 63 | return false; |
| 64 | } |
| 65 | |
| 66 | pushlen = scriptpubkey[1]; |
| 67 | /* Must be all of the rest of scriptpubkey */ |
| 68 | if (2 + pushlen != scriptpubkey_len) { |
| 69 | return false; |
| 70 | } |
| 71 | |
| 72 | return pushlen >= 2 && pushlen <= 40; |
| 73 | } |
| 74 | |
| 75 | bool valid_shutdown_scriptpubkey(const u8 *scriptpubkey, |
| 76 | bool anysegwit, |
no outgoing calls