(num_bytes: u32)
| 67 | } |
| 68 | |
| 69 | pub fn padding(num_bytes: u32) -> (Script, u32) { |
| 70 | let l = (num_bytes * 8) as i32; |
| 71 | let mut k = 512 - l - 8 - 32; // heres is usually minus 8, but as |
| 72 | // there will be never that many bytes to process |
| 73 | // one u32 will be enough |
| 74 | let mut chunks = 1; |
| 75 | while k < 0 { |
| 76 | k += 512; |
| 77 | chunks += 1; |
| 78 | } |
| 79 | let zeros = k / 16; |
| 80 | let extras = k % 16; |
| 81 | |
| 82 | ( |
| 83 | script! { |
| 84 | 8 |
| 85 | 0 |
| 86 | for i in 0..zeros { |
| 87 | if i == 0 { |
| 88 | 0 |
| 89 | OP_DUP |
| 90 | OP_2DUP |
| 91 | } else { |
| 92 | OP_2DUP |
| 93 | OP_2DUP |
| 94 | } |
| 95 | } |
| 96 | if extras > 0 { |
| 97 | 0 |
| 98 | 0 |
| 99 | } |
| 100 | { u4_number_to_nibble( l as u32 ) } |
| 101 | }, |
| 102 | chunks, |
| 103 | ) |
| 104 | } |
| 105 | |
| 106 | pub fn calculate_s_part_1( |
| 107 | offset_number: u32, |
no outgoing calls