aboutsummaryrefslogtreecommitdiff
path: root/cryptobyte/string.go
diff options
context:
space:
mode:
Diffstat (limited to 'cryptobyte/string.go')
-rw-r--r--cryptobyte/string.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/cryptobyte/string.go b/cryptobyte/string.go
index 0531a3d..10692a8 100644
--- a/cryptobyte/string.go
+++ b/cryptobyte/string.go
@@ -81,6 +81,17 @@ func (s *String) ReadUint32(out *uint32) bool {
return true
}
+// ReadUint48 decodes a big-endian, 48-bit value into out and advances over it.
+// It reports whether the read was successful.
+func (s *String) ReadUint48(out *uint64) bool {
+ v := s.read(6)
+ if v == nil {
+ return false
+ }
+ *out = uint64(v[0])<<40 | uint64(v[1])<<32 | uint64(v[2])<<24 | uint64(v[3])<<16 | uint64(v[4])<<8 | uint64(v[5])
+ return true
+}
+
// ReadUint64 decodes a big-endian, 64-bit value into out and advances over it.
// It reports whether the read was successful.
func (s *String) ReadUint64(out *uint64) bool {