pub fn push_scriptnum(&mut self, n: i64) -> Result<(), ScriptError> {
        
        if n == 0 {
            self.0.push(Box::new([]));
            return Ok(());
        }

        // two-complement -> sign & magnitude
        let sign_byte: u8 = ((n >> 56) & 0x80) as u8;
        let mut magnitude = n.abs();

        // push all but last
        let mut result : Vec<u8> = Vec::with_capacity(8);
        while magnitude > 0x7F
        {
            result.push((magnitude & 0xFF) as u8);
            magnitude >>= 8;
        }

        // push last with sign-byte
        result.push(((magnitude & 0xFF) as u8) | sign_byte);
        
        self.0.push(result.into_boxed_slice());
        Ok(())
    }
/// Stores a scriptnum on the stack
/// in signed-magnitude format (see pop_scriptnum)
/// 
/// If the value is more then 4-bytes,
/// it will not be possible to read it back as a scriptnum 
Stores a scriptnum on the stack
in signed-magnitude format

If the value is more then 4-bytes,
it will not be possible to read it back as a scriptnum
Stores a scriptnum on the stack in signed - magnitude format If the value is more then 4 - bytes it will not be possible to read it back as a scriptnum
pub fn push_scriptnum(&mut self, n: i64) -> Result<(), ScriptError> {
        if n == 0 {
            self.0.push(Box::new([]));
            return Ok(());
        }
        // two-complement -> sign & magnitude
        let sign_byte: u8 = ((n >> 56) & 0x80) as u8;
        let mut magnitude = n.abs();
        // push all but last
        let mut result : Vec<u8> = Vec::with_capacity(8);
        while magnitude > 0x7F
        {
            result.push((magnitude & 0xFF) as u8);
            magnitude >>= 8;
        }
        // push last with sign-byte
        result.push(((magnitude & 0xFF) as u8) | sign_byte);
        self.0.push(result.into_boxed_slice());
        Ok(())
    }
pub fn push_scriptnum ( & mut self , n : i64 ) -> Result < ( ) , ScriptError > { if n == 0 { self . 0 . push ( Box :: new ( [ ] ) ) ; return Ok ( ( ) ) ; } // two-complement -> sign & magnitude let sign_byte : u8 = ( ( n >> 56 ) & 0x80 ) as u8 ; let mut magnitude = n . abs ( ) ; // push all but last let mut result : Vec < u8 > = Vec :: with_capacity ( 8 ) ; while magnitude > 0x7F { result . push ( ( magnitude & 0xFF ) as u8 ) ; magnitude >>= 8 ; } // push last with sign-byte result . push ( ( ( magnitude & 0xFF ) as u8 ) | sign_byte ) ; self . 0 . push ( result . into_boxed_slice ( ) ) ; Ok ( ( ) ) }
Stores a scriptnum on the stack
in signed-magnitude format (see pop_scriptnum)
Stores a scriptnum on the stack in signed - magnitude format ( see pop_scriptnum )
&mut self
n
i64
&mut self
n
i64