sign.go 1.07 KB
Newer Older
1
2
3
4
5
6
7
8
9
package main

import (
	"fmt"
	"os"

	"dfss/dfssc/sign"
)

Loïck Bonniot's avatar
Loïck Bonniot committed
10
11
func signContract(args []string) {
	filename := args[0]
12
	fmt.Println("You are going to sign the following contract:")
Loïck Bonniot's avatar
Loïck Bonniot committed
13
	contract := getContract(filename)
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
	if contract == nil {
		os.Exit(1)
	}

	var passphrase string
	_ = readPassword(&passphrase, false)

	// Preparation
	manager, err := sign.NewSignatureManager(fca, fcert, fkey, addrPort, passphrase, localPort, contract)
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(2)
	}
	err = manager.ConnectToPeers()
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(3)
	}

	// Confirmation
	var ready string
	readStringParam("Do you REALLY want to sign "+contract.File.Name+"? Type 'yes' to confirm", "", &ready)
	if ready != "yes" {
		os.Exit(4)
	}

	// Ignition
Loïck Bonniot's avatar
Loïck Bonniot committed
41
42
43
44
45
46
47
	fmt.Println("Waiting for other signers to be ready...")
	signatureUUID, err := manager.SendReadySign()
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(5)
	}

48
	// TODO Warning, integration tests are checking Stdout
Loïck Bonniot's avatar
Loïck Bonniot committed
49
	fmt.Println("Everybody is ready, starting the signature", signatureUUID)
50
51
52

	// Signature
}