MCPcopy Create free account
hub / github.com/ElementsProject/lightning / add_number

Function add_number

bitcoin/script.c:58–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58static void add_number(u8 **script, u32 num)
59{
60 if (num == 0)
61 add_op(script, 0);
62 else if (num <= 16)
63 add_op(script, 0x50 + num);
64 else {
65 le64 n = cpu_to_le64(num);
66
67 /* Beware: encoding is signed! */
68 if (num <= 0x0000007F)
69 script_push_bytes(script, &n, 1);
70 else if (num <= 0x00007FFF)
71 script_push_bytes(script, &n, 2);
72 else if (num <= 0x007FFFFF)
73 script_push_bytes(script, &n, 3);
74 else if (num <= 0x7FFFFFFF)
75 script_push_bytes(script, &n, 4);
76 else
77 script_push_bytes(script, &n, 5);
78 }
79}
80
81static void add_push_key(u8 **scriptp, const struct pubkey *key)
82{

Calls 3

add_opFunction · 0.85
cpu_to_le64Function · 0.85
script_push_bytesFunction · 0.70

Tested by

no test coverage detected