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

Function add_number

bitcoin/script.c:69–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67}
68
69static void add_number(u8 **script, u32 num)
70{
71 if (num == 0)
72 add_op(script, 0);
73 else if (num <= 16)
74 add_op(script, 0x50 + num);
75 else {
76 le64 n = cpu_to_le64(num);
77
78 /* Beware: encoding is signed! */
79 if (num <= 0x0000007F)
80 script_push_bytes(script, &n, 1);
81 else if (num <= 0x00007FFF)
82 script_push_bytes(script, &n, 2);
83 else if (num <= 0x007FFFFF)
84 script_push_bytes(script, &n, 3);
85 else if (num <= 0x7FFFFFFF)
86 script_push_bytes(script, &n, 4);
87 else
88 script_push_bytes(script, &n, 5);
89 }
90}
91
92static void add_push_key(u8 **scriptp, const struct pubkey *key)
93{

Calls 3

add_opFunction · 0.85
cpu_to_le64Function · 0.85
script_push_bytesFunction · 0.85

Tested by

no test coverage detected