joinmarket: automatically generate wallet

This commit is contained in:
nixbitcoin
2020-09-11 11:53:12 +00:00
parent d6d3e8ff62
commit d0701f518c
6 changed files with 66 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
{ stdenv, fetchurl, python3 }:
{ stdenv, fetchurl, python3, pkgs }:
let
version = "0.7.0";
@@ -32,11 +32,13 @@ let
joinmarketdaemon
];
genwallet = pkgs.writeScriptBin "genwallet" (builtins.readFile ./genwallet/genwallet.py);
pythonEnv = python.withPackages (_: runtimePackages);
in
stdenv.mkDerivation {
pname = "joinmarket";
inherit version src;
inherit version src genwallet;
buildInputs = [ pythonEnv ];
@@ -57,6 +59,7 @@ stdenv.mkDerivation {
cpBin tumbler.py
cpBin wallet-tool.py
cpBin yg-privacyenhanced.py
cp $genwallet/bin/genwallet $out/bin/jm-genwallet
chmod +x -R $out/bin
patchShebangs $out/bin

View File

@@ -0,0 +1,36 @@
#!/usr/bin/env python3
"""
Prototype: demonstrate you can automatically generate a wallet
"""
import sys
import os
from optparse import OptionParser
from jmclient import load_program_config, add_base_options, SegwitLegacyWallet, create_wallet, jm_single
from jmbase.support import get_log, jmprint
log = get_log()
def main():
parser = OptionParser(
usage='usage: %prog [options] wallet_file_name password',
description='Create a wallet with the given wallet name and password.')
add_base_options(parser)
(options, args) = parser.parse_args()
if options.wallet_password_stdin:
stdin = sys.stdin.read()
password = stdin.encode("utf-8")
else:
assert len(args) > 1, "must provide password via stdin (see --help), or as second argument."
password = args[1].encode("utf-8")
load_program_config(config_path=options.datadir)
wallet_root_path = os.path.join(jm_single().datadir, "wallets")
wallet_name = os.path.join(wallet_root_path, args[0])
wallet = create_wallet(wallet_name, password, 4, SegwitLegacyWallet)
jmprint("recovery_seed:{}"
.format(wallet.get_mnemonic_words()[0]), "important")
wallet.close()
if __name__ == "__main__":
main()