Files

36 lines
1.0 KiB
Perl
Raw Permalink Normal View History

2022-12-26 15:36:06 +01:00
#!/usr/bin/perl
# Writes out an example. Instead of just having a byte-array, this way
# we can have an annotated example.
open $OUT,">example.backup";
# version = 1;
print $OUT "\x01";
# secret length = 17 (which is 0x11)
print $OUT "\x11";
# Secret is a direct coversion from the mnemoic
# legal winner thank year wave sausage worth useful legal winner thank yellow
# which is 16 bytes plus the checksum.
print $OUT "\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x80";
# language is english, which is language-code 0
print $OUT "\x00";
$message="Hello!";
print $OUT "\x06"; # length of message
print $OUT $message;
# -- paths
print $OUT "\x01"; # one path
$path="m/44'/0'/0'";
print $OUT "\x0b"; # length of path in bytes
print $OUT $path;
# var-int is bit weird, but you'll find it used in bitcoin a lot.
# Blockheight: 766000 => 0x0bb030
# var-int stores that with a preceding byte 0xFE
print $OUT "\xFE\x00\x0b\xb0\x30"; # var-int encoded 766000
print $OUT "\x00"; # No message for this path