Underlying add_ref implementation used by both `add_ref` and `add_ref_stack` functions. The commented section is supposed to handle depth=0, which fails. This adds to the script size, henced we assume that the caller ensures that the depth > 0
()
| 310 | // This adds to the script size, henced we assume that the caller ensures that |
| 311 | // the depth > 0 |
| 312 | fn _add_ref_inner() -> Script { |
| 313 | script! { |
| 314 | // OP_DUP OP_NOT OP_NOT OP_VERIFY // fail on {0} stack |
| 315 | // OP_DUP OP_NOT |
| 316 | // OP_IF |
| 317 | // OP_DROP |
| 318 | // { Self::topadd_new(0) } |
| 319 | // OP_ELSE |
| 320 | 3 OP_ADD |
| 321 | { 1 << LIMB_SIZE } |
| 322 | for i in 0..Self::N_LIMBS-1 { |
| 323 | if i == 0 { |
| 324 | OP_OVER OP_1SUB |
| 325 | OP_PICK |
| 326 | } else { |
| 327 | 2 OP_PICK |
| 328 | OP_PICK |
| 329 | OP_ADD |
| 330 | } |
| 331 | 3 OP_ROLL |
| 332 | OP_ADD |
| 333 | OP_2DUP |
| 334 | OP_LESSTHANOREQUAL |
| 335 | OP_TUCK |
| 336 | OP_IF 2 OP_PICK OP_SUB OP_ENDIF |
| 337 | OP_TOALTSTACK |
| 338 | } |
| 339 | OP_NIP OP_SWAP |
| 340 | 2 OP_SUB OP_PICK |
| 341 | |
| 342 | OP_SWAP { limb_add_with_carry_prevent_overflow(Self::HEAD_OFFSET) } |
| 343 | |
| 344 | for _ in 0..Self::N_LIMBS-1 { |
| 345 | OP_FROMALTSTACK |
| 346 | } |
| 347 | // OP_ENDIF |
| 348 | } |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | pub fn limb_add_create_carry() -> Script { |
nothing calls this directly
no outgoing calls
no test coverage detected