func init() {
	flagset.Usage = func() {
		fmt.Println("Usage: dcratomicswap [flags] cmd [cmd args]")
		fmt.Println()
		fmt.Println("Commands:")
		fmt.Println("  initiate <participant address> <amount>")
		fmt.Println("  participate <initiator address> <amount> <secret hash>")
		fmt.Println("  redeem <contract> <contract transaction> <secret>")
		fmt.Println("  refund <contract> <contract transaction>")
		fmt.Println("  extractsecret <redemption transaction> <secret hash>")
		fmt.Println("  auditcontract <contract> <contract transaction>")
		fmt.Println()
		fmt.Println("Flags:")
		flagset.PrintDefaults()
	}
}
There are two directions that the atomic swap can be performed, as the
initiator can be on either chain.  This tool only deals with creating the
Decred transactions for these swaps.  A second tool should be used for the
transaction on the other chain.  Any chain can be used so long as it supports
OP_SHA256 and OP_CHECKLOCKTIMEVERIFY.

Example scenerios using bitcoin as the second chain:

Scenerio 1:
cp1 initiates (dcr)
cp2 participates with cp1 H(S) (btc)
cp1 redeems btc revealing S
- must verify H(S) in contract is hash of known secret
cp2 redeems dcr with S

Scenerio 2:
cp1 initiates (btc)
cp2 participates with cp1 H(S) (dcr)
cp1 redeems dcr revealing S
- must verify H(S) in contract is hash of known secret
cp2 redeems btc with S
package main
import (
	"bufio"
	"bytes"
	"context"
	"crypto/rand"
	"crypto/sha256"
	"crypto/tls"
	"crypto/x509"
	"encoding/hex"
	"errors"
	"flag"
	"fmt"
	"io/ioutil"
	"net"
	"os"
	"path/filepath"
	"strconv"
	"strings"
	"time"
	pb "decred.org/dcrwallet/rpc/walletrpc"
	"decred.org/dcrwallet/wallet/txrules"
	"github.com/decred/dcrd/chaincfg/chainhash"
	"github.com/decred/dcrd/chaincfg/v3"
	"github.com/decred/dcrd/dcrec"
	"github.com/decred/dcrd/dcrutil/v3"
	"github.com/decred/dcrd/txscript/v3"
	"github.com/decred/dcrd/wire"
	"golang.org/x/crypto/ripemd160"
	"golang.org/x/crypto/ssh/terminal"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials"
)
const (
	isTreasuryEnabled = true
	verify            = true
	verifyFlags = txscript.ScriptDiscourageUpgradableNops |
		txscript.ScriptVerifyCleanStack |
		txscript.ScriptVerifyCheckLockTimeVerify |
		txscript.ScriptVerifyCheckSequenceVerify |
		txscript.ScriptVerifySHA256
	secretSize = 32
	feePerKb = 1e5
	scriptVersion = 0
)
var (
	chainParams = chaincfg.MainNetParams()
)
var (
	flagset        = flag.NewFlagSet("", flag.ExitOnError)
	connectFlag    = flagset.String("s", "localhost", "host[:port] of dcrwallet gRPC server")
	certFlag       = flagset.String("c", filepath.Join(dcrutil.AppDataDir("dcrwallet", false), "rpc.cert"), "dcrwallet RPC certificate path")
	clientCertFlag = flagset.String("clientcert", "", "path to client authentication certificate")
	clientKeyFlag  = flagset.String("clientkey", "", "path to client authentication key")
	testnetFlag    = flagset.Bool("testnet", false, "use testnet network")
)