Skip to content

Commit

Permalink
Add cmd/gots-verify
Browse files Browse the repository at this point in the history
Allows verification of created timestamps
  • Loading branch information
OttoAllmendinger committed Mar 25, 2017
1 parent b60e2cd commit 9e73f0a
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions cmd/gots-verify/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package main

import (
"flag"
"fmt"
"log"

"github.com/BlockchainSource/go-opentimestamps/opentimestamps"
"github.com/BlockchainSource/go-opentimestamps/opentimestamps/client"
"github.com/btcsuite/btcrpcclient"
)

func newBtcConn(host, user, pass string) (*btcrpcclient.Client, error) {
connCfg := &btcrpcclient.ConnConfig{
Host: host,
User: user,
Pass: pass,
HTTPPostMode: true,
DisableTLS: true,
}
return btcrpcclient.New(connCfg, nil)
}

var (
flagBTCHost = flag.String("btc-host", "localhost:8332", "bitcoin-rpc hostname")
flagBTCUser = flag.String("btc-user", "bitcoin", "bitcoin-rpc username")
flagBTCPass = flag.String("btc-pass", "bitcoin", "bitcoin-rpc password")
)

func main() {
flag.Parse()
path := flag.Arg(0)
dts, err := opentimestamps.NewDetachedTimestampFromPath(path)
if err != nil {
log.Fatalf("error reading %s: %v", path, err)
}

btcConn, err := newBtcConn(*flagBTCHost, *flagBTCUser, *flagBTCPass)
if err != nil {
log.Fatalf("error creating btc connection: %v", err)
}

verifier := client.NewBitcoinAttestationVerifier(btcConn)

ts, err := verifier.Verify(dts.Timestamp)
if err != nil {
log.Fatalf("error verifying timestamp: %v", err)
}
if ts == nil {
fmt.Printf("no bitcoin-verifiable timestamps found\n")
}
fmt.Printf("attested time: %v\n", ts)
}

0 comments on commit 9e73f0a

Please sign in to comment.