Ejemplo n.º 1
0
// createTestWallet creates a test LightningWallet will a total of 20BTC
// available for funding channels.
func createTestWallet(miningNode *rpctest.Harness, netParams *chaincfg.Params) (string, *LightningWallet, error) {
	privPass := []byte("private-test")
	tempTestDir, err := ioutil.TempDir("", "lnwallet")
	if err != nil {
		return "", nil, nil
	}

	rpcConfig := miningNode.RPCConfig()
	config := &Config{
		PrivatePass: privPass,
		HdSeed:      testHdSeed[:],
		DataDir:     tempTestDir,
		NetParams:   netParams,
		RpcHost:     rpcConfig.Host,
		RpcUser:     rpcConfig.User,
		RpcPass:     rpcConfig.Pass,
		CACert:      rpcConfig.Certificates,
	}

	wallet, _, err := NewLightningWallet(config)
	if err != nil {
		return "", nil, err
	}
	if err := wallet.Startup(); err != nil {
		return "", nil, err
	}

	// Load our test wallet with 5 outputs each holding 4BTC.
	if err := loadTestCredits(miningNode, wallet, 5, 4); err != nil {
		return "", nil, err
	}

	return tempTestDir, wallet, nil
}
Ejemplo n.º 2
0
// InitializeSeedNodes initialized alice and bob nodes given an already
// running instance of btcd's rpctest harness and extra command line flags,
// which should be formatted properly - "--arg=value".
func (n *networkHarness) InitializeSeedNodes(r *rpctest.Harness, lndArgs []string) error {
	nodeConfig := r.RPCConfig()

	n.netParams = r.ActiveNet
	n.Miner = r
	n.rpcConfig = nodeConfig

	var err error
	n.Alice, err = newLightningNode(&nodeConfig, lndArgs)
	if err != nil {
		return err
	}
	n.Bob, err = newLightningNode(&nodeConfig, lndArgs)
	if err != nil {
		return err
	}

	n.activeNodes[n.Alice.nodeId] = n.Alice
	n.activeNodes[n.Bob.nodeId] = n.Bob

	return err
}