Ejemplo n.º 1
0
func assertReadableTransactionHeader(t *testing.T,
	rth ReadableTransactionHeader, th coin.TransactionHeader) {
	assert.Equal(t, len(rth.Sigs), len(th.Sigs))
	assert.NotPanics(t, func() {
		for i, s := range rth.Sigs {
			assert.Equal(t, coin.MustSigFromHex(s), th.Sigs[i])
		}
		assert.Equal(t, coin.MustSHA256FromHex(rth.Hash), th.Hash)
	})
	assertJSONSerializability(t, &rth)
}
Ejemplo n.º 2
0
func configureDaemon(c *cli.Config) daemon.Config {
	coin.SetAddressVersion(c.AddressVersion)
	dc := daemon.NewConfig()
	dc.Peers.DataDirectory = c.DataDirectory
	dc.DHT.Disabled = c.DisableDHT
	dc.Peers.Disabled = c.DisablePEX
	dc.Daemon.DisableOutgoingConnections = c.DisableOutgoingConnections
	dc.Daemon.DisableIncomingConnections = c.DisableIncomingConnections
	dc.Daemon.DisableNetworking = c.DisableNetworking
	dc.Daemon.Port = c.Port
	dc.Daemon.Address = c.Address
	dc.Daemon.LocalhostOnly = c.LocalhostOnly
	if c.OutgoingConnectionsRate == 0 {
		c.OutgoingConnectionsRate = time.Millisecond
	}
	dc.Daemon.OutgoingRate = c.OutgoingConnectionsRate
	dc.Visor.Config.IsMaster = c.MasterChain
	dc.Visor.Config.CanSpend = c.CanSpend
	dc.Visor.Config.WalletFile = c.WalletFile
	dc.Visor.Config.WalletSizeMin = c.WalletSizeMin
	dc.Visor.Config.BlockchainFile = c.BlockchainFile
	dc.Visor.Config.BlockSigsFile = c.BlockSigsFile
	dc.Visor.Config.GenesisSignature = coin.MustSigFromHex(c.GenesisSignature)
	dc.Visor.Config.GenesisTimestamp = c.GenesisTimestamp
	if c.MasterChain {
		// The master chain should be reluctant to expire transactions
		dc.Visor.Config.UnconfirmedRefreshRate = time.Hour * 4096
	}

	dc.Visor.MasterKeysFile = c.MasterKeys
	if c.MasterChain {
		// Will panic if fails
		dc.Visor.LoadMasterKeys()
	} else {
		w := visor.ReadableWalletEntryFromPubkey(c.MasterPublic)
		dc.Visor.Config.MasterKeys = visor.WalletEntryFromReadable(&w)
	}
	return dc
}