]> Dogcows Code - chaz/multisig-backup-file/blob - gentex.pl
initial commit
[chaz/multisig-backup-file] / gentex.pl
1 #!/usr/bin/env perl
2
3 use warnings;
4 use strict;
5 use autodie;
6
7 use JSON::MaybeXS qw(decode_json);
8 use Template::Alloy;
9
10 my $filepath = shift or die "Usage: $0 wallet.json\n";
11
12 my $in = do { open(my $fh, '<', $filepath); local $/; <$fh> };
13 my $wallet = decode_json($in);
14
15 use Data::Dumper;
16 print STDERR Dumper $wallet;
17
18 my $qrcode = $filepath;
19 $qrcode =~ s/\.json$/.png/;
20
21 my $template = do { local $/; <DATA> };
22
23 my $doc;
24 my $t = Template::Alloy->new;
25 $t->process(\$template, { %$wallet, qrcode => $qrcode }, \$doc);
26
27 print $doc;
28 exit;
29
30 __DATA__
31 \documentclass[letterpaper]{article}
32
33 \author{Bitcoin Multisig Wallet Backup File}
34 \date{\today}
35 \title{[% name %]}
36
37 \usepackage[margin=1in]{geometry}
38 \usepackage{graphicx}
39
40 \begin{document}
41
42 \maketitle
43
44 \section{General Information}
45
46 \begin{itemize}
47 \item Quorum: \texttt{[% quorum.requiredSigners %] of [% quorum.totalSigners %]}
48 \item Address type: \texttt{[% addressType %]}
49 \item Network: \texttt{[% network %]}
50 \item Starting address index: \texttt{[% startingAddressIndex %]}
51 \end{itemize}
52
53 \subsection{Keys}
54
55 [%- FOR key IN extendedPublicKeys %]
56 \subsubsection{Cosigner [% loop.count %]}
57
58 \begin{itemize}
59 \item Label: \texttt{[% key.name %]}
60 \item Master fingerprint: \texttt{[% key.xfp %]}
61 \item Derivation path: \texttt{[% key.bip32Path %]}
62 \item Extended public key: \texttt{[% key.xpub.replace('(.{60})', '$1 \\\\ ') %]}
63 \end{itemize}
64
65 [%- END %]
66
67 \newpage
68 \section{QR Code}
69
70 \begin{figure}[hp]
71 \centering
72 \includegraphics{[% qrcode %]}
73 \end{figure}
74
75 \subsection{Directions}
76
77 Scan this QR code to quickly import the wallet backup file into a digital
78 device. \\
79 \\
80 The data file can be used by Caravan software, a stateless multisig coordinator: \\
81 \texttt{https://unchained-capital.github.io/caravan/} \\
82 \\
83 The data contained within the wallet backup file can also be entered into
84 other wallet software, such as Electrum, Sparrow and Specter.
85
86 \end{document}
87
88 % \ref{sec:foo}
89 % \label{sec:limitations}
90 % \footnote{ ... }
91
92 % \begin{figure}[hp]
93 % \includegraphics[scale=0.45]{fig1.pdf}
94 % \caption{Activity diagram.}
95 % \label{fig:activity1}
96 % \end{figure}
97
98 % \begin{lstlisting}[caption=Bar]
99 % ...
100 % \end{lstlisting}
101
102 % \begin{center}
103 % \begin{tabular}{r|l}
104 % Type & Value \\
105 % \hline
106 % byte & {\tt0x01} (literal) \\
107 % String & Player's name \\
108 % String & Message
109 % \end{tabular}
110 % \end{center}
111
112 % \newpage
113 % \appendix
114
115 % \begin{itemize}
116 % \item ...
117 % \end{itemize}
118
This page took 0.040127 seconds and 4 git commands to generate.