lib

package
v1.2.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2021 License: MIT Imports: 59 Imported by: 23

Documentation

Overview

TODO(DELETEME): This entire file is replaced by remote_miner.go. We should delete all of this code and use remote_miner in all the places where we currently use the miner. The reason we don't do this now is it would break a lot of test cases that we have.

Index

Constants

View Source
const (
	// MaxOrphansInMemory is the maximum number of orphan blocks that we're willing to keep in memory. We set
	// a maximum here in order to prevent memory exhaustion from someone sending us too
	// many unconnectedTxns.
	MaxOrphansInMemory = 100

	// MaxBlockIndexNodes needs to allow the block index to grow large enough to accommodate multiple
	// forks of material length while allowing us to avoid an out-of-memory issue due to
	// a "disk-fill" attack. Notice that because we will only ever download blocks
	// after we have a header chain that has beaten all other header chains we're aware
	// of, the common case for an attack will be someone sending us long useless header
	// chains that we never actually download blocks for. This results in the block index
	// bloating up (indefinitely if we don't prune it) due to storing useless headers
	// but not resulting in the downloading of any blocks, which is a good thing.
	//
	// At ten minute block times, 5,000,000 comes out to roughly 95 years worth of blocks,
	// which seems like a reasonable limit for now (if we had 25 years of blocks, we'd still
	// have room for multiple forks each an entire history's length with this value). If
	// each node takes up 100 bytes of space this amounts to around 500MB, which also seems
	// like a reasonable size.
	MaxBlockIndexNodes = 5000000
)
View Source
const (
	StatusNone BlockStatus = 0

	// Headers must always be Validated or ValidateFailed. We
	// don't store orphan headers and therefore any header that we do
	// have in our node index will be known definitively to be valid or
	// invalid one way or the other.
	StatusHeaderValidated = 1 << iota
	StatusHeaderValidateFailed

	StatusBlockProcessed
	StatusBlockStored
	StatusBlockValidated
	StatusBlockValidateFailed

	// These statuses are only used for Bitcoin header blocks in the BitcoinManager,
	// not DeSo blocks. As such, you should only see these referenced in the BitcoinManager.
	// We include them here because overloading the DeSo data structures to make it
	// so that the BitcoinManager can use them is easier than defining whole new data
	// structures that are incompatible with existing methods like LatestLocator(). If
	// Go supported generics, this would probably not be necessary but it doesn't and
	// so this is the path of least resistance.
	StatusBitcoinHeaderValidated
	StatusBitcoinHeaderValidateFailed
)
View Source
const (

	// Uint64Dec decrements a uint64 by one.
	Uint64Dec = ^uint64(0)
	// Uint32Dec decrements a uint32 by one.
	Uint32Dec = ^uint32(0)
)
View Source
const (
	// ConfigDirVendorName is the enclosing folder for user data.
	// It's required to created a ConfigDir.
	ConfigDirVendorName = "deso"
	// ConfigDirAppName is the folder where we keep user data.
	ConfigDirAppName = "deso"
	// UseridLengthBytes is the number of bytes of entropy to use for
	// a userid.
	UseridLengthBytes = 32

	// These constants are used by the DNS seed code to pick a random last
	// seen time.
	SecondsIn3Days int32 = 24 * 60 * 60 * 3
	SecondsIn4Days int32 = 24 * 60 * 60 * 4

	// MessagesToFetchPerCall is used to limit the number of messages to fetch
	// when getting a user's inbox.
	MessagesToFetchPerInboxCall = 10000
)
View Source
const (
	// This is the header version that the blockchain started with.
	HeaderVersion0 = uint32(0)
	// This version made several changes to the previous header encoding format:
	// - The Nonce field was expanded to 64 bits
	// - Another ExtraNonce field was added to provide *another* 64 bits of entropy,
	//   for a total of 128 bits of entropy in the header that miners can twiddle.
	// - The header height was expanded to 64 bits
	// - The TstampSecs were expanded to 64 bits
	// - All fields were moved from encoding in little-endian to big-endian
	//
	// The benefit of this change is that miners can hash over a wider space without
	// needing to twiddle ExtraData ever.
	//
	// At the time of this writing, the intent is to deploy it in a backwards-compatible
	// fashion, with the eventual goal of phasing out blocks with the previous version.
	HeaderVersion1       = uint32(1)
	CurrentHeaderVersion = HeaderVersion1
)
View Source
const (
	// Key in transaction's extra data map that points to a post that the current transaction is reposting
	RepostedPostHash = "RecloutedPostHash"
	// Key in transaction's extra map -- The presence of this key indicates that this post is a repost with a quote.
	IsQuotedRepostKey = "IsQuotedReclout"

	// Keys for a GlobalParamUpdate transaction's extra data map.
	USDCentsPerBitcoinKey            = "USDCentsPerBitcoin"
	MinNetworkFeeNanosPerKBKey       = "MinNetworkFeeNanosPerKB"
	CreateProfileFeeNanosKey         = "CreateProfileFeeNanos"
	CreateNFTFeeNanosKey             = "CreateNFTFeeNanos"
	MaxCopiesPerNFTKey               = "MaxCopiesPerNFT"
	ForbiddenBlockSignaturePubKeyKey = "ForbiddenBlockSignaturePubKey"

	DiamondLevelKey    = "DiamondLevel"
	DiamondPostHashKey = "DiamondPostHash"

	// Key in transaction's extra data map containing the derived key used in signing the txn.
	DerivedPublicKey = "DerivedPublicKey"
)

Defines keys that may exist in a transaction's ExtraData map

View Source
const (
	// MinNetworkFeeNanosPerKBValue - Minimum value to which the minimum network fee per KB can be set.
	MinNetworkFeeNanosPerKBValue = 0
	// MaxNetworkFeeNanosPerKBValue - Maximum value to which the maximum network fee per KB can be set.
	MaxNetworkFeeNanosPerKBValue = 100 * NanosPerUnit
	// MinCreateProfileFeeNanos - Minimum value to which the create profile fee can be set.
	MinCreateProfileFeeNanos = 0
	// MaxCreateProfileFeeNanos - Maximum value to which the create profile fee can be set.
	MaxCreateProfileFeeNanos = 100 * NanosPerUnit
	// Min/MaxCreateNFTFeeNanos - Min/max value to which the create NFT fee can be set.
	MinCreateNFTFeeNanos = 0
	MaxCreateNFTFeeNanos = 100 * NanosPerUnit
	// Min/MaxMaxCopiesPerNFTNanos - Min/max value to which the create NFT fee can be set.
	MinMaxCopiesPerNFT = 1
	MaxMaxCopiesPerNFT = 10000
)

Define min / max possible values for GlobalParams.

View Source
const (
	ChainTypeDeSoBlock = iota
	ChainTypeBitcoinHeader
)
View Source
const (
	// MaxTotalTransactionSizeBytes is the maximum number of bytes the pool can store
	// across all of its transactions. Once this limit is reached, transactions must
	// be evicted from the pool based on their feerate before new transactions can be
	// added.
	MaxTotalTransactionSizeBytes = 250000000 // 250MB

	// UnconnectedTxnExpirationInterval is how long we wait before automatically removing an
	// unconnected transaction.
	UnconnectedTxnExpirationInterval = time.Minute * 5

	// The maximum number of unconnected transactions the pool will store.
	MaxUnconnectedTransactions = 10000

	// The maximum number of bytes a single unconnected transaction can take up
	MaxUnconnectedTxSizeBytes = 100000
)
View Source
const (
	// MaxAddrsPerAddrMsg is the maximum number of addresses we allow in a single
	// addr message from a peer.
	MaxAddrsPerAddrMsg = 1000
	// AddrRelayIntervalSeconds is the amount of time we wait before relaying each
	// batch of addresses we've received recently.
	AddrRelayIntervalSeconds = 60

	// RebroadcastNodeAddrIntervalMinutes is how often we broadcast our own address
	// to our peers.
	RebroadcastNodeAddrIntervalMinutes = 24 * 60
)
View Source
const (
	// MaxDeSoInputSizeBytes is the size required to encode an DeSoInput.
	// 32 bytes for the TxID and 4 bytes for the Index = 36 bytes. Note
	// that because the index is encoded as a uvarint, this size represents
	// a maximum.
	MaxDeSoInputSizeBytes = 32 + 4
	// MaxDeSoOutputSizeBytes is the size required to encode an DeSoOutput.
	// It is 33 bytes for the public key and 8 bytes for the amount
	// = 41 bytes. Note that because the amount is encoded as a uvarint,
	// this size represents a maximum.
	MaxDeSoOutputSizeBytes = btcec.PubKeyBytesLenCompressed + 8
)
View Source
const (
	NanosPerUnit  = uint64(1000000000)
	BlocksPerYear = uint32(12 * 24 * 365)
	BlocksPerDay  = uint32(12 * 24)
	// Every 1M DeSo we sell causes the price to increase by a factor of 2.
	TrancheSizeNanos = uint64(1000000000000000)
	// When exchanging Bitcoin for DeSo, we don't allow transactions to create
	// less than this amount. This avoids issues around small transactions that
	// exploit floating point errors.
	MinNanosToCreate = 50

	// The price of DeSo at the beginning.
	StartDeSoPriceUSDCents = 50
	SatoshisPerBitcoin     = 100000000

	// The minimum and maximum Bitcoin prices, used as a sanity-check.
	MinUSDCentsPerBitcoin = 100 * 100
	MaxUSDCentsPerBitcoin = 1000000 * 100

	// Used for sanity checks for now. This is not necessarily the actual the max supply.
	MaxNanos = uint64(30000000) * NanosPerUnit
)
View Source
const (
	MaxVarintLen16 = 3
	MaxVarintLen32 = 5
	MaxVarintLen64 = 10
)

MaxVarintLenN is the maximum length of a varint-encoded N-bit integer.

View Source
const (
	FloatPrecision uint = 53
)
View Source
const HashSizeBytes = 32
View Source
const (
	MAIN_CHAIN = "main"
)
View Source
const (
	// MaxBlocksInFlight is the maximum number of blocks that can be requested
	// from a peer.
	MaxBlocksInFlight = 250
)
View Source
const MaxMessagePayload = (1024 * 1024 * 100) // 100MB

MaxMessagePayload is the maximum size alowed for a message payload.

View Source
const (
	MaxUsernameLengthBytes = 25
)
View Source
const SECURE_MIDDLEWARE_RESTRICTIVE_CONTENT_SECURITY_POLICY = "default-src 'self'"

Variables

View Source
var (

	// SalomonFixBlockHeight defines a block height where the protocol implements
	// two changes:
	// 	(1) The protocol now prints founder reward for all buy transactions instead
	//		of just when creators reach a new all time high.
	//		This was decided in order to provide lasting incentive for creators
	//		to utilize the protocol.
	//	(2) A fix was created to deal with a bug accidentally triggered by @salomon.
	//		After a series of buys and sells @salomon was left with a single creator coin
	//		nano in circulation and a single DeSo nano locked. This caused a detach
	//		between @salomon's bonding curve and others on the protocol. As more buys and sells
	//		continued, @salomon's bonding curve continued to detach further and further from its peers.
	// 		At its core, @salomon had too few creator coins in circulation. This fix introduces
	//		this missing supply back into circulation as well as prevented detached Bancor bonding
	//		curves from coming into existence.
	//		^ It was later decided to leave Salomon's coin circulation alone. A fix was introduced
	//		to prevent similar cases from occurring again, but @salomon is left alone.
	SalomonFixBlockHeight = uint32(15270)

	// DeSoFounderRewardBlockHeight defines a block height where the protocol switches from
	// paying the founder reward in the founder's own creator coin to paying in DeSo instead.
	DeSoFounderRewardBlockHeight = uint32(21869)

	// BuyCreatorCoinAfterDeletedBalanceEntryFixBlockHeight defines a block height after which the protocol will create
	// a new BalanceEntry when a user purchases a Creator Coin and their current BalanceEntry is deleted.
	// The situation in which a BalanceEntry reaches a deleted state occurs when a user transfers all their holdings
	// of a certain creator to another public key and subsequently purchases that same creator within the same block.
	// This resolves a bug in which users would purchase creator coins after transferring all holdings within the same
	// block and then the creator coins would be added to a deleted balance.  When the Balance Entries are flushed to
	// the database, the user would lose the creator coins they purchased.
	BuyCreatorCoinAfterDeletedBalanceEntryFixBlockHeight = uint32(39713)

	// ParamUpdaterProfileUpdateFixBlockHeight defines a block height after which the protocol uses the update profile
	// txMeta's ProfilePublicKey when the Param Updater is creating a profile for ProfilePublicKey.
	ParamUpdaterProfileUpdateFixBlockHeight = uint32(39713)

	// UpdateProfileFixBlockHeight defines the height at which a patch was added to prevent user from
	// updating the profile entry for arbitrary public keys that do not have existing profile entries.
	UpdateProfileFixBlockHeight = uint32(46165)

	// BrokenNFTBidsFixBlockHeight defines the height at which the deso balance index takes effect
	// for accepting NFT bids.  This is used to fix a fork that was created by nodes running with a corrupted
	// deso balance index, allowing bids to be submitted that were greater than the user's deso balance.
	BrokenNFTBidsFixBlockHeight = uint32(46917)

	// DeSoDiamondsBlockHeight defines the height at which diamonds will be given in DESO
	// rather than in creator coin.
	// Triggers: 3pm PT on 8/16/2021
	DeSoDiamondsBlockHeight = uint32(52112)

	// NFTTransfersBlockHeight defines the height at which NFT transfer txns, accept NFT
	// transfer txns, NFT burn txns, and AuthorizeDerivedKey txns will be accepted.
	// Triggers: 12PM PT on 9/15/2021
	NFTTransferOrBurnAndDerivedKeysBlockHeight = uint32(60743)
)
View Source
var (
	UsernameRegex = regexp.MustCompile("^[a-zA-Z0-9_]+$")
	// Profile pics are Base64 encoded plus ": ; ," used in the mime type spec.
	ProfilePicRegex = regexp.MustCompile("^[a-zA-Z0-9+/:;,]+$")

	TikTokShortURLRegex = regexp.MustCompile("^.*(vm\\.tiktok\\.com/)([A-Za-z0-9]{6,12}).*")
	TikTokFullURLRegex  = regexp.MustCompile("^.*((tiktok\\.com/)(v/)|(@[A-Za-z0-9_-]{2,24}/video/)|(embed/v2/))(\\d{0,30}).*")
)
View Source
var (
	ArchitectPubKeyBase58Check = "BC1YLg3oh6Boj8e2boCo1vQCYHLk1rjsHF6jthBdvSw79bixQvKK6Qa"
	// This is the public key corresponding to the BitcoinBurnAddress on mainnet.
	BurnPubKeyBase58Check = "BC1YLjWBf2qnDJmi8HZzzCPeXqy4dCKq95oqqzerAyW8MUTbuXTb1QT"

	GenesisBlock = MsgDeSoBlock{
		Header: &MsgDeSoHeader{
			Version:               0,
			PrevBlockHash:         &BlockHash{},
			TransactionMerkleRoot: mustDecodeHexBlockHash("4b71d103dd6fff1bd6110bc8ed0a2f3118bbe29a67e45c6c7d97546ad126906f"),
			TstampSecs:            uint64(1610948544),
			Height:                uint64(0),
			Nonce:                 uint64(0),
		},
		Txns: []*MsgDeSoTxn{
			{
				TxInputs: []*DeSoInput{},

				TxOutputs: SeedBalances,

				TxnMeta: &BlockRewardMetadataa{
					ExtraData: []byte(
						"They came here, to the New World. World 2.0, version 1776."),
				},
			},
		},
	}
	GenesisBlockHashHex = "5567c45b7b83b604f9ff5cb5e88dfc9ad7d5a1dd5818dd19e6d02466f47cbd62"
	GenesisBlockHash    = mustDecodeHexBlockHash(GenesisBlockHashHex)

	ParamUpdaterPublicKeys = map[PkMapKey]bool{

		MakePkMapKey(MustBase58CheckDecode(ArchitectPubKeyBase58Check)):                                true,
		MakePkMapKey(MustBase58CheckDecode("BC1YLiXwGTte8oXEEVzm4zqtDpGRx44Y4rqbeFeAs5MnzsmqT5RcqkW")): true,
		MakePkMapKey(MustBase58CheckDecode("BC1YLgGLKjuHUFZZQcNYrdWRrHsDKUofd9MSxDq4NY53x7vGt4H32oZ")): true,
		MakePkMapKey(MustBase58CheckDecode("BC1YLj8UkNMbCsmTUTx5Z2bhtp8q86csDthRmK6zbYstjjbS5eHoGkr")): true,
		MakePkMapKey(MustBase58CheckDecode("BC1YLgD1f7yw7Ue8qQiW7QMBSm6J7fsieK5rRtyxmWqL2Ypra2BAToc")): true,
		MakePkMapKey(MustBase58CheckDecode("BC1YLfz4GH3Gfj6dCtBi8bNdNTbTdcibk8iCZS75toUn4UKZaTJnz9y")): true,
		MakePkMapKey(MustBase58CheckDecode("BC1YLfoSyJWKjHGnj5ZqbSokC3LPDNBMDwHX3ehZDCA3HVkFNiPY5cQ")): true,
	}
)

GenesisBlock defines the genesis block used for the DeSo maainnet and testnet

View Source
var (
	QuotedRepostVal    = []byte{1}
	NotQuotedRepostVal = []byte{0}
)
View Source
var (
	// The readOnlyUtxoView will update after the number of seconds specified here OR
	// the number of transactions specified here, whichever comes first. An update
	// resets both counters.
	//
	// We make these vars rather than const for testing
	ReadOnlyUtxoViewRegenerationIntervalSeconds = float64(1.0)
	ReadOnlyUtxoViewRegenerationIntervalTxns    = int64(1000)

	// LowFeeTxLimitBytesPerTenMinutes defines the number of bytes per 10 minutes of "low fee"
	// transactions the mempool will tolerate before it starts rejecting transactions
	// that fail to meet the MinTxFeePerKBNanos threshold.
	LowFeeTxLimitBytesPerTenMinutes = 150000 // Allow 150KB per minute in low-fee txns.
)
View Source
var (
	// These transactions are simply here to bootstrap the profiles on the network. We had
	// some people testing things before it went live and wanted to preserve their profiles.
	SeedTxns     = []string{}
	TestSeedTxns = []string{

		"015e71a8a3b43fddb2cb9d487116338ffc8a089be76ce55b5fd16f7e20e3f47ebb000103aad5affbeee6118a91b914495f2bd0abffd0ac4782c2139a3ced0e353aa4ae49da7a068a20000762616c616a69731a3c703e747769747465722e636f6d2f62616c616a69733c2f703edf1f646174613a696d6167652f6a7065673b6261736536342c2f396a2f327743454141674742676347425167484277634a4351674b4442514e4441734c44426b534577385548526f6648683061484277674a43346e49434973497877634b4463704c4441784e44513048796335505467795043347a4e44494243516b4a4441734d4741304e47444968484345794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d762f4141424549414751415a414d4249674143455145444551482f7841476941414142425145424151454241514141414141414141414141514944424155474277674a436773514141494241774d4342414d4642515145414141426651454341774145455155534954464242684e525951636963525179675a476843434e4373634556557448774a444e69636f494a4368595847426b614a53596e4b436b714e4455324e7a67354f6b4e4552555a4853456c4b55315256566c64595756706a5a47566d5a326870616e4e3064585a3365486c3667345346686f6549695971536b3553566c7065596d5a71696f36536c7071656f716171797337533174726534756272437738544678736649796372533039545631746659326472683475506b3565626e364f6e7138664c7a39505832392f6a352b674541417745424151454241514542415141414141414141414543417751464267634943516f4c455141434151494542414d454277554542414142416e6341415149444551514649544547456b4652423246784579497967516755517047687363454a497a4e53384256696374454b46695130345358784678675a4769596e4b436b714e5459334f446b3651305246526b644953557054564656575631685a576d4e6b5a575a6e61476c7163335231646e64346558714367345346686f6549695971536b3553566c7065596d5a71696f36536c7071656f71617179733753317472653475627243773854467873664979637253303954563174665932647269342b546c3575666f36657279382f5431397666342b66722f3267414d41774541416845444551412f415061714b4b4d554146464648656741724d31727842706e682b32576655626c596735784847427565512b69714f542f41434663763852764878384a515132646973556d70334b6c6c4d764b776f4f4e784838524a3644323572784b396b3137786a657463586f6b75626c2f6b524a4d7156547163486f427766595a59347851423631716e7877384f5753736c7062334e334f4239304655516656763841616d384e2f46375364616e534f356c74724d75514172376c4f536363453848394b385930587772642b4b4e6353783062543175436f4264324a45435a343345396476314f546a69757a732f6778724c366d624f613349695253383871756f67633956566568395058337851423732724b36686c594d7036454867307465642b4835727277536e396e5874764f4e50334b49354c69596c687a3878554867714377393864754b39452f484e41425252525141744846464641435555744a514155645342533144647a6931733537672f38736f326b2f49452f77424b41504c62505459504748784d6b757232454745764967336b4b776a69796971423179784c6b6e2f437655443455306357567a6152326363635679686a6c32714d6c434d46515430424848487236313466384a333148567646736d71346b6b74394f676c6e534b4d457449584a4155456e4753636e6e6976554e61755048733976492b6c33476a576268437867614b53575350324c3872752f444641485736586f2b6e364c5a72616164615257304b67446247754d344741536570507561745453724247585a584948397853782f4963317a76677134312b62523258784463576339326a63535732506d552f3367414144394b79746138512b4a3766574a76374d4f697a574b714367637973787a3359714d4139652b4d55415876487470623674344c6e6b61586244437958445344494b71724173523379426b3439735646344e31523956384c5755307362527a704749706b62727555446e38657634314264617464613334583150547458734873356269786d4d63304c6834704d4b6337574249427a324a7a5758384d373058656e616a47522b3874706f6f6e4f63352f644b66356c767a6f41376d69696c6f414b4b4b4b41456f7061536742617a64654262517278414d37343968474d35424942483467347252714b35682b3057386b4f6346317744364873667a6f41356e34582b48573850324771776d4e6c4275676b6538446473564163456a726773772f4374505566437a7a617061366c50712b6f7969327933326447594c49782f3255494834592f4876544e4e3175574456622b30466d6d48564c75504d6f5142577970427a334471335156646e6e753954426a597869412f6569694a4959656a76787837415a2b6f6f4157317649493765565239706d615253486c6951754d386a6876346950555a35724558773232705132306474724e2f614a6163524e6253756762414149594167412b716b5a7963383130613269716f4453535a2f77426c746f2f4143713777584670634765336b4b7351417a624e7759446f4855646364694f61414456724a6f2f434772724737795379573072466e473073517077534f6d6341633435726a50684a7072576e686d34765a485a704e51754463454850413644723378585a334774734c4f51584e744538624c73667972674837334851674876533658617732576e5257317648356345513252726e4f4642774f66776f41755555555541464c69696967424b4b576b6f414b4f3946464146413238635775777a42522b2b67654d3539517763667a6170314d4c74734e354e757a3978704e702f4c414e564e58756862477a4b4b306c783536736b61444a5a656a2f6f33356b4372766d2b65676c524575625a786c53754d6a38447766304e4144785a322b442b35567339537733452f69615930554d4b2f386644776a303833414834484e526b5747666d67436e304d4a422f6c546c43352f30617a56542f66644e6748395451425876315734736f6f6b6c636d61346a5153734275474733456a4939464e5831554b67555a77426a6e72564e5a5264366b4657525a46737752497939504e5959782b43352f373646586141436969696742614b4b50776f41536969766e2f414f49586a2f786270766937556446743955614332676b2b517752694e74704149426247652b4f74414876747850466177505063537044436779306b6a42565565354e6342346c2b4d50686e5259474668634c71393252387364733379412f375439422b4754587a74714f7033757059463366334e797a4e3879764d7a2f6e6b6d71766c4c437042366e6f4b4150706e345758643534773054565045656f794c39766e752f4a673272386c756b574756564870754a4a3961363636747271654e727253646c766568735845442f635a752b3465762b304f534d56792f7752486b6541594c567475384d3078412f7742706d4838314e6478717a783246744c71545863566f734346705a4a76395755485a763645636a333655415a367936384a7843644d743258484d77754e696a2f674f436169764876476d537a38784a6275515a4e7462457173612f774236522f76626659594a7244384b664537536648476f5461665a585a7335567946526b4f2b5565714d65423334786d75323257656b574538345552777871303072395332426b7354314a774f706f413841316278394a34492b4b3839724377754e4b746f59724f36695142664d59444c4f423259466a6a3871396330507868346638526f447065715154502f7a7959374a422f774142626d766b37554c32585639617664546d623537715a37673768335a69522b6c5269507a477a76773436464f4d554166615051386969766c50512f696e3471384f4f74762f41476c4a6332364841697550336f78376275522b424665362b427669435047706b5347316a67654251307761546b357a3978526e6a703150656744754b4b5369674376663330476e57636c3163797048476e566e4f426e734b2b512f4645332f41425074516e74377837714b5335636965513879416b6e4a3631394e66456d79612b2b486574526f32313067383154366253442f41434272356a38523664467046326c684664435a746b636a507377446c6338653349363830415a3855697167437141657541436169754a585a6c546b44647a6e4171504c37386e6e36442b56575462454a6c786a75445142394a66434f36537a384761464b3771493556757265527a324b4f30696b2f6876726e664862613538522f433271367a424b396e346373464d746a616e68722f59666d6c663055444f3056642b44735547752f44753730753733474f432f634d46624232756f6247527941637344374531612b4d757477364c344c68304b30437850666b524b69444153424d5a2b672b36763530416563664348775a633633667a366e6d534f307465456c336c6633352b36526a6e4b416c76726756363538515045747a59664448573757396662716769573233714d435a5a4732695266596a646b646a6b656c63743842395a4c323271614849774c52737435467832623557483567666e566e3438583061614870476e74747a5063744b337273526638574835554165426252457a6c7541427836553172686b494233344a3639525669634b3879746b6263347a394b626454774e45565162736359365541567849584c6771583534794b2b67766770345a6974744a6b312b614d66616267744644496b755159754d67714f683344767a58694f67576e397058456b4a6c696a4372764d6b37375555444136386e754f42583052384c76446a364a7042757266567865324e2b676b38725951497051634e7450636359375a774b414f2f6f70614b414d627854382f68793968494253614d784e6b5a34595950343831386b367239387365544849554830782f774457723632385466384149436d2b712f7a72354a31582f6c722f414e64322f6b61414d637a4f534d48475053725379755967704a507a3479547a564772612f63482f4146306f4139342f5a2b6b59326576785a2b5153774f42376c5748394258492f4779396e6c386679784f2b5937654f4b4f4e66514664782f566a58562f732f66367278422f7651667965754d2b4e482f41435557392b6b502f6f746141462b4564334e423854394e6a6a62437a7779787944315861542f4d4374663436584d736e6a61317432624d55476e6f794c36466e596e2b512f4b734834552f386c5430582f646b2f7744526256736648442f6b66302f374230582f414b453141486c666d47545a45796772752f4774473567686874564b524c6b6e6b6e6d7374503841584a2f76567358332f48716c414768704869613674644d753950743757786957555a615a4950336e48624f6666307a3731395465484c4333307a7737703970616f5669574257414a7963734e7850356b3138666164392b622f645038712b79394d2f35424e6c2f313752662b674367433352525251422f2f32513d3de807d461002103aad5affbeee6118a91b914495f2bd0abffd0ac4782c2139a3ced0e353aa4ae4900463044022041123e82f809b41e566782a3f672ba78e7fead560a3cac5a0c2ce7738aefd41e02204af70a96b05b5e12b3503d41e106606ea5c57c0d754158165fcd14ee668c56b7",

		"01f0a8bf832ff02ee8bf0936db0666c9c1af7bc36ab57c747fe9bd2108902cc8f3000103aad5affbeee6118a91b914495f2bd0abffd0ac4782c2139a3ced0e353aa4ae49d07405ce040000bc047b22426f6479223a225c75303033636469765c75303033655c7530303363705c753030336554686973206973206120746573742e20486572655c75303032362333393b7320746865204b6c65696e20666f75722d67726f75703a5c7530303363696d67207372633d5c2268747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f7468756d622f392f39372f4b6c65696e5f666f75722d67726f75702533425f4361796c65795f7461626c652533425f73756267726f75705f6f665f53345f253238656c656d656e74735f302532433125324336253243372532392e7376672f32303070782d4b6c65696e5f666f75722d67726f75702533425f4361796c65795f7461626c652533425f73756267726f75705f6f665f53345f253238656c656d656e74735f302532433125324336253243372532392e7376672e706e675c2220616c743d5c227376672e706e675c225c7530303365205c75303033632f705c75303033655c7530303363705c75303033655c75303033636120687265663d5c2268747470733a2f2f656e2e77696b6970656469612e6f72672f77696b692f4b6c65696e5f666f75722d67726f75705c222072656c3d5c226e6f666f6c6c6f775c225c753030336568747470733a2f2f656e2e77696b6970656469612e6f72672f77696b692f4b6c65696e5f666f75722d67726f7570205c75303033632f615c75303033655c75303033632f705c75303033655c75303033632f6469765c7530303365227de807d46182bdd490cbb6e7a016002103aad5affbeee6118a91b914495f2bd0abffd0ac4782c2139a3ced0e353aa4ae49004630440220195f30b5afa46a8c854286a1bf4b3c484c0761c03dbbaf6658f05dfaadd421e702201359806b6d632d1fc9735d5f0652ecaf75767bb3d09f3873363143f60387890d",

		"019006717275a77fb150188e4522187065cfbc771ae47cf609f536956cb740df6f020102123085059a2f85bdd2e3e514b4aef0f3128652da20d40883cb2f70950c9a2be4c1ddeb170583020000f1017b22426f6479223a225c753030336368325c753030336541207461737465206f662066726565646f6d2063616e206d616b6520796f7520756e656d706c6f7961626c6520666f72206c6966655c753030336362725c75303033655c75303033632f68325c75303033655c75303033636469765c75303033655c7530303363696d67207372633d5c2268747470733a2f2f692e7974696d672e636f6d2f76692f35617665495a456c6d734d2f6d617872657364656661756c742e6a70675c2220616c743d5c226d617872657364656661756c742e6a70675c225c7530303365205c75303033632f6469765c7530303365227de807d461b189e7e9d7e8e99e16002102123085059a2f85bdd2e3e514b4aef0f3128652da20d40883cb2f70950c9a2be40046304402200ce37e660dfa13a9e6bb55a92f5522f43e01e9a8db662c94b54f7fde9aabefde0220531302c99524f744e669eb7742750857eeb766a07ee89a0fcebffef4335dd380",

		"01c8e71ed7bbc785fbb014ebbf21a45b411f28dbb1be528c1f72712f1bbd819fa8000102123085059a2f85bdd2e3e514b4aef0f3128652da20d40883cb2f70950c9a2be4ceaaeb1706f51a0008766c6164696d697200e31a646174613a696d6167652f6a7065673b6261736536342c2f396a2f327743454141674742676347425167484277634a4351674b4442514e4441734c44426b534577385548526f6648683061484277674a43346e49434973497877634b4463704c4441784e44513048796335505467795043347a4e44494243516b4a4441734d4741304e47444968484345794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d762f4141424549414573415a414d4249674143455145444551482f7841476941414142425145424151454241514141414141414141414141514944424155474277674a436773514141494241774d4342414d4642515145414141426651454341774145455155534954464242684e525951636963525179675a476843434e4373634556557448774a444e69636f494a4368595847426b614a53596e4b436b714e4455324e7a67354f6b4e4552555a4853456c4b55315256566c64595756706a5a47566d5a326870616e4e3064585a3365486c3667345346686f6549695971536b3553566c7065596d5a71696f36536c7071656f716171797337533174726534756272437738544678736649796372533039545631746659326472683475506b3565626e364f6e7138664c7a39505832392f6a352b674541417745424151454241514542415141414141414141414543417751464267634943516f4c455141434151494542414d454277554542414142416e6341415149444551514649544547456b4652423246784579497967516755517047687363454a497a4e53384256696374454b46695130345358784678675a4769596e4b436b714e5459334f446b3651305246526b644953557054564656575631685a576d4e6b5a575a6e61476c7163335231646e64346558714367345346686f6549695971536b3553566c7065596d5a71696f36536c7071656f71617179733753317472653475627243773854467873664979637253303954563174665932647269342b546c3575666f36657279382f5431397666342b66722f3267414d41774541416845444551412f41504438303544544f314f5470534b366a7761565430706e7255397243626935696858724977583836426f3662777234516b312b565a7271593231687577584179386d4f7577663150483172325052664450672f5372666246346468756d364e4c654d5a585035384438414b352f526f3067736f6767323844414136416442585132643742396f386e37516d2f70744a727a5a3469626c377578364650445135627a473674384e76436e694f316b2f7336322f73612b41796a524e6d4e6a3771655079785869586958773171666854552f73577077624759626f33427973712f336c5070587638414c6370417059796f75665671354834673278316a77704d585979535749382b4167357750346839434d2f6b4b306f346d584e797a366d6466435255584b4234715a4f4b694c356f592b394d4a7230447a6863304e77545463386970722b50794c32574c2b366636564e396246637235655968794b4d696d5a6f7a5645682f44546f786d676a3933546f686b564639446f55666551673731306e676d316a7539644964555a6f344864413534794d44383845317a593731712b4864554f6a3635615878424b5274687776557152672f7a714b6962673069714c536d6d396a313278674d396d4556796a5979434f745248514c6a7a2f41445074443767516435427a2f50485771396a716b4631494c2b336c64344a574f474b3753656534375630563365547459683765487a6e5567695064743344767a586c7136756a316c613130564e52307536613653534f59694d375142754b37654f54304f54557374764d746d304e367764586a5a584b6a2b457152302f4772756d616c4a65704a4a505a74417531514e357a7550394b77664632745132756936684e35717249497a46437537424c74787750624a2f4b7031756b74796e626c626c7365486e6a6a303470704e4b656e576d4531375a38384f4235725438524b453132354136664b662f4852575154576e34686666724d726735796b5a2f3841484257542f697839482b6876482b424c315835534d374e47615a6d6a507657706757796e2b6a4530747375564e5373762b676b303679584d5a72427939316e70716e2b38697649716763742b4e4f6a483361756162706c3571743662577774704c6963676b4a474d6e48716653756d58345a654b6f6a4573326e787846756f6534544b2f55416b6971636b747a434d4e55546544395245576d74424f7045586e4d71766a6a6e422f72585672625863397635746c6379507a38346a75504b782b50616f5044386567785742384c617578302f55726432594e4e494e73724e7a6c473645644f4436567a6b326f7757657358466c61547335686c614c664753466b77635a466364536b2b5a795231557138624b4c334f346a6a314f3274773933634d426e4152335279332f4167425843654c70497232385246473559304b6c76636e4a727576442b6c535879704e4f353873454576492b45583854785847654934625a64587649725734676e6a535674725179623132354f4d48765745564a53352b683079634a707762314f42754944412b436367394455445674586b4f3846652b4f4b647048672f584e64686561787374384b6e486d5049714b5437466a7a2b46656e436f6d727338657252635a57534d426a78567a56574c337537316a542f414e42464f316e5272375174516179314345527a716f6241594d47553943434f434b70334c6c354153663456483656567279545246375163583566715238305a4e4e7a526e33717a4d33594c64377132454d52547a484f46447571412f69534257705a364e6232635a2f74445662614a6765597263475a2f707867412f6a58506b354f505374337733706333695058725054496e43764f34566e592f6455444a5076674138566b6f4b327032564d544c6e7648533268332f41494f307a543757306c75744e467952636346376a415a73487342304761374270316d5569596c6d3735593830532b48786f5670486232323537574e51456475575564743376373944584e367a717161626154586330677847506b6a2f7648734b345a336c4a6e5a536b6c424f357a6e78415741616c7049756f4565315865485346747262636a7636342f437558306a7737724775582f2f41424b374b65544d6a415368534634353550544f4b7058577058477058472b6438675a32676e4f4d3831374838492f476c705a61524c6f326f794349514d30304d6836624479775066673950726975326e4677676b7a7a6130314f6f3549383238565776696d796e6a734e5a4e35354b6a3931356d566a59663750474b69384b7461616672476454684531724c47555a577a67636a6b456335474b2b705a4470327536566c6c6875374364417973774452794b5231482b4e654466466653744e304b37307550544c564c654e684c77766341726a2b5a71756c694533653548652b4664426d6d6975374c575761325935613345666d534165675966314661646c71467a4e644b746c617157414f576d4b694b41442b4841364848714d3135786233525268496b3677734477532b30316f326572726433506c586c2b493432484c42507645644d6e76584e557074367061486f554b385637736e7164623436304b665739434d376d4c37625949307165577077366457546e38783950657647584f534437563942364a4a466361636a4b356c2f684f57445a483172786e78543461766443316d346761306e2b796c79626558793232756e55594f4d635a77617644536573575a34324375706f352b6b707852676346534437696b326e30503556316e41614841596a72394b75326431505958554e31617974465043346b6a646571734f68716e4879546d704b676535394665472f47316e346c30574b376d6c696776455a596269497342686a774d5a366875333556795078566a305748534147486c616d307761336a6a66377939474c4c3041392f58474f39655a36456979612f5952754e794e637835553944387772582b4a6b7276342f31494d784954793158324777636671617a355065755770766c73637645635341383472566a6a456157383038544e62752b666b62617a41486b4139756e577379443775652b613648554f50446d6a34342f316e2f6f5272526b4830786f4d476e522b4372434853636d7746735049334e6b6c547a7966584a4f66657646766a59344f75365a45702f31646f5352365a632f345633587765755a7076682f50484a49575347376b534d482b46537174676669536678727a6a34754f7a654e63453543326b514874393430756f4938364c5a4f434f6c4b43696b4d565545486a4e4a363143354a3450536d467a313777566f63757257384d79615642645730772f312b7864716b443574782f684950623656662b4a576c36566f50684f4f4f794b322b705856796f6a6b684a517146423341592f6836412b7049394b58344e54534877753646323270645368567a774274552f7a4e637638565a704a4e547367376c68746b362f55437346424b65683054717555624d38372f747a56304a582b3037304563454764755031705037653166384136436c352f77422f322f787174666b2f616433646c42507561725a5072585263357a2f2f32513d3de807d461002102123085059a2f85bdd2e3e514b4aef0f3128652da20d40883cb2f70950c9a2be4004730450221008b352a6233e00b7ccfed62e40ab518b031f24ef2471bcee4b6a0c020d9c8c76602207e3a7ab017374854b3a0cfc34db7e9766a56e6d3a34f608e331cfb21582520c8",

		"011aa7e639a5c1c4f3923bdd5f36e0cc54c04bba68342de82e038cb212e7dc2e80020102123085059a2f85bdd2e3e514b4aef0f3128652da20d40883cb2f70950c9a2be494c0d72f06310000283c703e566c6164696d6972206861732066756e20706f7374696e67206e6577733c62723e3c2f703e00e807d461002102123085059a2f85bdd2e3e514b4aef0f3128652da20d40883cb2f70950c9a2be40046304402204aa9ab0a3e78524441609dfd9c0e028de0d9016a8d28fd54c3b55cbc2674db2002206e35dd4118449252967fa263e7e923015e39b168ae622d8625ce8f3051ef906b",

		"0141f58714ed013b1ee16e06dbe28b47f738ec159704269975a5dcbe0752138322010102397b1a80eba0a60644650af13c2a6ffdfbbf38830cafc34937a75ddd44b8ce52f7dfcfaa06054e00208c86eede87a561553c5672ada25cc0724938d7134de5f8e81040a3cf177480a21e7b22426f6479223a2266666666666666666666666666666666666666227d00d461f2b692b0ace797a116002102397b1a80eba0a60644650af13c2a6ffdfbbf38830cafc34937a75ddd44b8ce520046304402203cb2f4e486caf8bbc674781b976cb71f779da0cbe4d83b823eeaec1687e44c7f02200f78335ba3d4fee1625162ae71e224f84ca6e920c9989e25ad1f042dc88ab991",

		"0182d2f0b361e4f00161f81247bb27c173065a315b37c1b2a30dbb45b167c448e3000102397b1a80eba0a60644650af13c2a6ffdfbbf38830cafc34937a75ddd44b8ce52fbddcfaa06054100207eba2b76e2b1851070f2740e25c1c70c64a228e226f0dff5734f19d3baca8224117b22426f6479223a226c617777776c227d00d46180df88abc5e797a116002102397b1a80eba0a60644650af13c2a6ffdfbbf38830cafc34937a75ddd44b8ce5200473045022100bdd3b1348c8709c385a5ebbb7fda3f6ebd8fc368c8e95e2f7cdc1b0f6d00b4b002201e355fe9b04acd192b3e552eac667b7697d7c9913286ab8091b718a37e542308",

		"0147f91c232d725f915493355620709dd759ff8620452d2b145a17d6950cca4b38010102397b1a80eba0a60644650af13c2a6ffdfbbf38830cafc34937a75ddd44b8ce52dd80f8fa0506e71d000b43727970746f5472756d702f3c703e4920414d20544845204245535420504552534f4e204f4e205448495320504c4154464f524d2121213c2f703ea31d646174613a696d6167652f6a7065673b6261736536342c2f396a2f327743454141674742676347425167484277634a4351674b4442514e4441734c44426b534577385548526f6648683061484277674a43346e49434973497877634b4463704c4441784e44513048796335505467795043347a4e44494243516b4a4441734d4741304e47444968484345794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d6a49794d762f4141424549414751415a414d4249674143455145444551482f7841476941414142425145424151454241514141414141414141414141514944424155474277674a436773514141494241774d4342414d4642515145414141426651454341774145455155534954464242684e525951636963525179675a476843434e4373634556557448774a444e69636f494a4368595847426b614a53596e4b436b714e4455324e7a67354f6b4e4552555a4853456c4b55315256566c64595756706a5a47566d5a326870616e4e3064585a3365486c3667345346686f6549695971536b3553566c7065596d5a71696f36536c7071656f716171797337533174726534756272437738544678736649796372533039545631746659326472683475506b3565626e364f6e7138664c7a39505832392f6a352b674541417745424151454241514542415141414141414141414543417751464267634943516f4c455141434151494542414d454277554542414142416e6341415149444551514649544547456b4652423246784579497967516755517047687363454a497a4e53384256696374454b46695130345358784678675a4769596e4b436b714e5459334f446b3651305246526b644953557054564656575631685a576d4e6b5a575a6e61476c7163335231646e64346558714367345346686f6549695971536b3553566c7065596d5a71696f36536c7071656f71617179733753317472653475627243773854467873664979637253303954563174665932647269342b546c3575666f36657279382f5431397666342b66722f3267414d41774541416845444551412f414f692b4d5069582b7a644c743947743550333932664d6d414f4349683042396966304272784e726f7941687052763646683058324662587846316c6462386258313270486c4b5242486c7543715a476678362f6a57426257356c797952672b2b44696f6c4b37495553534f4568774e3252366e76567943324c6b63452f30716531302b5238626c7a5856615a6f6a4f46496a7839617a647a6f6843356957326d747838754165685061744b4c5357786e49493954585677364b45786e6731502f5a36727755552f685335724779676a6a704e4f38735a3446514e45454a36676a314f525858543251412b377a37566961685971716c6c47574866464371436c5254324d706f784b426a747a7a3142714a3430427943446a723378534e3573545a49497765445353346c2b5948424a344f4b3035726e504b6d346b7355757a47472b5850466574664432627a39456b5134506c79484848596976474a495a5558666a497a31577657506867386e3247354439474b6b66686b56634c6d556a3044416f7750536c78526a337261784a386777774d376c705474424f5170417961362f51744d2b314141634c363434726a596c437a446447514d392b4b377a5362703472634c4777585047514f61775453315a70474c62736a6654547257435256484c66537569302b4f4e59686852396177724333553757596b74366b354a72637470466a35504f4f657459637a6b7a73355646574e456846475770725252794a77617a376a5737464d52794d413550417752556158316934334c6468474842556d6d78786148584b4144672f685652376353416738357156376d4f515a527732546747677a4972424e347a744a7a6d736d624c597a4a64475275617248536f30626851635666625537627a6d426c36635a3756473135437a426b6c556a317a546a6447636d6e6f7a4f314b3152624d7156414937676331315077352f63466f54314959342f4556792b757a374c62654d594a4177666575693847466c31477763634b386367505074782f4c394b366f75364f476f724d394f41346f785551626755753456707a6f7a3557664e77303570775a376b69516c69547741525776706c7447484730644f4d314e66326b73576e736c735173684f30635a4f54314e50302b4d326b5563552f456f476135334b3650516c54355a58527078735647464f43505563556b75732f5a6c45666b504c4d352b564931334d7839753334303677635453685736567269326a57514d6971472f7659352f4f736c4b7a4b6b726e44333133346775575a5234595a6b50386254416e394b7a787032704759724e617952385a4731695150782f2f565870666b3344483547544872564339745a465a53386d543246564b55626145786a4b2b707a6d673239306c3669547a7533505139716c3854527a77334551686b6b546370425a6131724b46557651527a67302f57596c6c6e55594848576f586331656d68357264586a3238684d6e32356f6a3064454a42476670697569304856744e6d5a454e772b39683871797274592f6e5853573865457973616e334e52582b6d52586b5369346843674d47444b65515256707857706b34747655794e64496c736d57507363382f57756c30435a597276535931497a6c546a366a4e595637624567526a6c5467416a767a577034657335726a58496d4f504a74634e7a2f75344662306c7a5051354b2f75725539534536592b384b504f542b2b4b797830706136507178792f57456563724c495651424e3338594f4f6e4743507a724d6c6b616443374169524a43507771696e695951333777334a327779536c30596475324b747665326c7a644d4c5a6965686359774161382f37586b6575704b554c6b39764f384c3548424865756a7337337a6f3848466338792f506b437230475938484f5070536c7558485648524356554755775437316d617065724568643247515038414f4b55546c59386a705748715564334f4775493033694a6779702f65494e536d56796d70704a6b6e4a6c5a434f6334702b74544d6b443341552f4a676668584b32666950574c46705a6275785a494750794564562b6f7039783473754c6f78775232627949342b647359412f787254545968706e57576b6d4978774f6c4f7535564b383167615663797046484849434758672f30713764796c6b3436314679334571336c776937587a674b635a4e645a3459516d796c6c4947576647665841726c466745694a752f7668695055597276394e736d744e4e696a503373626a78334e642b4456356568354759797444314c426b7765744a357676556252746d6b387331363268345632654f7034664f735274634c7749474750553449712f64774c6150357139536356706174716b58674f3264627a5a4f4a326279496c487a6e312f41565731574b66374350744d4a696d43493749653251442f4931343034636b667a506f4d50506d6b794b326e38357335366442577a626a7a4f505431726c624363724c744a344a7270724f5651334c59394b354a486f775a64534d2b5946623776657035486941324c6a36656c56376f476359686b326e47633436566b7a3241747a766d315737436e37786a566344394b5564536d7a556131696c5678685366516e72564e374f4b493543716655656c557862366249344b2b495855676447565254477462555a4d5775795353486b624556686e2f50765776497262695a63614e4d68312b68715a347949386b6331485932386f634a4c634c4b765864747766787135644f7149514f6e63316c31427651302f444f6c513330725454676c6263676852305a7565746468494d566b65456f44466f6f6d624f626879347a2f6448412f6c57784a3372317350486c696a352f4679353576794b6a45687162754e4f6637314e72724f4b783832572b7233506a4c346a366663366951566e76496b57503841685350654d4b4b392f77444847682b666172714d532f63587935675037765a7677503647766d5051727a2b7a7466734c7739494c694f512f514d43612b306c45647842304478534c30504949492f77727a313730476d656e666b714a6f2b635a6f7a62546e726b486b56705756336e44416a4831726538622b465a4e4b757674454d5a617a632f492f58596637702f6f61344b5a70725a795559685431466356534469657054714a366f3941745a49356b2b384433344f4b5357304374754c6b44766e30726837445570625a3978636b64733130796131485043724e4b75635949724e4c716271535a6f2f32626179414f59304f6535417173326c787874694a4651483046527071614b7679754d65745176726c75736d412b653541717655624c61774e4143533350765459466c314f2f68735973683558326e483849376e38426d734b2b3851504e4b7363436b353448756670586f76677a773950706b4c582b6f4c69396d58416a50574a66512b35372b6c5852703838374935635458564f462b7031634d53515178777872694f4e51716a3041706b687a557537696f47363136305565424a3349474850536b775054394b632f7742377152394b622b4a72557a506a3448357858324e34467535623777506f74784f515a4874493978486641782f53766a67666648317237412b48502f4a5074442f3639457267702f437a30716e78493653356769757264345a34316b6963595a5747515258687669765372585464637562573356764b424741787a6a4e65374e3072786678332f77416a52646638422f6b4b552f684e6144393678773030616f53464655704352304a4658376e37782f4371456c656655305a337732497a4c4a356530534d4239616662707563416b6b66576f6a39327072582f41466c5a377330364550695741516547594c794a3357563777786b687363424e772f57765a506866346931447846345557665558575361462f4b4567474377413674366d76495046582f496c327638413245472f394669765376676e2f774169644c2f3138742f4956362b4753533037486a5976586675656c476f32342f4b704433706a663072704f4568666871626d6e5038416570745751662f5ae807d461002102397b1a80eba0a60644650af13c2a6ffdfbbf38830cafc34937a75ddd44b8ce520047304502210099eeee29c1a51b4de0b8bfe42977dc95d76c168e75df83f4faa401f37743bc3102201f6d4f9239754fa58d1e67f2db6f86cf0977b78e8dc6dc24449e4ffaec34d2cd",

		"0176af9a4ea8a9783249fbad57743ee9f12ff10e5a02bac7e40d397162b69549a9000102397b1a80eba0a60644650af13c2a6ffdfbbf38830cafc34937a75ddd44b8ce52c8fef7fa05055a0000497b22426f6479223a225c7530303363705c753030336554686973206973206120706f73742066726f6d207468652043727970746f5472756d705c75303033632f705c7530303365227df403d461d0e7f3a2a2fc97a116002102397b1a80eba0a60644650af13c2a6ffdfbbf38830cafc34937a75ddd44b8ce52004630440220151fb0af92ac4db9b3c0fcc35306df1c0f4e00c314802f8f7080b86ed6199f9502203c92d4e0ac33ee4981d1e8e1abb2dafea2e7cba4dccedc1d3cffaf919c5ccaa5",

		"014b161a70f82c0853ecbd42bf934e139eac1857675578f112c2ff3aa6ec5d9812020102397b1a80eba0a60644650af13c2a6ffdfbbf38830cafc34937a75ddd44b8ce52f581af5f06500000473c703e4920414d20544845204245535420504552534f4e204f4e205448495320504c4154464f524d21212120414e4f544845522050524f46494c4520555044415445213c2f703e00e807d461002102397b1a80eba0a60644650af13c2a6ffdfbbf38830cafc34937a75ddd44b8ce5200473045022100a5714789c19fbba22d8f5845ef8ffd53c48dd41995e283753ba0c67744b73cd2022026b806c5b756da02cbde6480888e9d88aeb83e6adf161cd2b0b21b23575f9454",

		"0147dc3c620db733240a309c01f501d0d01c21e7a5f795308dccc100b133869ec1000102397b1a80eba0a60644650af13c2a6ffdfbbf38830cafc34937a75ddd44b8ce52fafdae5f057c00006b7b22426f6479223a225c753030336368315c7530303365414e4f5448455220504f53545c75303033632f68315c75303033655c75303033636469765c7530303365486f775c75303032362333393b732074686973206f6e653f5c75303033632f6469765c7530303365227df403d461ea95c6f8d98198a116002102397b1a80eba0a60644650af13c2a6ffdfbbf38830cafc34937a75ddd44b8ce520046304402206d6335b5d7ecba50626411695f17955e523ea0d8ebec75c076aadbc95d6c439202203b3365c7c6ec5ab7565e64cdeae8f2b0a4932b7a1906339d55fd88d1db9afb9a",

		"013e42215a120a6e9d4848117f5829a2c4d9f692360fd14b78daea483a72d142dc000102397b1a80eba0a60644650af13c2a6ffdfbbf38830cafc34937a75ddd44b8ce52f9fbae5f054600203e42215a120a6e9d4848117f5829a2c4d9f692360fd14b78daea483a72d142dc167b22426f6479223a226666666666666666666666227d00d461a682a4f9f18198a116002102397b1a80eba0a60644650af13c2a6ffdfbbf38830cafc34937a75ddd44b8ce520046304402203ae6599a5b81e0c0a85cc5efbf008ed1e78a82c6152b2ad9127e10952faecbdd0220211475a8384c52d7a04781f7d704835e6ed8543a466551dd7c39187cecb714a0",
	}
	SeedBalances = []*DeSoOutput{}/* 482 elements not displayed */

	// In early blocks there was a bug that allowed users to claim usernames that
	// weren't actually available. This map defines exceptions for these cases that
	// assign a new username to the profile. It maps transaction hashes to new
	// usernames.
	ForgivenProfileUsernameClaims = map[BlockHash]string{
		*mustDecodeHexBlockHash("1f30c115192d72aa01149f08879db14158e66d859c1bd3bee3a2127cbd6f89fd"): "_nbatopshot",
		*mustDecodeHexBlockHash("8fe4f1ec5e5c53d610be773aa8e45680a3d7a55abf29aaab4e9ce2482e06c994"): "__nbatopshot",
		*mustDecodeHexBlockHash("3337781344dd5005541d028e8605bbc0851219d70b28d86a7f352877f3a1fde5"): "___nbatopshot",
		*mustDecodeHexBlockHash("5f52811f80c73764d887d7f82c6c233bb11da00a77dff11a85f7be851bd5745b"): "____nbatopshot",
		*mustDecodeHexBlockHash("02a3a9e28622b59ee59148847814deedb41b160c1edb5100b6964909351b4c04"): "_JulSwap",
	}
)
View Source
var (
	NaturalLogOfTwo = BigFloatLog(NewFloat().SetUint64(2))

	DeflationBombBlockRewardAdjustmentBlockHeight = uint32(32060)

	MiningSupplyIntervals = []*MiningSupplyIntervalStart{
		{
			StartBlockHeight: 0,
			BlockRewardNanos: 1 * NanosPerUnit,
		},

		{
			StartBlockHeight: DeflationBombBlockRewardAdjustmentBlockHeight,
			BlockRewardNanos: NanosPerUnit * 3 / 4,
		},
		{
			StartBlockHeight: DeflationBombBlockRewardAdjustmentBlockHeight + BlocksPerDay,
			BlockRewardNanos: NanosPerUnit / 2,
		},
		{
			StartBlockHeight: DeflationBombBlockRewardAdjustmentBlockHeight + 2*BlocksPerDay,
			BlockRewardNanos: NanosPerUnit / 4,
		},
		{
			StartBlockHeight: DeflationBombBlockRewardAdjustmentBlockHeight + 3*BlocksPerDay,
			BlockRewardNanos: NanosPerUnit / 8,
		},
		{
			StartBlockHeight: DeflationBombBlockRewardAdjustmentBlockHeight + 4*BlocksPerDay,
			BlockRewardNanos: NanosPerUnit / 10,
		},

		{
			StartBlockHeight: 15 * BlocksPerYear,
			BlockRewardNanos: NanosPerUnit / 20,
		},
		{
			StartBlockHeight: 32 * BlocksPerYear,
			BlockRewardNanos: 0,
		},
	}

	// This is used for various calculations but can be updated on the fly with a
	// special transaction type in the event that the Bitcoin price fluctuates
	// significantly. We make this a var rather than a const so that tests can
	// change the value.
	InitialUSDCentsPerBitcoinExchangeRate = uint64(3000000)
)
View Source
var DeSoMainnetParams = DeSoParams{
	NetworkType:        NetworkType_MAINNET,
	ProtocolVersion:    1,
	MinProtocolVersion: 1,
	UserAgent:          "Architect",
	DNSSeeds: []string{
		"deso.coinbase.com",
		"deso.gemini.com",
		"deso.kraken.com",
		"deso.bitstamp.com",
		"deso.bitfinex.com",
		"deso.binance.com",
		"deso.hbg.com",
		"deso.okex.com",
		"deso.bithumb.com",
		"deso.upbit.com",
	},
	DNSSeedGenerators: [][]string{
		{
			"deso-seed-",
			".io",
		},
	},

	GenesisBlock:        &GenesisBlock,
	GenesisBlockHashHex: GenesisBlockHashHex,

	MinDifficultyTargetHex: "000001FFFF000000000000000000000000000000000000000000000000000000",

	MinChainWorkHex: "000000000000000000000000000000000000000000000000006314f9a85a949b",

	MaxTipAge: 24 * time.Hour,

	BitcoinBtcdParams:  &chaincfg.MainNetParams,
	BitcoinBurnAddress: "1PuXkbwqqwzEYo9SPGyAihAge3e9Lc71b",

	BitcoinStartBlockNode: NewBlockNode(
		nil,
		mustDecodeHexBlockHashBitcoin("000000000000000000092d577cc673bede24b6d7199ee69c67eeb46c18fc978c"),

		653184,
		_difficultyBitsToHash(386798414),

		big.NewInt(0),

		&MsgDeSoHeader{
			TstampSecs: 1602950620,
			Height:     0,
		},
		StatusBitcoinHeaderValidated,
	),

	BitcoinExchangeFeeBasisPoints: 10,
	BitcoinDoubleSpendWaitSeconds: 5.0,
	DeSoNanosPurchasedAtGenesis:   uint64(6000000000000000),
	DefaultSocketPort:             uint16(17000),
	DefaultJSONPort:               uint16(17001),

	DialTimeout:               30 * time.Second,
	VersionNegotiationTimeout: 30 * time.Second,

	BlockRewardMaturity: time.Hour * 3,

	V1DifficultyAdjustmentFactor: 10,

	TimeBetweenBlocks: 5 * time.Minute,

	TimeBetweenDifficultyRetargets: 24 * time.Hour,

	MaxDifficultyRetargetFactor: 4,
	Base58PrefixPublicKey:       [3]byte{0xcd, 0x14, 0x0},
	Base58PrefixPrivateKey:      [3]byte{0x35, 0x0, 0x0},

	MaxTstampOffsetSeconds: 2 * 60 * 60,

	MaxBlockSizeBytes: 16000000,

	MinerMaxBlockSizeBytes: 2000000,

	MiningIterationsPerCycle: 95000,

	MaxUsernameLengthBytes: MaxUsernameLengthBytes,

	MaxUserDescriptionLengthBytes: 20000,

	MaxProfilePicLengthBytes: 20000,
	MaxProfilePicDimensions:  100,

	MaxPrivateMessageLengthBytes: 10000,

	StakeFeeBasisPoints: 10 * 100,

	MaxPostBodyLengthBytes: 20000,
	MaxPostSubLengthBytes:  140,

	MaxStakeMultipleBasisPoints: 10 * 100 * 100,

	MaxCreatorBasisPoints:    100 * 100,
	MaxNFTRoyaltyBasisPoints: 100 * 100,
	ParamUpdaterPublicKeys:   ParamUpdaterPublicKeys,

	SeedTxns: SeedTxns,

	SeedBalances: SeedBalances,

	CreatorCoinTradeFeeBasisPoints: 1,

	CreatorCoinSlope:        NewFloat().SetFloat64(0.003),
	CreatorCoinReserveRatio: NewFloat().SetFloat64(0.3333333),

	CreatorCoinAutoSellThresholdNanos: uint64(10),

	DeflationBombBlockHeight: 33783,
}

DeSoMainnetParams defines the DeSo parameters for the mainnet.

View Source
var DeSoTestnetParams = DeSoParams{
	NetworkType:        NetworkType_TESTNET,
	ProtocolVersion:    0,
	MinProtocolVersion: 0,
	UserAgent:          "Architect",
	DNSSeeds: []string{
		"dorsey.bitclout.com",
	},
	DNSSeedGenerators: [][]string{},

	BitcoinBtcdParams:             &chaincfg.TestNet3Params,
	BitcoinBurnAddress:            "mhziDsPWSMwUqvZkVdKY92CjesziGP3wHL",
	BitcoinExchangeFeeBasisPoints: 10,
	BitcoinDoubleSpendWaitSeconds: 5.0,
	DeSoNanosPurchasedAtGenesis:   uint64(6000000000000000),

	BitcoinStartBlockNode: NewBlockNode(
		nil,
		mustDecodeHexBlockHashBitcoin("000000000000003aae8fb976056413aa1d863eb5bee381ff16c9642283b1da1a"),
		1897056,
		_difficultyBitsToHash(424073553),

		big.NewInt(0),

		&MsgDeSoHeader{
			TstampSecs: 1607659152,
			Height:     0,
		},
		StatusBitcoinHeaderValidated,
	),

	DefaultSocketPort: uint16(18000),
	DefaultJSONPort:   uint16(18001),

	DialTimeout:               30 * time.Second,
	VersionNegotiationTimeout: 30 * time.Second,

	GenesisBlock:        &GenesisBlock,
	GenesisBlockHashHex: GenesisBlockHashHex,

	TimeBetweenBlocks: 1 * time.Minute,

	TimeBetweenDifficultyRetargets: 3 * time.Minute,

	MinDifficultyTargetHex: "0090000000000000000000000000000000000000000000000000000000000000",

	MinChainWorkHex: "0000000000000000000000000000000000000000000000000000000000000000",

	MaxTipAge: time.Hour * 24,

	MaxDifficultyRetargetFactor: 2,

	BlockRewardMaturity: 5 * time.Minute,

	V1DifficultyAdjustmentFactor: 10,

	MaxTstampOffsetSeconds: 2 * 60 * 60,

	MaxBlockSizeBytes: 1000000,

	MinerMaxBlockSizeBytes: 1000000,

	Base58PrefixPublicKey:  [3]byte{0x11, 0xc2, 0x0},
	Base58PrefixPrivateKey: [3]byte{0x4f, 0x6, 0x1b},

	MiningIterationsPerCycle: 9500,

	MaxUsernameLengthBytes: MaxUsernameLengthBytes,

	MaxUserDescriptionLengthBytes: 20000,

	MaxProfilePicLengthBytes: 20000,
	MaxProfilePicDimensions:  100,

	MaxPrivateMessageLengthBytes: 10000,

	StakeFeeBasisPoints: 5 * 100,

	MaxPostBodyLengthBytes: 50000,
	MaxPostSubLengthBytes:  140,

	MaxStakeMultipleBasisPoints: 10 * 100 * 100,

	MaxCreatorBasisPoints:    100 * 100,
	MaxNFTRoyaltyBasisPoints: 100 * 100,
	ParamUpdaterPublicKeys:   ParamUpdaterPublicKeys,

	SeedTxns: TestSeedTxns,

	SeedBalances: SeedBalances,

	CreatorCoinTradeFeeBasisPoints: 1,

	CreatorCoinSlope:        NewFloat().SetFloat64(0.003),
	CreatorCoinReserveRatio: NewFloat().SetFloat64(0.3333333),

	CreatorCoinAutoSellThresholdNanos: uint64(10),
}

DeSoTestnetParams defines the DeSo parameters for the testnet.

View Source
var (
	InitialGlobalParamsEntry = GlobalParamsEntry{

		USDCentsPerBitcoin: 0,

		MinimumNetworkFeeNanosPerKB: 0,

		CreateProfileFeeNanos: 0,

		CreateNFTFeeNanos: 0,
		MaxCopiesPerNFT:   0,
	}
)

InitialGlobalParamsEntry to be used before ParamUpdater creates the first update.

View Source
var (
	// "false" is used as a hack to indicate that an account should have a blue check mark.
	IsReserved = map[string]bool{}/* 14113 elements not displayed */

)
View Source
var MaxBitcoinHeadersPerMsg = uint32(2000)

MaxBitcoinHeadersPerMsg is the maximum number of headers Bitcoin allows in a getheaders response. It is used to determine whether a node has more headers to give us.

View Source
var MaxBlockRewardDataSizeBytes = 250

MaxBlockRewardDataSizeBytes is the maximum size allowed for a BLOCK_REWARD's ExtraData field.

View Source
var MaxHeadersPerMsg = uint32(2000)

MaxHeadersPerMsg is the maximum numbers allowed in a GetHeaders response.

View Source
var NODES = map[uint64]DeSoNode{
	1: {
		Name:  "DeSo",
		URL:   "https://node.deso.org",
		Owner: "diamondhands",
	},
	2: {
		Name:  "BitClout",
		URL:   "https://bitclout.com",
		Owner: "diamondhands",
	},
	3: {
		Name:  "Diamond",
		URL:   "https://diamondapp.com",
		Owner: "Zordon",
	},
	4: {
		Name:  "CloutFeed",
		URL:   "https://apps.apple.com/app/id1561532815",
		Owner: "Ribal",
	},
	5: {
		Name:  "Flick",
		URL:   "https://flickapp.com",
		Owner: "nigeleccles",
	},
	6: {
		Name:  "tijn's club",
		URL:   "https://tijn.club",
		Owner: "tijn",
	},
	7: {
		Name:  "Nacho Average",
		URL:   "https://nachoaverage.com/",
		Owner: "ClayPerryMusic",
	},
	8: {
		Name:  "love4src",
		URL:   "https://love4src.com",
		Owner: "kanshi",
	},
	9: {
		Name:  "Supernovas",
		URL:   "https://supernovas.app",
		Owner: "fransarthur",
	},
	10: {
		Name:  "GiftClout",
		URL:   "https://members.giftclout.com",
		Owner: "RajLahoti",
	},
	11: {
		Name:  "DeSocialWorld",
		URL:   "https://desocialworld.com",
		Owner: "edokoevoet",
	},
	12: {
		Name:  "NFTz",
		URL:   "https://nftz.zone",
		Owner: "mvanhalen",
	},
	13: {
		Name:  "Cloutible",
		URL:   "https://cloutible.club",
		Owner: "DawaynePerza",
	},
	14: {
		Name:  "Agbegbe",
		URL:   "https://agbegbe.org",
		Owner: "TheParkerazzi",
	},
	15: {
		Name:  "CloutingAround",
		URL:   "https://cloutingaround.dev",
		Owner: "TheParkerazzi",
	},
	16: {
		Name:  "MediaTech",
		URL:   "https://deso.mediatech.ventures",
		Owner: "paulobrien",
	},
	17: {
		Name:  "Mousai",
		URL:   "https://deso.mousai.stream",
		Owner: "marlonjm2k",
	},
	18: {
		Name:  "KoalaTBooks",
		URL:   "https://koalatbooks.com",
		Owner: "chriscelaya",
	},
	19: {
		Name:  "Beyond",
		URL:   "https://beyond.restartu.org",
		Owner: "RestartU",
	},
	20: {
		Name:  "DeverSo",
		URL:   "https://deverso.io/",
		Owner: "Nordian",
	},
	21: {
		Name:  "NinjaNode",
		URL:   "https://node.bitcloutapps.ninja",
		Owner: "mattpitts",
	},
}
View Source
var (
	PostExtraDataConsensusKeys = [2]string{RepostedPostHash, IsQuotedRepostKey}
)

Defines values that may exist in a transaction's ExtraData map

Functions

func Add

func Add(a *big.Float, b *big.Float) *big.Float

func Base58CheckDecode

func Base58CheckDecode(input string) (_result []byte, _prefix []byte, _err error)

func Base58CheckDecodePrefix

func Base58CheckDecodePrefix(input string, prefixLen int) (_result []byte, _prefix []byte, _err error)

func Base58CheckEncode

func Base58CheckEncode(input []byte, isPrivate bool, params *DeSoParams) string

func Base58CheckEncodeWithPrefix

func Base58CheckEncodeWithPrefix(input []byte, prefix [3]byte) string

func BigFloatExp

func BigFloatExp(z *big.Float) *big.Float

Exp returns a big.Float representation of exp(z).

func BigFloatExpMulti

func BigFloatExpMulti(hi, lo *big.Float, k int64) *big.Float

func BigFloatLog

func BigFloatLog(x *big.Float) *big.Float

Log returns the natural logarithm of x.

func BigFloatLog2

func BigFloatLog2(x *big.Float) *big.Float

Log2 returns the binary logarithm of x. The special cases are the same as for Log.

func BigFloatPow

func BigFloatPow(z *big.Float, w *big.Float) *big.Float

Pow returns a big.Float representation of z**w.

func BigintToBytes

func BigintToBytes(bigint *big.Int) []byte

func BlockCypherCheckBitcoinDoubleSpend

func BlockCypherCheckBitcoinDoubleSpend(txnHash *chainhash.Hash, blockCypherAPIKey string, params *DeSoParams) (
	_isDoubleSpend bool, _err error)

func BlockCypherPushAndWaitForTxn

func BlockCypherPushAndWaitForTxn(txnHex string, txnHash *chainhash.Hash,
	blockCypherAPIKey string, doubleSpendWaitSeconds float64, params *DeSoParams) (_isDoubleSpend bool, _err error)

func BlockCypherPushTransaction

func BlockCypherPushTransaction(txnHex string, txnHash *chainhash.Hash, blockCypherAPIKey string, params *DeSoParams) (
	_added bool, _err error)

func BlockHashToBlockKey

func BlockHashToBlockKey(blockHash *BlockHash) []byte

func BlockchainInfoCheckBitcoinDoubleSpend added in v1.2.3

func BlockchainInfoCheckBitcoinDoubleSpend(txnHash *chainhash.Hash, blockCypherAPIKey string, params *DeSoParams) (
	_isDoubleSpend bool, _err error)

func BlockonomicsCheckRBF

func BlockonomicsCheckRBF(bitcoinTxnHash string) (
	_hasRBF bool, _err error)

func BlocksPerDuration

func BlocksPerDuration(duration time.Duration, timeBetweenBlocks time.Duration) uint32

func BoolToByte

func BoolToByte(val bool) byte

func BytesToBigint

func BytesToBigint(bb []byte) *big.Int

func CalcBlockRewardNanos

func CalcBlockRewardNanos(blockHeight uint32) uint64

CalcBlockRewardNanos computes the block reward for a given block height.

func CalcNanosToCreate

func CalcNanosToCreate(
	startNanos uint64, satoshisToBurn uint64, usdCentsPerBitcoinExchangeRate uint64) (
	_nanosToCreate uint64)

func CalculateCreatorCoinToMint

func CalculateCreatorCoinToMint(
	desoToSellNanos uint64,
	coinsInCirculationNanos uint64, desoLockedNanos uint64,
	params *DeSoParams) uint64

func CalculateCreatorCoinToMintBancor

func CalculateCreatorCoinToMintBancor(
	deltaDeSoNanos uint64, currentCreatorCoinSupplyNanos uint64,
	currentDeSoLockedNanos uint64, params *DeSoParams) uint64

func CalculateCreatorCoinToMintPolynomial

func CalculateCreatorCoinToMintPolynomial(
	deltaDeSoNanos uint64, currentCreatorCoinSupplyNanos uint64, params *DeSoParams) uint64

func CalculateDeSoToReturn

func CalculateDeSoToReturn(
	deltaCreatorCoinNanos uint64, currentCreatorCoinSupplyNanos uint64,
	currentDeSoLockedNanos uint64, params *DeSoParams) uint64

func CheckBitcoinDoubleSpend added in v1.2.9

func CheckBitcoinDoubleSpend(txnHash *chainhash.Hash, blockCypherAPIKey string, params *DeSoParams) error

func CheckTransactionSanity

func CheckTransactionSanity(txn *MsgDeSoTxn) error

func ComputeKeysFromSeed

func ComputeKeysFromSeed(seedBytes []byte, index uint32, params *DeSoParams) (_pubKey *btcec.PublicKey, _privKey *btcec.PrivateKey, _btcAddress string, _err error)

func ComputeKeysFromSeedWithNet

func ComputeKeysFromSeedWithNet(seedBytes []byte, index uint32, isTestnet bool) (_pubKey *btcec.PublicKey, _privKey *btcec.PrivateKey, _btcAddress string, _err error)

func ComputeMerkleRoot

func ComputeMerkleRoot(txns []*MsgDeSoTxn) (_merkle *BlockHash, _txHashes []*BlockHash, _err error)

func CreateBitcoinSpendTransaction

func CreateBitcoinSpendTransaction(
	spendAmountSatoshis uint64, feeRateSatoshisPerKB uint64,
	pubKey *btcec.PublicKey,
	recipientAddrString string, params *DeSoParams,
	utxoSource func(addr string, params *DeSoParams) ([]*BitcoinUtxo, error)) (_txn *wire.MsgTx, _totalInput uint64, _fee uint64, _unsignedHashes []string, _err error)

func CreateUnsignedBitcoinSpendTransaction

func CreateUnsignedBitcoinSpendTransaction(
	spendAmountSatoshis uint64,
	feeRateSatoshisPerKB uint64,
	spendAddrString string,
	recipientAddrString string,
	params *DeSoParams,
	utxoSource func(addr string, params *DeSoParams) ([]*BitcoinUtxo, error)) (
	_txn *wire.MsgTx, _totalInput uint64, _fee uint64, _err error)

func DBCheckTxnExistenceWithTxn

func DBCheckTxnExistenceWithTxn(txn *badger.Txn, txID *BlockHash) bool

func DBDeleteAcceptedNFTBidEntriesMappingsWithTxn

func DBDeleteAcceptedNFTBidEntriesMappingsWithTxn(txn *badger.Txn, nftPostHash *BlockHash, serialNumber uint64) error

func DBDeleteAcceptedNFTBidMappings

func DBDeleteAcceptedNFTBidMappings(
	handle *badger.DB, postHash *BlockHash, serialNumber uint64) error

func DBDeleteCreatorCoinBalanceEntryMappings

func DBDeleteCreatorCoinBalanceEntryMappings(
	handle *badger.DB, hodlerPKID *PKID, creatorPKID *PKID,
	params *DeSoParams) error

func DBDeleteCreatorCoinBalanceEntryMappingsWithTxn

func DBDeleteCreatorCoinBalanceEntryMappingsWithTxn(
	txn *badger.Txn, hodlerPKID *PKID, creatorPKID *PKID,
	params *DeSoParams) error

func DBDeleteDerivedKeyMapping

func DBDeleteDerivedKeyMapping(
	handle *badger.DB, ownerPublicKey PublicKey, derivedPublicKey PublicKey) error

func DBDeleteDerivedKeyMappingWithTxn

func DBDeleteDerivedKeyMappingWithTxn(
	txn *badger.Txn, ownerPublicKey PublicKey, derivedPublicKey PublicKey) error

func DBDeleteNFTBidMappings

func DBDeleteNFTBidMappings(handle *badger.DB, nftBidKey *NFTBidKey) error

func DBDeleteNFTBidMappingsWithTxn

func DBDeleteNFTBidMappingsWithTxn(txn *badger.Txn, nftBidKey *NFTBidKey) error

func DBDeleteNFTMappings

func DBDeleteNFTMappings(
	handle *badger.DB, postHash *BlockHash, serialNumber uint64) error

func DBDeleteNFTMappingsWithTxn

func DBDeleteNFTMappingsWithTxn(txn *badger.Txn, nftPostHash *BlockHash, serialNumber uint64) error

func DBDeletePKIDMappingsWithTxn

func DBDeletePKIDMappingsWithTxn(
	txn *badger.Txn, publicKey []byte, params *DeSoParams) error

func DBDeletePostEntryMappings

func DBDeletePostEntryMappings(
	handle *badger.DB, postHash *BlockHash, params *DeSoParams) error

func DBDeletePostEntryMappingsWithTxn

func DBDeletePostEntryMappingsWithTxn(
	txn *badger.Txn, postHash *BlockHash, params *DeSoParams) error

func DBDeleteProfileEntryMappings

func DBDeleteProfileEntryMappings(
	handle *badger.DB, pkid *PKID, params *DeSoParams) error

func DBDeleteProfileEntryMappingsWithTxn

func DBDeleteProfileEntryMappingsWithTxn(
	txn *badger.Txn, pkid *PKID, params *DeSoParams) error

func DBGetAcceptedNFTBidEntriesByPostHashSerialNumber

func DBGetAcceptedNFTBidEntriesByPostHashSerialNumber(db *badger.DB, postHash *BlockHash, serialNumber uint64) *[]*NFTBidEntry

func DBGetAcceptedNFTBidEntriesByPostHashSerialNumberWithTxn

func DBGetAcceptedNFTBidEntriesByPostHashSerialNumberWithTxn(
	txn *badger.Txn, postHash *BlockHash, serialNumber uint64) *[]*NFTBidEntry

func DBGetAllPostsAndCommentsForPublicKeyOrderedByTimestamp

func DBGetAllPostsAndCommentsForPublicKeyOrderedByTimestamp(
	handle *badger.DB, publicKey []byte, fetchEntries bool, minTimestampNanos uint64, maxTimestampNanos uint64) (
	_tstamps []uint64, _postAndCommentHashes []*BlockHash, _postAndCommentEntries []*PostEntry, _err error)

Specifying minTimestampNanos gives you all posts after minTimestampNanos Pass minTimestampNanos = 0 && maxTimestampNanos = 0 if you want all posts Setting maxTimestampNanos = 0, will default maxTimestampNanos to the current time.

func DBGetAllPostsByTstamp

func DBGetAllPostsByTstamp(handle *badger.DB, fetchEntries bool) (
	_tstamps []uint64, _postHashes []*BlockHash, _postEntries []*PostEntry, _err error)

DBGetAllPostsByTstamp returns all the posts in the db with the newest posts first.

TODO(performance): This currently fetches all posts. We should implement some kind of pagination instead though.

func DBGetAllProfilesByCoinValue

func DBGetAllProfilesByCoinValue(handle *badger.DB, fetchEntries bool) (
	_lockedDeSoNanos []uint64, _profilePublicKeys []*PKID,
	_profileEntries []*ProfileEntry, _err error)

DBGetAllProfilesByCoinValue returns all the profiles in the db with the highest coin values first.

TODO(performance): This currently fetches all profiles. We should implement some kind of pagination instead though.

func DBGetCommentPostHashesForParentStakeID

func DBGetCommentPostHashesForParentStakeID(
	handle *badger.DB, stakeIDXXX []byte, fetchEntries bool) (
	_tstamps []uint64, _commentPostHashes []*BlockHash, _commentPostEntryes []*PostEntry, _err error)

DBGetCommentPostHashesForParentStakeID returns all the comments, which are indexed by their stake ID rather than by their timestamp.

TODO(performance): This currently fetches all comments. We should implement something where we only get the comments for particular posts instead.

func DBGetPaginatedKeysAndValuesForPrefix

func DBGetPaginatedKeysAndValuesForPrefix(
	db *badger.DB, startPrefix []byte, validForPrefix []byte,
	keyLen int, numToFetch int, reverse bool, fetchValues bool) (
	_keysFound [][]byte, _valsFound [][]byte, _err error)

func DBGetPaginatedKeysAndValuesForPrefixWithTxn

func DBGetPaginatedKeysAndValuesForPrefixWithTxn(
	dbTxn *badger.Txn, startPrefix []byte, validForPrefix []byte,
	maxKeyLen int, numToFetch int, reverse bool, fetchValues bool) (

	_keysFound [][]byte, _valsFound [][]byte, _err error)

startPrefix specifies a point in the DB at which the iteration should start. It doesn't have to map to an exact key because badger will just binary search and start right before/after that location.

validForPrefix helps determine when the iteration should stop. The iteration stops at the last entry that has this prefix. Setting it to an empty byte string would cause the iteration to seek to the beginning of the db, whereas setting it to one of the _Prefix bytes would cause the iteration to stop at the last entry with that prefix.

maxKeyLen is required so we can pad the key with FF in the case the user wants to seek backwards. This is required due to a quirk of badgerdb. It is ignored if reverse == false.

numToFetch specifies the number of entries to fetch. If set to zero then it fetches all entries that match the validForPrefix passed in.

func DBGetPaginatedPostsOrderedByTime

func DBGetPaginatedPostsOrderedByTime(
	db *badger.DB, startPostTimestampNanos uint64, startPostHash *BlockHash,
	numToFetch int, fetchPostEntries bool, reverse bool) (
	_postHashes []*BlockHash, _tstampNanos []uint64, _postEntries []*PostEntry,
	_err error)

func DBGetPublicKeyForPKID

func DBGetPublicKeyForPKID(db *badger.DB, pkidd *PKID) []byte

func DBGetPublicKeyForPKIDWithTxn

func DBGetPublicKeyForPKIDWithTxn(txn *badger.Txn, pkidd *PKID) []byte

func DBPutAcceptedNFTBidEntriesMapping

func DBPutAcceptedNFTBidEntriesMapping(handle *badger.DB, nftKey NFTKey, nftBidEntries *[]*NFTBidEntry) error

func DBPutAcceptedNFTBidEntriesMappingWithTxn

func DBPutAcceptedNFTBidEntriesMappingWithTxn(txn *badger.Txn, nftKey NFTKey, nftBidEntries *[]*NFTBidEntry) error

func DBPutCreatorCoinBalanceEntryMappings

func DBPutCreatorCoinBalanceEntryMappings(
	handle *badger.DB, balanceEntry *BalanceEntry, params *DeSoParams) error

func DBPutCreatorCoinBalanceEntryMappingsWithTxn

func DBPutCreatorCoinBalanceEntryMappingsWithTxn(
	txn *badger.Txn, balanceEntry *BalanceEntry,
	params *DeSoParams) error

func DBPutDerivedKeyMapping

func DBPutDerivedKeyMapping(
	handle *badger.DB, ownerPublicKey PublicKey, derivedPublicKey PublicKey, derivedKeyEntry *DerivedKeyEntry) error

func DBPutDerivedKeyMappingWithTxn

func DBPutDerivedKeyMappingWithTxn(
	txn *badger.Txn, ownerPublicKey PublicKey, derivedPublicKey PublicKey, derivedKeyEntry *DerivedKeyEntry) error

func DBPutNFTBidEntryMappings

func DBPutNFTBidEntryMappings(handle *badger.DB, nftEntry *NFTBidEntry) error

func DBPutNFTBidEntryMappingsWithTxn

func DBPutNFTBidEntryMappingsWithTxn(txn *badger.Txn, nftBidEntry *NFTBidEntry) error

func DBPutNFTEntryMappings

func DBPutNFTEntryMappings(handle *badger.DB, nftEntry *NFTEntry) error

func DBPutNFTEntryMappingsWithTxn

func DBPutNFTEntryMappingsWithTxn(txn *badger.Txn, nftEntry *NFTEntry) error

func DBPutPKIDMappingsWithTxn

func DBPutPKIDMappingsWithTxn(
	txn *badger.Txn, publicKey []byte, pkidEntry *PKIDEntry, params *DeSoParams) error

func DBPutPostEntryMappings

func DBPutPostEntryMappings(handle *badger.DB, postEntry *PostEntry, params *DeSoParams) error

func DBPutPostEntryMappingsWithTxn

func DBPutPostEntryMappingsWithTxn(
	txn *badger.Txn, postEntry *PostEntry, params *DeSoParams) error

func DBPutProfileEntryMappings

func DBPutProfileEntryMappings(
	handle *badger.DB, profileEntry *ProfileEntry, pkid *PKID, params *DeSoParams) error

func DBPutProfileEntryMappingsWithTxn

func DBPutProfileEntryMappingsWithTxn(
	txn *badger.Txn, profileEntry *ProfileEntry, pkid *PKID, params *DeSoParams) error

func DbBufForUtxoKey

func DbBufForUtxoKey(utxoKey *UtxoKey) []byte

func DbBulkDeleteHeightHashToNodeInfo

func DbBulkDeleteHeightHashToNodeInfo(
	nodes []*BlockNode, handle *badger.DB, bitcoinNodes bool) error

func DbCheckTxnExistence

func DbCheckTxnExistence(handle *badger.DB, txID *BlockHash) bool

func DbDeleteAllMempoolTxns

func DbDeleteAllMempoolTxns(handle *badger.DB) error

func DbDeleteAllMempoolTxnsWithTxn

func DbDeleteAllMempoolTxnsWithTxn(txn *badger.Txn) error

func DbDeleteBitcoinBurnTxIDWithTxn

func DbDeleteBitcoinBurnTxIDWithTxn(txn *badger.Txn, bitcoinBurnTxID *BlockHash) error

func DbDeleteDiamondMappings

func DbDeleteDiamondMappings(handle *badger.DB, diamondEntry *DiamondEntry) error

func DbDeleteDiamondMappingsWithTxn

func DbDeleteDiamondMappingsWithTxn(txn *badger.Txn, diamondEntry *DiamondEntry) error

func DbDeleteFollowMappings

func DbDeleteFollowMappings(
	handle *badger.DB, followerPKID *PKID, followedPKID *PKID) error

func DbDeleteFollowMappingsWithTxn

func DbDeleteFollowMappingsWithTxn(
	txn *badger.Txn, followerPKID *PKID, followedPKID *PKID) error

Note this deletes the follow for the follower *and* followed since a mapping should exist for each.

func DbDeleteForbiddenBlockSignaturePubKey

func DbDeleteForbiddenBlockSignaturePubKey(handle *badger.DB, publicKey []byte) error

func DbDeleteForbiddenBlockSignaturePubKeyWithTxn

func DbDeleteForbiddenBlockSignaturePubKeyWithTxn(txn *badger.Txn, publicKey []byte) error

func DbDeleteHeightHashToNodeInfoWithTxn

func DbDeleteHeightHashToNodeInfoWithTxn(
	node *BlockNode, txn *badger.Txn, bitcoinNodes bool) error

func DbDeleteLikeMappings

func DbDeleteLikeMappings(
	handle *badger.DB, userPubKey []byte, likedPostHash BlockHash) error

func DbDeleteLikeMappingsWithTxn

func DbDeleteLikeMappingsWithTxn(
	txn *badger.Txn, userPubKey []byte, likedPostHash BlockHash) error

Note this deletes the like for the user *and* the liked post since a mapping should exist for each.

func DbDeleteMempoolTxn

func DbDeleteMempoolTxn(handle *badger.DB, mempoolTx *MempoolTx) error

func DbDeleteMempoolTxnKey

func DbDeleteMempoolTxnKey(handle *badger.DB, txnKey []byte) error

func DbDeleteMempoolTxnKeyWithTxn

func DbDeleteMempoolTxnKeyWithTxn(txn *badger.Txn, txnKey []byte) error

func DbDeleteMempoolTxnWithTxn

func DbDeleteMempoolTxnWithTxn(txn *badger.Txn, mempoolTx *MempoolTx) error

func DbDeleteMessageEntryMappings

func DbDeleteMessageEntryMappings(handle *badger.DB, publicKey []byte, tstampNanos uint64) error

func DbDeleteMessageEntryMappingsWithTxn

func DbDeleteMessageEntryMappingsWithTxn(
	txn *badger.Txn, publicKey []byte, tstampNanos uint64) error

Note this deletes the message for the sender *and* receiver since a mapping should exist for each.

func DbDeletePublicKeyToDeSoBalance

func DbDeletePublicKeyToDeSoBalance(handle *badger.DB, publicKey []byte) error

func DbDeletePublicKeyToDeSoBalanceWithTxn

func DbDeletePublicKeyToDeSoBalanceWithTxn(txn *badger.Txn, publicKey []byte) error

func DbDeleteRepostMappings

func DbDeleteRepostMappings(
	handle *badger.DB, userPubKey []byte, repostedPostHash BlockHash) error

func DbDeleteRepostMappingsWithTxn

func DbDeleteRepostMappingsWithTxn(
	txn *badger.Txn, userPubKey []byte, repostedPostHash BlockHash) error

Note this deletes the repost for the user *and* the reposted post since a mapping should exist for each.

func DbDeleteTxindexNextIndexForPublicKeyWithTxn

func DbDeleteTxindexNextIndexForPublicKeyWithTxn(txn *badger.Txn, publicKey []byte) error

func DbDeleteTxindexPublicKeyToTxnMappingSingleWithTxn

func DbDeleteTxindexPublicKeyToTxnMappingSingleWithTxn(
	dbTxn *badger.Txn, publicKey []byte, txID *BlockHash) error

func DbDeleteTxindexTransactionMappings

func DbDeleteTxindexTransactionMappings(
	handle *badger.DB, txn *MsgDeSoTxn, params *DeSoParams) error

func DbDeleteTxindexTransactionMappingsWithTxn

func DbDeleteTxindexTransactionMappingsWithTxn(
	dbTxn *badger.Txn, txn *MsgDeSoTxn, params *DeSoParams) error

func DbExistsBitcoinBurnTxID

func DbExistsBitcoinBurnTxID(db *badger.DB, bitcoinBurnTxID *BlockHash) bool

func DbExistsBitcoinBurnTxIDWithTxn

func DbExistsBitcoinBurnTxIDWithTxn(txn *badger.Txn, bitcoinBurnTxID *BlockHash) bool

func DbGetBlockRewardForPublicKeyBlockHash

func DbGetBlockRewardForPublicKeyBlockHash(db *badger.DB, publicKey []byte, blockHash *BlockHash,
) (_balance uint64, _err error)

func DbGetBlockRewardForPublicKeyBlockHashWithTxn

func DbGetBlockRewardForPublicKeyBlockHashWithTxn(txn *badger.Txn, publicKey []byte, blockHash *BlockHash,
) (_balance uint64, _err error)

func DbGetDeSoBalanceNanosForPublicKey

func DbGetDeSoBalanceNanosForPublicKey(db *badger.DB, publicKey []byte,
) (_balance uint64, _err error)

func DbGetDeSoBalanceNanosForPublicKeyWithTxn

func DbGetDeSoBalanceNanosForPublicKeyWithTxn(txn *badger.Txn, publicKey []byte,
) (_balance uint64, _err error)

func DbGetFollowerToFollowedMapping

func DbGetFollowerToFollowedMapping(db *badger.DB, followerPKID *PKID, followedPKID *PKID) []byte

func DbGetFollowerToFollowedMappingWithTxn

func DbGetFollowerToFollowedMappingWithTxn(
	txn *badger.Txn, followerPKID *PKID, followedPKID *PKID) []byte

func DbGetForbiddenBlockSignaturePubKey

func DbGetForbiddenBlockSignaturePubKey(db *badger.DB, publicKey []byte) []byte

func DbGetForbiddenBlockSignaturePubKeyWithTxn

func DbGetForbiddenBlockSignaturePubKeyWithTxn(txn *badger.Txn, publicKey []byte) []byte

func DbGetLikerPubKeyToLikedPostHashMapping

func DbGetLikerPubKeyToLikedPostHashMapping(
	db *badger.DB, userPubKey []byte, likedPostHash BlockHash) []byte

func DbGetLikerPubKeyToLikedPostHashMappingWithTxn

func DbGetLikerPubKeyToLikedPostHashMappingWithTxn(
	txn *badger.Txn, userPubKey []byte, likedPostHash BlockHash) []byte

func DbGetLikerPubKeysLikingAPostHash

func DbGetLikerPubKeysLikingAPostHash(handle *badger.DB, likedPostHash BlockHash) (
	_pubKeys [][]byte, _err error)

func DbGetNanosPurchased

func DbGetNanosPurchased(handle *badger.DB) uint64

func DbGetNanosPurchasedWithTxn

func DbGetNanosPurchasedWithTxn(txn *badger.Txn) uint64

func DbGetPKIDsThatDiamondedYouMap

func DbGetPKIDsThatDiamondedYouMap(handle *badger.DB, yourPKID *PKID, fetchYouDiamonded bool) (
	_pkidToDiamondsMap map[PKID][]*DiamondEntry, _err error)

This function returns a map of PKIDs that gave diamonds to a list of DiamondEntrys that contain post hashes.

func DbGetPrefixForPublicKeyToDesoBalanceNanos added in v1.2.9

func DbGetPrefixForPublicKeyToDesoBalanceNanos() []byte

func DbGetPubKeysFollowingYou

func DbGetPubKeysFollowingYou(handle *badger.DB, yourPubKey []byte) (
	_pubKeys [][]byte, _err error)

func DbGetPubKeysYouFollow

func DbGetPubKeysYouFollow(handle *badger.DB, yourPubKey []byte) (
	_pubKeys [][]byte, _err error)

func DbGetTxindexFullTransactionByTxID

func DbGetTxindexFullTransactionByTxID(
	txindexDBHandle *badger.DB, blockchainDBHandle *badger.DB, txID *BlockHash) (
	_txn *MsgDeSoTxn, _txnMeta *TransactionMetadata)

DbGetTxindexFullTransactionByTxID TODO: This makes lookups inefficient when blocks are large. Shouldn't be a problem for a while, but keep an eye on it.

func DbGetTxindexNextIndexForPublicKey

func DbGetTxindexNextIndexForPublicKey(handle *badger.DB, publicKey []byte) *uint64

func DbGetUSDCentsPerBitcoinExchangeRate

func DbGetUSDCentsPerBitcoinExchangeRate(handle *badger.DB) uint64

func DbGetUSDCentsPerBitcoinExchangeRateWithTxn

func DbGetUSDCentsPerBitcoinExchangeRateWithTxn(txn *badger.Txn) uint64

func DbPrefixForCreatorDeSoLockedNanosCreatorPKID added in v1.2.9

func DbPrefixForCreatorDeSoLockedNanosCreatorPKID() []byte

func DbPutBitcoinBurnTxIDWithTxn

func DbPutBitcoinBurnTxIDWithTxn(txn *badger.Txn, bitcoinBurnTxID *BlockHash) error

func DbPutDeSoBalanceForPublicKey

func DbPutDeSoBalanceForPublicKey(handle *badger.DB, publicKey []byte, balanceNanos uint64) error

func DbPutDeSoBalanceForPublicKeyWithTxn

func DbPutDeSoBalanceForPublicKeyWithTxn(
	txn *badger.Txn, publicKey []byte, balanceNanos uint64) error

func DbPutDiamondMappings

func DbPutDiamondMappings(
	handle *badger.DB,
	diamondEntry *DiamondEntry) error

func DbPutDiamondMappingsWithTxn

func DbPutDiamondMappingsWithTxn(
	txn *badger.Txn,
	diamondEntry *DiamondEntry) error

func DbPutFollowMappings

func DbPutFollowMappings(
	handle *badger.DB, followerPKID *PKID, followedPKID *PKID) error

func DbPutFollowMappingsWithTxn

func DbPutFollowMappingsWithTxn(
	txn *badger.Txn, followerPKID *PKID, followedPKID *PKID) error

Note that this adds a mapping for the follower *and* the pub key being followed.

func DbPutForbiddenBlockSignaturePubKey

func DbPutForbiddenBlockSignaturePubKey(handle *badger.DB, publicKey []byte) error

func DbPutForbiddenBlockSignaturePubKeyWithTxn

func DbPutForbiddenBlockSignaturePubKeyWithTxn(txn *badger.Txn, publicKey []byte) error

func DbPutGlobalParamsEntry

func DbPutGlobalParamsEntry(handle *badger.DB, globalParamsEntry GlobalParamsEntry) error

func DbPutGlobalParamsEntryWithTxn

func DbPutGlobalParamsEntryWithTxn(txn *badger.Txn, globalParamsEntry GlobalParamsEntry) error

func DbPutLikeMappings

func DbPutLikeMappings(
	handle *badger.DB, userPubKey []byte, likedPostHash BlockHash) error

func DbPutLikeMappingsWithTxn

func DbPutLikeMappingsWithTxn(
	txn *badger.Txn, userPubKey []byte, likedPostHash BlockHash) error

Note that this adds a mapping for the user *and* the liked post.

func DbPutMempoolTxn

func DbPutMempoolTxn(handle *badger.DB, mempoolTx *MempoolTx) error

func DbPutMempoolTxnWithTxn

func DbPutMempoolTxnWithTxn(txn *badger.Txn, mempoolTx *MempoolTx) error

func DbPutMessageEntry

func DbPutMessageEntry(handle *badger.DB, messageEntry *MessageEntry) error

func DbPutMessageEntryWithTxn

func DbPutMessageEntryWithTxn(
	txn *badger.Txn, messageEntry *MessageEntry) error

Note that this adds a mapping for the sender *and* the recipient.

func DbPutNanosPurchased

func DbPutNanosPurchased(handle *badger.DB, nanosPurchased uint64) error

func DbPutNanosPurchasedWithTxn

func DbPutNanosPurchasedWithTxn(txn *badger.Txn, nanosPurchased uint64) error

func DbPutRepostMappings

func DbPutRepostMappings(
	handle *badger.DB, userPubKey []byte, repostedPostHash BlockHash, repostEntry RepostEntry) error

func DbPutRepostMappingsWithTxn

func DbPutRepostMappingsWithTxn(
	txn *badger.Txn, userPubKey []byte, repostedPostHash BlockHash, repostEntry RepostEntry) error

Note that this adds a mapping for the user *and* the reposted post.

func DbPutTxindexNextIndexForPublicKeyWithTxn

func DbPutTxindexNextIndexForPublicKeyWithTxn(txn *badger.Txn, publicKey []byte, nextIndex uint64) error

func DbPutTxindexPublicKeyToTxnMappingSingleWithTxn

func DbPutTxindexPublicKeyToTxnMappingSingleWithTxn(
	dbTxn *badger.Txn, publicKey []byte, txID *BlockHash) error

func DbPutTxindexTip

func DbPutTxindexTip(handle *badger.DB, tipHash *BlockHash) error

func DbPutTxindexTipWithTxn

func DbPutTxindexTipWithTxn(dbTxn *badger.Txn, tipHash *BlockHash) error

func DbPutTxindexTransaction

func DbPutTxindexTransaction(
	handle *badger.DB, txID *BlockHash, txnMeta *TransactionMetadata) error

func DbPutTxindexTransactionMappings

func DbPutTxindexTransactionMappings(
	handle *badger.DB, desoTxn *MsgDeSoTxn, params *DeSoParams, txnMeta *TransactionMetadata) error

func DbPutTxindexTransactionMappingsWithTxn

func DbPutTxindexTransactionMappingsWithTxn(
	dbTx *badger.Txn, txn *MsgDeSoTxn, params *DeSoParams, txnMeta *TransactionMetadata) error

func DbPutTxindexTransactionWithTxn

func DbPutTxindexTransactionWithTxn(
	txn *badger.Txn, txID *BlockHash, txnMeta *TransactionMetadata) error

func DbPutUSDCentsPerBitcoinExchangeRateWithTxn

func DbPutUSDCentsPerBitcoinExchangeRateWithTxn(txn *badger.Txn, usdCentsPerBitcoinExchangeRate uint64) error

func DbTxindexPublicKeyIndexToTxnKey

func DbTxindexPublicKeyIndexToTxnKey(publicKey []byte, index uint32) []byte

func DbTxindexPublicKeyPrefix

func DbTxindexPublicKeyPrefix(publicKey []byte) []byte

func DbTxindexTxIDKey

func DbTxindexTxIDKey(txID *BlockHash) []byte

func DecodeUint32

func DecodeUint32(num []byte) uint32

func DecodeUint64

func DecodeUint64(scoreBytes []byte) uint64

func DecryptBytesWithPrivateKey

func DecryptBytesWithPrivateKey(bytesToDecrypt []byte, privKey *ecdsa.PrivateKey) ([]byte, error)

func DeletePubKeyUtxoKeyMappingWithTxn

func DeletePubKeyUtxoKeyMappingWithTxn(txn *badger.Txn, publicKey []byte, utxoKey *UtxoKey) error

func DeleteUnmodifiedMappingsForUtxoWithTxn

func DeleteUnmodifiedMappingsForUtxoWithTxn(txn *badger.Txn, utxoKey *UtxoKey) error

func DeleteUtxoEntryForKeyWithTxn

func DeleteUtxoEntryForKeyWithTxn(txn *badger.Txn, utxoKey *UtxoKey) error

func DeleteUtxoOperationsForBlockWithTxn

func DeleteUtxoOperationsForBlockWithTxn(txn *badger.Txn, blockHash *BlockHash) error

func Diff

func Diff(expected interface{}, actual interface{}) string

Diff returns a diff of both values as long as both are of the same type and are a struct, map, slice, array or string. Otherwise it returns an empty string.

func Div

func Div(a *big.Float, b *big.Float) *big.Float

func EncodeUint64

func EncodeUint64(num uint64) []byte

func EncryptBytesWithPublicKey

func EncryptBytesWithPublicKey(bytesToEncrypt []byte, pubkey *ecdsa.PublicKey) ([]byte, error)

func EnumerateKeysForPrefix

func EnumerateKeysForPrefix(db *badger.DB, dbPrefix []byte) (_keysFound [][]byte, _valsFound [][]byte)

func EstimateBitcoinTxFee

func EstimateBitcoinTxFee(
	numInputs int, numOutputs int, feeRateSatoshisPerKB uint64) uint64

func ExtractBitcoinBurnTransactionsFromBitcoinBlock

func ExtractBitcoinBurnTransactionsFromBitcoinBlock(
	bitcoinBlock *wire.MsgBlock, bitcoinBurnAddress string, params *DeSoParams) []*wire.MsgTx

func ExtractBitcoinBurnTransactionsFromBitcoinBlockWithMerkleProofs

func ExtractBitcoinBurnTransactionsFromBitcoinBlockWithMerkleProofs(
	bitcoinBlock *wire.MsgBlock, burnAddress string, params *DeSoParams) (
	_txns []*wire.MsgTx, _merkleProofs [][]*merkletree.ProofPart, _err error)

func ExtractBitcoinPublicKeyFromBitcoinTransactionInputs

func ExtractBitcoinPublicKeyFromBitcoinTransactionInputs(
	bitcoinTransaction *wire.MsgTx, btcdParams *chaincfg.Params) (
	_publicKey *btcec.PublicKey, _err error)

func FlushMempoolToDb

func FlushMempoolToDb(handle *badger.DB, allTxns []*MempoolTx) error

func FlushMempoolToDbWithTxn

func FlushMempoolToDbWithTxn(txn *badger.Txn, allTxns []*MempoolTx) error

func GetBadgerDbPath

func GetBadgerDbPath(dataDir string) string

GetBadgerDbPath returns the path where we store the badgerdb data.

func GetBlockIndex

func GetBlockIndex(handle *badger.DB, bitcoinNodes bool) (map[BlockHash]*BlockNode, error)

func GetCreatorCoinNanosForDiamondLevelAtBlockHeight

func GetCreatorCoinNanosForDiamondLevelAtBlockHeight(
	coinsInCirculationNanos uint64, desoLockedNanos uint64,
	diamondLevel int64, blockHeight int64, params *DeSoParams) uint64

At a particular diamond level, a fixed amount of DeSo is converted into creator coins and then sent to a user. This function computes the amount of creator coins required for a particular level.

func GetDataDir

func GetDataDir(params *DeSoParams) string

GetDataDir gets the user data directory where we store files in a cross-platform way.

func GetDeSoNanosDiamondLevelMapAtBlockHeight

func GetDeSoNanosDiamondLevelMapAtBlockHeight(
	blockHeight int64) map[int64]uint64

Each diamond level is worth a fixed amount of DeSo. These amounts can be changed in the future by simply returning a new set of values after a particular block height.

func GetDeSoNanosForDiamondLevelAtBlockHeight

func GetDeSoNanosForDiamondLevelAtBlockHeight(
	diamondLevel int64, blockHeight int64) uint64

func GetReorgBlocks

func GetReorgBlocks(tip *BlockNode, newNode *BlockNode) (_commonAncestor *BlockNode, _detachNodes []*BlockNode, _attachNodes []*BlockNode)

func GetSatoshisPerUnitExchangeRate

func GetSatoshisPerUnitExchangeRate(startNanos uint64, usdCentsPerBitcoinExchangeRate uint64) uint64

func GetStartPriceSatoshisPerDeSo

func GetStartPriceSatoshisPerDeSo(usdCentsPerBitcoinExchangeRate uint64) uint64

func GetUtxoNumEntries

func GetUtxoNumEntries(handle *badger.DB) uint64

func GetUtxoNumEntriesWithTxn

func GetUtxoNumEntriesWithTxn(txn *badger.Txn) uint64

func GetUtxoOperationsForBlock

func GetUtxoOperationsForBlock(handle *badger.DB, blockHash *BlockHash) ([][]*UtxoOperation, error)

func GetUtxoOperationsForBlockWithTxn

func GetUtxoOperationsForBlockWithTxn(txn *badger.Txn, blockHash *BlockHash) ([][]*UtxoOperation, error)

func HashToBigint

func HashToBigint(hash *BlockHash) *big.Int

func HeaderSizeBytes

func HeaderSizeBytes() int

func IPToNetAddr

func IPToNetAddr(ipStr string, addrMgr *addrmgr.AddrManager, params *DeSoParams) (*wire.NetAddress, error)

func InitDbWithDeSoGenesisBlock

func InitDbWithDeSoGenesisBlock(params *DeSoParams, handle *badger.DB, eventManager *EventManager) error

InitDbWithGenesisBlock initializes the database to contain only the genesis block.

func InitializeSecureMiddleware

func InitializeSecureMiddleware(allowedHosts []string, isDevelopment bool, contentSecurityPolicy string) *secure.Secure

allowedHost is expected to be of the form "bitclout.com" See comments in this function for a description of these params

Note: FeaturePolicy is apparently renamed to PermissionsPolicy. Maybe we should fork secure.go and add that. https://scotthelme.co.uk/goodbye-feature-policy-and-hello-permissions-policy/

func IntAdd

func IntAdd(a *big.Int, b *big.Int) *big.Int

func IntDiv

func IntDiv(a *big.Int, b *big.Int) *big.Int

func IntMul

func IntMul(a *big.Int, b *big.Int) *big.Int

func IntSub

func IntSub(a *big.Int, b *big.Int) *big.Int

func IntToBuf

func IntToBuf(xx int64) []byte

func IsBitcoinTestnet

func IsBitcoinTestnet(params *DeSoParams) bool

func IsControlMessage

func IsControlMessage(msgType MsgType) bool

IsControlMessage is used by functions to determine whether a particular message is a control message. This is useful, for example, in disallowing external Peers from manipulating our node by sending control messages of their own.

func IsQuotedRepost

func IsQuotedRepost(postEntry *PostEntry) bool

func IsRuleError

func IsRuleError(err error) bool

IsRuleError returns true if the error is any of the errors specified above.

func IsVanillaRepost

func IsVanillaRepost(postEntry *PostEntry) bool

Return true if postEntry is a vanilla repost. A vanilla repost is a post that reposts another post, but does not have a body.

func LessThan

func LessThan(aa *BlockHash, bb *BlockHash) bool

func LogDBSummarySnapshot

func LogDBSummarySnapshot(db *badger.DB)

func LogSelect

func LogSelect(query *orm.Query) error

LogSelect is a helpful utility when developing or debugging queries. Simply call LogSelect(query) instead of query.Select() to get a log of the raw query.

func MakeDirIfNonExistent

func MakeDirIfNonExistent(filePath string) error

This function attempts to make the file path provided. Returns an =errors if a parent directory in the path does not exist or another error is encountered. User permissions are set to "rwx" so that it can be manipulated. See: https://stackoverflow.com/questions/14249467/os-mkdir-and-os-mkdirall-permission-value/31151508

func MinInt

func MinInt(a, b int) int

func MinUint32

func MinUint32(a, b uint32) uint32

func Mul

func Mul(a *big.Float, b *big.Float) *big.Float

func MustBase58CheckDecode

func MustBase58CheckDecode(input string) []byte

func NewFloat

func NewFloat() *big.Float

func PKIDToPublicKey

func PKIDToPublicKey(pkid *PKID) []byte

func PPrintJSON

func PPrintJSON(xx interface{})

PPrintJSON prints a JSON object but pretty.

func PkToString

func PkToString(pk []byte, params *DeSoParams) string

func PkToStringBoth

func PkToStringBoth(pk []byte) string

func PkToStringMainnet

func PkToStringMainnet(pk []byte) string

func PkToStringTestnet

func PkToStringTestnet(pk []byte) string

func PrivToString

func PrivToString(priv []byte, params *DeSoParams) string

func PublicKeyBlockHashToBlockRewardKey

func PublicKeyBlockHashToBlockRewardKey(publicKey []byte, blockHash *BlockHash) []byte

func PutBestHash

func PutBestHash(bh *BlockHash, handle *badger.DB, chainType ChainType) error

func PutBestHashWithTxn

func PutBestHashWithTxn(txn *badger.Txn, bh *BlockHash, chainType ChainType) error

func PutBlock

func PutBlock(desoBlock *MsgDeSoBlock, handle *badger.DB) error

func PutBlockWithTxn

func PutBlockWithTxn(txn *badger.Txn, desoBlock *MsgDeSoBlock) error

func PutHeightHashToNodeInfo

func PutHeightHashToNodeInfo(node *BlockNode, handle *badger.DB, bitcoinNodes bool) error

func PutHeightHashToNodeInfoWithTxn

func PutHeightHashToNodeInfoWithTxn(txn *badger.Txn, node *BlockNode, bitcoinNodes bool) error

func PutMappingsForUtxoWithTxn

func PutMappingsForUtxoWithTxn(txn *badger.Txn, utxoKey *UtxoKey, utxoEntry *UtxoEntry) error

func PutPubKeyUtxoKeyWithTxn

func PutPubKeyUtxoKeyWithTxn(txn *badger.Txn, publicKey []byte, utxoKey *UtxoKey) error

func PutUtxoEntryForUtxoKeyWithTxn

func PutUtxoEntryForUtxoKeyWithTxn(txn *badger.Txn, utxoKey *UtxoKey, utxoEntry *UtxoEntry) error

func PutUtxoNumEntriesWithTxn

func PutUtxoNumEntriesWithTxn(txn *badger.Txn, newNumEntries uint64) error

func PutUtxoOperationsForBlockWithTxn

func PutUtxoOperationsForBlockWithTxn(txn *badger.Txn, blockHash *BlockHash, utxoOpsForBlock [][]*UtxoOperation) error

func PutUvarint

func PutUvarint(buf []byte, x uint64) int

PutUvarint encodes a uint64 into buf and returns the number of bytes written. If the buffer is too small, PutUvarint will panic.

func PutVarint

func PutVarint(buf []byte, x int64) int

PutVarint encodes an int64 into buf and returns the number of bytes written. If the buffer is too small, PutVarint will panic.

func RandInt32

func RandInt32(max int32) int32

RandInt32 returns a random 32-bit int.

func RandInt64

func RandInt64(max int64) int64

RandInt64 returns a random 64-bit int.

func RandomBytes

func RandomBytes(numBytes int32) []byte

RandomBytes returns a []byte with random values.

func RandomBytesHex

func RandomBytesHex(numBytes int32) string

RandomBytesHex returns a hex string representing numBytes of entropy.

func ReadBoolByte

func ReadBoolByte(rr *bytes.Reader) bool

func ReadUvarint

func ReadUvarint(r io.Reader) (uint64, error)

ReadUvarint reads an encoded unsigned integer from r and returns it as a uint64.

func ReadVarString

func ReadVarString(rr io.Reader) ([]byte, error)

func ReadVarint

func ReadVarint(r io.Reader) (int64, error)

ReadVarint reads an encoded signed integer from r and returns it as an int64.

func SerializeBlockNode

func SerializeBlockNode(blockNode *BlockNode) ([]byte, error)

func SignTransactionWithDerivedKey

func SignTransactionWithDerivedKey(txnBytes []byte, privateKey *btcec.PrivateKey) ([]byte, []byte, error)

SignTransactionWithDerivedKey the signature contains solution iteration, which allows us to recover signer public key from the signature. Returns (new txn bytes, txn signature, error)

func StartDBSummarySnapshots

func StartDBSummarySnapshots(db *badger.DB)

func Sub

func Sub(a *big.Float, b *big.Float) *big.Float

func UintToBuf

func UintToBuf(xx uint64) []byte

func Uvarint

func Uvarint(buf []byte) (uint64, int)

Uvarint decodes a uint64 from buf and returns that value and the number of bytes read (> 0). If an error occurred, the value is 0 and the number of bytes n is <= 0 meaning:

n == 0: buf too small
n  < 0: value larger than 64 bits (overflow)
        and -n is the number of bytes read

func Varint

func Varint(buf []byte) (int64, int)

Varint decodes an int64 from buf and returns that value and the number of bytes read (> 0). If an error occurred, the value is 0 and the number of bytes n is <= 0 with the following meaning:

n == 0: buf too small
n  < 0: value larger than 64 bits (overflow)
        and -n is the number of bytes read

func WriteMessage

func WriteMessage(ww io.Writer, msg DeSoMessage, networkType NetworkType) ([]byte, error)

WriteMessage takes an io.Writer and serializes and writes the specified message to it. Returns an error if the message is malformed or invalid for any reason. Otherwise returns the payload that was written sans the header.

Types

type AcceptNFTBidMetadata

type AcceptNFTBidMetadata struct {
	NFTPostHash    *BlockHash
	SerialNumber   uint64
	BidderPKID     *PKID
	BidAmountNanos uint64
	UnlockableText []byte

	// When an NFT owner accepts a bid, they must specify the bidder's UTXO inputs they will lock up
	// as payment for the purchase. This prevents the transaction from accidentally using UTXOs
	// that are used by future transactions.
	BidderInputs []*DeSoInput
}

func (*AcceptNFTBidMetadata) FromBytes

func (txnData *AcceptNFTBidMetadata) FromBytes(dataa []byte) error

func (*AcceptNFTBidMetadata) GetTxnType

func (txnData *AcceptNFTBidMetadata) GetTxnType() TxnType

func (*AcceptNFTBidMetadata) New

func (txnData *AcceptNFTBidMetadata) New() DeSoTxnMetadata

func (*AcceptNFTBidMetadata) ToBytes

func (txnData *AcceptNFTBidMetadata) ToBytes(preSignature bool) ([]byte, error)

type AcceptNFTBidTxindexMetadata

type AcceptNFTBidTxindexMetadata struct {
	NFTPostHashHex              string
	SerialNumber                uint64
	BidAmountNanos              uint64
	CreatorCoinRoyaltyNanos     uint64
	CreatorPublicKeyBase58Check string
}

type AcceptNFTTransferMetadata

type AcceptNFTTransferMetadata struct {
	NFTPostHash  *BlockHash
	SerialNumber uint64
}

func (*AcceptNFTTransferMetadata) FromBytes

func (txnData *AcceptNFTTransferMetadata) FromBytes(dataa []byte) error

func (*AcceptNFTTransferMetadata) GetTxnType

func (txnData *AcceptNFTTransferMetadata) GetTxnType() TxnType

func (*AcceptNFTTransferMetadata) New

func (*AcceptNFTTransferMetadata) ToBytes

func (txnData *AcceptNFTTransferMetadata) ToBytes(preSignature bool) ([]byte, error)

type AffectedPublicKey

type AffectedPublicKey struct {
	PublicKeyBase58Check string
	// Metadata about how this public key was affected by the transaction.
	Metadata string
}

type AuthorizeDerivedKeyMetadata

type AuthorizeDerivedKeyMetadata struct {
	// DerivedPublicKey is the key that is authorized to sign transactions
	// on behalf of the public key owner.
	DerivedPublicKey []byte

	// ExpirationBlock is the block at which this authorization becomes invalid.
	ExpirationBlock uint64

	// OperationType determines if transaction validates or invalidates derived key.
	OperationType AuthorizeDerivedKeyOperationType

	// AccessSignature is the signed hash of (derivedPublicKey + expirationBlock)
	// made with the ownerPublicKey. Signature is in the DER format.
	AccessSignature []byte
}

func (*AuthorizeDerivedKeyMetadata) FromBytes

func (txnData *AuthorizeDerivedKeyMetadata) FromBytes(data []byte) error

func (*AuthorizeDerivedKeyMetadata) GetTxnType

func (txnData *AuthorizeDerivedKeyMetadata) GetTxnType() TxnType

func (*AuthorizeDerivedKeyMetadata) New

func (*AuthorizeDerivedKeyMetadata) ToBytes

func (txnData *AuthorizeDerivedKeyMetadata) ToBytes(preSignature bool) ([]byte, error)

type AuthorizeDerivedKeyOperationType

type AuthorizeDerivedKeyOperationType uint8
const (
	AuthorizeDerivedKeyOperationNotValid AuthorizeDerivedKeyOperationType = 0
	AuthorizeDerivedKeyOperationValid    AuthorizeDerivedKeyOperationType = 1
)

type BalanceEntry

type BalanceEntry struct {
	// The PKID of the HODLer. This should never change after it's set initially.
	HODLerPKID *PKID
	// The PKID of the creator. This should never change after it's set initially.
	CreatorPKID *PKID

	// How much this HODLer owns of a particular creator coin.
	BalanceNanos uint64

	// Has the hodler purchased any amount of this user's coin
	HasPurchased bool
	// contains filtered or unexported fields
}

This struct is mainly used to track a user's balance of a particular creator coin. In the database, we store it as the value in a mapping that looks as follows: <HodlerPKID, CreatorPKID> -> HODLerEntry

func DBGetCreatorCoinBalanceEntryForCreatorPKIDAndHODLerPubKeyWithTxn

func DBGetCreatorCoinBalanceEntryForCreatorPKIDAndHODLerPubKeyWithTxn(
	txn *badger.Txn, creatorPKID *PKID, hodlerPKID *PKID) *BalanceEntry

func DBGetCreatorCoinBalanceEntryForHODLerAndCreatorPKIDs

func DBGetCreatorCoinBalanceEntryForHODLerAndCreatorPKIDs(
	handle *badger.DB, hodlerPKID *PKID, creatorPKID *PKID) *BalanceEntry

func DBGetCreatorCoinBalanceEntryForHODLerAndCreatorPKIDsWithTxn

func DBGetCreatorCoinBalanceEntryForHODLerAndCreatorPKIDsWithTxn(
	txn *badger.Txn, hodlerPKID *PKID, creatorPKID *PKID) *BalanceEntry

func DbGetBalanceEntriesHodlingYou

func DbGetBalanceEntriesHodlingYou(db *badger.DB, pkid *PKID, filterOutZeroBalances bool) ([]*BalanceEntry, error)

DbGetBalanceEntriesHodlingYou fetches the BalanceEntries that hold the pkid passed in.

func DbGetBalanceEntriesYouHold

func DbGetBalanceEntriesYouHold(db *badger.DB, pkid *PKID, filterOutZeroBalances bool) ([]*BalanceEntry, error)

DbGetBalanceEntriesHodlingYou fetchs the BalanceEntries that the passed in pkid holds.

func DbGetBalanceEntry

func DbGetBalanceEntry(db *badger.DB, holder *PKID, creator *PKID) *BalanceEntry

DbGetBalanceEntry returns a balance entry from the database

func DbGetHolderPKIDCreatorPKIDToBalanceEntryWithTxn

func DbGetHolderPKIDCreatorPKIDToBalanceEntryWithTxn(txn *badger.Txn, holder *PKID, creator *PKID) *BalanceEntry

func GetSingleBalanceEntryFromPublicKeys

func GetSingleBalanceEntryFromPublicKeys(holder []byte, creator []byte, utxoView *UtxoView) (*BalanceEntry, error)

GetSingleBalanceEntryFromPublicKeys fetchs a single balance entry of a holder's creator coin. Returns nil if the balance entry never existed.

type BalanceEntryMapKey

type BalanceEntryMapKey struct {
	HODLerPKID  PKID
	CreatorPKID PKID
}

func MakeCreatorCoinBalanceKey

func MakeCreatorCoinBalanceKey(hodlerPKID *PKID, creatorPKID *PKID) BalanceEntryMapKey

func (BalanceEntryMapKey) String

func (mm BalanceEntryMapKey) String() string

type BasicTransferMetadata

type BasicTransferMetadata struct {
}

func (*BasicTransferMetadata) FromBytes

func (txnData *BasicTransferMetadata) FromBytes(data []byte) error

func (*BasicTransferMetadata) GetTxnType

func (txnData *BasicTransferMetadata) GetTxnType() TxnType

func (*BasicTransferMetadata) New

func (txnData *BasicTransferMetadata) New() DeSoTxnMetadata

func (*BasicTransferMetadata) ToBytes

func (txnData *BasicTransferMetadata) ToBytes(preSignature bool) ([]byte, error)

type BasicTransferTxindexMetadata

type BasicTransferTxindexMetadata struct {
	TotalInputNanos  uint64
	TotalOutputNanos uint64
	FeeNanos         uint64
	UtxoOpsDump      string
	UtxoOps          []*UtxoOperation
	DiamondLevel     int64
	PostHashHex      string
}

type BitcoinExchangeMetadata

type BitcoinExchangeMetadata struct {
	// The Bitcoin transaction that sends Bitcoin to the designated burn address.
	BitcoinTransaction *wire.MsgTx
	// The hash of the Bitcoin block in which the Bitcoin transaction was mined.
	BitcoinBlockHash *BlockHash
	// The Bitcoin mekle root corresponding to the block in which the BitcoinTransaction
	// above was mined. Note that it is not strictly necessary to include this field
	// since we can look it up from the Bitcoin header if we know the BitcoinBlockHash.
	// However, having it here is convenient and allows us to do more validation prior
	// to looking up the header in the Bitcoin header chain.
	BitcoinMerkleRoot *BlockHash
	// This is a merkle proof that shows that the BitcoinTransaction above, with
	// hash equal to BitcoinTransactionHash, exists in the block with hash equal
	// to BitcoinBlockHash. This is effectively a path through a Merkle tree starting
	// from BitcoinTransactionHash as a leaf node and finishing with BitcoinMerkleRoot
	// as the root.
	BitcoinMerkleProof []*merkletree.ProofPart
}

func (*BitcoinExchangeMetadata) FromBytes

func (txnData *BitcoinExchangeMetadata) FromBytes(data []byte) error

func (*BitcoinExchangeMetadata) GetTxnType

func (txnData *BitcoinExchangeMetadata) GetTxnType() TxnType

func (*BitcoinExchangeMetadata) New

func (*BitcoinExchangeMetadata) ToBytes

func (txnData *BitcoinExchangeMetadata) ToBytes(preSignature bool) ([]byte, error)

type BitcoinExchangeTxindexMetadata

type BitcoinExchangeTxindexMetadata struct {
	BitcoinSpendAddress string
	// DeSoOutputPubKeyBase58Check = TransactorPublicKeyBase58Check
	SatoshisBurned uint64
	// NanosCreated = 0 OR TotalOutputNanos+FeeNanos
	NanosCreated uint64
	// TotalNanosPurchasedBefore = TotalNanosPurchasedAfter - NanosCreated
	TotalNanosPurchasedBefore uint64
	TotalNanosPurchasedAfter  uint64
	BitcoinTxnHash            string
}

type BitcoinUtxo

type BitcoinUtxo struct {
	TxID           *chainhash.Hash
	Index          int64
	AmountSatoshis int64
}

func BlockCypherExtractBitcoinUtxosFromResponse

func BlockCypherExtractBitcoinUtxosFromResponse(
	apiData *BlockCypherAPIFullAddressResponse, addrString string, params *DeSoParams) (
	[]*BitcoinUtxo, error)

func BlockCypherUtxoSource

func BlockCypherUtxoSource(addrString string, params *DeSoParams) (
	[]*BitcoinUtxo, error)

func FrontendBlockCypherUtxoSource

func FrontendBlockCypherUtxoSource(
	apiData *BlockCypherAPIFullAddressResponse, addrString string,
	params *DeSoParams) (
	[]*BitcoinUtxo, error)

The frontend passes in the apiData. We do this so that our server doesn't get rate-limited by the free tier.

type BlockCypherAPIFullAddressResponse

type BlockCypherAPIFullAddressResponse struct {
	Address string `json:"address"`
	// Balance data
	ConfirmedBalance   int64 `json:"balance"`
	UnconfirmedBalance int64 `json:"unconfirmed_balance"`
	FinalBalance       int64 `json:"final_balance"`

	// Transaction data
	Txns []*BlockCypherAPITxnResponse `json:"txs"`

	HasMore bool `json:"hasMore"`

	Error string `json:"error"`
}

func GetBlockCypherAPIFullAddressResponse

func GetBlockCypherAPIFullAddressResponse(addrString string, params *DeSoParams) (
	_apiData *BlockCypherAPIFullAddressResponse, _err error)

type BlockCypherAPIInputResponse

type BlockCypherAPIInputResponse struct {
	PrevTxIDHex    string   `json:"prev_hash"`
	Index          int64    `json:"output_index"`
	ScriptHex      string   `json:"script"`
	AmountSatoshis int64    `json:"output_value"`
	Sequence       int64    `json:"sequence"`
	Addresses      []string `json:"addresses"`
	ScriptType     string   `json:"script_type"`
	Age            int64    `json:"age"`
}

type BlockCypherAPIOutputResponse

type BlockCypherAPIOutputResponse struct {
	AmountSatoshis int64    `json:"value"`
	ScriptHex      string   `json:"script"`
	Addresses      []string `json:"addresses"`
	ScriptType     string   `json:"script_type"`
	SpentBy        string   `json:"spent_by"`
}

type BlockCypherAPITxnResponse

type BlockCypherAPITxnResponse struct {
	BlockHashHex  string                          `json:"block_hash"`
	BlockHeight   int64                           `json:"block_height"`
	LockTime      int64                           `json:"lock_time"`
	TxIDHex       string                          `json:"hash"`
	Inputs        []*BlockCypherAPIInputResponse  `json:"inputs"`
	Outputs       []*BlockCypherAPIOutputResponse `json:"outputs"`
	Confirmations int64                           `json:"confirmations"`
	DoubleSpend   bool                            `json:"double_spend"`
}

func GetBlockCypherTxnResponse added in v1.2.8

func GetBlockCypherTxnResponse(txnHash *chainhash.Hash, blockCypherAPIKey string, params *DeSoParams) (*BlockCypherAPITxnResponse, error)

type BlockEvent added in v1.2.6

type BlockEvent struct {
	Block *MsgDeSoBlock

	// Optional
	UtxoView *UtxoView
	UtxoOps  [][]*UtxoOperation
}

type BlockEventFunc added in v1.2.6

type BlockEventFunc func(event *BlockEvent)

type BlockHash

type BlockHash [HashSizeBytes]byte

BlockHash is a convenient alias for a block hash.

func BigintToHash

func BigintToHash(bigint *big.Int) *BlockHash

func CalcNextDifficultyTarget

func CalcNextDifficultyTarget(
	lastNode *BlockNode, version uint32, params *DeSoParams) (*BlockHash, error)

CalcNextDifficultyTarget computes the difficulty target expected of the next block.

func ComputeTransactionHashes

func ComputeTransactionHashes(txns []*MsgDeSoTxn) ([]*BlockHash, error)

func CopyBytesIntoBlockHash

func CopyBytesIntoBlockHash(data []byte) *BlockHash

func DbGetAllBitcoinBurnTxIDs

func DbGetAllBitcoinBurnTxIDs(handle *badger.DB) (_bitcoinBurnTxIDs []*BlockHash)

func DbGetBestHash

func DbGetBestHash(handle *badger.DB, chainType ChainType) *BlockHash

func DbGetPostHashesYouLike

func DbGetPostHashesYouLike(handle *badger.DB, yourPublicKey []byte) (
	_postHashes []*BlockHash, _err error)

func DbGetPostHashesYouRepost

func DbGetPostHashesYouRepost(handle *badger.DB, yourPublicKey []byte) (
	_postHashes []*BlockHash, _err error)

func DbGetTxindexTip

func DbGetTxindexTip(handle *badger.DB) *BlockHash

func DbGetTxindexTxnsForPublicKey

func DbGetTxindexTxnsForPublicKey(handle *badger.DB, publicKey []byte) []*BlockHash

func DbGetTxindexTxnsForPublicKeyWithTxn

func DbGetTxindexTxnsForPublicKeyWithTxn(dbTxn *badger.Txn, publicKey []byte) []*BlockHash

func ExpectedWorkForBlockHash

func ExpectedWorkForBlockHash(hash *BlockHash) *BlockHash

The number of hashing attempts in expectation it would take to produce the hash passed in. This is computed as:

E(min(X_i, ..., X_n)) where:
- n = (number of attempted hashes) and
- the X_i are all U(0, MAX_HASH)

-> E(min(X_i, ..., X_n)) = MAX_HASH / (n + 1) -> E(n) ~= MAX_HASH / min_hash - 1

  • where min_hash is the block hash

We approximate this as MAX_HASH / (min_hash + 1), adding 1 to min_hash in order to mitigate the possibility of a divide-by-zero error.

The value returned is the expected number of hashes performed to produce the input hash formatted as a big-endian big integer that uses the BlockHash type for convenience (though it is likely to be much lower in terms of magnitude than a typical BlockHash object).

func FindLowestHash

func FindLowestHash(
	blockHeaderr *MsgDeSoHeader, iterations uint64) (
	lowestHash *BlockHash, lowestNonce uint64, ee error)

FindLowestHash Mine for a given number of iterations and return the lowest hash value found and its associated nonce. Hashing starts at the value of the Nonce set on the blockHeader field when it is passed and increments the value of the passed blockHeader field as it iterates. This makes it easy to continue a subsequent batch of iterations after we return.

func MustDecodeHexBlockHash

func MustDecodeHexBlockHash(ss string) *BlockHash

func NewBlockHash

func NewBlockHash(input []byte) *BlockHash

func ProofOfWorkHash

func ProofOfWorkHash(inputBytes []byte, version uint32) *BlockHash

ProofOfWorkHash is a hash function designed for computing DeSo block hashes. It seems the optimal hash function is one that satisfies two properties:

  1. It is not computable by any existing ASICs. If this property isn't satisfied then miners with pre-existing investments in ASICs for other coins can very cheaply mine on our chain for a short period of time to pull off a 51% attack. This has actually happened with "merge-mined" coins like Namecoin.
  2. If implemented on an ASIC, there is an "orders of magnitude" speed-up over using a CPU or GPU. This is because ASICs require some amount of capital expenditure up-front in order to mine, which then aligns the owner of the ASIC to care about the health of the network over a longer period of time. In contrast, a hash function that is CPU or GPU-mineable can be attacked with an AWS fleet early on. This also may result in a more eco-friendly chain, since the hash power will be more bottlenecked by up-front CapEx rather than ongoing electricity cost, as is the case with GPU-mined coins.

Note that our pursuit of (2) above runs counter to existing dogma which seeks to prioritize "ASIC-resistance" in hash functions.

Given the above, the hash function chosen is a simple twist on sha3 that we don't think any ASIC exists for currently. Note that creating an ASIC for this should be relatively straightforward, however, which allows us to satisfy property (2) above.

func Sha256DoubleHash

func Sha256DoubleHash(input []byte) *BlockHash

func (*BlockHash) IsEqual

func (bh *BlockHash) IsEqual(target *BlockHash) bool

IsEqual returns true if target is the same as hash.

func (*BlockHash) NewBlockHash

func (bh *BlockHash) NewBlockHash() *BlockHash

func (*BlockHash) String

func (bh *BlockHash) String() string

func (*BlockHash) ToBytes

func (bh *BlockHash) ToBytes() []byte

type BlockNode

type BlockNode struct {
	// Pointer to a node representing the block's parent.
	Parent *BlockNode

	// The hash computed on this block.
	Hash *BlockHash

	// Height is the position in the block chain.
	Height uint32

	// The difficulty target for this block. Used to compute the next
	// block's difficulty target so it can be validated.
	DifficultyTarget *BlockHash

	// A computation of the total amount of work that has been performed
	// on this chain, including the current node.
	CumWork *big.Int

	// The block header.
	Header *MsgDeSoHeader

	// Status holds the validation state for the block and whether or not
	// it's stored in the database.
	Status BlockStatus
}

Add some fields in addition to the header to aid in the selection of the best chain.

func DeserializeBlockNode

func DeserializeBlockNode(data []byte) (*BlockNode, error)

func GetBestChain

func GetBestChain(tipNode *BlockNode, blockIndex map[BlockHash]*BlockNode) ([]*BlockNode, error)

func GetHeightHashToNodeInfo

func GetHeightHashToNodeInfo(
	handle *badger.DB, height uint32, hash *BlockHash, bitcoinNodes bool) *BlockNode

func GetHeightHashToNodeInfoWithTxn

func GetHeightHashToNodeInfoWithTxn(
	txn *badger.Txn, height uint32, hash *BlockHash, bitcoinNodes bool) *BlockNode

func NewBlockNode

func NewBlockNode(
	parent *BlockNode,
	hash *BlockHash,
	height uint32,
	difficultyTarget *BlockHash,
	cumWork *big.Int,
	header *MsgDeSoHeader,
	status BlockStatus) *BlockNode

TODO: Height not needed in this since it's in the header.

func (*BlockNode) Ancestor

func (nn *BlockNode) Ancestor(height uint32) *BlockNode

func (*BlockNode) RelativeAncestor

func (nn *BlockNode) RelativeAncestor(distance uint32) *BlockNode

RelativeAncestor returns the ancestor block node a relative 'distance' blocks before this node. This is equivalent to calling Ancestor with the node's height minus provided distance.

This function is safe for concurrent access.

func (*BlockNode) String

func (nn *BlockNode) String() string

type BlockProducerInfo

type BlockProducerInfo struct {
	PublicKey []byte
	Signature *btcec.Signature
}

func (*BlockProducerInfo) Deserialize

func (bpi *BlockProducerInfo) Deserialize(data []byte) error

func (*BlockProducerInfo) Serialize

func (bpi *BlockProducerInfo) Serialize() []byte

func (*BlockProducerInfo) String

func (bpi *BlockProducerInfo) String() string

type BlockRewardMetadataa

type BlockRewardMetadataa struct {
	// A block reward txn has an ExtraData field that can be between
	// zero and 100 bytes long. It can theoretically contain anything
	// but in practice it's likely that miners will use this field to
	// update the merkle root of the block, which may make the block
	// easier to mine (namely by allowing the Nonce in the header to
	// be shorter).
	ExtraData []byte
}

func (*BlockRewardMetadataa) FromBytes

func (txnData *BlockRewardMetadataa) FromBytes(dataa []byte) error

func (*BlockRewardMetadataa) GetTxnType

func (txnData *BlockRewardMetadataa) GetTxnType() TxnType

func (*BlockRewardMetadataa) New

func (txnData *BlockRewardMetadataa) New() DeSoTxnMetadata

func (*BlockRewardMetadataa) ToBytes

func (txnData *BlockRewardMetadataa) ToBytes(preSignature bool) ([]byte, error)

type BlockStatus

type BlockStatus uint32

func (BlockStatus) String

func (blockStatus BlockStatus) String() string

type BlockTemplateStats

type BlockTemplateStats struct {
	// The number of txns in the block template.
	TxnCount uint32
	// The final txn we attempted to put in the block.
	FailingTxnHash string
	// The reason why the final txn failed to add.
	FailingTxnError string
	// The "Added" time on a transaction changes every time a block is mined so we record
	// the first time added val we are aware of for a specific txn hash here.
	FailingTxnOriginalTimeAdded time.Time
	// The time since the failing txn was added to the mempool.
	FailingTxnMinutesSinceAdded float64
}

type Blockchain

type Blockchain struct {

	// Protects most of the fields below this point.
	ChainLock deadlock.RWMutex
	// contains filtered or unexported fields
}

func NewBlockchain

func NewBlockchain(
	trustedBlockProducerPublicKeyStrs []string,
	trustedBlockProducerStartHeight uint64,
	params *DeSoParams,
	timeSource chainlib.MedianTimeSource,
	db *badger.DB,
	postgres *Postgres,
	eventManager *EventManager,
) (*Blockchain, error)

NewBlockchain returns a new blockchain object. It initializes some in-memory data structures by reading from the db. It also initializes the db if it hasn't been initialized in the past. This function should only be called once per db, and one should never run two blockhain objects over the same db at the same time as they will likely step on each other and become inconsistent.

func (*Blockchain) AddInputsAndChangeToTransaction

func (bc *Blockchain) AddInputsAndChangeToTransaction(
	txArg *MsgDeSoTxn, minFeeRateNanosPerKB uint64, mempool *DeSoMempool) (
	_totalInputAdded uint64, _spendAmount uint64, _totalChangeAdded uint64, _fee uint64, _err error)

AddInputsAndChangeToTransaction fetches and adds utxos to the transaction passed in to meet the desired spend amount while also satisfying the desired minimum fee rate. Additionally, if it's worth it, this function will add a change output sending excess DeSo back to the spend public key. Note that the final feerate of the transaction after calling this function may exceed the minimum feerate requested. This can happen if the signature occupies fewer bytes than the expected maximum number of bytes or if the change output occupies fewer bytes than the expected maximum (though there could be other ways for this to happen).

The transaction passed in should not have any inputs on it before calling this function (an error is returned if it does). Additionally, the output of the transaction passed in is assumed to be the amount the caller wishes us to find inputs for.

An error is returned if there is not enough input associated with this public key to satisfy the transaction's output (subject to the minimum feerate).

func (*Blockchain) AddInputsAndChangeToTransactionWithSubsidy

func (bc *Blockchain) AddInputsAndChangeToTransactionWithSubsidy(
	txArg *MsgDeSoTxn, minFeeRateNanosPerKB uint64, inputSubsidy uint64, mempool *DeSoMempool, additionalFees uint64) (
	_totalInputAdded uint64, _spendAmount uint64, _totalChangeAdded uint64, _fee uint64, _err error)

func (*Blockchain) BestChain

func (bc *Blockchain) BestChain() []*BlockNode

func (*Blockchain) BlockTip

func (bc *Blockchain) BlockTip() *BlockNode

func (*Blockchain) ChainState

func (bc *Blockchain) ChainState() SyncState

func (*Blockchain) CopyBestChain

func (bc *Blockchain) CopyBestChain() ([]*BlockNode, map[BlockHash]*BlockNode)

func (*Blockchain) CopyBestHeaderChain

func (bc *Blockchain) CopyBestHeaderChain() ([]*BlockNode, map[BlockHash]*BlockNode)

func (*Blockchain) CopyBlockIndex

func (bc *Blockchain) CopyBlockIndex() map[BlockHash]*BlockNode

func (*Blockchain) CreateAcceptNFTBidTxn

func (bc *Blockchain) CreateAcceptNFTBidTxn(
	UpdaterPublicKey []byte,
	NFTPostHash *BlockHash,
	SerialNumber uint64,
	BidderPKID *PKID,
	BidAmountNanos uint64,
	EncryptedUnlockableTextBytes []byte,

	minFeeRateNanosPerKB uint64, mempool *DeSoMempool, additionalOutputs []*DeSoOutput) (
	_txn *MsgDeSoTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, _err error)

func (*Blockchain) CreateAcceptNFTTransferTxn

func (bc *Blockchain) CreateAcceptNFTTransferTxn(
	UpdaterPublicKey []byte,
	NFTPostHash *BlockHash,
	SerialNumber uint64,

	minFeeRateNanosPerKB uint64, mempool *DeSoMempool, additionalOutputs []*DeSoOutput) (
	_txn *MsgDeSoTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, _err error)

func (*Blockchain) CreateAuthorizeDerivedKeyTxn

func (bc *Blockchain) CreateAuthorizeDerivedKeyTxn(
	ownerPublicKey []byte,
	derivedPublicKey []byte,
	expirationBlock uint64,
	accessSignature []byte,
	deleteKey bool,
	derivedKeySignature bool,

	minFeeRateNanosPerKB uint64, mempool *DeSoMempool, additionalOutputs []*DeSoOutput) (
	_txn *MsgDeSoTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, _err error)

func (*Blockchain) CreateBasicTransferTxnWithDiamonds

func (bc *Blockchain) CreateBasicTransferTxnWithDiamonds(
	SenderPublicKey []byte,
	DiamondPostHash *BlockHash,
	DiamondLevel int64,

	minFeeRateNanosPerKB uint64, mempool *DeSoMempool, additionalOutputs []*DeSoOutput) (
	_txn *MsgDeSoTxn, _totalInput uint64, _spendAmount uint64, _changeAmount uint64, _fees uint64, _err error)

func (*Blockchain) CreateBurnNFTTxn

func (bc *Blockchain) CreateBurnNFTTxn(
	UpdaterPublicKey []byte,
	NFTPostHash *BlockHash,
	SerialNumber uint64,

	minFeeRateNanosPerKB uint64, mempool *DeSoMempool, additionalOutputs []*DeSoOutput) (
	_txn *MsgDeSoTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, _err error)

func (*Blockchain) CreateCreateNFTTxn

func (bc *Blockchain) CreateCreateNFTTxn(
	UpdaterPublicKey []byte,
	NFTPostHash *BlockHash,
	NumCopies uint64,
	HasUnlockable bool,
	IsForSale bool,
	MinBidAmountNanos uint64,
	NFTFee uint64,
	NFTRoyaltyToCreatorBasisPoints uint64,
	NFTRoyaltyToCoinBasisPoints uint64,

	minFeeRateNanosPerKB uint64, mempool *DeSoMempool, additionalOutputs []*DeSoOutput) (
	_txn *MsgDeSoTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, _err error)

func (*Blockchain) CreateCreatorCoinTransferTxn

func (bc *Blockchain) CreateCreatorCoinTransferTxn(
	UpdaterPublicKey []byte,
	ProfilePublicKey []byte,
	CreatorCoinToTransferNanos uint64,
	RecipientPublicKey []byte,

	minFeeRateNanosPerKB uint64, mempool *DeSoMempool, additionalOutputs []*DeSoOutput) (
	_txn *MsgDeSoTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, _err error)

func (*Blockchain) CreateCreatorCoinTransferTxnWithDiamonds

func (bc *Blockchain) CreateCreatorCoinTransferTxnWithDiamonds(
	SenderPublicKey []byte,
	ReceiverPublicKey []byte,
	DiamondPostHash *BlockHash,
	DiamondLevel int64,

	minFeeRateNanosPerKB uint64, mempool *DeSoMempool, additionalOutputs []*DeSoOutput) (
	_txn *MsgDeSoTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, _err error)

func (*Blockchain) CreateCreatorCoinTxn

func (bc *Blockchain) CreateCreatorCoinTxn(
	UpdaterPublicKey []byte,

	ProfilePublicKey []byte,
	OperationType CreatorCoinOperationType,
	DeSoToSellNanos uint64,
	CreatorCoinToSellNanos uint64,
	DeSoToAddNanos uint64,
	MinDeSoExpectedNanos uint64,
	MinCreatorCoinExpectedNanos uint64,

	minFeeRateNanosPerKB uint64, mempool *DeSoMempool, additionalOutputs []*DeSoOutput) (
	_txn *MsgDeSoTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, _err error)

func (*Blockchain) CreateFollowTxn

func (bc *Blockchain) CreateFollowTxn(
	senderPublicKey []byte, followedPublicKey []byte, isUnfollow bool,
	minFeeRateNanosPerKB uint64, mempool *DeSoMempool, additionalOutputs []*DeSoOutput) (
	_txn *MsgDeSoTxn, _totalInput uint64, _changeAmount uint64, _fees uint64,
	_err error)

func (*Blockchain) CreateLikeTxn

func (bc *Blockchain) CreateLikeTxn(
	userPublicKey []byte, likedPostHash BlockHash, isUnlike bool,
	minFeeRateNanosPerKB uint64, mempool *DeSoMempool, additionalOutputs []*DeSoOutput) (
	_txn *MsgDeSoTxn, _totalInput uint64, _changeAmount uint64, _fees uint64,
	_err error)

func (*Blockchain) CreateMaxSpend

func (bc *Blockchain) CreateMaxSpend(
	senderPkBytes []byte, recipientPkBytes []byte, minFeeRateNanosPerKB uint64,
	mempool *DeSoMempool, additionalOutputs []*DeSoOutput) (
	_txn *MsgDeSoTxn, _totalInputAdded uint64, _spendAmount uint64, _fee uint64, _err error)

func (*Blockchain) CreateNFTBidTxn

func (bc *Blockchain) CreateNFTBidTxn(
	UpdaterPublicKey []byte,
	NFTPostHash *BlockHash,
	SerialNumber uint64,
	BidAmountNanos uint64,

	minFeeRateNanosPerKB uint64, mempool *DeSoMempool, additionalOutputs []*DeSoOutput) (
	_txn *MsgDeSoTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, _err error)

func (*Blockchain) CreateNFTTransferTxn

func (bc *Blockchain) CreateNFTTransferTxn(
	SenderPublicKey []byte,
	ReceiverPublicKey []byte,
	NFTPostHash *BlockHash,
	SerialNumber uint64,
	EncryptedUnlockableTextBytes []byte,

	minFeeRateNanosPerKB uint64, mempool *DeSoMempool, additionalOutputs []*DeSoOutput) (
	_txn *MsgDeSoTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, _err error)

func (*Blockchain) CreatePrivateMessageTxn

func (bc *Blockchain) CreatePrivateMessageTxn(
	senderPublicKey []byte, recipientPublicKey []byte,
	unencryptedMessageText string, encryptedMessageText string,
	tstampNanos uint64,
	minFeeRateNanosPerKB uint64, mempool *DeSoMempool, additionalOutputs []*DeSoOutput) (
	_txn *MsgDeSoTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, _err error)

func (*Blockchain) CreateSubmitPostTxn

func (bc *Blockchain) CreateSubmitPostTxn(

	updaterPublicKey []byte,
	postHashToModify []byte,
	parentStakeID []byte,
	body []byte,
	repostPostHashBytes []byte,
	isQuotedRepost bool,
	tstampNanos uint64,
	postExtraData map[string][]byte,
	isHidden bool,

	minFeeRateNanosPerKB uint64, mempool *DeSoMempool, additionalOutputs []*DeSoOutput) (
	_txn *MsgDeSoTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, _err error)

func (*Blockchain) CreateSwapIdentityTxn

func (bc *Blockchain) CreateSwapIdentityTxn(
	UpdaterPublicKeyBytes []byte,
	FromPublicKeyBytes []byte,
	ToPublicKeyBytes []byte,

	minFeeRateNanosPerKB uint64, mempool *DeSoMempool, additionalOutputs []*DeSoOutput) (
	_txn *MsgDeSoTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, _err error)

func (*Blockchain) CreateUpdateBitcoinUSDExchangeRateTxn

func (bc *Blockchain) CreateUpdateBitcoinUSDExchangeRateTxn(

	updaterPublicKey []byte,
	usdCentsPerbitcoin uint64,

	minFeeRateNanosPerKB uint64, mempool *DeSoMempool, additionalOutputs []*DeSoOutput) (
	_txn *MsgDeSoTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, _err error)

func (*Blockchain) CreateUpdateGlobalParamsTxn

func (bc *Blockchain) CreateUpdateGlobalParamsTxn(updaterPublicKey []byte,
	usdCentsPerBitcoin int64,
	createProfileFeesNanos int64,
	createNFTFeesNanos int64,
	maxCopiesPerNFT int64,
	minimumNetworkFeeNanosPerKb int64,
	forbiddenPubKey []byte,

	minFeeRateNanosPerKB uint64, mempool *DeSoMempool, additionalOutputs []*DeSoOutput) (
	_txn *MsgDeSoTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, _err error)

func (*Blockchain) CreateUpdateNFTTxn

func (bc *Blockchain) CreateUpdateNFTTxn(
	UpdaterPublicKey []byte,
	NFTPostHash *BlockHash,
	SerialNumber uint64,
	IsForSale bool,
	MinBidAmountNanos uint64,

	minFeeRateNanosPerKB uint64, mempool *DeSoMempool, additionalOutputs []*DeSoOutput) (
	_txn *MsgDeSoTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, _err error)

func (*Blockchain) CreateUpdateProfileTxn

func (bc *Blockchain) CreateUpdateProfileTxn(
	UpdaterPublicKeyBytes []byte,

	OptionalProfilePublicKeyBytes []byte,
	NewUsername string,
	NewDescription string,
	NewProfilePic string,
	NewCreatorBasisPoints uint64,
	NewStakeMultipleBasisPoints uint64,
	IsHidden bool,
	AdditionalFees uint64,

	minFeeRateNanosPerKB uint64, mempool *DeSoMempool, additionalOutputs []*DeSoOutput) (
	_txn *MsgDeSoTxn, _totalInput uint64, _changeAmount uint64, _fees uint64, _err error)

func (*Blockchain) DB

func (bc *Blockchain) DB() *badger.DB

func (*Blockchain) EstimateDefaultFeeRateNanosPerKB

func (bc *Blockchain) EstimateDefaultFeeRateNanosPerKB(
	medianThreshold float64, minFeeRateNanosPerKB uint64) uint64

func (*Blockchain) GetBlock

func (bc *Blockchain) GetBlock(blockHash *BlockHash) *MsgDeSoBlock

Don't need a lock because blocks don't get removed from the db after they're added

func (*Blockchain) GetBlockAtHeight

func (bc *Blockchain) GetBlockAtHeight(height uint32) *MsgDeSoBlock

func (*Blockchain) GetBlockNodesToFetch

func (bc *Blockchain) GetBlockNodesToFetch(
	numBlocks int, _maxHeight int, blocksToIgnore map[BlockHash]bool) []*BlockNode

func (*Blockchain) GetSpendableUtxosForPublicKey

func (bc *Blockchain) GetSpendableUtxosForPublicKey(spendPublicKeyBytes []byte, mempool *DeSoMempool, referenceUtxoView *UtxoView) ([]*UtxoEntry, error)

func (*Blockchain) HasBlock

func (bc *Blockchain) HasBlock(blockHash *BlockHash) bool

func (*Blockchain) HasHeader

func (bc *Blockchain) HasHeader(headerHash *BlockHash) bool

func (*Blockchain) HeaderAtHeight

func (bc *Blockchain) HeaderAtHeight(blockHeight uint32) *BlockNode

func (*Blockchain) HeaderLocatorWithNodeHash

func (bc *Blockchain) HeaderLocatorWithNodeHash(blockHash *BlockHash) ([]*BlockHash, error)

func (*Blockchain) HeaderTip

func (bc *Blockchain) HeaderTip() *BlockNode

func (*Blockchain) LatestHeaderLocator

func (bc *Blockchain) LatestHeaderLocator() []*BlockHash

LatestHeaderLocator calls LatestLocator in order to fetch a locator for the best header chain.

func (*Blockchain) LatestLocator

func (bc *Blockchain) LatestLocator(tip *BlockNode) []*BlockHash

LatestLocator returns a block locator for the passed block node. The passed node can be nil in which case the block locator for the current tip associated with the view will be returned.

BlockLocator is used to help locate a specific block. The algorithm for building the block locator is to add the hashes in reverse order until the genesis block is reached. In order to keep the list of locator hashes to a reasonable number of entries, first the most recent previous 12 block hashes are added, then the step is doubled each loop iteration to exponentially decrease the number of hashes as a function of the distance from the block being located.

For example, assume a block chain with a side chain as depicted below:

genesis -> 1 -> 2 -> ... -> 15 -> 16  -> 17  -> 18
                              \-> 16a -> 17a

The block locator for block 17a would be the hashes of blocks: [17a 16a 15 14 13 12 11 10 9 8 7 6 4 genesis]

Caller is responsible for acquiring the ChainLock before calling this function.

func (*Blockchain) LocateBestBlockChainHeaders

func (bc *Blockchain) LocateBestBlockChainHeaders(locator []*BlockHash, stopHash *BlockHash) []*MsgDeSoHeader

LocateBestBlockChainHeaders returns the headers of the blocks after the first known block in the locator until the provided stop hash is reached, or up to a max of wire.MaxBlockHeadersPerMsg headers. Note that it returns the best headers considering only headers for which we have blocks (that is, it considers the best *block* chain we have rather than the best *header* chain). This is the correct thing to do because in general this function is called in order to serve a response to a peer's GetHeaders request.

In addition, there are two special cases:

  • When no locators are provided, the stop hash is treated as a request for that header, so it will either return the header for the stop hash itself if it is known, or nil if it is unknown
  • When locators are provided, but none of them are known, headers starting after the genesis block will be returned

This function is safe for concurrent access.

func (*Blockchain) MarkBlockInvalid

func (bc *Blockchain) MarkBlockInvalid(node *BlockNode, errOccurred RuleError)

func (*Blockchain) ProcessBlock

func (bc *Blockchain) ProcessBlock(desoBlock *MsgDeSoBlock, verifySignatures bool) (_isMainChain bool, _isOrphan bool, _err error)

Note: It is the caller's responsibility to ensure that the BitcoinManager is time-current prior to calling ProcessBlock on any transactions that require the BitcoinManager for validation (e.g. BitcoinExchange transactions). Failure to do so will cause ProcessBlock to error on blocks that could otherwise be valid if a time-current BitcoinManager were available. If it is known for sure that no BitcoinExchange transactions need to be validated then it is OK for the BitcoinManager to not be time-current and even for it to be nil entirely. This is useful e.g. for tests where we want to exercise ProcessBlock without setting up a time-current BitcoinManager.

func (*Blockchain) ProcessHeader

func (bc *Blockchain) ProcessHeader(blockHeader *MsgDeSoHeader, headerHash *BlockHash) (_isMainChain bool, _isOrphan bool, _err error)

ProcessHeader is a wrapper around processHeader, which does the leg-work, that acquires the ChainLock first.

func (*Blockchain) ProcessOrphanBlock

func (bc *Blockchain) ProcessOrphanBlock(desoBlock *MsgDeSoBlock, blockHash *BlockHash) error

ProcessOrphanBlock runs some very basic validation on the orphan block and adds it to our orphan data structure if it passes. If there are too many orphan blocks in our data structure, it also evicts the oldest block to make room for this one.

TODO: Currently we only remove orphan blocks if we have too many. This means in a steady state we are potentially keeping MaxOrphansInMemory at all times, which is wasteful of resources. Better would be to clean up orphan blocks once they're too old or something like that.

func (*Blockchain) SetBestChain

func (bc *Blockchain) SetBestChain(bestChain []*BlockNode)

func (*Blockchain) SetBestChainMap

func (bc *Blockchain) SetBestChainMap(bestChain []*BlockNode, bestChainMap map[BlockHash]*BlockNode, blockIndex map[BlockHash]*BlockNode)

func (*Blockchain) ValidateTransaction

func (bc *Blockchain) ValidateTransaction(
	txnMsg *MsgDeSoTxn, blockHeight uint32, verifySignatures bool, mempool *DeSoMempool) error

ValidateTransaction creates a UtxoView and sees if the transaction can be connected to it. If a mempool is provided, this function tries to find dependencies of the passed-in transaction in the pool and connect them before trying to connect the passed-in transaction.

type BlockchainInfoAPIResponse added in v1.2.3

type BlockchainInfoAPIResponse struct {
	DoubleSpend bool `json:"double_spend"`
}

type BlockonomicsRBFResponse

type BlockonomicsRBFResponse struct {
	RBF    int64  `json:"rbf"`
	Status string `json:"status"`
}

type BurnNFTMetadata

type BurnNFTMetadata struct {
	NFTPostHash  *BlockHash
	SerialNumber uint64
}

func (*BurnNFTMetadata) FromBytes

func (txnData *BurnNFTMetadata) FromBytes(dataa []byte) error

func (*BurnNFTMetadata) GetTxnType

func (txnData *BurnNFTMetadata) GetTxnType() TxnType

func (*BurnNFTMetadata) New

func (txnData *BurnNFTMetadata) New() DeSoTxnMetadata

func (*BurnNFTMetadata) ToBytes

func (txnData *BurnNFTMetadata) ToBytes(preSignature bool) ([]byte, error)

type ChainType

type ChainType uint8

type CoinEntry

type CoinEntry struct {
	// The amount the owner of this profile receives when there is a
	// "net new" purchase of their coin.
	CreatorBasisPoints uint64

	// The amount of DeSo backing the coin. Whenever a user buys a coin
	// from the protocol this amount increases, and whenever a user sells a
	// coin to the protocol this decreases.
	DeSoLockedNanos uint64

	// The number of public keys who have holdings in this creator coin.
	// Due to floating point truncation, it can be difficult to simultaneously
	// reset CoinsInCirculationNanos and DeSoLockedNanos to zero after
	// everyone has sold all their creator coins. Initially NumberOfHolders
	// is set to zero. Once it returns to zero after a series of buys & sells
	// we reset the DeSoLockedNanos and CoinsInCirculationNanos to prevent
	// abnormal bancor curve behavior.
	NumberOfHolders uint64

	// The number of coins currently in circulation. Whenever a user buys a
	// coin from the protocol this increases, and whenever a user sells a
	// coin to the protocol this decreases.
	CoinsInCirculationNanos uint64

	// This field keeps track of the highest number of coins that has ever
	// been in circulation. It is used to determine when a creator should
	// receive a "founder reward." In particular, whenever the number of
	// coins being minted would push the number of coins in circulation
	// beyond the watermark, we allocate a percentage of the coins being
	// minted to the creator as a "founder reward."
	CoinWatermarkNanos uint64
}

This struct contains all the information required to support coin buy/sell transactions on profiles.

type ConnectionManager

type ConnectionManager struct {
	// contains filtered or unexported fields
}

func NewConnectionManager

func NewConnectionManager(
	_params *DeSoParams, _addrMgr *addrmgr.AddrManager, _listeners []net.Listener,
	_connectIps []string, _timeSource chainlib.MedianTimeSource,
	_targetOutboundPeers uint32, _maxInboundPeers uint32,
	_limitOneInboundConnectionPerIP bool,
	_stallTimeoutSeconds uint64,
	_minFeeRateNanosPerKB uint64,
	_serverMessageQueue chan *ServerMessage,
	_srv *Server) *ConnectionManager

func (*ConnectionManager) ConnectPeer

func (cmgr *ConnectionManager) ConnectPeer(conn net.Conn, persistentAddr *wire.NetAddress)

Connect either an INBOUND or OUTBOUND peer. If conn == nil, then we will set up an OUTBOUND peer. Otherwise we will use the conn to create an INBOUND peer. If the connectoin is OUTBOUND and the persistentAddr is set, then we will connect only to that addr. Otherwise, we will use the addrmgr to randomly select addrs and create OUTBOUND connections with them until we find a worthy peer.

func (*ConnectionManager) GetAddrManager

func (cmgr *ConnectionManager) GetAddrManager() *addrmgr.AddrManager

func (*ConnectionManager) GetAllPeers

func (cmgr *ConnectionManager) GetAllPeers() []*Peer

GetAllPeers holds the mtxPeerMaps lock for reading and returns a list containing pointers to all the active peers.

func (*ConnectionManager) RandomPeer

func (cmgr *ConnectionManager) RandomPeer() *Peer

func (*ConnectionManager) RemovePeer

func (cmgr *ConnectionManager) RemovePeer(pp *Peer)

Update our data structures to remove this peer.

func (*ConnectionManager) Start

func (cmgr *ConnectionManager) Start()

func (*ConnectionManager) Stop

func (cmgr *ConnectionManager) Stop()

type CreateNFTMetadata

type CreateNFTMetadata struct {
	NFTPostHash                    *BlockHash
	NumCopies                      uint64
	HasUnlockable                  bool
	IsForSale                      bool
	MinBidAmountNanos              uint64
	NFTRoyaltyToCreatorBasisPoints uint64
	NFTRoyaltyToCoinBasisPoints    uint64
}

func (*CreateNFTMetadata) FromBytes

func (txnData *CreateNFTMetadata) FromBytes(dataa []byte) error

func (*CreateNFTMetadata) GetTxnType

func (txnData *CreateNFTMetadata) GetTxnType() TxnType

func (*CreateNFTMetadata) New

func (txnData *CreateNFTMetadata) New() DeSoTxnMetadata

func (*CreateNFTMetadata) ToBytes

func (txnData *CreateNFTMetadata) ToBytes(preSignature bool) ([]byte, error)

type CreatorCoinMetadataa

type CreatorCoinMetadataa struct {
	// ProfilePublicKey is the public key of the profile that owns the
	// coin the person wants to operate on. Creator coins can only be
	// bought and sold if a valid profile exists.
	ProfilePublicKey []byte

	// OperationType specifies what the user wants to do with this
	// creator coin.
	OperationType CreatorCoinOperationType

	// Generally, only one of these will be used depending on the OperationType
	// set. In a Buy transaction, DeSoToSellNanos will be converted into
	// creator coin on behalf of the user. In a Sell transaction,
	// CreatorCoinToSellNanos will be converted into DeSo. In an AddDeSo
	// operation, DeSoToAddNanos will be aded for the user. This allows us to
	// support multiple transaction types with same meta field.
	DeSoToSellNanos        uint64
	CreatorCoinToSellNanos uint64
	DeSoToAddNanos         uint64

	// When a user converts DeSo into CreatorCoin, MinCreatorCoinExpectedNanos
	// specifies the minimum amount of creator coin that the user expects from their
	// transaction. And vice versa when a user is converting CreatorCoin for DeSo.
	// Specifying these fields prevents the front-running of users' buy/sell. Setting
	// them to zero turns off the check. Give it your best shot, Ivan.
	MinDeSoExpectedNanos        uint64
	MinCreatorCoinExpectedNanos uint64
}

func (*CreatorCoinMetadataa) FromBytes

func (txnData *CreatorCoinMetadataa) FromBytes(dataa []byte) error

func (*CreatorCoinMetadataa) GetTxnType

func (txnData *CreatorCoinMetadataa) GetTxnType() TxnType

func (*CreatorCoinMetadataa) New

func (txnData *CreatorCoinMetadataa) New() DeSoTxnMetadata

func (*CreatorCoinMetadataa) ToBytes

func (txnData *CreatorCoinMetadataa) ToBytes(preSignature bool) ([]byte, error)

type CreatorCoinOperationType

type CreatorCoinOperationType uint8
const (
	CreatorCoinOperationTypeBuy     CreatorCoinOperationType = 0
	CreatorCoinOperationTypeSell    CreatorCoinOperationType = 1
	CreatorCoinOperationTypeAddDeSo CreatorCoinOperationType = 2
)

type CreatorCoinTransferMetadataa

type CreatorCoinTransferMetadataa struct {
	// ProfilePublicKey is the public key of the profile that owns the
	// coin the person wants to transer. Creator coins can only be
	// transferred if a valid profile exists.
	ProfilePublicKey []byte

	CreatorCoinToTransferNanos uint64
	ReceiverPublicKey          []byte
}

func (*CreatorCoinTransferMetadataa) FromBytes

func (txnData *CreatorCoinTransferMetadataa) FromBytes(dataa []byte) error

func (*CreatorCoinTransferMetadataa) GetTxnType

func (txnData *CreatorCoinTransferMetadataa) GetTxnType() TxnType

func (*CreatorCoinTransferMetadataa) New

func (*CreatorCoinTransferMetadataa) ToBytes

func (txnData *CreatorCoinTransferMetadataa) ToBytes(preSignature bool) ([]byte, error)

type CreatorCoinTransferTxindexMetadata

type CreatorCoinTransferTxindexMetadata struct {
	CreatorUsername            string
	CreatorCoinToTransferNanos uint64
	DiamondLevel               int64
	PostHashHex                string
}

type CreatorCoinTxindexMetadata

type CreatorCoinTxindexMetadata struct {
	OperationType string

	// Differs depending on OperationType.
	DeSoToSellNanos        uint64
	CreatorCoinToSellNanos uint64
	DeSoToAddNanos         uint64

	// Rosetta needs to know how much DESO was added or removed so it can
	// model the change to the total deso locked in the creator coin
	DESOLockedNanosDiff int64
}

type DeSoBlockProducer

type DeSoBlockProducer struct {
	// contains filtered or unexported fields
}

func NewDeSoBlockProducer

func NewDeSoBlockProducer(
	minBlockUpdateIntervalSeconds uint64,
	maxBlockTemplatesToCache uint64,
	blockProducerSeed string,
	mempool *DeSoMempool,
	chain *Blockchain,
	params *DeSoParams,
	postgres *Postgres,
) (*DeSoBlockProducer, error)

func (*DeSoBlockProducer) AddBlockTemplate

func (desoBlockProducer *DeSoBlockProducer) AddBlockTemplate(block *MsgDeSoBlock, diffTarget *BlockHash)

func (*DeSoBlockProducer) GetCopyOfRecentBlock

func (desoBlockProducer *DeSoBlockProducer) GetCopyOfRecentBlock(blockID string) (*MsgDeSoBlock, error)

func (*DeSoBlockProducer) GetHeadersAndExtraDatas

func (blockProducer *DeSoBlockProducer) GetHeadersAndExtraDatas(
	publicKeyBytes []byte, numHeaders int64, headerVersion uint32) (
	_blockID string, _headers [][]byte, _extraNonces []uint64, _diffTarget *BlockHash, _err error)

func (*DeSoBlockProducer) GetLatestBlockTemplateStats

func (bbp *DeSoBlockProducer) GetLatestBlockTemplateStats() *BlockTemplateStats

func (*DeSoBlockProducer) GetRecentBlock

func (desoBlockProducer *DeSoBlockProducer) GetRecentBlock(blockHash *BlockHash) *MsgDeSoBlock

func (*DeSoBlockProducer) SignBlock

func (desoBlockProducer *DeSoBlockProducer) SignBlock(blockFound *MsgDeSoBlock) error

func (*DeSoBlockProducer) Start

func (desoBlockProducer *DeSoBlockProducer) Start()

func (*DeSoBlockProducer) Stop

func (desoBlockProducer *DeSoBlockProducer) Stop()

func (*DeSoBlockProducer) UpdateLatestBlockTemplate

func (desoBlockProducer *DeSoBlockProducer) UpdateLatestBlockTemplate() error

type DeSoBodySchema

type DeSoBodySchema struct {
	Body      string   `json:",omitempty"`
	ImageURLs []string `json:",omitempty"`
	VideoURLs []string `json:",omitempty"`
}

DeSoBodySchema Within a post, the body typically has a particular schema defined below.

type DeSoInput

type DeSoInput UtxoKey

DeSoInput represents a single unspent output from a previous txn. For that reason it specifies the previous txn and the index in that txn where the output appears by simply aliasing UtxoKey.

func NewDeSoInput

func NewDeSoInput() *DeSoInput

func (*DeSoInput) String

func (desoInput *DeSoInput) String() string

type DeSoMempool

type DeSoMempool struct {
	// contains filtered or unexported fields
}

DeSoMempool is the core mempool object. It's what any outside service should use to aggregate transactions and mine them into blocks.

func NewDeSoMempool

func NewDeSoMempool(_bc *Blockchain, _rateLimitFeerateNanosPerKB uint64,
	_minFeerateNanosPerKB uint64, _blockCypherAPIKey string,
	_runReadOnlyViewUpdater bool, _dataDir string, _mempoolDumpDir string) *DeSoMempool

Create a new pool with no transactions in it.

func (*DeSoMempool) BlockUntilReadOnlyViewRegenerated

func (mp *DeSoMempool) BlockUntilReadOnlyViewRegenerated()

func (*DeSoMempool) CheckSpend

func (mp *DeSoMempool) CheckSpend(op UtxoKey) *MsgDeSoTxn

func (*DeSoMempool) Count

func (mp *DeSoMempool) Count() int

Returns an estimate of the number of txns in the mempool. This is an estimate because it looks up the number from a readOnly view, which updates at regular intervals and *not* every time a txn is added to the pool.

func (*DeSoMempool) DumpTxnsToDB

func (mp *DeSoMempool) DumpTxnsToDB()

func (*DeSoMempool) FetchTransaction

func (mp *DeSoMempool) FetchTransaction(txHash *BlockHash) *MempoolTx

func (*DeSoMempool) GetAugmentedUniversalView

func (mp *DeSoMempool) GetAugmentedUniversalView() (*UtxoView, error)

GetAugmentedUniversalView creates a view that just connects everything in the mempool... TODO(performance): We should make a read-only version of the universal view that you can get from the mempool.

func (*DeSoMempool) GetAugmentedUtxoViewForPublicKey

func (mp *DeSoMempool) GetAugmentedUtxoViewForPublicKey(pkBytes []byte, optionalTxn *MsgDeSoTxn) (*UtxoView, error)

GetAugmentedUtxoViewForPublicKey creates a UtxoView that has connected all of the transactions that could result in utxos for the passed-in public key plus all of the dependencies of those transactions. This is useful for when we want to validate a transaction that builds on a transaction that has not yet been mined into a block. It is also useful for when we want to fetch all the unspent UtxoEntrys factoring in what's been spent by transactions in the mempool.

func (*DeSoMempool) GetMempoolSummaryStats

func (mp *DeSoMempool) GetMempoolSummaryStats() (_summaryStatsMap map[string]*SummaryStats)

func (*DeSoMempool) GetTransaction

func (mp *DeSoMempool) GetTransaction(txId *BlockHash) (txn *MempoolTx)

func (*DeSoMempool) GetTransactionsOrderedByTimeAdded

func (mp *DeSoMempool) GetTransactionsOrderedByTimeAdded() (_poolTxns []*MempoolTx, _unconnectedTxns []*UnconnectedTx, _err error)

Acquires a read lock before returning the transactions.

func (*DeSoMempool) InefficientRemoveTransaction

func (mp *DeSoMempool) InefficientRemoveTransaction(tx *MsgDeSoTxn)

func (*DeSoMempool) IsTransactionInPool

func (mp *DeSoMempool) IsTransactionInPool(hash *BlockHash) bool

Whether or not a txn is in the pool. Safe for concurrent access.

func (*DeSoMempool) LoadTxnsFromDB

func (mp *DeSoMempool) LoadTxnsFromDB()

func (*DeSoMempool) MempoolTxs

func (mp *DeSoMempool) MempoolTxs() []*MempoolTx

Returns all MempoolTxs from the readOnly view.

func (*DeSoMempool) OpenTempDBAndDumpTxns

func (mp *DeSoMempool) OpenTempDBAndDumpTxns() error

func (*DeSoMempool) ProcessTransaction

func (mp *DeSoMempool) ProcessTransaction(tx *MsgDeSoTxn, allowUnconnectedTxn bool, rateLimit bool, peerID uint64, verifySignatures bool) ([]*MempoolTx, error)

ProcessTransaction is the main function called by outside services to potentially add a transaction to the mempool. It will try to add the txn to the main pool, and then try to add it as an unconnected txn if that fails.

func (*DeSoMempool) ProcessUnconnectedTransactions

func (mp *DeSoMempool) ProcessUnconnectedTransactions(acceptedTx *MsgDeSoTxn, rateLimit bool, verifySignatures bool) []*MempoolTx

ProcessUnconnectedTransactions tries to see if any unconnectedTxns can now be added to the pool.

func (*DeSoMempool) PublicKeyTxnMap

func (mp *DeSoMempool) PublicKeyTxnMap(publicKey []byte) (txnMap map[BlockHash]*MempoolTx)

func (*DeSoMempool) RegenerateReadOnlyView

func (mp *DeSoMempool) RegenerateReadOnlyView() error

func (*DeSoMempool) StartMempoolDBDumper

func (mp *DeSoMempool) StartMempoolDBDumper()

func (*DeSoMempool) StartReadOnlyUtxoViewRegenerator

func (mp *DeSoMempool) StartReadOnlyUtxoViewRegenerator()

func (*DeSoMempool) Stop

func (mp *DeSoMempool) Stop()

func (*DeSoMempool) TryAcceptTransaction

func (mp *DeSoMempool) TryAcceptTransaction(tx *MsgDeSoTxn, rateLimit bool, verifySignatures bool) ([]*BlockHash, *MempoolTx, error)

This is the main function used for adding a new txn to the pool. It will run all needed validation on the txn before adding it, and it will only accept the txn if these validations pass.

The ChainLock must be held for reading calling this function.

func (*DeSoMempool) TxHashes

func (mp *DeSoMempool) TxHashes() []*BlockHash

Returns the hashes of all the txns in the pool using the readOnly view, which could be slightly out of date.

func (*DeSoMempool) UpdateAfterConnectBlock

func (mp *DeSoMempool) UpdateAfterConnectBlock(blk *MsgDeSoBlock) (_txnsAddedToMempool []*MempoolTx)

UpdateAfterConnectBlock updates the mempool after a block has been added to the blockchain. It does this by basically removing all known transactions in the block from the mempool as follows:

  • Build a map of all of the transactions in the block indexed by their hash.
  • Create a new mempool object.
  • Iterate through all the transactions in the mempool and add the transactions to the new pool object *only if* they don't appear in the block. Do this for transactions in the pool and in the unconnectedTx pool.
  • Compute which transactions were newly-accepted into the pool by effectively diffing the new pool's transactions with the old pool's transactions.
  • Once the new pool object is up-to-date, the fields of the new pool object replace the fields of the original pool object.
  • Return the newly added transactions computed earlier.

TODO: This is fairly inefficient but the story is the same as for UpdateAfterDisconnectBlock.

func (*DeSoMempool) UpdateAfterDisconnectBlock

func (mp *DeSoMempool) UpdateAfterDisconnectBlock(blk *MsgDeSoBlock)

UpdateAfterDisconnectBlock updates the mempool to reflect that a block has been disconnected from the blockchain. It does this by basically adding all the transactions in the block back to the mempool as follows:

  • A new pool object is created containing no transactions.
  • The block's transactions are added to this new pool object. This is done in order to minimize dependency-related conflicts with transactions already in the mempool.
  • Then the transactions in the original pool are layered on top of the block's transactions in the new pool object. Again this is done to avoid dependency issues since the ordering of <block txns> followed by <original mempool txns> is much less likely to have issues.
  • Then, once the new pool object is up-to-date, the fields of the new pool object replace the fields of the original pool object.

This function is safe for concurrent access. It is assumed the ChainLock is held before this function is a accessed.

TODO: This is fairly inefficient and basically only necessary because computing a transaction's dependencies is a little shaky. If we end up making the dependency detection logic more robust then we could come back here and change this so that we're not effectively reprocessing the entire mempool every time we have a new block. But until then doing it this way significantly reduces complexity and should hold up for a while.

type DeSoMessage

type DeSoMessage interface {
	// The following methods allow one to convert a message struct into
	// a byte slice and back. Example usage:
	//
	//   params := &DeSoTestnetParams
	//   msgType := MsgTypeVersion
	//   byteSlice := []byte{0x00, ...}
	//
	// 	 msg := NewMessage(msgType)
	//   err := msg.FromBytes(byteSlice)
	//   newByteSlice, err := msg.ToBytes(false)
	//
	// The data format is intended to be compact while allowing for efficient
	// transmission over the wire and storage in a database.
	//
	// The preSignature field specifies whether the message should be fully
	// serialized or whether it should be serialized in such a way that it
	// can be signed (which involves, for example, not serializing signature
	// fields).
	ToBytes(preSignature bool) ([]byte, error)
	FromBytes(data []byte) error

	// Each Message has a particular type.
	GetMsgType() MsgType
}

DeSoMessage is the interface that a message we send on the wire must implement.

func NewMessage

func NewMessage(msgType MsgType) DeSoMessage

func ReadMessage

func ReadMessage(rr io.Reader, networkType NetworkType) (DeSoMessage, []byte, error)

ReadMessage takes an io.Reader and de-serializes a single message from it. Returns an error if the message is malformed or invalid for any reason. Otherwise returns a formed message object and the raw byte payload from which it was derived.

type DeSoMessageMeta

type DeSoMessageMeta struct {
	DeSoMessage DeSoMessage
	Inbound     bool
}

type DeSoMiner

type DeSoMiner struct {
	PublicKeys []*btcec.PublicKey

	BlockProducer *DeSoBlockProducer
	// contains filtered or unexported fields
}

func NewDeSoMiner

func NewDeSoMiner(_minerPublicKeys []string, _numThreads uint32,
	_blockProducer *DeSoBlockProducer, _params *DeSoParams) (*DeSoMiner, error)

func (*DeSoMiner) MineAndProcessSingleBlock

func (desoMiner *DeSoMiner) MineAndProcessSingleBlock(threadIndex uint32, mempoolToUpdate *DeSoMempool) (_block *MsgDeSoBlock, _err error)

func (*DeSoMiner) Start

func (desoMiner *DeSoMiner) Start()

func (*DeSoMiner) Stop

func (desoMiner *DeSoMiner) Stop()

type DeSoNode added in v1.2.8

type DeSoNode struct {
	// Name of the node, displayed to users
	Name string

	// HTTPs URL to the node or app
	URL string

	// DeSo username of the node owner
	Owner string
}

type DeSoOutput

type DeSoOutput struct {
	// Outputs always compensate a specific public key.
	PublicKey []byte
	// The amount of DeSo to send to this public key.
	AmountNanos uint64
}

func (*DeSoOutput) String

func (desoOutput *DeSoOutput) String() string

type DeSoParams

type DeSoParams struct {
	// The network type (mainnet, testnet, etc).
	NetworkType NetworkType
	// The current protocol version we're running.
	ProtocolVersion uint64
	// The minimum protocol version we'll allow a peer we connect to
	// to have.
	MinProtocolVersion uint64
	// Used as a "vanity plate" to identify different DeSo
	// clients. Mainly useful in analyzing the network at
	// a meta level, not in the protocol itself.
	UserAgent string
	// The list of DNS seed hosts to use during bootstrapping.
	DNSSeeds []string

	// A list of DNS seed prefixes and suffixes to use during bootstrapping.
	// These prefixes and suffixes will be scanned and all IPs found will be
	// incorporated into the address manager.
	DNSSeedGenerators [][]string

	// The network parameter for Bitcoin messages as defined by the btcd library.
	// Useful for certain function calls we make to this library.
	BitcoinBtcdParams *chaincfg.Params

	// Because we use the Bitcoin header chain only to process exchanges from
	// BTC to DeSo, we don't need to worry about Bitcoin blocks before a certain
	// point, which is specified by this node. This is basically used to make
	// header download more efficient but it's important to note that if for
	// some reason there becomes a different main chain that is stronger than
	// this one, then we will still switch to that one even with this parameter
	// set such as it is.
	BitcoinStartBlockNode *BlockNode

	// The base58Check-encoded Bitcoin address that users must send Bitcoin to in order
	// to purchase DeSo. Note that, unfortunately, simply using an all-zeros or
	// mostly-all-zeros address or public key doesn't work and, in fact, I found that
	// using almost any address other than this one also doesn't work.
	BitcoinBurnAddress string

	// This is a fee in basis points charged on BitcoinExchange transactions that gets
	// paid to the miners. Basically, if a user burned enough Satoshi to create 100 DeSo,
	// and if the BitcoinExchangeFeeBasisPoints was 1%, then 99 DeSo would be allocated to
	// the user's public key while 1 DeSo would be left as a transaction fee to the miner.
	BitcoinExchangeFeeBasisPoints uint64

	// The amount of time to wait for a Bitcoin txn to broadcast throughout the Bitcoin
	// network before checking for double-spends.
	BitcoinDoubleSpendWaitSeconds float64

	// This field allows us to set the amount purchased at genesis to a non-zero
	// value.
	DeSoNanosPurchasedAtGenesis uint64

	// Port used for network communications among full nodes.
	DefaultSocketPort uint16
	// Port used for the limited JSON API that supports light clients.
	DefaultJSONPort uint16

	// The amount of time we wait when connecting to a peer.
	DialTimeout time.Duration
	// The amount of time we wait to receive a version message from a peer.
	VersionNegotiationTimeout time.Duration

	// The genesis block to use as the base of our chain.
	GenesisBlock *MsgDeSoBlock
	// The expected hash of the genesis block. Should align with what one
	// would get from actually hashing the provided genesis block.
	GenesisBlockHashHex string
	// How often we target a single block to be generated.
	TimeBetweenBlocks time.Duration
	// How many blocks between difficulty retargets.
	TimeBetweenDifficultyRetargets time.Duration
	// Block hashes, when interpreted as big-endian big integers, must be
	// values less than or equal to the difficulty
	// target. The difficulty target is expressed below as a big-endian
	// big integer and is adjusted every TargetTimePerBlock
	// order to keep blocks generating at consistent intervals.
	MinDifficultyTargetHex string
	// We will reject chains that have less than this amount of total work,
	// expressed as a hexadecimal big-endian bigint. Useful for preventing
	// disk-fill attacks, among other things.
	MinChainWorkHex string

	// This is used for determining whether we are still in initial block download.
	// If our tip is older than this, we continue with IBD.
	MaxTipAge time.Duration

	// Do not allow the difficulty to change by more than a factor of this
	// variable during each adjustment period.
	MaxDifficultyRetargetFactor int64
	// Amount of time one must wait before a block reward can be spent.
	BlockRewardMaturity time.Duration
	// When shifting from v0 blocks to v1 blocks, we changed the hash function to
	// DeSoHash, which is technically easier. Thus we needed to apply an adjustment
	// factor in order to phase it in.
	V1DifficultyAdjustmentFactor int64

	// The maximum number of seconds in a future a block timestamp is allowed
	// to be before it is rejected.
	MaxTstampOffsetSeconds uint64

	// The maximum number of bytes that can be allocated to transactions in
	// a block.
	MaxBlockSizeBytes uint64

	// It's useful to set the miner maximum block size to a little lower than the
	// maximum block size in certain cases. For example, on initial launch, setting
	// it significantly lower is a good way to avoid getting hit by spam blocks.
	MinerMaxBlockSizeBytes uint64

	// In order to make public keys more human-readable, we convert
	// them to base58. When we do that, we use a prefix that makes
	// the public keys to become more identifiable. For example, all
	// mainnet public keys start with "X" because we do this.
	Base58PrefixPublicKey  [3]byte
	Base58PrefixPrivateKey [3]byte

	// MaxFetchBlocks is the maximum number of blocks that can be fetched from
	// a peer at one time.
	MaxFetchBlocks uint32

	MiningIterationsPerCycle uint64

	// deso
	MaxUsernameLengthBytes        uint64
	MaxUserDescriptionLengthBytes uint64
	MaxProfilePicLengthBytes      uint64
	MaxProfilePicDimensions       uint64
	MaxPrivateMessageLengthBytes  uint64

	StakeFeeBasisPoints         uint64
	MaxPostBodyLengthBytes      uint64
	MaxPostSubLengthBytes       uint64
	MaxStakeMultipleBasisPoints uint64
	MaxCreatorBasisPoints       uint64
	MaxNFTRoyaltyBasisPoints    uint64
	ParamUpdaterPublicKeys      map[PkMapKey]bool

	// A list of transactions to apply when initializing the chain. Useful in
	// cases where we want to hard fork or reboot the chain with specific
	// transactions applied.
	SeedTxns []string

	// A list of balances to initialize the blockchain with. This is useful for
	// testing and useful in the event that the devs need to hard fork the chain.
	SeedBalances []*DeSoOutput

	// This is a small fee charged on creator coin transactions. It helps
	// prevent issues related to floating point calculations.
	CreatorCoinTradeFeeBasisPoints uint64
	// These two params define the "curve" that we use when someone buys/sells
	// creator coins. Effectively, this curve amounts to a polynomial of the form:
	// - currentCreatorCoinPrice ~= slope * currentCreatorCoinSupply^(1/reserveRatio-1)
	// Buys and sells effectively take the integral of the curve in opposite directions.
	//
	// To better understand where this curve comes from and how it works, check out
	// the following links. They are all well written so don't be intimidated/afraid to
	// dig in and read them:
	// - Primer on bonding curves: https://medium.com/@simondlr/tokens-2-0-curved-token-bonding-in-curation-markets-1764a2e0bee5
	// - The Uniswap v2 white paper: https://whitepaper.io/document/600/uniswap-whitepaper
	// - The Bancor white paper: https://whitepaper.io/document/52/bancor-whitepaper
	// - Article relating Bancor curves to polynomial curves: https://medium.com/@aventus/token-bonding-curves-547f3a04914
	// - Derivations of the Bancor supply increase/decrease formulas: https://blog.relevant.community/bonding-curves-in-depth-intuition-parametrization-d3905a681e0a
	// - Implementations of Bancor equations in Solidity with code: https://yos.io/2018/11/10/bonding-curves/
	// - Bancor is flawed blog post discussing Bancor edge cases: https://hackingdistributed.com/2017/06/19/bancor-is-flawed/
	// - A mathematica equation sheet with tests that walks through all the
	//   equations. You will need to copy this into a Mathematica notebook to
	//   run it: https://pastebin.com/raw/M4a1femY
	CreatorCoinSlope        *big.Float
	CreatorCoinReserveRatio *big.Float

	// CreatorCoinAutoSellThresholdNanos defines two things. The first is the minimum amount
	// of creator coins a user must purchase in order for a transaction to be valid. Secondly
	// it defines the point at which a sell operation will auto liquidate all remaining holdings.
	// For example if I hold 1000 nanos of creator coins and sell x nanos such that
	// 1000 - x < CreatorCoinAutoSellThresholdNanos, we auto liquidate the remaining holdings.
	// It does this to prevent issues with floating point rounding that can arise.
	// This value should be chosen such that the chain is resistant to "phantom nanos." Phantom nanos
	// are tiny amounts of CreatorCoinsInCirculation/DeSoLocked which can cause
	// the effective reserve ratio to deviate from the expected reserve ratio of the bancor curve.
	// A higher CreatorCoinAutoSellThresholdNanos makes it prohibitively expensive for someone to
	// attack the bancor curve to any meaningful measure.
	CreatorCoinAutoSellThresholdNanos uint64

	// The most deflationary event in DeSo history has yet to come...
	DeflationBombBlockHeight uint64
}

DeSoParams defines the full list of possible parameters for the DeSo network.

func (*DeSoParams) EnableRegtest

func (params *DeSoParams) EnableRegtest()

EnableRegtest allows for local development and testing with incredibly fast blocks with block rewards that can be spent as soon as they are mined. It also removes the default testnet seeds

type DeSoTxnMetadata

type DeSoTxnMetadata interface {
	ToBytes(preSignature bool) ([]byte, error)
	FromBytes(data []byte) error
	New() DeSoTxnMetadata
	GetTxnType() TxnType
}

func NewTxnMetadata

func NewTxnMetadata(txType TxnType) (DeSoTxnMetadata, error)

type DerivedKeyEntry

type DerivedKeyEntry struct {
	// Owner public key
	OwnerPublicKey PublicKey

	// Derived public key
	DerivedPublicKey PublicKey

	// Expiration Block
	ExpirationBlock uint64

	// Operation type determines if the derived key is
	// authorized or de-authorized.
	OperationType AuthorizeDerivedKeyOperationType
	// contains filtered or unexported fields
}

func DBGetAllOwnerToDerivedKeyMappings

func DBGetAllOwnerToDerivedKeyMappings(handle *badger.DB, ownerPublicKey PublicKey) (
	_entries []*DerivedKeyEntry, _err error)

func DBGetOwnerToDerivedKeyMapping

func DBGetOwnerToDerivedKeyMapping(
	db *badger.DB, ownerPublicKey PublicKey, derivedPublicKey PublicKey) *DerivedKeyEntry

func DBGetOwnerToDerivedKeyMappingWithTxn

func DBGetOwnerToDerivedKeyMappingWithTxn(
	txn *badger.Txn, ownerPublicKey PublicKey, derivedPublicKey PublicKey) *DerivedKeyEntry

type DerivedKeyMapKey

type DerivedKeyMapKey struct {
	// Owner public key
	OwnerPublicKey PublicKey

	// Derived public key
	DerivedPublicKey PublicKey
}

func MakeDerivedKeyMapKey

func MakeDerivedKeyMapKey(ownerPublicKey PublicKey, derivedPublicKey PublicKey) DerivedKeyMapKey

type DiamondEntry

type DiamondEntry struct {
	SenderPKID      *PKID
	ReceiverPKID    *PKID
	DiamondPostHash *BlockHash
	DiamondLevel    int64
	// contains filtered or unexported fields
}

DiamondEntry stores the number of diamonds given by a sender to a post.

func DbGetDiamondEntriesForSenderToReceiver

func DbGetDiamondEntriesForSenderToReceiver(handle *badger.DB, receiverPKID *PKID, senderPKID *PKID) (
	_diamondEntries []*DiamondEntry, _err error)

This function returns a list of DiamondEntrys given by giverPKID to receiverPKID that contain post hashes.

func DbGetDiamondMappings

func DbGetDiamondMappings(
	db *badger.DB, diamondReceiverPKID *PKID, diamondSenderPKID *PKID, diamondPostHash *BlockHash) *DiamondEntry

func DbGetDiamondMappingsWithTxn

func DbGetDiamondMappingsWithTxn(
	txn *badger.Txn, diamondReceiverPKID *PKID, diamondSenderPKID *PKID, diamondPostHash *BlockHash) *DiamondEntry

type DiamondKey

type DiamondKey struct {
	SenderPKID      PKID
	ReceiverPKID    PKID
	DiamondPostHash BlockHash
}

func MakeDiamondKey

func MakeDiamondKey(senderPKID *PKID, receiverPKID *PKID, diamondPostHash *BlockHash) DiamondKey

func (*DiamondKey) String

func (mm *DiamondKey) String() string

type EventManager added in v1.2.6

type EventManager struct {
	// contains filtered or unexported fields
}

func NewEventManager added in v1.2.6

func NewEventManager() *EventManager

func (*EventManager) OnBlockAccepted added in v1.2.6

func (em *EventManager) OnBlockAccepted(handler BlockEventFunc)

func (*EventManager) OnBlockConnected added in v1.2.6

func (em *EventManager) OnBlockConnected(handler BlockEventFunc)

func (*EventManager) OnBlockDisconnected added in v1.2.6

func (em *EventManager) OnBlockDisconnected(handler BlockEventFunc)

func (*EventManager) OnTransactionConnected added in v1.2.6

func (em *EventManager) OnTransactionConnected(handler TransactionEventFunc)

type ExpectedResponse

type ExpectedResponse struct {
	TimeExpected time.Time
	MessageType  MsgType
}

ExpectedResponse is a struct used to enforce timeouts on peers. For example, if we send a GetBlocks message, we would expect a response within a given window and disconnect from the Peer if we don't get that response.

type FollowEntry

type FollowEntry struct {
	// Note: It's a little redundant to have these in the entry because they're
	// already used as the key in the DB but it doesn't hurt for now.
	FollowerPKID *PKID
	FollowedPKID *PKID
	// contains filtered or unexported fields
}

FollowEntry stores the content of a follow transaction.

type FollowKey

type FollowKey struct {
	FollowerPKID PKID
	FollowedPKID PKID
}

func MakeFollowKey

func MakeFollowKey(followerPKID *PKID, followedPKID *PKID) FollowKey

type FollowMetadata

type FollowMetadata struct {

	// The public key to follow.
	FollowedPublicKey []byte

	// Set to true when a user is requesting to unfollow.
	IsUnfollow bool
}

func (*FollowMetadata) FromBytes

func (txnData *FollowMetadata) FromBytes(data []byte) error

func (*FollowMetadata) GetTxnType

func (txnData *FollowMetadata) GetTxnType() TxnType

func (*FollowMetadata) New

func (txnData *FollowMetadata) New() DeSoTxnMetadata

func (*FollowMetadata) ToBytes

func (txnData *FollowMetadata) ToBytes(preSignature bool) ([]byte, error)

type FollowTxindexMetadata

type FollowTxindexMetadata struct {
	IsUnfollow bool
}

type ForbiddenPubKeyEntry

type ForbiddenPubKeyEntry struct {
	PubKey []byte
	// contains filtered or unexported fields
}

Entry for a public key forbidden from signing blocks.

type GetDataRequestInfo

type GetDataRequestInfo struct {
	PeerWhoSentInv *Peer
	TimeRequested  time.Time
}

GetDataRequestInfo is a data structure used to keep track of which transactions we've requested from a Peer.

type GlobalParamsEntry

type GlobalParamsEntry struct {
	// The new exchange rate to set.
	USDCentsPerBitcoin uint64

	// The new create profile fee
	CreateProfileFeeNanos uint64

	// The fee to create a single NFT (NFTs with n copies incur n of these fees).
	CreateNFTFeeNanos uint64

	// The maximum number of NFT copies that are allowed to be minted.
	MaxCopiesPerNFT uint64

	// The new minimum fee the network will accept
	MinimumNetworkFeeNanosPerKB uint64
}

func DbGetGlobalParamsEntry

func DbGetGlobalParamsEntry(handle *badger.DB) *GlobalParamsEntry

func DbGetGlobalParamsEntryWithTxn

func DbGetGlobalParamsEntryWithTxn(txn *badger.Txn) *GlobalParamsEntry

type InvType

type InvType uint32

InvType represents the allowed types of inventory vectors. See InvVect.

const (
	InvTypeTx    InvType = 0
	InvTypeBlock InvType = 1
)

These constants define the various supported inventory vector types.

func (InvType) String

func (invtype InvType) String() string

String returns the InvType in human-readable form.

type InvVect

type InvVect struct {
	Type InvType   // Type of data
	Hash BlockHash // Hash of the data
}

InvVect defines an inventory vector which is used to describe data, as specified by the Type field, that a peer wants, has, or does not have to another peer.

func (*InvVect) String

func (invVect *InvVect) String() string

type LikeEntry

type LikeEntry struct {
	LikerPubKey   []byte
	LikedPostHash *BlockHash
	// contains filtered or unexported fields
}

LikeEntry stores the content of a like transaction.

type LikeKey

type LikeKey struct {
	LikerPubKey   PkMapKey
	LikedPostHash BlockHash
}

func MakeLikeKey

func MakeLikeKey(userPk []byte, LikedPostHash BlockHash) LikeKey

type LikeMetadata

type LikeMetadata struct {

	// The post hash to like.
	LikedPostHash *BlockHash

	// Set to true when a user is requesting to unlike a post.
	IsUnlike bool
}

func (*LikeMetadata) FromBytes

func (txnData *LikeMetadata) FromBytes(data []byte) error

func (*LikeMetadata) GetTxnType

func (txnData *LikeMetadata) GetTxnType() TxnType

func (*LikeMetadata) New

func (txnData *LikeMetadata) New() DeSoTxnMetadata

func (*LikeMetadata) ToBytes

func (txnData *LikeMetadata) ToBytes(preSignature bool) ([]byte, error)

type LikeTxindexMetadata

type LikeTxindexMetadata struct {
	// LikerPublicKeyBase58Check = TransactorPublicKeyBase58Check
	IsUnlike bool

	PostHashHex string
}

type MempoolTx

type MempoolTx struct {
	Tx *MsgDeSoTxn

	// TxMeta is the transaction metadata
	TxMeta *TransactionMetadata

	// Hash is a hash of the transaction so we don't have to recompute
	// it all the time.
	Hash *BlockHash

	// TxSizeBytes is the cached size of the transaction.
	TxSizeBytes uint64

	// The time when the txn was added to the pool
	Added time.Time

	// The block height when the txn was added to the pool. It's generally set
	// to tip+1.
	Height uint32

	// The total fee the txn pays. Cached for efficiency reasons.
	Fee uint64

	// The fee rate of the transaction in nanos per KB.
	FeePerKB uint64
	// contains filtered or unexported fields
}

MempoolTx contains a transaction along with additional metadata like the fee and time added.

func (*MempoolTx) String

func (mempoolTx *MempoolTx) String() string

type MempoolTxFeeMinHeap

type MempoolTxFeeMinHeap []*MempoolTx

MempoolTxFeeMinHeap is a priority queue based on transaction fee rate

func (MempoolTxFeeMinHeap) Len

func (pq MempoolTxFeeMinHeap) Len() int

func (MempoolTxFeeMinHeap) Less

func (pq MempoolTxFeeMinHeap) Less(i, j int) bool

func (*MempoolTxFeeMinHeap) Pop

func (pq *MempoolTxFeeMinHeap) Pop() interface{}

func (*MempoolTxFeeMinHeap) Push

func (pq *MempoolTxFeeMinHeap) Push(x interface{})

func (MempoolTxFeeMinHeap) Swap

func (pq MempoolTxFeeMinHeap) Swap(i, j int)

type MessageEntry

type MessageEntry struct {
	SenderPublicKey    []byte
	RecipientPublicKey []byte
	EncryptedText      []byte
	// TODO: Right now a sender can fake the timestamp and make it appear to
	// the recipient that she sent messages much earlier than she actually did.
	// This isn't a big deal because there is generally not much to gain from
	// faking a timestamp, and it's still impossible for a user to impersonate
	// another user, which is the important thing. Moreover, it is easy to fix
	// the timestamp spoofing issue: You just need to make it so that the nodes
	// index messages based on block height in addition to on the tstamp. The
	// reason I didn't do it yet is because it adds some complexity around
	// detecting duplicates, particularly if a transaction is allowed to have
	// zero inputs/outputs, which is advantageous for various reasons.
	TstampNanos uint64

	// Indicates message encryption method
	// Version = 2 : message encrypted using shared secret
	// Version = 1 : message encrypted using public key
	Version uint8
	// contains filtered or unexported fields
}

MessageEntry stores the essential content of a message transaction.

func DbGetLimitedMessageEntriesForPublicKey

func DbGetLimitedMessageEntriesForPublicKey(handle *badger.DB, publicKey []byte) (
	_privateMessages []*MessageEntry, _err error)

func DbGetMessageEntriesForPublicKey

func DbGetMessageEntriesForPublicKey(handle *badger.DB, publicKey []byte) (
	_privateMessages []*MessageEntry, _err error)

func DbGetMessageEntry

func DbGetMessageEntry(db *badger.DB, publicKey []byte, tstampNanos uint64) *MessageEntry

func DbGetMessageEntryWithTxn

func DbGetMessageEntryWithTxn(
	txn *badger.Txn, publicKey []byte, tstampNanos uint64) *MessageEntry

type MessageKey

type MessageKey struct {
	PublicKey   PkMapKey
	BlockHeight uint32
	TstampNanos uint64
}

func MakeMessageKey

func MakeMessageKey(pk []byte, tstampNanos uint64) MessageKey

func (*MessageKey) String

func (mm *MessageKey) String() string

func (*MessageKey) StringKey

func (mm *MessageKey) StringKey(params *DeSoParams) string

StringKey is useful for creating maps that need to be serialized to JSON.

type MiningSupplyIntervalStart

type MiningSupplyIntervalStart struct {
	StartBlockHeight uint32
	BlockRewardNanos uint64
}

type MsgDeSoAddr

type MsgDeSoAddr struct {
	// The definition of NetAddress as defined by the btcd guys works fine for
	// our purposes. The only difference is that for DeSo nodes, the Service
	// flag in the NetAddress is as we define it above in ServiceFlag.
	// Note that we also rewrite the serialization logic as well to avoid
	// relying on potentially crusty Bitcoin-related work-arounds going forward.
	AddrList []*SingleAddr
}

func (*MsgDeSoAddr) FromBytes

func (msg *MsgDeSoAddr) FromBytes(data []byte) error

func (*MsgDeSoAddr) GetMsgType

func (msg *MsgDeSoAddr) GetMsgType() MsgType

func (*MsgDeSoAddr) String

func (msg *MsgDeSoAddr) String() string

func (*MsgDeSoAddr) ToBytes

func (msg *MsgDeSoAddr) ToBytes(preSignature bool) ([]byte, error)

type MsgDeSoBitcoinManagerUpdate

type MsgDeSoBitcoinManagerUpdate struct {
	// Keep it simple for now. A BitcoinManagerUpdate just signals that
	// the BitcoinManager has added at least one block or done a reorg.
	// No serialization because we don't want this sent on the wire ever.
	TransactionsFound []*MsgDeSoTxn
}

func (*MsgDeSoBitcoinManagerUpdate) FromBytes

func (msg *MsgDeSoBitcoinManagerUpdate) FromBytes(data []byte) error

func (*MsgDeSoBitcoinManagerUpdate) GetMsgType

func (msg *MsgDeSoBitcoinManagerUpdate) GetMsgType() MsgType

func (*MsgDeSoBitcoinManagerUpdate) ToBytes

func (msg *MsgDeSoBitcoinManagerUpdate) ToBytes(preSignature bool) ([]byte, error)

type MsgDeSoBlock

type MsgDeSoBlock struct {
	Header *MsgDeSoHeader
	Txns   []*MsgDeSoTxn

	// This field is optional and provides the producer of the block the ability to sign it
	// with their private key. Doing this proves that this block was produced by a particular
	// entity, which can be useful for nodes that want to restrict who they accept blocks
	// from.
	BlockProducerInfo *BlockProducerInfo
}

func GetBlock

func GetBlock(blockHash *BlockHash, handle *badger.DB) (*MsgDeSoBlock, error)

func GetBlockWithTxn

func GetBlockWithTxn(txn *badger.Txn, blockHash *BlockHash) *MsgDeSoBlock

func (*MsgDeSoBlock) EncodeBlockCommmon

func (msg *MsgDeSoBlock) EncodeBlockCommmon(preSignature bool) ([]byte, error)

func (*MsgDeSoBlock) EncodeBlockVersion0

func (msg *MsgDeSoBlock) EncodeBlockVersion0(preSignature bool) ([]byte, error)

func (*MsgDeSoBlock) EncodeBlockVersion1

func (msg *MsgDeSoBlock) EncodeBlockVersion1(preSignature bool) ([]byte, error)

func (*MsgDeSoBlock) FromBytes

func (msg *MsgDeSoBlock) FromBytes(data []byte) error

func (*MsgDeSoBlock) GetMsgType

func (msg *MsgDeSoBlock) GetMsgType() MsgType

func (*MsgDeSoBlock) Hash

func (msg *MsgDeSoBlock) Hash() (*BlockHash, error)

func (*MsgDeSoBlock) String

func (msg *MsgDeSoBlock) String() string

func (*MsgDeSoBlock) ToBytes

func (msg *MsgDeSoBlock) ToBytes(preSignature bool) ([]byte, error)

type MsgDeSoDonePeer

type MsgDeSoDonePeer struct {
}

func (*MsgDeSoDonePeer) FromBytes

func (msg *MsgDeSoDonePeer) FromBytes(data []byte) error

func (*MsgDeSoDonePeer) GetMsgType

func (msg *MsgDeSoDonePeer) GetMsgType() MsgType

func (*MsgDeSoDonePeer) ToBytes

func (msg *MsgDeSoDonePeer) ToBytes(preSignature bool) ([]byte, error)

type MsgDeSoGetAddr

type MsgDeSoGetAddr struct {
}

func (*MsgDeSoGetAddr) FromBytes

func (msg *MsgDeSoGetAddr) FromBytes(data []byte) error

func (*MsgDeSoGetAddr) GetMsgType

func (msg *MsgDeSoGetAddr) GetMsgType() MsgType

func (*MsgDeSoGetAddr) ToBytes

func (msg *MsgDeSoGetAddr) ToBytes(preSignature bool) ([]byte, error)

type MsgDeSoGetBlocks

type MsgDeSoGetBlocks struct {
	HashList []*BlockHash
}

func (*MsgDeSoGetBlocks) FromBytes

func (msg *MsgDeSoGetBlocks) FromBytes(data []byte) error

func (*MsgDeSoGetBlocks) GetMsgType

func (msg *MsgDeSoGetBlocks) GetMsgType() MsgType

func (*MsgDeSoGetBlocks) String

func (msg *MsgDeSoGetBlocks) String() string

func (*MsgDeSoGetBlocks) ToBytes

func (msg *MsgDeSoGetBlocks) ToBytes(preSignature bool) ([]byte, error)

type MsgDeSoGetHeaders

type MsgDeSoGetHeaders struct {
	StopHash     *BlockHash
	BlockLocator []*BlockHash
}

func (*MsgDeSoGetHeaders) FromBytes

func (msg *MsgDeSoGetHeaders) FromBytes(data []byte) error

func (*MsgDeSoGetHeaders) GetMsgType

func (msg *MsgDeSoGetHeaders) GetMsgType() MsgType

func (*MsgDeSoGetHeaders) String

func (msg *MsgDeSoGetHeaders) String() string

func (*MsgDeSoGetHeaders) ToBytes

func (msg *MsgDeSoGetHeaders) ToBytes(preSignature bool) ([]byte, error)

type MsgDeSoGetTransactions

type MsgDeSoGetTransactions struct {
	HashList []*BlockHash
}

func (*MsgDeSoGetTransactions) FromBytes

func (msg *MsgDeSoGetTransactions) FromBytes(data []byte) error

func (*MsgDeSoGetTransactions) GetMsgType

func (msg *MsgDeSoGetTransactions) GetMsgType() MsgType

func (*MsgDeSoGetTransactions) String

func (msg *MsgDeSoGetTransactions) String() string

func (*MsgDeSoGetTransactions) ToBytes

func (msg *MsgDeSoGetTransactions) ToBytes(preSignature bool) ([]byte, error)

type MsgDeSoHeader

type MsgDeSoHeader struct {
	// Note this is encoded as a fixed-width uint32 rather than a
	// uvarint or a uint64.
	Version uint32

	// Hash of the previous block in the chain.
	PrevBlockHash *BlockHash

	// The merkle root of all the transactions contained within the block.
	TransactionMerkleRoot *BlockHash

	// The unix timestamp (in seconds) specifying when this block was
	// mined.
	TstampSecs uint64

	// The height of the block this header corresponds to.
	Height uint64

	// The nonce that is used by miners in order to produce valid blocks.
	//
	// Note: Before the upgrade from HeaderVersion0 to HeaderVersion1, miners would make
	// use of ExtraData in the BlockRewardMetadata to get extra nonces. However, this is
	// no longer needed since HeaderVersion1 upgraded the nonce to 64 bits from 32 bits.
	Nonce uint64

	// An extra nonce that can be used to provice *even more* entropy for miners, in the
	// event that ASICs become powerful enough to have birthday problems in the future.
	ExtraNonce uint64
}

MsgDeSoHeader definition.

Note that all of these fields must be encoded as *full* big-endian ints/uints rather than varints. This is because these fields are hashed to produce a block and allowing them to be varints will heavily incentivize miners to keep them short, which corrupts their actual utility.

Additionally note that it's particularly important that headers be space-efficient, since light clients will need to download an entire history of them in order to be able to validate anything.

func DecodeHeader

func DecodeHeader(rr io.Reader) (*MsgDeSoHeader, error)

func DecodeHeaderVersion0

func DecodeHeaderVersion0(rr io.Reader) (*MsgDeSoHeader, error)

func DecodeHeaderVersion1

func DecodeHeaderVersion1(rr io.Reader) (*MsgDeSoHeader, error)

func (*MsgDeSoHeader) EncodeHeaderVersion0

func (msg *MsgDeSoHeader) EncodeHeaderVersion0(preSignature bool) ([]byte, error)

func (*MsgDeSoHeader) EncodeHeaderVersion1

func (msg *MsgDeSoHeader) EncodeHeaderVersion1(preSignature bool) ([]byte, error)

func (*MsgDeSoHeader) FromBytes

func (msg *MsgDeSoHeader) FromBytes(data []byte) error

func (*MsgDeSoHeader) GetMsgType

func (msg *MsgDeSoHeader) GetMsgType() MsgType

func (*MsgDeSoHeader) Hash

func (msg *MsgDeSoHeader) Hash() (*BlockHash, error)

Hash is a helper function to compute a hash of the header. Note that the header hash is special in that we always hash it using the ProofOfWorkHash rather than Sha256DoubleHash.

func (*MsgDeSoHeader) String

func (msg *MsgDeSoHeader) String() string

func (*MsgDeSoHeader) ToBytes

func (msg *MsgDeSoHeader) ToBytes(preSignature bool) ([]byte, error)

type MsgDeSoHeaderBundle

type MsgDeSoHeaderBundle struct {
	Headers   []*MsgDeSoHeader
	TipHash   *BlockHash
	TipHeight uint32
}

func (*MsgDeSoHeaderBundle) FromBytes

func (msg *MsgDeSoHeaderBundle) FromBytes(data []byte) error

func (*MsgDeSoHeaderBundle) GetMsgType

func (msg *MsgDeSoHeaderBundle) GetMsgType() MsgType

func (*MsgDeSoHeaderBundle) String

func (msg *MsgDeSoHeaderBundle) String() string

func (*MsgDeSoHeaderBundle) ToBytes

func (msg *MsgDeSoHeaderBundle) ToBytes(preSignature bool) ([]byte, error)

type MsgDeSoInv

type MsgDeSoInv struct {
	InvList []*InvVect
	// IsSyncResponse indicates that the inv was sent in response to a sync message.
	// This indicates that the node shouldn't relay it to peers because they likely
	// already have it.
	IsSyncResponse bool
}

func (*MsgDeSoInv) FromBytes

func (msg *MsgDeSoInv) FromBytes(data []byte) error

func (*MsgDeSoInv) GetMsgType

func (msg *MsgDeSoInv) GetMsgType() MsgType

func (*MsgDeSoInv) String

func (msg *MsgDeSoInv) String() string

func (*MsgDeSoInv) ToBytes

func (msg *MsgDeSoInv) ToBytes(preSignature bool) ([]byte, error)

type MsgDeSoMempool

type MsgDeSoMempool struct {
}

func (*MsgDeSoMempool) FromBytes

func (msg *MsgDeSoMempool) FromBytes(data []byte) error

func (*MsgDeSoMempool) GetMsgType

func (msg *MsgDeSoMempool) GetMsgType() MsgType

func (*MsgDeSoMempool) String

func (msg *MsgDeSoMempool) String() string

func (*MsgDeSoMempool) ToBytes

func (msg *MsgDeSoMempool) ToBytes(preSignature bool) ([]byte, error)

type MsgDeSoNewPeer

type MsgDeSoNewPeer struct {
}

func (*MsgDeSoNewPeer) FromBytes

func (msg *MsgDeSoNewPeer) FromBytes(data []byte) error

func (*MsgDeSoNewPeer) GetMsgType

func (msg *MsgDeSoNewPeer) GetMsgType() MsgType

func (*MsgDeSoNewPeer) ToBytes

func (msg *MsgDeSoNewPeer) ToBytes(preSignature bool) ([]byte, error)

type MsgDeSoPing

type MsgDeSoPing struct {
	Nonce uint64
}

func (*MsgDeSoPing) FromBytes

func (msg *MsgDeSoPing) FromBytes(data []byte) error

func (*MsgDeSoPing) GetMsgType

func (msg *MsgDeSoPing) GetMsgType() MsgType

func (*MsgDeSoPing) ToBytes

func (msg *MsgDeSoPing) ToBytes(preSignature bool) ([]byte, error)

type MsgDeSoPong

type MsgDeSoPong struct {
	Nonce uint64
}

func (*MsgDeSoPong) FromBytes

func (msg *MsgDeSoPong) FromBytes(data []byte) error

func (*MsgDeSoPong) GetMsgType

func (msg *MsgDeSoPong) GetMsgType() MsgType

func (*MsgDeSoPong) ToBytes

func (msg *MsgDeSoPong) ToBytes(preSignature bool) ([]byte, error)

type MsgDeSoQuit

type MsgDeSoQuit struct {
}

func (*MsgDeSoQuit) FromBytes

func (msg *MsgDeSoQuit) FromBytes(data []byte) error

func (*MsgDeSoQuit) GetMsgType

func (msg *MsgDeSoQuit) GetMsgType() MsgType

func (*MsgDeSoQuit) ToBytes

func (msg *MsgDeSoQuit) ToBytes(preSignature bool) ([]byte, error)

type MsgDeSoTransactionBundle

type MsgDeSoTransactionBundle struct {
	Transactions []*MsgDeSoTxn
}

func (*MsgDeSoTransactionBundle) FromBytes

func (msg *MsgDeSoTransactionBundle) FromBytes(data []byte) error

func (*MsgDeSoTransactionBundle) GetMsgType

func (msg *MsgDeSoTransactionBundle) GetMsgType() MsgType

func (*MsgDeSoTransactionBundle) String

func (msg *MsgDeSoTransactionBundle) String() string

func (*MsgDeSoTransactionBundle) ToBytes

func (msg *MsgDeSoTransactionBundle) ToBytes(preSignature bool) ([]byte, error)

type MsgDeSoTxn

type MsgDeSoTxn struct {
	TxInputs  []*DeSoInput
	TxOutputs []*DeSoOutput

	// DeSoTxnMetadata is an interface type that will give us information on how
	// we should handle the transaction, including what type of transaction this
	// is.
	TxnMeta DeSoTxnMetadata

	// Transactions must generally explicitly include the key that is
	// spending the inputs to the transaction. The exception to this rule is that
	// BlockReward and BitcoinExchange transactions do not require the inclusion
	// of a public key since they have no inputs to spend.
	//
	// The public key should be a serialized compressed ECDSA public key on the
	// secp256k1 curve.
	PublicKey []byte

	// This is typically a JSON field that can be used to add extra information to
	// a transaction without causing a hard fork. It is useful in rare cases where we
	// realize that something needs to be added to a transaction but where we can't
	// afford a hard fork.
	ExtraData map[string][]byte

	// Transactions must generally be signed by the key that is spending the
	// inputs to the transaction. The exception to this rule is that
	// BLOCK_REWARD and CREATE_deso transactions do not require a signature
	// since they have no inputs.
	Signature *btcec.Signature

	// (!!) **DO_NOT_USE** (!!)
	//
	// Use txn.TxnMeta.GetTxnType() instead.
	//
	// We need this for JSON encoding/decoding. It isn't used for anything
	// else and it isn't actually serialized or de-serialized when sent
	// across the network using ToBytes/FromBytes because we prefer that
	// any use of the MsgDeSoTxn in Go code rely on TxnMeta.GetTxnType() rather
	// than checking this value, which, in Go context, is redundant and
	// therefore error-prone (e.g. someone might change TxnMeta while
	// forgetting to set it). We make it a uint64 explicitly to prevent
	// people from using it in Go code.
	TxnTypeJSON uint64
}

func DbGetAllMempoolTxnsSortedByTimeAdded

func DbGetAllMempoolTxnsSortedByTimeAdded(handle *badger.DB) (_mempoolTxns []*MsgDeSoTxn, _error error)

func DbGetMempoolTxn

func DbGetMempoolTxn(db *badger.DB, mempoolTx *MempoolTx) *MsgDeSoTxn

func DbGetMempoolTxnWithTxn

func DbGetMempoolTxnWithTxn(txn *badger.Txn, mempoolTx *MempoolTx) *MsgDeSoTxn

func ExtractBitcoinExchangeTransactionsFromBitcoinBlock

func ExtractBitcoinExchangeTransactionsFromBitcoinBlock(
	bitcoinBlock *wire.MsgBlock, burnAddress string, params *DeSoParams) (
	_txns []*MsgDeSoTxn, _err error)

func (*MsgDeSoTxn) Copy

func (msg *MsgDeSoTxn) Copy() (*MsgDeSoTxn, error)

func (*MsgDeSoTxn) FromBytes

func (msg *MsgDeSoTxn) FromBytes(data []byte) error

func (*MsgDeSoTxn) GetMsgType

func (msg *MsgDeSoTxn) GetMsgType() MsgType

func (*MsgDeSoTxn) Hash

func (msg *MsgDeSoTxn) Hash() *BlockHash

Hash is a helper function to compute a hash of the transaction aka a transaction ID.

func (*MsgDeSoTxn) MarshalJSON

func (msg *MsgDeSoTxn) MarshalJSON() ([]byte, error)

MarshalJSON and UnmarshalJSON implement custom JSON marshaling/unmarshaling to support transaction metadata. The reason this needs to exist is because TxnMeta is an abstract interface and therefore when its decoded to JSON, the type information (i.e. which TxnType it is) cannot be inferred from the JSON unless we augment it a little bit. Note this format is not used to relay messages between nodes, only for replying to frontend/user-facing queries.

func (*MsgDeSoTxn) Sign

func (msg *MsgDeSoTxn) Sign(privKey *btcec.PrivateKey) (*btcec.Signature, error)

func (*MsgDeSoTxn) String

func (msg *MsgDeSoTxn) String() string

func (*MsgDeSoTxn) ToBytes

func (msg *MsgDeSoTxn) ToBytes(preSignature bool) ([]byte, error)

func (*MsgDeSoTxn) UnmarshalJSON

func (msg *MsgDeSoTxn) UnmarshalJSON(data []byte) error

UnmarshalJSON is covered by the comment on MarshalJSON.

type MsgDeSoVerack

type MsgDeSoVerack struct {
	// A verack message must contain the nonce the peer received in the
	// initial version message. This ensures the peer that is communicating
	// with us actually controls the address she says she does similar to
	// "SYN Cookie" DDOS protection.
	Nonce uint64
}

VERACK messages have no payload.

func (*MsgDeSoVerack) FromBytes

func (msg *MsgDeSoVerack) FromBytes(data []byte) error

func (*MsgDeSoVerack) GetMsgType

func (msg *MsgDeSoVerack) GetMsgType() MsgType

func (*MsgDeSoVerack) ToBytes

func (msg *MsgDeSoVerack) ToBytes(preSignature bool) ([]byte, error)

type MsgDeSoVersion

type MsgDeSoVersion struct {
	// What is the current version we're on?
	Version uint64

	// What are the services offered by this node?
	Services ServiceFlag

	// The node's unix timestamp that we use to compute a
	// robust "network time" using NTP.
	TstampSecs int64

	// Used to detect when a node connects to itself, which
	// we generally want to prevent.
	Nonce uint64

	// Used as a "vanity plate" to identify different DeSo
	// clients. Mainly useful in analyzing the network at
	// a meta level, not in the protocol itself.
	UserAgent string

	// The height of the last block on the main chain for
	// this node.
	//
	// TODO: We need to update this to uint64
	StartBlockHeight uint32

	// MinFeeRateNanosPerKB is the minimum feerate that a peer will
	// accept from other peers when validating transactions.
	MinFeeRateNanosPerKB uint64
}

func (*MsgDeSoVersion) FromBytes

func (msg *MsgDeSoVersion) FromBytes(data []byte) error

func (*MsgDeSoVersion) GetMsgType

func (msg *MsgDeSoVersion) GetMsgType() MsgType

func (*MsgDeSoVersion) ToBytes

func (msg *MsgDeSoVersion) ToBytes(preSignature bool) ([]byte, error)

type MsgType

type MsgType uint64

The MsgType is usually sent on the wire to indicate what type of struct is being sent in the payload part of the message.

const (
	// ControlMessagesStart is used to indicate the ID value at which control
	// messages start. Anything with an ID value greater than or equal to this
	// is a control message.
	ControlMessagesStart = 1000000

	MsgTypeUnset MsgType = 0
	//
	// The first message a peer sends. Used to negotiate a version
	// between the two peers.
	MsgTypeVersion MsgType = 1
	//
	// Sent after a peer has both sent its version message
	// and received its peer's version message and completed
	// the version negotiation.
	MsgTypeVerack MsgType = 2
	MsgTypeHeader MsgType = 3
	MsgTypeBlock  MsgType = 4
	MsgTypeTxn    MsgType = 5
	// MsgTypeGetHeaders is used to fetch headers from a peer.
	MsgTypeGetHeaders MsgType = 6
	// MsgTypeHeaderBundle contains headers from a peer.
	MsgTypeHeaderBundle    MsgType = 7
	MsgTypePing            MsgType = 8
	MsgTypePong            MsgType = 9
	MsgTypeInv             MsgType = 10
	MsgTypeGetBlocks       MsgType = 11
	MsgTypeGetTransactions MsgType = 12
	// MsgTypeTransactionBundle contains transactions from a peer.
	MsgTypeTransactionBundle MsgType = 13
	MsgTypeMempool           MsgType = 14
	// MsgTypeAddr is used by peers to share addresses of nodes they're aware about
	// with other peers.
	MsgTypeAddr MsgType = 15
	// MsgTypeGetAddr is used to solicit Addr messages from peers.
	MsgTypeGetAddr MsgType = 16

	MsgTypeQuit                 MsgType = ControlMessagesStart
	MsgTypeNewPeer              MsgType = ControlMessagesStart + 1
	MsgTypeDonePeer             MsgType = ControlMessagesStart + 2
	MsgTypeBlockAccepted        MsgType = ControlMessagesStart + 3
	MsgTypeBitcoinManagerUpdate MsgType = ControlMessagesStart + 4
)

func (MsgType) String

func (msgType MsgType) String() string

type NFTBidEntry

type NFTBidEntry struct {
	BidderPKID     *PKID
	NFTPostHash    *BlockHash
	SerialNumber   uint64
	BidAmountNanos uint64
	// contains filtered or unexported fields
}

This struct defines a single bid on an NFT.

func DBGetNFTBidEntries

func DBGetNFTBidEntries(handle *badger.DB, nftPostHash *BlockHash, serialNumber uint64,
) (_nftBidEntries []*NFTBidEntry)

Get NFT bid Entries *from the DB*. Does not include mempool txns.

func DBGetNFTBidEntriesForPKID

func DBGetNFTBidEntriesForPKID(handle *badger.DB, bidderPKID *PKID) (_nftBidEntries []*NFTBidEntry)

func DBGetNFTBidEntriesPaginated

func DBGetNFTBidEntriesPaginated(
	handle *badger.DB,
	nftHash *BlockHash,
	serialNumber uint64,
	startEntry *NFTBidEntry,
	limit int,
	reverse bool,
) (_bidEntries []*NFTBidEntry)

func DBGetNFTBidEntryForNFTBidKey

func DBGetNFTBidEntryForNFTBidKey(db *badger.DB, nftBidKey *NFTBidKey) *NFTBidEntry

func DBGetNFTBidEntryForNFTBidKeyWithTxn

func DBGetNFTBidEntryForNFTBidKeyWithTxn(txn *badger.Txn, nftBidKey *NFTBidKey) *NFTBidEntry

type NFTBidKey

type NFTBidKey struct {
	BidderPKID   PKID
	NFTPostHash  BlockHash
	SerialNumber uint64
}

func MakeNFTBidKey

func MakeNFTBidKey(bidderPKID *PKID, nftPostHash *BlockHash, serialNumber uint64) NFTBidKey

type NFTBidMetadata

type NFTBidMetadata struct {
	NFTPostHash    *BlockHash
	SerialNumber   uint64
	BidAmountNanos uint64
}

func (*NFTBidMetadata) FromBytes

func (txnData *NFTBidMetadata) FromBytes(dataa []byte) error

func (*NFTBidMetadata) GetTxnType

func (txnData *NFTBidMetadata) GetTxnType() TxnType

func (*NFTBidMetadata) New

func (txnData *NFTBidMetadata) New() DeSoTxnMetadata

func (*NFTBidMetadata) ToBytes

func (txnData *NFTBidMetadata) ToBytes(preSignature bool) ([]byte, error)

type NFTBidTxindexMetadata

type NFTBidTxindexMetadata struct {
	NFTPostHashHex string
	SerialNumber   uint64
	BidAmountNanos uint64
}

type NFTEntry

type NFTEntry struct {
	LastOwnerPKID              *PKID // This is needed to decrypt unlockable text.
	OwnerPKID                  *PKID
	NFTPostHash                *BlockHash
	SerialNumber               uint64
	IsForSale                  bool
	MinBidAmountNanos          uint64
	UnlockableText             []byte
	LastAcceptedBidAmountNanos uint64

	// If this NFT was transferred to the current owner, it will be pending until accepted.
	IsPending bool
	// contains filtered or unexported fields
}

This struct defines an individual NFT owned by a PKID. An NFT entry maps to a single postEntry, but a single postEntry can map to multiple NFT entries. Each NFT copy is defined by a serial number, which denotes it's place in the set (ie. #1 of 100).

func DBGetNFTEntriesForPKID

func DBGetNFTEntriesForPKID(handle *badger.DB, ownerPKID *PKID) (_nftEntries []*NFTEntry)

DBGetNFTEntriesForPKID gets NFT Entries *from the DB*. Does not include mempool txns.

func DBGetNFTEntriesForPostHash

func DBGetNFTEntriesForPostHash(handle *badger.DB, nftPostHash *BlockHash) (_nftEntries []*NFTEntry)

DBGetNFTEntriesForPostHash gets NFT Entries *from the DB*. Does not include mempool txns.

func DBGetNFTEntryByNFTOwnershipDetails

func DBGetNFTEntryByNFTOwnershipDetails(db *badger.DB, ownerPKID *PKID, isForSale bool, bidAmountNanos uint64, postHash *BlockHash, serialNumber uint64) *NFTEntry

func DBGetNFTEntryByNFTOwnershipDetailsWithTxn

func DBGetNFTEntryByNFTOwnershipDetailsWithTxn(
	txn *badger.Txn, ownerPKID *PKID, isForSale bool, bidAmountNanos uint64, postHash *BlockHash, serialNumber uint64) *NFTEntry

func DBGetNFTEntryByPostHashSerialNumber

func DBGetNFTEntryByPostHashSerialNumber(db *badger.DB, postHash *BlockHash, serialNumber uint64) *NFTEntry

func DBGetNFTEntryByPostHashSerialNumberWithTxn

func DBGetNFTEntryByPostHashSerialNumberWithTxn(
	txn *badger.Txn, postHash *BlockHash, serialNumber uint64) *NFTEntry

type NFTKey

type NFTKey struct {
	NFTPostHash  BlockHash
	SerialNumber uint64
}

func MakeNFTKey

func MakeNFTKey(nftPostHash *BlockHash, serialNumber uint64) NFTKey

type NFTTransferMetadata

type NFTTransferMetadata struct {
	NFTPostHash       *BlockHash
	SerialNumber      uint64
	ReceiverPublicKey []byte
	UnlockableText    []byte
}

func (*NFTTransferMetadata) FromBytes

func (txnData *NFTTransferMetadata) FromBytes(dataa []byte) error

func (*NFTTransferMetadata) GetTxnType

func (txnData *NFTTransferMetadata) GetTxnType() TxnType

func (*NFTTransferMetadata) New

func (txnData *NFTTransferMetadata) New() DeSoTxnMetadata

func (*NFTTransferMetadata) ToBytes

func (txnData *NFTTransferMetadata) ToBytes(preSignature bool) ([]byte, error)

type NFTTransferTxindexMetadata added in v1.2.8

type NFTTransferTxindexMetadata struct {
	NFTPostHashHex string
	SerialNumber   uint64
}

type NetworkType

type NetworkType uint64
const (
	// The different network types. For now we have a mainnet and a testnet.
	// Also create an UNSET value to catch errors.
	NetworkType_UNSET   NetworkType = 0
	NetworkType_MAINNET NetworkType = 1
	NetworkType_TESTNET NetworkType = 2
)

func (NetworkType) String

func (nt NetworkType) String() string

type NotificationType

type NotificationType uint8
const (
	NotificationUnknown NotificationType = iota
	NotificationSendDESO
	NotificationLike
	NotificationFollow
	NotificationCoinPurchase
	NotificationCoinTransfer
	NotificationCoinDiamond
	NotificationPostMention
	NotificationPostReply
	NotificationPostRepost
	NotificationDESODiamond
)

type Notifier

type Notifier struct {
	// contains filtered or unexported fields
}

func NewNotifier

func NewNotifier(coreChain *Blockchain, postgres *Postgres) *Notifier

func (*Notifier) Start

func (notifier *Notifier) Start()

func (*Notifier) Update

func (notifier *Notifier) Update() error

type OperationType

type OperationType uint
const (
	// Every operation has a type that we document here. This information is
	// used when rolling back a txn to determine what kind of operations need
	// to be performed. For example, rolling back a BitcoinExchange may require
	// rolling back an AddUtxo operation.
	OperationTypeAddUtxo                      OperationType = 0
	OperationTypeSpendUtxo                    OperationType = 1
	OperationTypeBitcoinExchange              OperationType = 2
	OperationTypePrivateMessage               OperationType = 3
	OperationTypeSubmitPost                   OperationType = 4
	OperationTypeUpdateProfile                OperationType = 5
	OperationTypeDeletePost                   OperationType = 7
	OperationTypeUpdateBitcoinUSDExchangeRate OperationType = 8
	OperationTypeFollow                       OperationType = 9
	OperationTypeLike                         OperationType = 10
	OperationTypeCreatorCoin                  OperationType = 11
	OperationTypeSwapIdentity                 OperationType = 12
	OperationTypeUpdateGlobalParams           OperationType = 13
	OperationTypeCreatorCoinTransfer          OperationType = 14
	OperationTypeCreateNFT                    OperationType = 15
	OperationTypeUpdateNFT                    OperationType = 16
	OperationTypeAcceptNFTBid                 OperationType = 17
	OperationTypeNFTBid                       OperationType = 18
	OperationTypeDeSoDiamond                  OperationType = 19
	OperationTypeNFTTransfer                  OperationType = 20
	OperationTypeAcceptNFTTransfer            OperationType = 21
	OperationTypeBurnNFT                      OperationType = 22
	OperationTypeAuthorizeDerivedKey          OperationType = 23
)

func (OperationType) String

func (op OperationType) String() string

type OrphanBlock

type OrphanBlock struct {
	Block *MsgDeSoBlock
	Hash  *BlockHash
}

type PGBalance

type PGBalance struct {
	PublicKey    *PublicKey `pg:",pk,type:bytea"`
	BalanceNanos uint64     `pg:",use_zero"`
	// contains filtered or unexported fields
}

PGBalance represents PublicKeyToDeSoBalanceNanos

type PGBlock

type PGBlock struct {

	// BlockNode and MsgDeSoHeader
	Hash       *BlockHash `pg:",pk,type:bytea"`
	ParentHash *BlockHash `pg:",type:bytea"`
	Height     uint64     `pg:",use_zero"`

	// BlockNode
	DifficultyTarget *BlockHash  `pg:",type:bytea"`
	CumWork          *BlockHash  `pg:",type:bytea"`
	Status           BlockStatus `pg:",use_zero"` // TODO: Refactor

	// MsgDeSoHeader
	TxMerkleRoot *BlockHash `pg:",type:bytea"`
	Version      uint32     `pg:",use_zero"`
	Timestamp    uint64     `pg:",use_zero"`
	Nonce        uint64     `pg:",use_zero"`
	ExtraNonce   uint64     `pg:",use_zero"`

	// Notifications
	Notified bool `pg:",use_zero"`
	// contains filtered or unexported fields
}

PGBlock represents BlockNode and MsgDeSoHeader

type PGChain

type PGChain struct {
	Name    string     `pg:",pk"`
	TipHash *BlockHash `pg:",type:bytea"`
	// contains filtered or unexported fields
}

type PGCreatorCoinBalance

type PGCreatorCoinBalance struct {
	HolderPKID   *PKID `pg:",pk,type:bytea"`
	CreatorPKID  *PKID `pg:",pk,type:bytea"`
	BalanceNanos uint64
	HasPurchased bool
	// contains filtered or unexported fields
}

func (*PGCreatorCoinBalance) NewBalanceEntry

func (balance *PGCreatorCoinBalance) NewBalanceEntry() *BalanceEntry

type PGDerivedKey

type PGDerivedKey struct {
	OwnerPublicKey   PublicKey                        `pg:",pk,type:bytea"`
	DerivedPublicKey PublicKey                        `pg:",pk,type:bytea"`
	ExpirationBlock  uint64                           `pg:",use_zero"`
	OperationType    AuthorizeDerivedKeyOperationType `pg:",use_zero"`
	// contains filtered or unexported fields
}

PGDerivedKey represents DerivedKeyEntry

func (*PGDerivedKey) NewDerivedKeyEntry

func (key *PGDerivedKey) NewDerivedKeyEntry() *DerivedKeyEntry

type PGDiamond

type PGDiamond struct {
	SenderPKID      *PKID      `pg:",pk,type:bytea"`
	ReceiverPKID    *PKID      `pg:",pk,type:bytea"`
	DiamondPostHash *BlockHash `pg:",pk,type:bytea"`
	DiamondLevel    uint8
	// contains filtered or unexported fields
}

type PGFollow

type PGFollow struct {
	FollowerPKID *PKID `pg:",pk,type:bytea"`
	FollowedPKID *PKID `pg:",pk,type:bytea"`
	// contains filtered or unexported fields
}

func (*PGFollow) NewFollowEntry

func (follow *PGFollow) NewFollowEntry() *FollowEntry

type PGForbiddenKey

type PGForbiddenKey struct {
	PublicKey *PublicKey `pg:",pk,type:bytea"`
	// contains filtered or unexported fields
}

PGForbiddenKey represents ForbiddenPubKeyEntry

type PGGlobalParams

type PGGlobalParams struct {
	ID uint64

	USDCentsPerBitcoin      uint64 `pg:",use_zero"`
	CreateProfileFeeNanos   uint64 `pg:",use_zero"`
	CreateNFTFeeNanos       uint64 `pg:",use_zero"`
	MaxCopiesPerNFT         uint64 `pg:",use_zero"`
	MinNetworkFeeNanosPerKB uint64 `pg:",use_zero"`
	// contains filtered or unexported fields
}

PGGlobalParams represents GlobalParamsEntry

type PGLike

type PGLike struct {
	LikerPublicKey []byte     `pg:",pk,type:bytea"`
	LikedPostHash  *BlockHash `pg:",pk,type:bytea"`
	// contains filtered or unexported fields
}

func (*PGLike) NewLikeEntry

func (like *PGLike) NewLikeEntry() *LikeEntry

type PGMessage

type PGMessage struct {
	MessageHash        *BlockHash `pg:",pk,type:bytea"`
	SenderPublicKey    []byte
	RecipientPublicKey []byte
	EncryptedText      []byte
	TimestampNanos     uint64
	// contains filtered or unexported fields
}

TODO: This doesn't need to be a table. Just add sender to PGMetadataPrivateMessage? The only reason we might not want to do this is if we end up pruning Metadata tables.

type PGMetadataAcceptNFTBid

type PGMetadataAcceptNFTBid struct {
	TransactionHash *BlockHash            `pg:",pk,type:bytea"`
	NFTPostHash     *BlockHash            `pg:",type:bytea"`
	SerialNumber    uint64                `pg:",use_zero"`
	BidderPKID      *PKID                 `pg:",type:bytea"`
	BidAmountNanos  uint64                `pg:",use_zero"`
	UnlockableText  []byte                `pg:",type:bytea"`
	BidderInputs    []*PGMetadataBidInput `pg:"rel:has-many,join_fk:transaction_hash"`
	// contains filtered or unexported fields
}

PGMetadataAcceptNFTBid represents AcceptNFTBidMetadata

type PGMetadataAcceptNFTTransfer

type PGMetadataAcceptNFTTransfer struct {
	TransactionHash *BlockHash `pg:",pk,type:bytea"`
	NFTPostHash     *BlockHash `pg:",pk,type:bytea"`
	SerialNumber    uint64     `pg:",use_zero"`
	// contains filtered or unexported fields
}

PGMetadataAcceptNFTTransfer represents AcceptNFTTransferMetadata

type PGMetadataBidInput

type PGMetadataBidInput struct {
	TransactionHash *BlockHash `pg:",pk,type:bytea"`
	InputHash       *BlockHash `pg:",pk,type:bytea"`
	InputIndex      uint32     `pg:",pk,use_zero"`
	// contains filtered or unexported fields
}

type PGMetadataBitcoinExchange

type PGMetadataBitcoinExchange struct {
	TransactionHash   *BlockHash `pg:",pk,type:bytea"`
	BitcoinBlockHash  *BlockHash `pg:",type:bytea"`
	BitcoinMerkleRoot *BlockHash `pg:",type:bytea"`
	// contains filtered or unexported fields
}

PGMetadataBitcoinExchange represents BitcoinExchangeMetadata

type PGMetadataBlockReward

type PGMetadataBlockReward struct {
	TransactionHash *BlockHash `pg:",pk,type:bytea"`
	ExtraData       []byte     `pg:",type:bytea"`
	// contains filtered or unexported fields
}

PGMetadataBlockReward represents BlockRewardMetadataa

type PGMetadataBurnNFT

type PGMetadataBurnNFT struct {
	TransactionHash *BlockHash `pg:",pk,type:bytea"`
	NFTPostHash     *BlockHash `pg:",pk,type:bytea"`
	SerialNumber    uint64     `pg:",use_zero"`
	// contains filtered or unexported fields
}

PGMetadataBurnNFT represents BurnNFTMetadata

type PGMetadataCreateNFT

type PGMetadataCreateNFT struct {
	TransactionHash           *BlockHash `pg:",pk,type:bytea"`
	NFTPostHash               *BlockHash `pg:",type:bytea"`
	NumCopies                 uint64     `pg:",use_zero"`
	HasUnlockable             bool       `pg:",use_zero"`
	IsForSale                 bool       `pg:",use_zero"`
	MinBidAmountNanos         uint64     `pg:",use_zero"`
	CreatorRoyaltyBasisPoints uint64     `pg:",use_zero"`
	CoinRoyaltyBasisPoints    uint64     `pg:",use_zero"`
	// contains filtered or unexported fields
}

PGMetadataCreateNFT represents CreateNFTMetadata

type PGMetadataCreatorCoin

type PGMetadataCreatorCoin struct {
	TransactionHash             *BlockHash               `pg:",pk,type:bytea"`
	ProfilePublicKey            []byte                   `pg:",type:bytea"`
	OperationType               CreatorCoinOperationType `pg:",use_zero"`
	DeSoToSellNanos             uint64                   `pg:",use_zero"`
	CreatorCoinToSellNanos      uint64                   `pg:",use_zero"`
	DeSoToAddNanos              uint64                   `pg:",use_zero"`
	MinDeSoExpectedNanos        uint64                   `pg:",use_zero"`
	MinCreatorCoinExpectedNanos uint64                   `pg:",use_zero"`
	// contains filtered or unexported fields
}

PGMetadataCreatorCoin represents CreatorCoinMetadataa

type PGMetadataCreatorCoinTransfer

type PGMetadataCreatorCoinTransfer struct {
	TransactionHash            *BlockHash `pg:",pk,type:bytea"`
	ProfilePublicKey           []byte     `pg:",type:bytea"`
	CreatorCoinToTransferNanos uint64     `pg:",use_zero"`
	ReceiverPublicKey          []byte     `pg:",type:bytea"`
	// contains filtered or unexported fields
}

PGMetadataCreatorCoinTransfer represents CreatorCoinTransferMetadataa

type PGMetadataDerivedKey

type PGMetadataDerivedKey struct {
	TransactionHash  *BlockHash                       `pg:",pk,type:bytea"`
	DerivedPublicKey PublicKey                        `pg:",type:bytea"`
	ExpirationBlock  uint64                           `pg:",use_zero"`
	OperationType    AuthorizeDerivedKeyOperationType `pg:",use_zero"`
	AccessSignature  []byte                           `pg:",type:bytea"`
	// contains filtered or unexported fields
}

PGMetadataDerivedKey represents AuthorizeDerivedKeyMetadata

type PGMetadataFollow

type PGMetadataFollow struct {
	TransactionHash   *BlockHash `pg:",pk,type:bytea"`
	FollowedPublicKey []byte     `pg:",type:bytea"`
	IsUnfollow        bool       `pg:",use_zero"`
	// contains filtered or unexported fields
}

PGMetadataFollow represents FollowMetadata

type PGMetadataLike

type PGMetadataLike struct {
	TransactionHash *BlockHash `pg:",pk,type:bytea"`
	LikedPostHash   *BlockHash `pg:",type:bytea"`
	IsUnlike        bool       `pg:",use_zero"`
	// contains filtered or unexported fields
}

PGMetadataLike represents LikeMetadata

type PGMetadataNFTBid

type PGMetadataNFTBid struct {
	TransactionHash *BlockHash `pg:",pk,type:bytea"`
	NFTPostHash     *BlockHash `pg:",type:bytea"`
	SerialNumber    uint64     `pg:",use_zero"`
	BidAmountNanos  uint64     `pg:",use_zero"`
	// contains filtered or unexported fields
}

PGMetadataNFTBid represents NFTBidMetadata

type PGMetadataNFTTransfer

type PGMetadataNFTTransfer struct {
	TransactionHash   *BlockHash `pg:",pk,type:bytea"`
	NFTPostHash       *BlockHash `pg:",pk,type:bytea"`
	SerialNumber      uint64     `pg:",use_zero"`
	ReceiverPublicKey []byte     `pg:",pk,type:bytea"`
	UnlockableText    []byte     `pg:",type:bytea"`
	// contains filtered or unexported fields
}

PGMetadataNFTTransfer represents NFTTransferMetadata

type PGMetadataPrivateMessage

type PGMetadataPrivateMessage struct {
	TransactionHash    *BlockHash `pg:",pk,type:bytea"`
	RecipientPublicKey []byte     `pg:",type:bytea"`
	EncryptedText      []byte     `pg:",type:bytea"`
	TimestampNanos     uint64
	// contains filtered or unexported fields
}

PGMetadataPrivateMessage represents PrivateMessageMetadata

type PGMetadataSubmitPost

type PGMetadataSubmitPost struct {
	TransactionHash  *BlockHash `pg:",pk,type:bytea"`
	PostHashToModify *BlockHash `pg:",type:bytea"`
	ParentStakeID    *BlockHash `pg:",type:bytea"`
	Body             []byte     `pg:",type:bytea"`
	TimestampNanos   uint64
	IsHidden         bool `pg:",use_zero"`
	// contains filtered or unexported fields
}

PGMetadataSubmitPost represents SubmitPostMetadata

type PGMetadataSwapIdentity

type PGMetadataSwapIdentity struct {
	TransactionHash *BlockHash `pg:",pk,type:bytea"`
	FromPublicKey   []byte     `pg:",type:bytea"`
	ToPublicKey     []byte     `pg:",type:bytea"`
	// contains filtered or unexported fields
}

PGMetadataSwapIdentity represents SwapIdentityMetadataa

type PGMetadataUpdateExchangeRate

type PGMetadataUpdateExchangeRate struct {
	TransactionHash    *BlockHash `pg:",pk,type:bytea"`
	USDCentsPerBitcoin uint64     `pg:",use_zero"`
	// contains filtered or unexported fields
}

PGMetadataUpdateExchangeRate represents UpdateBitcoinUSDExchangeRateMetadataa

type PGMetadataUpdateNFT

type PGMetadataUpdateNFT struct {
	TransactionHash   *BlockHash `pg:",pk,type:bytea"`
	NFTPostHash       *BlockHash `pg:",type:bytea"`
	SerialNumber      uint64     `pg:",use_zero"`
	IsForSale         bool       `pg:",use_zero"`
	MinBidAmountNanos uint64     `pg:",use_zero"`
	// contains filtered or unexported fields
}

PGMetadataUpdateNFT represents UpdateNFTMetadata

type PGMetadataUpdateProfile

type PGMetadataUpdateProfile struct {
	TransactionHash       *BlockHash `pg:",pk,type:bytea"`
	ProfilePublicKey      []byte     `pg:",type:bytea"`
	NewUsername           []byte     `pg:",type:bytea"`
	NewDescription        []byte     `pg:",type:bytea"`
	NewProfilePic         []byte     `pg:",type:bytea"`
	NewCreatorBasisPoints uint64     `pg:",use_zero"`
	// contains filtered or unexported fields
}

PGMetadataUpdateProfile represents UpdateProfileMetadata

type PGNFT

type PGNFT struct {
	NFTPostHash  *BlockHash `pg:",pk,type:bytea"`
	SerialNumber uint64     `pg:",pk"`

	// This is needed to decrypt unlockable text.
	LastOwnerPKID              *PKID  `pg:",type:bytea"`
	OwnerPKID                  *PKID  `pg:",type:bytea"`
	ForSale                    bool   `pg:",use_zero"`
	MinBidAmountNanos          uint64 `pg:",use_zero"`
	UnlockableText             string
	LastAcceptedBidAmountNanos uint64 `pg:",use_zero"`
	IsPending                  bool   `pg:",use_zero"`
	// contains filtered or unexported fields
}

PGNFT represents NFTEntry

func (*PGNFT) NewNFTEntry

func (nft *PGNFT) NewNFTEntry() *NFTEntry

type PGNFTBid

type PGNFTBid struct {
	BidderPKID     *PKID      `pg:",pk,type:bytea"`
	NFTPostHash    *BlockHash `pg:",pk,type:bytea"`
	SerialNumber   uint64     `pg:",pk,use_zero"`
	BidAmountNanos uint64     `pg:",use_zero"`
	Accepted       bool       `pg:",use_zero"`
	// contains filtered or unexported fields
}

PGNFTBid represents NFTBidEntry

func (*PGNFTBid) NewNFTBidEntry

func (bid *PGNFTBid) NewNFTBidEntry() *NFTBidEntry

type PGNotification

type PGNotification struct {
	TransactionHash *BlockHash       `pg:",pk,type:bytea"`
	Mined           bool             `pg:",use_zero"`
	ToUser          []byte           `pg:",type:bytea"`
	FromUser        []byte           `pg:",type:bytea"`
	OtherUser       []byte           `pg:",type:bytea"`
	Type            NotificationType `pg:",use_zero"`
	Amount          uint64           `pg:",use_zero"`
	PostHash        *BlockHash       `pg:",type:bytea"`
	Timestamp       uint64           `pg:",use_zero"`
	// contains filtered or unexported fields
}

type PGPost

type PGPost struct {
	PostHash                  *BlockHash `pg:",pk,type:bytea"`
	PosterPublicKey           []byte
	ParentPostHash            *BlockHash `pg:",type:bytea"`
	Body                      string
	RepostedPostHash          *BlockHash `pg:",type:bytea"`
	QuotedRepost              bool       `pg:",use_zero"`
	Timestamp                 uint64     `pg:",use_zero"`
	Hidden                    bool       `pg:",use_zero"`
	LikeCount                 uint64     `pg:",use_zero"`
	RepostCount               uint64     `pg:",use_zero"`
	QuoteRepostCount          uint64     `pg:",use_zero"`
	DiamondCount              uint64     `pg:",use_zero"`
	CommentCount              uint64     `pg:",use_zero"`
	Pinned                    bool       `pg:",use_zero"`
	NFT                       bool       `pg:",use_zero"`
	NumNFTCopies              uint64     `pg:",use_zero"`
	NumNFTCopiesForSale       uint64     `pg:",use_zero"`
	NumNFTCopiesBurned        uint64     `pg:",use_zero"`
	Unlockable                bool       `pg:",use_zero"`
	CreatorRoyaltyBasisPoints uint64     `pg:",use_zero"`
	CoinRoyaltyBasisPoints    uint64     `pg:",use_zero"`
	ExtraData                 map[string][]byte
	// contains filtered or unexported fields
}

func (*PGPost) HasMedia

func (post *PGPost) HasMedia() bool

HasMedia is inefficient and needs to be moved to a column in the Posts table

func (*PGPost) NewPostEntry

func (post *PGPost) NewPostEntry() *PostEntry

type PGProfile

type PGProfile struct {
	PKID                    *PKID      `pg:",pk,type:bytea"`
	PublicKey               *PublicKey `pg:",type:bytea"`
	Username                string
	Description             string
	ProfilePic              []byte
	CreatorBasisPoints      uint64
	DeSoLockedNanos         uint64
	NumberOfHolders         uint64
	CoinsInCirculationNanos uint64
	CoinWatermarkNanos      uint64
	// contains filtered or unexported fields
}

func (*PGProfile) Empty

func (profile *PGProfile) Empty() bool

type PGRepost

type PGRepost struct {
	ReposterPublickey *PublicKey `pg:",pk,type:bytea"`
	RepostedPostHash  *BlockHash `pg:",pk,type:bytea"`
	RepostPostHash    *BlockHash `pg:",type:bytea"`
	// contains filtered or unexported fields
}

type PGTransaction

type PGTransaction struct {
	Hash      *BlockHash `pg:",pk,type:bytea"`
	BlockHash *BlockHash `pg:",type:bytea"`
	Type      TxnType    `pg:",use_zero"`
	PublicKey []byte     `pg:",type:bytea"`
	ExtraData map[string][]byte
	R         *BlockHash `pg:",type:bytea"`
	S         *BlockHash `pg:",type:bytea"`

	// Relationships
	Outputs                     []*PGTransactionOutput         `pg:"rel:has-many,join_fk:output_hash"`
	MetadataBlockReward         *PGMetadataBlockReward         `pg:"rel:belongs-to,join_fk:transaction_hash"`
	MetadataBitcoinExchange     *PGMetadataBitcoinExchange     `pg:"rel:belongs-to,join_fk:transaction_hash"`
	MetadataPrivateMessage      *PGMetadataPrivateMessage      `pg:"rel:belongs-to,join_fk:transaction_hash"`
	MetadataSubmitPost          *PGMetadataSubmitPost          `pg:"rel:belongs-to,join_fk:transaction_hash"`
	MetadataUpdateExchangeRate  *PGMetadataUpdateExchangeRate  `pg:"rel:belongs-to,join_fk:transaction_hash"`
	MetadataUpdateProfile       *PGMetadataUpdateProfile       `pg:"rel:belongs-to,join_fk:transaction_hash"`
	MetadataFollow              *PGMetadataFollow              `pg:"rel:belongs-to,join_fk:transaction_hash"`
	MetadataLike                *PGMetadataLike                `pg:"rel:belongs-to,join_fk:transaction_hash"`
	MetadataCreatorCoin         *PGMetadataCreatorCoin         `pg:"rel:belongs-to,join_fk:transaction_hash"`
	MetadataCreatorCoinTransfer *PGMetadataCreatorCoinTransfer `pg:"rel:belongs-to,join_fk:transaction_hash"`
	MetadataSwapIdentity        *PGMetadataSwapIdentity        `pg:"rel:belongs-to,join_fk:transaction_hash"`
	MetadataCreateNFT           *PGMetadataCreateNFT           `pg:"rel:belongs-to,join_fk:transaction_hash"`
	MetadataUpdateNFT           *PGMetadataUpdateNFT           `pg:"rel:belongs-to,join_fk:transaction_hash"`
	MetadataAcceptNFTBid        *PGMetadataAcceptNFTBid        `pg:"rel:belongs-to,join_fk:transaction_hash"`
	MetadataNFTBid              *PGMetadataNFTBid              `pg:"rel:belongs-to,join_fk:transaction_hash"`
	MetadataNFTTransfer         *PGMetadataNFTTransfer         `pg:"rel:belongs-to,join_fk:transaction_hash"`
	MetadataAcceptNFTTransfer   *PGMetadataAcceptNFTTransfer   `pg:"rel:belongs-to,join_fk:transaction_hash"`
	MetadataBurnNFT             *PGMetadataBurnNFT             `pg:"rel:belongs-to,join_fk:transaction_hash"`
	MetadataDerivedKey          *PGMetadataDerivedKey          `pg:"rel:belongs-to,join_fk:transaction_hash"`
	// contains filtered or unexported fields
}

PGTransaction represents MsgDeSoTxn

type PGTransactionOutput

type PGTransactionOutput struct {
	OutputHash  *BlockHash `pg:",pk"`
	OutputIndex uint32     `pg:",pk,use_zero"`
	OutputType  UtxoType   `pg:",use_zero"`
	Height      uint32     `pg:",use_zero"`
	PublicKey   []byte
	AmountNanos uint64 `pg:",use_zero"`
	Spent       bool   `pg:",use_zero"`
	InputHash   *BlockHash
	InputIndex  uint32 `pg:",pk,use_zero"`
	// contains filtered or unexported fields
}

PGTransactionOutput represents DeSoOutput, DeSoInput, and UtxoEntry

func (*PGTransactionOutput) NewUtxoEntry

func (utxo *PGTransactionOutput) NewUtxoEntry() *UtxoEntry

type PKID

type PKID [33]byte

A PKID is an ID associated with a public key. In the DB, various fields are indexed using the PKID rather than the user's public key directly in order to create one layer of indirection between the public key and the user's data. This makes it easy for the user to transfer certain data to a new public key.

func DBGetPKIDForUsername

func DBGetPKIDForUsername(db *badger.DB, username []byte) *PKID

func DBGetPKIDForUsernameWithTxn

func DBGetPKIDForUsernameWithTxn(
	txn *badger.Txn, username []byte) *PKID

func DbGetPKIDsFollowingYou

func DbGetPKIDsFollowingYou(handle *badger.DB, yourPKID *PKID) (
	_pkids []*PKID, _err error)

func DbGetPKIDsYouFollow

func DbGetPKIDsYouFollow(handle *badger.DB, yourPKID *PKID) (
	_pkids []*PKID, _err error)

func NewPKID

func NewPKID(pkidBytes []byte) *PKID

func PublicKeyToPKID

func PublicKeyToPKID(publicKey []byte) *PKID

func (*PKID) NewPKID

func (pkid *PKID) NewPKID() *PKID

func (*PKID) ToBytes

func (pkid *PKID) ToBytes() []byte

type PKIDEntry

type PKIDEntry struct {
	PKID *PKID
	// We add the public key only so we can reuse this struct to store the reverse
	// mapping of pkid -> public key.
	PublicKey []byte
	// contains filtered or unexported fields
}

func DBGetPKIDEntryForPublicKey

func DBGetPKIDEntryForPublicKey(db *badger.DB, publicKey []byte) *PKIDEntry

func DBGetPKIDEntryForPublicKeyWithTxn

func DBGetPKIDEntryForPublicKeyWithTxn(txn *badger.Txn, publicKey []byte) *PKIDEntry

func (*PKIDEntry) String

func (pkid *PKIDEntry) String() string

type Peer

type Peer struct {

	// Stats that should be accessed using the mutex below.
	StatsMtx deadlock.RWMutex

	ID uint64
	// Ping-related fields.
	LastPingNonce  uint64
	LastPingTime   time.Time
	LastPingMicros int64

	Params      *DeSoParams
	MessageChan chan *ServerMessage
	// A hack to make it so that we can allow an API endpoint to manually
	// delete a peer.
	PeerManuallyRemovedFromConnectionManager bool

	// Basic state.
	PeerInfoMtx deadlock.Mutex
	// contains filtered or unexported fields
}

Peer is an object that holds all of the state for a connection to another node. Any communication with other nodes happens via this object, which maintains a queue of messages to send to the other node.

func NewPeer

func NewPeer(_conn net.Conn, _isOutbound bool, _netAddr *wire.NetAddress,
	_isPersistent bool, _stallTimeoutSeconds uint64,
	_minFeeRateNanosPerKB uint64,
	params *DeSoParams,
	messageChan chan *ServerMessage,
	_cmgr *ConnectionManager, _srv *Server) *Peer

NewPeer creates a new Peer object.

func (*Peer) AddDeSoMessage

func (pp *Peer) AddDeSoMessage(desoMessage DeSoMessage, inbound bool)

func (*Peer) Address

func (pp *Peer) Address() string

func (*Peer) Connected

func (pp *Peer) Connected() bool

func (*Peer) Disconnect

func (pp *Peer) Disconnect()

Disconnect closes a peer's network connection.

func (*Peer) HandleGetBlocks

func (pp *Peer) HandleGetBlocks(msg *MsgDeSoGetBlocks)

func (*Peer) HandleGetTransactionsMsg

func (pp *Peer) HandleGetTransactionsMsg(getTxnMsg *MsgDeSoGetTransactions)

This call blocks on the Peer's queue.

func (*Peer) HandleInv

func (pp *Peer) HandleInv(msg *MsgDeSoInv)

func (*Peer) HandleTransactionBundleMessage

func (pp *Peer) HandleTransactionBundleMessage(msg *MsgDeSoTransactionBundle)

func (*Peer) HelpHandleInv

func (pp *Peer) HelpHandleInv(msg *MsgDeSoInv)

func (*Peer) IP

func (pp *Peer) IP() string

func (*Peer) IsOutbound

func (pp *Peer) IsOutbound() bool

func (*Peer) IsSyncCandidate

func (pp *Peer) IsSyncCandidate() bool

func (*Peer) MaybeDequeueDeSoMessage

func (pp *Peer) MaybeDequeueDeSoMessage() *DeSoMessageMeta

func (*Peer) MinFeeRateNanosPerKB

func (pp *Peer) MinFeeRateNanosPerKB() uint64

MinFeeRateNanosPerKB returns the minimum fee rate this peer requires in order to accept transactions into its mempool. We should generally not send a peer a transaction below this fee rate.

func (*Peer) NegotiateVersion

func (pp *Peer) NegotiateVersion(versionNegotiationTimeout time.Duration) error

func (*Peer) NewVersionMessage

func (pp *Peer) NewVersionMessage(params *DeSoParams) *MsgDeSoVersion

func (*Peer) NumBlocksToSend

func (pp *Peer) NumBlocksToSend() uint32

NumBlocksToSend is the number of blocks the Peer has requested from us that we have yet to send them.

func (*Peer) Port

func (pp *Peer) Port() uint16

func (*Peer) QueueMessage

func (pp *Peer) QueueMessage(desoMessage DeSoMessage)

func (*Peer) ReadDeSoMessage

func (pp *Peer) ReadDeSoMessage() (DeSoMessage, error)

func (*Peer) Start

func (pp *Peer) Start()

func (*Peer) StartDeSoMessageProcessor

func (pp *Peer) StartDeSoMessageProcessor()

func (*Peer) StartingBlockHeight

func (pp *Peer) StartingBlockHeight() uint32

StartingBlockHeight is the height of the peer's blockchain tip.

func (*Peer) String

func (pp *Peer) String() string

func (*Peer) WriteDeSoMessage

func (pp *Peer) WriteDeSoMessage(msg DeSoMessage) error

type PkMapKey

DEPRECATED: Replace all instances with lib.PublicKey

func MakePkMapKey

func MakePkMapKey(pk []byte) PkMapKey

func (PkMapKey) String

func (mm PkMapKey) String() string

type PostEntry

type PostEntry struct {
	// The hash of this post entry. Used as the ID for the entry.
	PostHash *BlockHash

	// The public key of the user who made the post.
	PosterPublicKey []byte

	// The parent post. This is used for comments.
	ParentStakeID []byte

	// The body of this post.
	Body []byte

	// The PostHash of the post this post reposts
	RepostedPostHash *BlockHash

	// Indicator if this PostEntry is a quoted repost or not
	IsQuotedRepost bool

	// The amount the creator of the post gets when someone stakes
	// to the post.
	CreatorBasisPoints uint64

	// The multiple of the payout when a user stakes to a post.
	// 2x multiple = 200% = 20,000bps
	StakeMultipleBasisPoints uint64

	// The block height when the post was confirmed.
	ConfirmationBlockHeight uint32

	// A timestamp used for ordering messages when displaying them to
	// users. The timestamp must be unique. Note that we use a nanosecond
	// timestamp because it makes it easier to deal with the uniqueness
	// constraint technically (e.g. If one second spacing is required
	// as would be the case with a standard Unix timestamp then any code
	// that generates these transactions will need to potentially wait
	// or else risk a timestamp collision. This complexity is avoided
	// by just using a nanosecond timestamp). Note that the timestamp is
	// an unsigned int as opposed to a signed int, which means times
	// before the zero time are not represented which doesn't matter
	// for our purposes. Restricting the timestamp in this way makes
	// lexicographic sorting based on bytes easier in our database which
	// is one of the reasons we do it.
	TimestampNanos uint64

	// Users can "delete" posts, but right now we just implement this as
	// setting a flag on the post to hide it rather than actually deleting
	// it. This simplifies the implementation and makes it easier to "undelete"
	// posts in certain situations.
	IsHidden bool

	// Counter of users that have liked this post.
	LikeCount uint64

	// Counter of users that have reposted this post.
	RepostCount uint64

	// Counter of quote reposts for this post.
	QuoteRepostCount uint64

	// Counter of diamonds that the post has received.
	DiamondCount uint64

	// How many comments this post has
	CommentCount uint64

	// Indicator if a post is pinned or not.
	IsPinned bool

	// NFT info.
	IsNFT                          bool
	NumNFTCopies                   uint64
	NumNFTCopiesForSale            uint64
	NumNFTCopiesBurned             uint64
	HasUnlockable                  bool
	NFTRoyaltyToCreatorBasisPoints uint64
	NFTRoyaltyToCoinBasisPoints    uint64

	// ExtraData map to hold arbitrary attributes of a post. Holds non-consensus related information about a post.
	PostExtraData map[string][]byte
	// contains filtered or unexported fields
}

func DBGetPostEntryByPostHash

func DBGetPostEntryByPostHash(db *badger.DB, postHash *BlockHash) *PostEntry

func DBGetPostEntryByPostHashWithTxn

func DBGetPostEntryByPostHashWithTxn(
	txn *badger.Txn, postHash *BlockHash) *PostEntry

func (*PostEntry) HasMedia

func (pe *PostEntry) HasMedia() bool

func (*PostEntry) IsDeleted

func (pe *PostEntry) IsDeleted() bool

type PostEntryReaderState

type PostEntryReaderState struct {
	// This is true if the reader has liked the associated post.
	LikedByReader bool

	// The number of diamonds that the reader has given this post.
	DiamondLevelBestowed int64

	// This is true if the reader has reposted the associated post.
	RepostedByReader bool

	// This is the post hash hex of the repost
	RepostPostHashHex string
}

This struct holds info on a readers interactions (e.g. likes) with a post. It is added to a post entry response in the frontend server api.

type Postgres

type Postgres struct {
	// contains filtered or unexported fields
}

func NewPostgres

func NewPostgres(db *pg.DB) *Postgres

func (*Postgres) FlushView

func (postgres *Postgres) FlushView(view *UtxoView) error

func (*Postgres) GetAllDerivedKeysForOwner

func (postgres *Postgres) GetAllDerivedKeysForOwner(ownerPublicKey *PublicKey) []*PGDerivedKey

func (*Postgres) GetBalance

func (postgres *Postgres) GetBalance(publicKey *PublicKey) uint64

func (*Postgres) GetBlockIndex

func (postgres *Postgres) GetBlockIndex() (map[BlockHash]*BlockNode, error)

GetBlockIndex gets all the PGBlocks and creates a map of BlockHash to BlockNode as needed by blockchain.go

func (*Postgres) GetBlockRewardsForPublicKey

func (postgres *Postgres) GetBlockRewardsForPublicKey(publicKey *PublicKey, startHeight uint32, endHeight uint32) []*PGTransactionOutput

func (*Postgres) GetChain

func (postgres *Postgres) GetChain(name string) *PGChain

GetChain returns the current chain by name. Postgres only supports MAIN_CHAIN for now but will eventually support multiple chains. A chain is defined by its Name and TipHash.

func (*Postgres) GetComments

func (postgres *Postgres) GetComments(parentPostHash *BlockHash) []*PGPost

TODO: Pagination

func (*Postgres) GetCreatorCoinBalance

func (postgres *Postgres) GetCreatorCoinBalance(holderPkid *PKID, creatorPkid *PKID) *PGCreatorCoinBalance

func (*Postgres) GetCreatorCoinBalances

func (postgres *Postgres) GetCreatorCoinBalances(balances []*PGCreatorCoinBalance) []*PGCreatorCoinBalance

func (*Postgres) GetDerivedKey

func (postgres *Postgres) GetDerivedKey(ownerPublicKey *PublicKey, derivedPublicKey *PublicKey) *PGDerivedKey

func (*Postgres) GetDiamond

func (postgres *Postgres) GetDiamond(senderPkid *PKID, receiverPkid *PKID, postHash *BlockHash) *PGDiamond

func (*Postgres) GetFollow

func (postgres *Postgres) GetFollow(followerPkid *PKID, followedPkid *PKID) *PGFollow

func (*Postgres) GetFollowers

func (postgres *Postgres) GetFollowers(pkid *PKID) []*PGFollow

func (*Postgres) GetFollowing

func (postgres *Postgres) GetFollowing(pkid *PKID) []*PGFollow

func (*Postgres) GetFollows

func (postgres *Postgres) GetFollows(follows []*PGFollow) []*PGFollow

func (*Postgres) GetHolders

func (postgres *Postgres) GetHolders(pkid *PKID) []*PGCreatorCoinBalance

func (*Postgres) GetHoldings

func (postgres *Postgres) GetHoldings(pkid *PKID) []*PGCreatorCoinBalance

func (*Postgres) GetLike

func (postgres *Postgres) GetLike(likerPublicKey []byte, likedPostHash *BlockHash) *PGLike

func (*Postgres) GetLikes

func (postgres *Postgres) GetLikes(likes []*PGLike) []*PGLike

func (*Postgres) GetLikesForPost

func (postgres *Postgres) GetLikesForPost(postHash *BlockHash) []*PGLike

func (*Postgres) GetMessage

func (postgres *Postgres) GetMessage(messageHash *BlockHash) *PGMessage

func (*Postgres) GetNFT

func (postgres *Postgres) GetNFT(nftPostHash *BlockHash, serialNumber uint64) *PGNFT

func (*Postgres) GetNFTBid

func (postgres *Postgres) GetNFTBid(nftPostHash *BlockHash, bidderPKID *PKID, serialNumber uint64) *PGNFTBid

func (*Postgres) GetNFTBidsForPKID

func (postgres *Postgres) GetNFTBidsForPKID(pkid *PKID) []*PGNFTBid

func (*Postgres) GetNFTBidsForSerial

func (postgres *Postgres) GetNFTBidsForSerial(nftPostHash *BlockHash, serialNumber uint64) []*PGNFTBid

func (*Postgres) GetNFTsForPKID

func (postgres *Postgres) GetNFTsForPKID(pkid *PKID) []*PGNFT

func (*Postgres) GetNFTsForPostHash

func (postgres *Postgres) GetNFTsForPostHash(nftPostHash *BlockHash) []*PGNFT

func (*Postgres) GetNotifications

func (postgres *Postgres) GetNotifications(publicKey string) ([]*PGNotification, error)

func (*Postgres) GetOutputs

func (postgres *Postgres) GetOutputs(outputs []*PGTransactionOutput) []*PGTransactionOutput

func (*Postgres) GetPost

func (postgres *Postgres) GetPost(postHash *BlockHash) *PGPost

func (*Postgres) GetPosts

func (postgres *Postgres) GetPosts(posts []*PGPost) []*PGPost

func (*Postgres) GetPostsForPublicKey

func (postgres *Postgres) GetPostsForPublicKey(publicKey []byte, startTime uint64, limit uint64) []*PGPost

func (*Postgres) GetProfile

func (postgres *Postgres) GetProfile(pkid PKID) *PGProfile

func (*Postgres) GetProfileForPublicKey

func (postgres *Postgres) GetProfileForPublicKey(publicKey []byte) *PGProfile

func (*Postgres) GetProfileForUsername

func (postgres *Postgres) GetProfileForUsername(nonLowercaseUsername string) *PGProfile

func (*Postgres) GetProfilesByCoinValue

func (postgres *Postgres) GetProfilesByCoinValue(startLockedNanos uint64, limit int) []*PGProfile

func (*Postgres) GetProfilesForPublicKeys

func (postgres *Postgres) GetProfilesForPublicKeys(publicKeys []*PublicKey) []*PGProfile

func (*Postgres) GetProfilesForUsername

func (postgres *Postgres) GetProfilesForUsername(usernames []string) []*PGProfile

func (*Postgres) GetProfilesForUsernamePrefixByCoinValue

func (postgres *Postgres) GetProfilesForUsernamePrefixByCoinValue(usernamePrefix string, limit int) []*PGProfile

func (*Postgres) GetUtxoEntriesForPublicKey

func (postgres *Postgres) GetUtxoEntriesForPublicKey(publicKey []byte) []*UtxoEntry

func (*Postgres) GetUtxoEntryForUtxoKey

func (postgres *Postgres) GetUtxoEntryForUtxoKey(utxoKey *UtxoKey) *UtxoEntry

func (*Postgres) InitGenesisBlock

func (postgres *Postgres) InitGenesisBlock(params *DeSoParams, db *badger.DB) error

func (*Postgres) InsertTransactionsTx

func (postgres *Postgres) InsertTransactionsTx(tx *pg.Tx, desoTxns []*MsgDeSoTxn, blockNode *BlockNode) error

InsertTransactionsTx inserts all the transactions from a block in a bulk query

func (*Postgres) UpsertBlock

func (postgres *Postgres) UpsertBlock(blockNode *BlockNode) error

func (*Postgres) UpsertBlockAndTransactions

func (postgres *Postgres) UpsertBlockAndTransactions(blockNode *BlockNode, desoBlock *MsgDeSoBlock) error

func (*Postgres) UpsertBlockTx

func (postgres *Postgres) UpsertBlockTx(tx *pg.Tx, blockNode *BlockNode) error

func (*Postgres) UpsertChain

func (postgres *Postgres) UpsertChain(name string, tipHash *BlockHash) error

func (*Postgres) UpsertChainTx

func (postgres *Postgres) UpsertChainTx(tx *pg.Tx, name string, tipHash *BlockHash) error

type PrivateMessageMetadata

type PrivateMessageMetadata struct {

	// The public key of the recipient of the message.
	RecipientPublicKey []byte

	// The content of the message. It is encrypted with the recipient's
	// public key using ECIES.
	EncryptedText []byte

	// A timestamp used for ordering messages when displaying them to
	// users. The timestamp must be unique. Note that we use a nanosecond
	// timestamp because it makes it easier to deal with the uniqueness
	// constraint technically (e.g. If one second spacing is required
	// as would be the case with a standard Unix timestamp then any code
	// that generates these transactions will need to potentially wait
	// or else risk a timestamp collision. This complexity is avoided
	// by just using a nanosecond timestamp). Note that the timestamp is
	// an unsigned int as opposed to a signed int, which means times
	// before the zero time are not represented which doesn't matter
	// for our purposes. Restricting the timestamp in this way makes
	// lexicographic sorting based on bytes easier in our database which
	// is one of the reasons we do it.
	TimestampNanos uint64
}

func (*PrivateMessageMetadata) FromBytes

func (txnData *PrivateMessageMetadata) FromBytes(data []byte) error

func (*PrivateMessageMetadata) GetTxnType

func (txnData *PrivateMessageMetadata) GetTxnType() TxnType

func (*PrivateMessageMetadata) New

func (txnData *PrivateMessageMetadata) New() DeSoTxnMetadata

func (*PrivateMessageMetadata) ToBytes

func (txnData *PrivateMessageMetadata) ToBytes(preSignature bool) ([]byte, error)

type PrivateMessageTxindexMetadata

type PrivateMessageTxindexMetadata struct {
	TimestampNanos uint64
}

type ProfileEntry

type ProfileEntry struct {
	// PublicKey is the key used by the user to sign for things and generally
	// verify her identity.
	PublicKey []byte

	// Username is a unique human-readable identifier associated with a profile.
	Username []byte

	// Some text describing the profile.
	Description []byte

	// The profile pic string encoded as a link e.g.
	// data:image/png;base64,<data in base64>
	ProfilePic []byte

	// Users can "delete" profiles, but right now we just implement this as
	// setting a flag on the post to hide it rather than actually deleting
	// it. This simplifies the implementation and makes it easier to "undelete"
	// profiles in certain situations.
	IsHidden bool

	// CoinEntry tracks the information required to buy/sell coins on a user's
	// profile. We "embed" it here for convenience so we can access the fields
	// directly on the ProfileEntry object. Embedding also makes it so that we
	// don't need to initialize it explicitly.
	CoinEntry
	// contains filtered or unexported fields
}

func DBGetPaginatedProfilesByDeSoLocked

func DBGetPaginatedProfilesByDeSoLocked(
	db *badger.DB, startDeSoLockedNanos uint64,
	startProfilePubKeyy []byte, numToFetch int, fetchProfileEntries bool) (
	_profilePublicKeys [][]byte, _profileEntries []*ProfileEntry, _err error)

DBGetPaginatedProfilesByDeSoLocked returns up to 'numToFetch' profiles from the db.

func DBGetProfileEntryForPKID

func DBGetProfileEntryForPKID(db *badger.DB, pkid *PKID) *ProfileEntry

func DBGetProfileEntryForPKIDWithTxn

func DBGetProfileEntryForPKIDWithTxn(
	txn *badger.Txn, pkid *PKID) *ProfileEntry

func DBGetProfileEntryForUsername

func DBGetProfileEntryForUsername(db *badger.DB, username []byte) *ProfileEntry

func DBGetProfileEntryForUsernameWithTxn

func DBGetProfileEntryForUsernameWithTxn(
	txn *badger.Txn, username []byte) *ProfileEntry

func DBGetProfilesByUsernamePrefixAndDeSoLocked

func DBGetProfilesByUsernamePrefixAndDeSoLocked(
	db *badger.DB, usernamePrefix string, utxoView *UtxoView) (
	_profileEntries []*ProfileEntry, _err error)

func (*ProfileEntry) IsDeleted

func (pe *ProfileEntry) IsDeleted() bool

type PublicKey

type PublicKey [33]byte

func NewPublicKey

func NewPublicKey(publicKeyBytes []byte) *PublicKey

func (*PublicKey) ToBytes

func (publicKey *PublicKey) ToBytes() []byte

type PurchaseSupplyIntervalStart

type PurchaseSupplyIntervalStart struct {
	// How much each unit costs to purchase in Satoshis.
	SatoshisPerUnit uint64
	// The total supply cutoff at which this price applies.
	SupplyStartNanos uint64
}

type RepostEntry

type RepostEntry struct {
	ReposterPubKey []byte

	// BlockHash of the repost
	RepostPostHash *BlockHash

	// Post Hash of post that was reposted
	RepostedPostHash *BlockHash
	// contains filtered or unexported fields
}

RepostEntry stores the content of a Repost transaction.

func DbGetReposterPubKeyRepostedPostHashToRepostEntryWithTxn

func DbGetReposterPubKeyRepostedPostHashToRepostEntryWithTxn(
	txn *badger.Txn, userPubKey []byte, repostedPostHash BlockHash) *RepostEntry

func DbReposterPubKeyRepostedPostHashToRepostEntry

func DbReposterPubKeyRepostedPostHashToRepostEntry(
	db *badger.DB, userPubKey []byte, repostedPostHash BlockHash) *RepostEntry

type RepostKey

type RepostKey struct {
	ReposterPubKey PkMapKey
	// Post Hash of post that was reposted
	RepostedPostHash BlockHash
}

func MakeRepostKey

func MakeRepostKey(userPk []byte, RepostedPostHash BlockHash) RepostKey

type RuleError

type RuleError string

RuleError is an error type that specifies an error occurred during block processing that is related to a consensus rule. By checking the type of the error the caller can determine that the error was due to a consensus rule and determine which consensus rule caused the issue.

const (
	RuleErrorDuplicateBlock                       RuleError = "RuleErrorDuplicateBlock"
	RuleErrorDuplicateOrphan                      RuleError = "RuleErrorDuplicateOrphan"
	RuleErrorMinDifficulty                        RuleError = "RuleErrorMinDifficulty"
	RuleErrorBlockTooBig                          RuleError = "RuleErrorBlockTooBig"
	RuleErrorNoTxns                               RuleError = "RuleErrorNoTxns"
	RuleErrorFirstTxnMustBeBlockReward            RuleError = "RuleErrorFirstTxnMustBeBlockReward"
	RuleErrorMoreThanOneBlockReward               RuleError = "RuleErrorMoreThanOneBlockReward"
	RuleErrorPreviousBlockInvalid                 RuleError = "RuleErrorPreviousBlockInvalid"
	RuleErrorPreviousBlockHeaderInvalid           RuleError = "RuleErrorPreviousBlockHeaderInvalid"
	RuleErrorTxnMustHaveAtLeastOneInput           RuleError = "RuleErrorTxnMustHaveAtLeastOneInput"
	RuleErrorTxnMustHaveAtLeastOneOutput          RuleError = "RuleErrorTxnMustHaveAtLeastOneOutput"
	RuleErrorOutputExceedsMax                     RuleError = "RuleErrorOutputExceedsMax"
	RuleErrorOutputOverflowsTotal                 RuleError = "RuleErrorOutputOverflowsTotal"
	RuleErrorTotalOutputExceedsMax                RuleError = "RuleErrorTotalOutputExceedsMax"
	RuleErrorDuplicateInputs                      RuleError = "RuleErrorDuplicateInputs"
	RuleErrorInvalidTxnMerkleRoot                 RuleError = "RuleErrorInvalidTxnMerkleRoot"
	RuleErrorDuplicateTxn                         RuleError = "RuleErrorDuplicateTxn"
	RuleErrorInputSpendsNonexistentUtxo           RuleError = "RuleErrorInputSpendsNonexistentUtxo"
	RuleErrorInputSpendsPreviouslySpentOutput     RuleError = "RuleErrorInputSpendsPreviouslySpentOutput"
	RuleErrorInputSpendsImmatureBlockReward       RuleError = "RuleErrorInputSpendsImmatureBlockReward"
	RuleErrorInputSpendsOutputWithInvalidAmount   RuleError = "RuleErrorInputSpendsOutputWithInvalidAmount"
	RuleErrorTxnOutputWithInvalidAmount           RuleError = "RuleErrorTxnOutputWithInvalidAmount"
	RuleErrorTxnOutputExceedsInput                RuleError = "RuleErrorTxnOutputExceedsInput"
	RuleErrorTxnFeeBelowNetworkMinimum            RuleError = "RuleErrorTxnFeeBelowNetworkMinimum"
	RuleErrorOverflowDetectedInFeeRateCalculation RuleError = "RuleErrorOverflowDetectedInFeeRateCalculation"
	RuleErrorBlockRewardOutputWithInvalidAmount   RuleError = "RuleErrorBlockRewardOutputWithInvalidAmount"
	RuleErrorBlockRewardOverflow                  RuleError = "RuleErrorBlockRewardOverflow"
	RuleErrorBlockRewardExceedsMaxAllowed         RuleError = "RuleErrorBlockRewardExceedsMaxAllowed"
	RuleErrorProfileUsernameExists                RuleError = "RuleErrorProfileUsernameExists"
	RuleErrorPubKeyLen                            RuleError = "RuleErrorPubKeyLen"
	RuleErrorMaxProfilePicSize                    RuleError = "RuleErrorMaxProfilePicSize"
	RuleErrorProfileCreatorPercentageSize         RuleError = "RuleErrorProfileCreatorPercentageSize"
	RuleErrorProfileStakeMultipleSize             RuleError = "RuleErrorProfileStakeMultipleSize"
	RuleErrorInvalidUsername                      RuleError = "RuleErrorInvalidUsername"
	RuleErrorEncryptedDataLen                     RuleError = "RuleErrorEncryptedDataLen"
	RuleErrorInputOverflows                       RuleError = "RuleErrorInputOverflows"
	RuleErrorInsufficientRefund                   RuleError = "RuleErrorInsufficientRefund"
	RuleErrorMissingSignature                     RuleError = "RuleErrorMissingSignature"
	RuleErrorSigHash                              RuleError = "RuleErrorSigHash"
	RuleErrorParsePublicKey                       RuleError = "RuleErrorParsePublicKey"
	RuleErrorSigCheckFailed                       RuleError = "RuleErrorSigCheckFailed"
	RuleErrorOutputPublicKeyNotRecognized         RuleError = "RuleErrorOutputPublicKeyNotRecognized"
	RuleErrorInputsWithDifferingSpendKeys         RuleError = "RuleErrorInputsWithDifferingSpendKeys"
	RuleErrorInvalidTransactionSignature          RuleError = "RuleErrorInvalidTransactionSignature"

	RuleErrorMissingBlockProducerSignature                      RuleError = "RuleErrorMissingBlockProducerSignature"
	RuleErrorInvalidBlockProducerPublicKey                      RuleError = "RuleErrorInvalidBlockProducerPublicKey"
	RuleErrorBlockProducerPublicKeyNotInWhitelist               RuleError = "RuleErrorBlockProducerPublicKeyNotInWhitelist"
	RuleErrorForbiddenBlockProducerPublicKey                    RuleError = "RuleErrorForbiddenBlockProducerPublicKey"
	RuleErrorInvalidBlockProducerSIgnature                      RuleError = "RuleErrorInvalidBlockProducerSIgnature"
	RuleErrorInvalidBlockHeader                                 RuleError = "RuleErrorInvalidBlockHeader"
	RuleErrorOrphanBlock                                        RuleError = "RuleErrorOrphanBlock"
	RuleErrorInputWithPublicKeyDifferentFromTxnPublicKey        RuleError = "RuleErrorInputWithPublicKeyDifferentFromTxnPublicKey"
	RuleErrorBlockRewardTxnNotAllowedToHaveInputs               RuleError = "RuleErrorBlockRewardTxnNotAllowedToHaveInputs"
	RuleErrorBlockRewardTxnNotAllowedToHaveSignature            RuleError = "RuleErrorBlockRewardTxnNotAllowedToHaveSignature"
	RuleErrorDeflationBombForbidsMintingAnyMoreDeSo             RuleError = "RuleErrorDeflationBombForbidsMintingAnyMoreDeSo"
	RuleErrorBitcoinExchangeShouldNotHaveInputs                 RuleError = "RuleErrorBitcoinExchangeShouldNotHaveInputs"
	RuleErrorBitcoinExchangeShouldNotHaveOutputs                RuleError = "RuleErrorBitcoinExchangeShouldNotHaveOutputs"
	RuleErrorBitcoinExchangeShouldNotHavePublicKey              RuleError = "RuleErrorBitcoinExchangeShouldNotHavePublicKey"
	RuleErrorBitcoinExchangeShouldNotHaveSignature              RuleError = "RuleErrorBitcoinExchangeShouldNotHaveSignature"
	RuleErrorBitcoinExchangeHasBadBitcoinTxHash                 RuleError = "RuleErrorBitcoinExchangeHasBadBitcoinTxHash"
	RuleErrorBitcoinExchangeDoubleSpendingBitcoinTransaction    RuleError = "RuleErrorBitcoinExchangeDoubleSpendingBitcoinTransaction"
	RuleErrorBitcoinExchangeBlockHashNotFoundInMainBitcoinChain RuleError = "RuleErrorBitcoinExchangeBlockHashNotFoundInMainBitcoinChain"
	RuleErrorBitcoinExchangeHasBadMerkleRoot                    RuleError = "RuleErrorBitcoinExchangeHasBadMerkleRoot"
	RuleErrorBitcoinExchangeInvalidMerkleProof                  RuleError = "RuleErrorBitcoinExchangeInvalidMerkleProof"
	RuleErrorBitcoinExchangeValidPublicKeyNotFoundInInputs      RuleError = "RuleErrorBitcoinExchangeValidPublicKeyNotFoundInInputs"
	RuleErrorBitcoinExchangeProblemComputingBurnOutput          RuleError = "RuleErrorBitcoinExchangeProblemComputingBurnOutput"
	RuleErrorBitcoinExchangeFeeOverflow                         RuleError = "RuleErrorBitcoinExchangeFeeOverflow"
	RuleErrorBitcoinExchangeTotalOutputLessThanOrEqualZero      RuleError = "RuleErrorBitcoinExchangeTotalOutputLessThanOrEqualZero"
	RuleErrorTxnSanity                                          RuleError = "RuleErrorTxnSanity"
	RuleErrorTxnTooBig                                          RuleError = "RuleErrorTxnTooBig"

	RuleErrorPrivateMessageEncryptedTextLengthExceedsMax           RuleError = "RuleErrorPrivateMessageEncryptedTextLengthExceedsMax"
	RuleErrorPrivateMessageRecipientPubKeyLen                      RuleError = "RuleErrorPrivateMessageRecipientPubKeyLen"
	RuleErrorPrivateMessageTstampIsZero                            RuleError = "RuleErrorPrivateMessageTstampIsZero"
	RuleErrorTransactionMissingPublicKey                           RuleError = "RuleErrorTransactionMissingPublicKey"
	RuleErrorPrivateMessageExistsWithSenderPublicKeyTstampTuple    RuleError = "RuleErrorPrivateMessageExistsWithSenderPublicKeyTstampTuple"
	RuleErrorPrivateMessageExistsWithRecipientPublicKeyTstampTuple RuleError = "RuleErrorPrivateMessageExistsWithRecipientPublicKeyTstampTuple"
	RuleErrorPrivateMessageParsePubKeyError                        RuleError = "RuleErrorPrivateMessageParsePubKeyError"
	RuleErrorPrivateMessageSenderPublicKeyEqualsRecipientPublicKey RuleError = "RuleErrorPrivateMessageSenderPublicKeyEqualsRecipientPublicKey"
	RuleErrorBurnAddressCannotBurnBitcoin                          RuleError = "RuleErrorBurnAddressCannotBurnBitcoin"

	RuleErrorFollowPubKeyLen                         RuleError = "RuleErrorFollowFollowedPubKeyLen"
	RuleErrorFollowParsePubKeyError                  RuleError = "RuleErrorFollowParsePubKeyError"
	RuleErrorFollowEntryAlreadyExists                RuleError = "RuleErrorFollowEntryAlreadyExists"
	RuleErrorFollowingNonexistentProfile             RuleError = "RuleErrorFollowingNonexistentProfile"
	RuleErrorCannotUnfollowNonexistentFollowEntry    RuleError = "RuleErrorCannotUnfollowNonexistentFollowEntry"
	RuleErrorProfilePublicKeyNotEqualToPKIDPublicKey RuleError = "RuleErrorProfilePublicKeyNotEqualToPKIDPublicKey"

	RuleErrorLikeEntryAlreadyExists            RuleError = "RuleErrorLikeEntryAlreadyExists"
	RuleErrorCannotLikeNonexistentPost         RuleError = "RuleErrorCannotLikeNonexistentPost"
	RuleErrorCannotUnlikeWithoutAnExistingLike RuleError = "RuleErrorCannotUnlikeWithoutAnExistingLike"

	RuleErrorProfileUsernameTooShort            RuleError = "RuleErrorProfileUsernameTooShort"
	RuleErrorProfileDescriptionTooShort         RuleError = "RuleErrorProfileDescriptionTooShort"
	RuleErrorProfileUsernameTooLong             RuleError = "RuleErrorProfileUsernameTooLong"
	RuleErrorProfileDescriptionTooLong          RuleError = "RuleErrorProfileDescriptionTooLong"
	RuleErrorProfileProfilePicTooShort          RuleError = "RuleErrorProfileProfilePicTooShort"
	RuleErrorProfileUpdateRequiresNonZeroInput  RuleError = "RuleErrorProfileUpdateRequiresNonZeroInput"
	RuleErrorCreateProfileTxnOutputExceedsInput RuleError = "RuleErrorCreateProfileTxnOutputExceedsInput"
	RuleErrorProfilePublicKeySize               RuleError = "RuleErrorProfilePublicKeySize"
	RuleErrorProfileBadPublicKey                RuleError = "RuleErrorProfileBadPublicKey"
	RuleErrorProfilePubKeyNotAuthorized         RuleError = "RuleErrorProfilePubKeyNotAuthorized"
	RuleErrorProfileModificationNotAuthorized   RuleError = "RuleErrorProfileModificationNotAuthorized"
	RuleErrorProfileUsernameCannotContainZeros  RuleError = "RuleErrorProfileUsernameCannotContainZeros"

	RuleSubmitPostNilParentPostHash                  RuleError = "RuleSubmitPostNilParentPostHash"
	RuleSubmitPostTitleLength                        RuleError = "RuleSubmitPostTitleLength"
	RuleSubmitPostBodyLength                         RuleError = "RuleSubmitPostBodyLength"
	RuleSubmitPostSubLength                          RuleError = "RuleSubmitPostSubLength"
	RuleErrorSubmitPostStakeMultipleSize             RuleError = "RuleErrorSubmitPostStakeMultipleSize"
	RuleErrorSubmitPostCreatorPercentageSize         RuleError = "RuleErrorSubmitPostCreatorPercentageSize"
	RuleErrorSubmitPostTimestampIsZero               RuleError = "RuleErrorSubmitPostTimestampIsZero"
	RuleErrorPostAlreadyExists                       RuleError = "RuleErrorPostAlreadyExists"
	RuleErrorSubmitPostInvalidCommentStakeID         RuleError = "RuleErrorSubmitPostInvalidCommentStakeID"
	RuleErrorSubmitPostRequiresNonZeroInput          RuleError = "RuleErrorSubmitPostRequiresNonZeroInput"
	RuleErrorSubmitPostInvalidPostHashToModify       RuleError = "RuleErrorSubmitPostInvalidPostHashToModify"
	RuleErrorSubmitPostModifyingNonexistentPost      RuleError = "RuleErrorSubmitPostModifyingNonexistentPost"
	RuleErrorSubmitPostPostModificationNotAuthorized RuleError = "RuleErrorSubmitPostPostModificationNotAuthorized"
	RuleErrorSubmitPostInvalidParentStakeIDLength    RuleError = "RuleErrorSubmitPostInvalidParentStakeIDLength"
	RuleErrorSubmitPostParentNotFound                RuleError = "RuleErrorSubmitPostParentNotFound"
	RuleErrorSubmitPostRepostPostNotFound            RuleError = "RuleErrorSubmitPostRepostPostNotFound"
	RuleErrorSubmitPostRepostOfRepost                RuleError = "RuleErrorSubmitPostRepostOfRepost"
	RuleErrorSubmitPostUpdateRepostHash              RuleError = "RuleErrorSubmitPostUpdateRepostHash"
	RuleErrorSubmitPostUpdateIsQuotedRepost          RuleError = "RuleErrorSubmitPostUpdateIsQuotedRepost"
	RuleErrorSubmitPostCannotUpdateNFT               RuleError = "RuleErrorSubmitPostCannotUpdateNFT"

	RuleErrorInvalidStakeID                      RuleError = "RuleErrorInvalidStakeID"
	RuleErrorInvalidStakeIDSize                  RuleError = "RuleErrorInvalidStakeIDSize"
	RuleErrorStakingToNonexistentPost            RuleError = "RuleErrorStakingToNonexistentPost"
	RuleErrorStakingToNonexistentProfile         RuleError = "RuleErrorStakingToNonexistentProfile"
	RuleErrorNotImplemented                      RuleError = "RuleErrorNotImplemented"
	RuleErrorStakingZeroNanosNotAllowed          RuleError = "RuleErrorStakingZeroNanosNotAllowed"
	RuleErrorAddStakeTxnMustHaveExactlyOneOutput RuleError = "RuleErrorAddStakeTxnMustHaveExactlyOneOutput"
	RuleErrorExistingStakeExceedsMaxAllowed      RuleError = "RuleErrorExistingStakeExceedsMaxAllowed"
	RuleErrorAddStakeRequiresNonZeroInput        RuleError = "RuleErrorAddStakeRequiresNonZeroInput"
	RuleErrorProfileForPostDoesNotExist          RuleError = "RuleErrorProfileForPostDoesNotExist"

	// Global Params
	RuleErrorExchangeRateTooLow                    RuleError = "RuleErrorExchangeRateTooLow"
	RuleErrorExchangeRateTooHigh                   RuleError = "RuleErrorExchangeRateTooHigh"
	RuleErrorMinNetworkFeeTooLow                   RuleError = "RuleErrorMinNetworkFeeTooLow"
	RuleErrorMinNetworkFeeTooHigh                  RuleError = "RuleErrorMinNetworkFeeTooHigh"
	RuleErrorCreateProfileFeeTooLow                RuleError = "RuleErrorCreateProfileFeeTooLow"
	RuleErrorCreateProfileTooHigh                  RuleError = "RuleErrorCreateProfileTooHigh"
	RuleErrorCreateNFTFeeTooLow                    RuleError = "RuleErrorCreateNFTFeeTooLow"
	RuleErrorCreateNFTFeeTooHigh                   RuleError = "RuleErrorCreateNFTFeeTooHigh"
	RuleErrorMaxCopiesPerNFTTooLow                 RuleError = "RuleErrorMaxCopiesPerNFTTooLow"
	RuleErrorMaxCopiesPerNFTTooHigh                RuleError = "RuleErrorMaxCopiesPerNFTTooHigh"
	RuleErrorForbiddenPubKeyLength                 RuleError = "RuleErrorForbiddenPubKeyLength"
	RuleErrorUserNotAuthorizedToUpdateExchangeRate RuleError = "RuleErrorUserNotAuthorizedToUpdateExchangeRate"
	RuleErrorUserNotAuthorizedToUpdateGlobalParams RuleError = "RuleErrorUserNotAuthorizedToUpdateGlobalParams"
	RuleErrorUserOutputMustBeNonzero               RuleError = "RuleErrorUserOutputMustBeNonzero"

	// DeSo Diamonds
	RuleErrorBasicTransferHasDiamondPostHashWithoutDiamondLevel   RuleError = "RuleErrorBasicTransferHasDiamondPostHashWithoutDiamondLevel"
	RuleErrorBasicTransferHasInvalidDiamondLevel                  RuleError = "RuleErrorBasicTransferHasInvalidDiamondLevel"
	RuleErrorBasicTransferDiamondInvalidLengthForPostHashBytes    RuleError = "RuleErrorBasicTransferInvalidLengthForPostHashBytes"
	RuleErrorBasicTransferDiamondPostEntryDoesNotExist            RuleError = "RuleErrorBasicTransferDiamondPostEntryDoesNotExist"
	RuleErrorBasicTransferInsufficientCreatorCoinsForDiamondLevel RuleError = "RuleErrorBasicTransferInsufficientCreatorCoinsForDiamondLevel"
	RuleErrorBasicTransferDiamondCannotTransferToSelf             RuleError = "RuleErrorBasicTransferDiamondCannotTransferToSelf"
	RuleErrorBasicTransferInsufficientDeSoForDiamondLevel         RuleError = "RuleErrorBasicTransferInsufficientDeSoForDiamondLevel"

	RuleErrorCreatorCoinTransferRequiresNonZeroInput                    RuleError = "RuleErrorCreatorCoinTransferRequiresNonZeroInput"
	RuleErrorCreatorCoinTransferInvalidProfilePubKeySize                RuleError = "RuleErrorCreatorCoinTransferInvalidProfilePubKeySize"
	RuleErrorCreatorCoinTransferInvalidReceiverPubKeySize               RuleError = "RuleErrorCreatorCoinTransferInvalidReceiverPubKeySize"
	RuleErrorCreatorCoinTransferOnNonexistentProfile                    RuleError = "RuleErrorCreatorCoinTransferOnNonexistentProfile"
	RuleErrorCreatorCoinTransferBalanceEntryDoesNotExist                RuleError = "RuleErrorCreatorCoinTransferBalanceEntryDoesNotExist"
	RuleErrorCreatorCoinTransferMustBeGreaterThanMinThreshold           RuleError = "RuleErrorCreatorCoinTransferMustBeGreaterThanMinThreshold"
	RuleErrorCreatorCoinTransferInsufficientCoins                       RuleError = "RuleErrorCreatorCoinTransferInsufficientCoins"
	RuleErrorCreatorCoinTransferCannotTransferToSelf                    RuleError = "RuleErrorCreatorCoinTransferCannotTransferToSelf"
	RuleErrorCreatorCoinTransferHasDiamondPostHashWithoutDiamondLevel   RuleError = "RuleErrorCreatorCoinTransferHasDiamondPostHashWithoutDiamondLevel"
	RuleErrorCreatorCoinTransferCantSendDiamondsForOtherProfiles        RuleError = "RuleErrorCreatorCoinTransferCantSendDiamondsForOtherProfiles"
	RuleErrorCreatorCoinTransferCantDiamondYourself                     RuleError = "RuleErrorCreatorCoinTransferCantDiamondYourself"
	RuleErrorCreatorCoinTransferInvalidLengthForPostHashBytes           RuleError = "RuleErrorCreatorCoinTransferInvalidLengthForPostHashBytes"
	RuleErrorCreatorCoinTransferInsufficientCreatorCoinsForDiamondLevel RuleError = "RuleErrorCreatorCoinTransferInsufficientCreatorCoinsForDiamondLevel"
	RuleErrorCreatorCoinTransferHasInvalidDiamondLevel                  RuleError = "RuleErrorCreatorCoinTransferHasInvalidDiamondLevel"
	RuleErrorCreatorCoinTransferHasDiamondsAfterDeSoBlockHeight         RuleError = "RuleErrorCreatorCoinTransferHasDiamondsAfterDeSoBlockHeight"
	RuleErrorCreatorCoinTransferPostAlreadyHasSufficientDiamonds        RuleError = "RuleErrorCreatorCoinTransferPostAlreadyHasSufficientDiamonds"
	RuleErrorCreatorCoinTransferDiamondsCantHaveNegativeNanos           RuleError = "RuleErrorCreatorCoinTransferDiamondsCantHaveNegativeNanos"
	RuleErrorCreatorCoinTransferDiamondPostEntryDoesNotExist            RuleError = "RuleErrorCreatorCoinTransferDiamondPostEntryDoesNotExist"

	RuleErrorCreatorCoinRequiresNonZeroInput                           RuleError = "RuleErrorCreatorCoinRequiresNonZeroInput"
	RuleErrorCreatorCoinInvalidPubKeySize                              RuleError = "RuleErrorCreatorCoinInvalidPubKeySize"
	RuleErrorCreatorCoinOperationOnNonexistentProfile                  RuleError = "RuleErrorCreatorCoinOperationOnNonexistentProfile"
	RuleErrorCreatorCoinBuyMustTradeNonZeroDeSo                        RuleError = "RuleErrorCreatorCoinBuyMustTradeNonZeroDeSo"
	RuleErrorCreatorCoinTxnOutputWithInvalidBuyAmount                  RuleError = "RuleErrorCreatorCoinTxnOutputWithInvalidBuyAmount"
	RuleErrorCreatorCoinTxnOutputExceedsInput                          RuleError = "RuleErrorCreatorCoinTxnOutputExceedsInput"
	RuleErrorCreatorCoinLessThanMinimumSetByUser                       RuleError = "RuleErrorCreatorCoinLessThanMinimumSetByUser"
	RuleErrorCreatorCoinBuyMustTradeNonZeroDeSoAfterFees               RuleError = "RuleErrorCreatorCoinBuyMustTradeNonZeroDeSoAfterFees"
	RuleErrorCreatorCoinBuyMustTradeNonZeroDeSoAfterFounderReward      RuleError = "RuleErrorCreatorCoinBuyMustTradeNonZeroDeSoAfterFounderReward"
	RuleErrorCreatorCoinBuyMustSatisfyAutoSellThresholdNanos           RuleError = "RuleErrorCreatorCoinBuyMustSatisfyAutoSellThresholdNanos"
	RuleErrorCreatorCoinBuyMustSatisfyAutoSellThresholdNanosForCreator RuleError = "RuleErrorCreatorCoinBuyMustSatisfyAutoSellThresholdNanosForCreator"
	RuleErrorCreatorCoinBuyMustSatisfyAutoSellThresholdNanosForBuyer   RuleError = "RuleErrorCreatorCoinBuyMustSatisfyAutoSellThresholdNanosForBuyer"
	RuleErrorCreatorCoinBuyZeroLockedNanosAndNonZeroHolders            RuleError = "RuleErrorCreatorCoinBuyZeroLockedNanosAndNonZeroHolders"
	RuleErrorCreatorCoinSellMustHaveAtLeastOneInput                    RuleError = "RuleErrorCreatorCoinSellMustHaveAtLeastOneInput"
	RuleErrorCreatorCoinSellMustTradeNonZeroCreatorCoin                RuleError = "RuleErrorCreatorCoinSellMustTradeNonZeroCreatorCoin"
	RuleErrorCreatorCoinSellerBalanceEntryDoesNotExist                 RuleError = "RuleErrorCreatorCoinSellerBalanceEntryDoesNotExist"
	RuleErrorCreatorCoinSellInsufficientCoins                          RuleError = "RuleErrorCreatorCoinSellInsufficientCoins"
	RuleErrorCreatorCoinSellNotAllowedWhenZeroDeSoLocked               RuleError = "RuleErrorCreatorCoinSellNotAllowedWhenZeroDeSoLocked"
	RuleErrorDeSoReceivedIsLessThanMinimumSetBySeller                  RuleError = "RuleErrorDeSoReceivedIsLessThanMinimumSetBySeller"

	// Derived Keys
	RuleErrorAuthorizeDerivedKeyAccessSignatureNotValid RuleError = "RuleErrorAuthorizeDerivedKeyAccessSignatureNotValid"
	RuleErrorAuthorizeDerivedKeyRequiresNonZeroInput    RuleError = "RuleErrorAuthorizeDerivedKeyRequiresNonZeroInput"
	RuleErrorAuthorizeDerivedKeyExpiredDerivedPublicKey RuleError = "RuleErrorAuthorizeDerivedKeyExpired"
	RuleErrorAuthorizeDerivedKeyInvalidDerivedPublicKey RuleError = "RuleErrorAuthorizeDerivedKeyInvalidDerivedKey"
	RuleErrorAuthorizeDerivedKeyDeletedDerivedPublicKey RuleError = "RuleErrorAuthorizeDerivedKeyDeletedDerivedPublicKey"
	RuleErrorAuthorizeDerivedKeyInvalidOwnerPublicKey   RuleError = "RuleErrorAuthorizeDerivedKeyInvalidOwnerPublicKey"
	RuleErrorDerivedKeyNotAuthorized                    RuleError = "RuleErrorDerivedKeyNotAuthorized"
	RuleErrorDerivedKeyInvalidExtraData                 RuleError = "RuleErrorDerivedKeyInvalidExtraData"
	RuleErrorDerivedKeyBeforeBlockHeight                RuleError = "RuleErrorDerivedKeyBeforeBlockHeight"

	// NFTs
	RuleErrorTooManyNFTCopies                     RuleError = "RuleErrorTooManyNFTCopies"
	RuleErrorCreateNFTRequiresNonZeroInput        RuleError = "RuleErrorCreateNFTRequiresNonZeroInput"
	RuleErrorUpdateNFTRequiresNonZeroInput        RuleError = "RuleErrorUpdateNFTRequiresNonZeroInput"
	RuleErrorCreateNFTOnNonexistentPost           RuleError = "RuleErrorCreateNFTOnNonexistentPost"
	RuleErrorCreateNFTOnVanillaRepost             RuleError = "RuleErrorCreateNFTOnVanillaRepost"
	RuleErrorCreateNFTWithInsufficientFunds       RuleError = "RuleErrorCreateNFTWithInsufficientFunds"
	RuleErrorCreateNFTOnPostThatAlreadyIsNFT      RuleError = "RuleErrorCreateNFTOnPostThatAlreadyIsNFT"
	RuleErrorCreateNFTMustBeCalledByPoster        RuleError = "RuleErrorCreateNFTMustBeCalledByPoster"
	RuleErrorNFTMustHaveNonZeroCopies             RuleError = "RuleErrorNFTMustHaveNonZeroCopies"
	RuleErrorCannotUpdateNonExistentNFT           RuleError = "RuleErrorCannotUpdateNonExistentNFT"
	RuleErrorCannotUpdatePendingNFTTransfer       RuleError = "RuleErrorCannotUpdatePendingNFTTransfer"
	RuleErrorCannotAcceptBidForPendingNFTTransfer RuleError = "RuleErrorCannotAcceptBidForPendingNFTTransfer"
	RuleErrorCannotBidForPendingNFTTransfer       RuleError = "RuleErrorCannotBidForPendingNFTTransfer"
	RuleErrorUpdateNFTByNonOwner                  RuleError = "RuleErrorUpdateNFTByNonOwner"
	RuleErrorAcceptNFTBidByNonOwner               RuleError = "RuleErrorAcceptNFTBidByNonOwner"
	RuleErrorCantCreateNFTWithoutProfileEntry     RuleError = "RuleErrorCantCreateNFTWithoutProfileEntry"
	RuleErrorNFTRoyaltyHasTooManyBasisPoints      RuleError = "RuleErrorNFTRoyaltyHasTooManyBasisPoints"
	RuleErrorNFTRoyaltyOverflow                   RuleError = "RuleErrorNFTRoyaltyOverflow"
	RuleErrorNFTUpdateMustUpdateIsForSaleStatus   RuleError = "RuleErrorNFTUpdateMustUpdateIsForSaleStatus"

	// NFT Bids
	RuleErrorNFTBidRequiresNonZeroInput                    RuleError = "RuleErrorNFTBidRequiresNonZeroInput"
	RuleErrorAcceptNFTBidRequiresNonZeroInput              RuleError = "RuleErrorAcceptNFTBidRequiresNonZeroInput"
	RuleErrorNFTBidOnNonExistentPost                       RuleError = "RuleErrorNFTBidOnNonExistentPost"
	RuleErrorNFTBidOnPostThatIsNotAnNFT                    RuleError = "RuleErrorNFTBidOnPostThatIsNotAnNFT"
	RuleErrorNFTBidOnInvalidSerialNumber                   RuleError = "RuleErrorNFTBidOnInvalidSerialNumber"
	RuleErrorNFTBidOnNonExistentNFTEntry                   RuleError = "RuleErrorNFTBidOnNonExistentNFTEntry"
	RuleErrorNFTBidOnNFTThatIsNotForSale                   RuleError = "RuleErrorNFTBidOnNFTThatIsNotForSale"
	RuleErrorNFTOwnerCannotBidOnOwnedNFT                   RuleError = "RuleErrorNFTOwnerCannotBidOnOwnedNFT"
	RuleErrorCantAcceptNonExistentBid                      RuleError = "RuleErrorCantAcceptNonExistentBid"
	RuleErrorAcceptedNFTBidAmountDoesNotMatch              RuleError = "RuleErrorAcceptedNFTBidAmountDoesNotMatch"
	RuleErrorPostEntryNotFoundForAcceptedNFTBid            RuleError = "RuleErrorPostEntryNotFoundForAcceptedNFTBid"
	RuleErrorUnlockableNFTMustProvideUnlockableText        RuleError = "RuleErrorUnlockableNFTMustProvideUnlockableText"
	RuleErrorUnlockableTextLengthExceedsMax                RuleError = "RuleErrorUnlockableTextLengthExceedsMax"
	RuleErrorAcceptedNFTBidMustSpecifyBidderInputs         RuleError = "RuleErrorAcceptedNFTBidMustSpecifyBidderInputs"
	RuleErrorBidderInputForAcceptedNFTBidNoLongerExists    RuleError = "RuleErrorBidderInputForAcceptedNFTBidNoLongerExists"
	RuleErrorAcceptNFTBidderInputsInsufficientForBidAmount RuleError = "RuleErrorAcceptNFTBidderInputsInsufficientForBidAmount"
	RuleErrorInsufficientFundsForNFTBid                    RuleError = "RuleErrorInsufficientFundsForNFTBid"
	RuleErrorNFTBidLessThanMinBidAmountNanos               RuleError = "RuleErrorNFTBidLessThanMinBidAmountNanos"

	// NFT Transfers
	RuleErrorNFTTransferBeforeBlockHeight                 RuleError = "RuleErrorNFTTranserBeforeBlockHeight"
	RuleErrorAcceptNFTTransferBeforeBlockHeight           RuleError = "RuleErrorAcceptNFTTranserBeforeBlockHeight"
	RuleErrorNFTTransferInvalidReceiverPubKeySize         RuleError = "RuleErrorNFTTransferInvalidReceiverPubKeySize"
	RuleErrorNFTTransferCannotTransferToSelf              RuleError = "RuleErrorNFTTransferCannotTransferToSelf"
	RuleErrorCannotTransferNonExistentNFT                 RuleError = "RuleErrorCannotTransferNonExistentNFT"
	RuleErrorNFTTransferByNonOwner                        RuleError = "RuleErrorNFTTransferByNonOwner"
	RuleErrorCannotTransferForSaleNFT                     RuleError = "RuleErrorCannotTransferForSaleNFT"
	RuleErrorCannotTransferUnlockableNFTWithoutUnlockable RuleError = "RuleErrorCannotTransferUnlockableNFTWithoutUnlockable"
	RuleErrorNFTTransferRequiresNonZeroInput              RuleError = "RuleErrorNFTTransferRequiresNonZeroInput"
	RuleErrorCannotAcceptTransferOfNonExistentNFT         RuleError = "RuleErrorCannotAcceptTransferOfNonExistentNFT"
	RuleErrorAcceptNFTTransferByNonOwner                  RuleError = "RuleErrorAcceptNFTTransferByNonOwner"
	RuleErrorAcceptNFTTransferForNonPendingNFT            RuleError = "RuleErrorAcceptNFTTransferForNonPendingNFT"
	RuleErrorAcceptNFTTransferRequiresNonZeroInput        RuleError = "RuleErrorAcceptNFTTransferRequiresNonZeroInput"

	// NFT Burns
	RuleErrorBurnNFTBeforeBlockHeight    RuleError = "RuleErrorBurnNFTBeforeBlockHeight"
	RuleErrorCannotBurnNonExistentNFT    RuleError = "RuleErrorCannotBurnNonExistentNFT"
	RuleErrorBurnNFTByNonOwner           RuleError = "RuleErrorBurnNFTByNonOwner"
	RuleErrorCannotBurnNFTThatIsForSale  RuleError = "RuleErrorCannotBurnNFTThatIsForSale"
	RuleErrorBurnNFTRequiresNonZeroInput RuleError = "RuleErrorBurnNFTRequiresNonZeroInput"

	RuleErrorSwapIdentityIsParamUpdaterOnly RuleError = "RuleErrorSwapIdentityIsParamUpdaterOnly"
	RuleErrorFromPublicKeyIsRequired        RuleError = "RuleErrorFromPublicKeyIsRequired"
	RuleErrorInvalidFromPublicKey           RuleError = "RuleErrorInvalidFromPublicKey"
	RuleErrorToPublicKeyIsRequired          RuleError = "RuleErrorToPublicKeyIsRequired"
	RuleErrorInvalidToPublicKey             RuleError = "RuleErrorInvalidToPublicKey"
	RuleErrorOldFromPublicKeyHasDeletedPKID RuleError = "RuleErrorOldFromPublicKeyHasDeletedPKID"
	RuleErrorOldToPublicKeyHasDeletedPKID   RuleError = "RuleErrorOldToPublicKeyHasDeletedPKID"

	HeaderErrorDuplicateHeader                                                   RuleError = "HeaderErrorDuplicateHeader"
	HeaderErrorNilPrevHash                                                       RuleError = "HeaderErrorNilPrevHash"
	HeaderErrorInvalidParent                                                     RuleError = "HeaderErrorInvalidParent"
	HeaderErrorBlockTooFarInTheFuture                                            RuleError = "HeaderErrorBlockTooFarInTheFuture"
	HeaderErrorTimestampTooEarly                                                 RuleError = "HeaderErrorTimestampTooEarly"
	HeaderErrorBlockDifficultyAboveTarget                                        RuleError = "HeaderErrorBlockDifficultyAboveTarget"
	HeaderErrorHeightInvalid                                                     RuleError = "HeaderErrorHeightInvalid"
	HeaderErrorDifficultyBitsNotConsistentWithTargetDifficultyComputedFromParent RuleError = "HeaderErrorDifficultyBitsNotConsistentWithTargetDifficultyComputedFromParent"

	TxErrorTooLarge                                                 RuleError = "TxErrorTooLarge"
	TxErrorDuplicate                                                RuleError = "TxErrorDuplicate"
	TxErrorIndividualBlockReward                                    RuleError = "TxErrorIndividualBlockReward"
	TxErrorInsufficientFeeMinFee                                    RuleError = "TxErrorInsufficientFeeMinFee"
	TxErrorInsufficientFeeRateLimit                                 RuleError = "TxErrorInsufficientFeeRateLimit"
	TxErrorInsufficientFeePriorityQueue                             RuleError = "TxErrorInsufficientFeePriorityQueue"
	TxErrorUnconnectedTxnNotAllowed                                 RuleError = "TxErrorUnconnectedTxnNotAllowed"
	TxErrorCannotProcessBitcoinExchangeUntilBitcoinManagerIsCurrent RuleError = "TxErrorCannotProcessBitcoinExchangeUntilBitcoinManagerIsCurrent"
)

func (RuleError) Error

func (e RuleError) Error() string

type Server

type Server struct {

	// During initial block download, we request headers and blocks from a single
	// peer. Note: These fields should only be accessed from the messageHandler thread.
	//
	// TODO: This could be much faster if we were to download blocks in parallel
	// rather than from a single peer but it won't be a problem until later, at which
	// point we can make the optimization.
	SyncPeer *Peer

	Notifier *Notifier
	// contains filtered or unexported fields
}

Server is the core of the DeSo node. It effectively runs a single-threaded main loop that processes transactions from other peers and responds to them accordingly. Probably the best place to start looking is the messageHandler function.

func NewServer

func NewServer(
	_params *DeSoParams,
	_listeners []net.Listener,
	_desoAddrMgr *addrmgr.AddrManager,
	_connectIps []string,
	_db *badger.DB,
	postgres *Postgres,
	_targetOutboundPeers uint32,
	_maxInboundPeers uint32,
	_minerPublicKeys []string,
	_numMiningThreads uint64,
	_limitOneInboundConnectionPerIP bool,
	_rateLimitFeerateNanosPerKB uint64,
	_minFeeRateNanosPerKB uint64,
	_stallTimeoutSeconds uint64,
	_maxBlockTemplatesToCache uint64,
	_minBlockUpdateIntervalSeconds uint64,
	_blockCypherAPIKey string,
	_runReadOnlyUtxoViewUpdater bool,
	_dataDir string,
	_mempoolDumpDir string,
	_disableNetworking bool,
	_readOnlyMode bool,
	_ignoreInboundPeerInvMessages bool,
	statsd *statsd.Client,
	_blockProducerSeed string,
	_trustedBlockProducerPublicKeys []string,
	_trustedBlockProducerStartHeight uint64,
	eventManager *EventManager,
) (*Server, error)

NewServer initializes all of the internal data structures. Right now this basically looks as follows:

  • ConnectionManager starts and keeps track of peers.
  • When messages are received from peers, they get forwarded on a channel to the Server to handle them. In that sense the ConnectionManager is basically just acting as a router.
  • When the Server receives a message from a peer, it can do any of the following:
  • Take no action.
  • Use the Blockchain data structure to validate the transaction or update the. Blockchain data structure.
  • Send a new message. This can be a message directed back to that actually sent this message or it can be a message to another peer for whatever reason. When a message is sent in this way it can also have a deadline on it that the peer needs to respond by or else it will be disconnected.
  • Disconnect the peer. In this case the ConnectionManager gets notified about the disconnection and may opt to replace the now-disconnected peer with a new peer. This happens for example when an outbound peer is disconnected in order to maintain TargetOutboundPeers.
  • The server could also receive a control message that a peer has been disconnected. This can be useful to the server if, for example, it was expecting a response from a particular peer, which could be the case in initial block download where a single sync peer is used.

TODO: Refactor all these arguments into a config object or something.

func (*Server) BroadcastTransaction

func (srv *Server) BroadcastTransaction(txn *MsgDeSoTxn) ([]*MempoolTx, error)

func (*Server) ExpireRequests

func (srv *Server) ExpireRequests()

ExpireRequests checks to see if any requests have expired and removes them if so.

func (*Server) GetBlockProducer

func (srv *Server) GetBlockProducer() *DeSoBlockProducer

TODO: The hallmark of a messy non-law-of-demeter-following interface...

func (*Server) GetBlockchain

func (srv *Server) GetBlockchain() *Blockchain

TODO: The hallmark of a messy non-law-of-demeter-following interface...

func (*Server) GetBlocks

func (srv *Server) GetBlocks(pp *Peer, maxHeight int)

GetBlocks computes what blocks we need to fetch and asks for them from the corresponding peer. It is typically called after we have exited SyncStateSyncingHeaders.

func (*Server) GetConnectionManager

func (srv *Server) GetConnectionManager() *ConnectionManager

TODO: The hallmark of a messy non-law-of-demeter-following interface...

func (*Server) GetMempool

func (srv *Server) GetMempool() *DeSoMempool

TODO: The hallmark of a messy non-law-of-demeter-following interface...

func (*Server) GetMiner

func (srv *Server) GetMiner() *DeSoMiner

TODO: The hallmark of a messy non-law-of-demeter-following interface...

func (*Server) GetStatsdClient

func (srv *Server) GetStatsdClient() *statsd.Client

func (*Server) HasProcessedFirstTransactionBundle

func (srv *Server) HasProcessedFirstTransactionBundle() bool

func (*Server) ProcessSingleTxnWithChainLock

func (srv *Server) ProcessSingleTxnWithChainLock(
	pp *Peer, txn *MsgDeSoTxn) ([]*MempoolTx, error)

func (*Server) ResetRequestQueues

func (srv *Server) ResetRequestQueues()

ResetRequestQueues resets all the request queues.

func (*Server) Start

func (srv *Server) Start()

Start actually kicks off all of the management processes. Among other things, it causes the ConnectionManager to actually start connecting to peers and receiving messages. If requested, it also starts the miner.

func (*Server) StartStatsdReporter

func (srv *Server) StartStatsdReporter()

func (*Server) Stop

func (srv *Server) Stop()

func (*Server) VerifyAndBroadcastTransaction

func (srv *Server) VerifyAndBroadcastTransaction(txn *MsgDeSoTxn) error

type ServerMessage

type ServerMessage struct {
	Peer      *Peer
	Msg       DeSoMessage
	ReplyChan chan *ServerReply
}

ServerMessage is the core data structure processed by the Server in its main loop.

type ServerReply

type ServerReply struct {
}

ServerReply is used to signal to outside programs that a particuler ServerMessage they may have been waiting on has been processed.

type ServiceFlag

type ServiceFlag uint64
const (
	// SFFullNode is a flag used to indicate a peer is a full node.
	SFFullNode ServiceFlag = 1 << iota
)

type SingleAddr

type SingleAddr struct {
	// Last time the address was seen. Encoded as number UNIX seconds on the wire.
	Timestamp time.Time

	// Bitfield which identifies the services supported by the address.
	Services ServiceFlag

	// IP address of the peer. Must be 4 or 16 bytes for IPV4 or IPV6 respectively.
	IP net.IP

	// Port the peer is using.
	Port uint16
}

SingleAddr is similar to the wire.NetAddress definition from the btcd guys.

func (*SingleAddr) String

func (addr *SingleAddr) String() string

func (*SingleAddr) StringWithPort

func (addr *SingleAddr) StringWithPort(includePort bool) string

type SubmitPostMetadata

type SubmitPostMetadata struct {

	// When set, this transaction is treated as modifying an existing
	// post rather than creating a new post.
	PostHashToModify []byte

	// When a ParentStakeID is set, the post is actually a comment on
	// another entity (either a post or a profile depending on the
	// type of StakeID provided).
	ParentStakeID []byte
	Body          []byte

	// The amount the creator of the post gets when someone stakes
	// to the post.
	CreatorBasisPoints uint64
	// The multiple of the payout when a user stakes to a post.
	// 2x multiple = 200% = 20,000bps
	StakeMultipleBasisPoints uint64

	// A timestamp used for ordering messages when displaying them to
	// users. The timestamp must be unique. Note that we use a nanosecond
	// timestamp because it makes it easier to deal with the uniqueness
	// constraint technically (e.g. If one second spacing is required
	// as would be the case with a standard Unix timestamp then any code
	// that generates these transactions will need to potentially wait
	// or else risk a timestamp collision. This complexity is avoided
	// by just using a nanosecond timestamp). Note that the timestamp is
	// an unsigned int as opposed to a signed int, which means times
	// before the zero time are not represented which doesn't matter
	// for our purposes. Restricting the timestamp in this way makes
	// lexicographic sorting based on bytes easier in our database which
	// is one of the reasons we do it.
	TimestampNanos uint64

	// When set to true, indicates that the post should be deleted. This
	// value is only considered when PostHashToModify is set to a valid
	// pre-existing post.
	IsHidden bool
}

func (*SubmitPostMetadata) FromBytes

func (txnData *SubmitPostMetadata) FromBytes(data []byte) error

func (*SubmitPostMetadata) GetTxnType

func (txnData *SubmitPostMetadata) GetTxnType() TxnType

func (*SubmitPostMetadata) New

func (txnData *SubmitPostMetadata) New() DeSoTxnMetadata

func (*SubmitPostMetadata) ToBytes

func (txnData *SubmitPostMetadata) ToBytes(preSignature bool) ([]byte, error)

type SubmitPostTxindexMetadata

type SubmitPostTxindexMetadata struct {
	PostHashBeingModifiedHex string

	// If this is a reply to an existing post, then the ParentPostHashHex
	ParentPostHashHex string
}

type SummaryStats

type SummaryStats struct {
	// Number of transactions of this type in the mempool.
	Count uint32

	// Number of bytes for transactions of this type in the mempool.
	TotalBytes uint64
}

Summary stats for a set of transactions of a specific type in the mempool.

type SwapIdentityMetadataa

type SwapIdentityMetadataa struct {

	// The public key that we are swapping *from*. Doesn't matter which public
	// key is *from* and which public key is *to* because it's just a swap.
	FromPublicKey []byte

	// The public key that we are swapping *to*. Doesn't matter which public
	// key is *from* and which public key is *to* because it's just a swap.
	ToPublicKey []byte
}

func (*SwapIdentityMetadataa) FromBytes

func (txnData *SwapIdentityMetadataa) FromBytes(dataa []byte) error

func (*SwapIdentityMetadataa) GetTxnType

func (txnData *SwapIdentityMetadataa) GetTxnType() TxnType

func (*SwapIdentityMetadataa) New

func (txnData *SwapIdentityMetadataa) New() DeSoTxnMetadata

func (*SwapIdentityMetadataa) ToBytes

func (txnData *SwapIdentityMetadataa) ToBytes(preSignature bool) ([]byte, error)

type SwapIdentityOperationType

type SwapIdentityOperationType uint8

type SwapIdentityTxindexMetadata

type SwapIdentityTxindexMetadata struct {
	FromPublicKeyBase58Check string
	ToPublicKeyBase58Check   string

	// Rosetta needs this information to track creator coin balances
	FromDeSoLockedNanos uint64
	ToDeSoLockedNanos   uint64
}

type SyncState

type SyncState uint8
const (
	// SyncStateSyncingHeaders indicates that our header chain is not current.
	// This is the state a node will start in when it hasn't downloaded
	// anything from its peers. Because we always download headers and
	// validate them before we download blocks, SyncingHeaders implies that
	// the block tip is also not current yet.
	SyncStateSyncingHeaders SyncState = iota
	// SyncStateSyncingBlocks indicates that our header chain is current but
	// that the block chain we have is not current yet. In particular, it
	// means, among other things, that the tip of the block chain is still
	// older than max tip age.
	SyncStateSyncingBlocks
	// SyncStateNeedBlocksss indicates that our header chain is current and our
	// block chain is current but that there are headers in our main chain for
	// which we have not yet processed blocks.
	SyncStateNeedBlocksss
	// SyncStateFullyCurrent indicates that our header chain is current and that
	// we've fetched all the blocks corresponding to this chain.
	SyncStateFullyCurrent
)

func (SyncState) String

func (ss SyncState) String() string

type TXIndex

type TXIndex struct {
	// TXIndexLock protects the transaction index.
	TXIndexLock deadlock.RWMutex

	// The txindex has it s own separate Blockchain object. This allows us to
	// capture more metadata when collecting transactions without interfering
	// with the goings-on of the main chain.
	TXIndexChain *Blockchain

	// Core objects from Server
	CoreChain *Blockchain

	// Core params object
	Params *DeSoParams
	// contains filtered or unexported fields
}

func NewTXIndex

func NewTXIndex(coreChain *Blockchain, params *DeSoParams, dataDirectory string) (*TXIndex, error)

func (*TXIndex) GetTxindexUpdateBlockNodes

func (txi *TXIndex) GetTxindexUpdateBlockNodes() (
	_txindexTipNode *BlockNode, _blockTipNode *BlockNode, _commonAncestor *BlockNode,
	_detachBlocks []*BlockNode, _attachBlocks []*BlockNode)

GetTxindexUpdateBlockNodes ...

func (*TXIndex) Start

func (txi *TXIndex) Start()

func (*TXIndex) Stop

func (txi *TXIndex) Stop()

func (*TXIndex) Update

func (txi *TXIndex) Update() error

Update syncs the transaction index with the blockchain. Specifically, it reads in all the blocks that have come in since the last time this function was called and adds the new transactions to the txindex. It also handles reorgs properly.

TODO(DELETEME, cleanup): This code is error-prone. Moving the transaction indexing code to block_view.go may be a clean way to refactor this.

type TransactionEvent added in v1.2.6

type TransactionEvent struct {
	Txn     *MsgDeSoTxn
	TxnHash *BlockHash

	// Optional
	UtxoView *UtxoView
	UtxoOps  []*UtxoOperation
}

type TransactionEventFunc added in v1.2.6

type TransactionEventFunc func(event *TransactionEvent)

type TransactionMetadata

type TransactionMetadata struct {
	BlockHashHex    string
	TxnIndexInBlock uint64
	TxnType         string
	// All transactions have a public key who executed the transaction and some
	// public keys that are affected by the transaction. Notifications are created
	// for the affected public keys. _getPublicKeysForTxn uses this to set entries in the
	// database.
	TransactorPublicKeyBase58Check string
	AffectedPublicKeys             []*AffectedPublicKey

	// We store these outputs so we don't have to load the full transaction from disk
	// when looking up output amounts
	TxnOutputs []*DeSoOutput

	BasicTransferTxindexMetadata       *BasicTransferTxindexMetadata       `json:",omitempty"`
	BitcoinExchangeTxindexMetadata     *BitcoinExchangeTxindexMetadata     `json:",omitempty"`
	CreatorCoinTxindexMetadata         *CreatorCoinTxindexMetadata         `json:",omitempty"`
	CreatorCoinTransferTxindexMetadata *CreatorCoinTransferTxindexMetadata `json:",omitempty"`
	UpdateProfileTxindexMetadata       *UpdateProfileTxindexMetadata       `json:",omitempty"`
	SubmitPostTxindexMetadata          *SubmitPostTxindexMetadata          `json:",omitempty"`
	LikeTxindexMetadata                *LikeTxindexMetadata                `json:",omitempty"`
	FollowTxindexMetadata              *FollowTxindexMetadata              `json:",omitempty"`
	PrivateMessageTxindexMetadata      *PrivateMessageTxindexMetadata      `json:",omitempty"`
	SwapIdentityTxindexMetadata        *SwapIdentityTxindexMetadata        `json:",omitempty"`
	NFTBidTxindexMetadata              *NFTBidTxindexMetadata              `json:",omitempty"`
	AcceptNFTBidTxindexMetadata        *AcceptNFTBidTxindexMetadata        `json:",omitempty"`
	NFTTransferTxindexMetadata         *NFTTransferTxindexMetadata         `json:",omitempty"`
}

func ComputeTransactionMetadata

func ComputeTransactionMetadata(txn *MsgDeSoTxn, utxoView *UtxoView, blockHash *BlockHash,
	totalNanosPurchasedBefore uint64, usdCentsPerBitcoinBefore uint64, totalInput uint64, totalOutput uint64,
	fees uint64, txnIndexInBlock uint64, utxoOps []*UtxoOperation) (*TransactionMetadata, error)

func ConnectTxnAndComputeTransactionMetadata

func ConnectTxnAndComputeTransactionMetadata(
	txn *MsgDeSoTxn, utxoView *UtxoView, blockHash *BlockHash,
	blockHeight uint32, txnIndexInBlock uint64) (*TransactionMetadata, error)

func DbGetTxindexTransactionRefByTxID

func DbGetTxindexTransactionRefByTxID(handle *badger.DB, txID *BlockHash) *TransactionMetadata

func DbGetTxindexTransactionRefByTxIDWithTxn

func DbGetTxindexTransactionRefByTxIDWithTxn(txn *badger.Txn, txID *BlockHash) *TransactionMetadata

type TxnString added in v1.2.3

type TxnString string
const (
	TxnStringUnset                        TxnString = "UNSET"
	TxnStringBlockReward                  TxnString = "BLOCK_REWARD"
	TxnStringBasicTransfer                TxnString = "BASIC_TRANSFER"
	TxnStringBitcoinExchange              TxnString = "BITCOIN_EXCHANGE"
	TxnStringPrivateMessage               TxnString = "PRIVATE_MESSAGE"
	TxnStringSubmitPost                   TxnString = "SUBMIT_POST"
	TxnStringUpdateProfile                TxnString = "UPDATE_PROFILE"
	TxnStringUpdateBitcoinUSDExchangeRate TxnString = "UPDATE_BITCOIN_USD_EXCHANGE_RATE"
	TxnStringFollow                       TxnString = "FOLLOW"
	TxnStringLike                         TxnString = "LIKE"
	TxnStringCreatorCoin                  TxnString = "CREATOR_COIN"
	TxnStringSwapIdentity                 TxnString = "SWAP_IDENTITY"
	TxnStringUpdateGlobalParams           TxnString = "UPDATE_GLOBAL_PARAMS"
	TxnStringCreatorCoinTransfer          TxnString = "CREATOR_COIN_TRANSFER"
	TxnStringCreateNFT                    TxnString = "CREATE_NFT"
	TxnStringUpdateNFT                    TxnString = "UPDATE_NFT"
	TxnStringAcceptNFTBid                 TxnString = "ACCEPT_NFT_BID"
	TxnStringNFTBid                       TxnString = "NFT_BID"
	TxnStringNFTTransfer                  TxnString = "NFT_TRANSFER"
	TxnStringAcceptNFTTransfer            TxnString = "ACCEPT_NFT_TRANSFER"
	TxnStringBurnNFT                      TxnString = "BURN_NFT"
	TxnStringAuthorizeDerivedKey          TxnString = "AUTHORIZE_DERIVED_KEY"
	TxnStringUndefined                    TxnString = "TXN_UNDEFINED"
)

type TxnType

type TxnType uint8

TxnType specifies the type for a transaction message.

const (
	TxnTypeUnset                        TxnType = 0
	TxnTypeBlockReward                  TxnType = 1
	TxnTypeBasicTransfer                TxnType = 2
	TxnTypeBitcoinExchange              TxnType = 3
	TxnTypePrivateMessage               TxnType = 4
	TxnTypeSubmitPost                   TxnType = 5
	TxnTypeUpdateProfile                TxnType = 6
	TxnTypeUpdateBitcoinUSDExchangeRate TxnType = 8
	TxnTypeFollow                       TxnType = 9
	TxnTypeLike                         TxnType = 10
	TxnTypeCreatorCoin                  TxnType = 11
	TxnTypeSwapIdentity                 TxnType = 12
	TxnTypeUpdateGlobalParams           TxnType = 13
	TxnTypeCreatorCoinTransfer          TxnType = 14
	TxnTypeCreateNFT                    TxnType = 15
	TxnTypeUpdateNFT                    TxnType = 16
	TxnTypeAcceptNFTBid                 TxnType = 17
	TxnTypeNFTBid                       TxnType = 18
	TxnTypeNFTTransfer                  TxnType = 19
	TxnTypeAcceptNFTTransfer            TxnType = 20
	TxnTypeBurnNFT                      TxnType = 21
	TxnTypeAuthorizeDerivedKey          TxnType = 22
)

func GetTxnTypeFromString added in v1.2.3

func GetTxnTypeFromString(txnString TxnString) TxnType

func (TxnType) GetTxnString added in v1.2.3

func (txnType TxnType) GetTxnString() TxnString

func (TxnType) String

func (txnType TxnType) String() string

type UnconnectedTx

type UnconnectedTx struct {
	// contains filtered or unexported fields
}

UnconnectedTx is a transaction that has dependencies that we haven't added yet.

type UpdateBitcoinUSDExchangeRateMetadataa

type UpdateBitcoinUSDExchangeRateMetadataa struct {
	// The new exchange rate to set.
	USDCentsPerBitcoin uint64
}

func (*UpdateBitcoinUSDExchangeRateMetadataa) FromBytes

func (txnData *UpdateBitcoinUSDExchangeRateMetadataa) FromBytes(dataa []byte) error

func (*UpdateBitcoinUSDExchangeRateMetadataa) GetTxnType

func (txnData *UpdateBitcoinUSDExchangeRateMetadataa) GetTxnType() TxnType

func (*UpdateBitcoinUSDExchangeRateMetadataa) New

func (*UpdateBitcoinUSDExchangeRateMetadataa) ToBytes

func (txnData *UpdateBitcoinUSDExchangeRateMetadataa) ToBytes(preSignature bool) ([]byte, error)

type UpdateGlobalParamsMetadata

type UpdateGlobalParamsMetadata struct {
}

================================================================== UpdateGlobalParamsMetadata ==================================================================

func (*UpdateGlobalParamsMetadata) FromBytes

func (txnData *UpdateGlobalParamsMetadata) FromBytes(data []byte) error

func (*UpdateGlobalParamsMetadata) GetTxnType

func (txnData *UpdateGlobalParamsMetadata) GetTxnType() TxnType

func (*UpdateGlobalParamsMetadata) New

func (*UpdateGlobalParamsMetadata) ToBytes

func (txnData *UpdateGlobalParamsMetadata) ToBytes(preSignature bool) ([]byte, error)

type UpdateNFTMetadata

type UpdateNFTMetadata struct {
	NFTPostHash       *BlockHash
	SerialNumber      uint64
	IsForSale         bool
	MinBidAmountNanos uint64
}

func (*UpdateNFTMetadata) FromBytes

func (txnData *UpdateNFTMetadata) FromBytes(dataa []byte) error

func (*UpdateNFTMetadata) GetTxnType

func (txnData *UpdateNFTMetadata) GetTxnType() TxnType

func (*UpdateNFTMetadata) New

func (txnData *UpdateNFTMetadata) New() DeSoTxnMetadata

func (*UpdateNFTMetadata) ToBytes

func (txnData *UpdateNFTMetadata) ToBytes(preSignature bool) ([]byte, error)

type UpdateProfileMetadata

type UpdateProfileMetadata struct {

	// The public key of the profile to update. When left unset, the public
	// key in the transaction is used.
	ProfilePublicKey []byte

	NewUsername    []byte
	NewDescription []byte
	NewProfilePic  []byte

	// This is the percentage of each "net buy" that a creator earns when
	// someone purchases her coin. For example, if this were set to 25%,
	// then every time their coin reaches a new high, they would get 25%
	// of the coins as they're being minted. More concretely, if someone
	// put in enough DeSo to buy 10 coins, the creator would get 2.5
	// and this person would get 7.5. However, if they sold 5 coins and
	// someone subsequently bought those same coins, the creator wouldn't
	// get any coins because no "net new" coins have been created.
	NewCreatorBasisPoints uint64

	// The multiple of the payout when a user stakes to this profile. If
	// unset, a sane default is set when the first person stakes to this
	// profile.
	// 2x multiple = 200% = 20,000bps
	//
	// TODO: This field is deprecated; delete it.
	NewStakeMultipleBasisPoints uint64

	// Profile is hidden from the UI when this field is true.
	// TODO: This field is deprecated; delete it.
	IsHidden bool
}

func (*UpdateProfileMetadata) FromBytes

func (txnData *UpdateProfileMetadata) FromBytes(data []byte) error

func (*UpdateProfileMetadata) GetTxnType

func (txnData *UpdateProfileMetadata) GetTxnType() TxnType

func (*UpdateProfileMetadata) New

func (txnData *UpdateProfileMetadata) New() DeSoTxnMetadata

func (*UpdateProfileMetadata) ToBytes

func (txnData *UpdateProfileMetadata) ToBytes(preSignature bool) ([]byte, error)

type UpdateProfileTxindexMetadata

type UpdateProfileTxindexMetadata struct {
	ProfilePublicKeyBase58Check string

	NewUsername    string
	NewDescription string
	NewProfilePic  string

	NewCreatorBasisPoints uint64

	NewStakeMultipleBasisPoints uint64

	IsHidden bool
}

type UsernameMapKey

type UsernameMapKey [MaxUsernameLengthBytes]byte

Have to define these because Go doesn't let you use raw byte slices as map keys. This needs to be in-sync with DeSoMainnetParams.MaxUsernameLengthBytes

func MakeUsernameMapKey

func MakeUsernameMapKey(nonLowercaseUsername []byte) UsernameMapKey

type UtxoEntry

type UtxoEntry struct {
	AmountNanos uint64
	PublicKey   []byte
	BlockHeight uint32
	UtxoType    UtxoType

	// A back-reference to the utxo key associated with this entry.
	UtxoKey *UtxoKey
	// contains filtered or unexported fields
}

UtxoEntry identifies the data associated with a UTXO.

func DbGetUtxoEntryForUtxoKey

func DbGetUtxoEntryForUtxoKey(handle *badger.DB, utxoKey *UtxoKey) *UtxoEntry

func DbGetUtxoEntryForUtxoKeyWithTxn

func DbGetUtxoEntryForUtxoKeyWithTxn(txn *badger.Txn, utxoKey *UtxoKey) *UtxoEntry

func DbGetUtxosForPubKey

func DbGetUtxosForPubKey(publicKey []byte, handle *badger.DB) ([]*UtxoEntry, error)

DbGetUtxosForPubKey finds the UtxoEntry's corresponding to the public key passed in. It also attaches the UtxoKeys to the UtxoEntry's it returns for easy access.

func (*UtxoEntry) String

func (utxoEntry *UtxoEntry) String() string

type UtxoKey

type UtxoKey struct {
	// The 32-byte transaction id where the unspent output occurs.
	TxID BlockHash
	// The index within the txn where the unspent output occurs.
	Index uint32
}

UtxoKey is a 32-byte txid with a 4-byte uint32 index identifying the particular output in the transaction where this utxo occurs. When fetching from the db the txid and index are concatenated to form the key, with the index serialized as big-endian.

func (*UtxoKey) String

func (utxoKey *UtxoKey) String() string

type UtxoOperation

type UtxoOperation struct {
	Type OperationType

	// Only set for OperationTypeSpendUtxo
	//
	// When we SPEND a UTXO entry we delete it from the utxo set but we still
	// store its info in case we want to reverse
	// it in the future. This information is not needed for ADD since
	// reversing an ADD just means deleting an entry from the end of our list.
	//
	// SPEND works by swapping the UTXO we want to spend with the UTXO at
	// the end of the list and then deleting from the end of the list. Obviously
	// this is more efficient than deleting the element in-place and then shifting
	// over everything after it. In order to be able to undo this operation,
	// however, we need to store the original index of the item we are
	// spending/deleting. Reversing the operation then amounts to adding a utxo entry
	// at the end of the list and swapping with this index. Given this, the entry
	// we store here has its position set to the position it was at right before the
	// SPEND operation was performed.
	Entry *UtxoEntry

	// Only set for OperationTypeSpendUtxo
	//
	// Store the UtxoKey as well. This isn't necessary but it helps
	// with error-checking during a roll-back so we just keep it.
	//
	// TODO: We can probably delete this at some point and save some space. UTXOs
	// are probably our biggest disk hog so getting rid of this should materially
	// improve disk usage.
	Key *UtxoKey

	// Used to revert BitcoinExchange transaction.
	PrevNanosPurchased uint64
	// Used to revert UpdateBitcoinUSDExchangeRate transaction.
	PrevUSDCentsPerBitcoin uint64

	// Save the previous post entry when making an update to a post.
	PrevPostEntry            *PostEntry
	PrevParentPostEntry      *PostEntry
	PrevGrandparentPostEntry *PostEntry
	PrevRepostedPostEntry    *PostEntry

	// Save the previous profile entry when making an update.
	PrevProfileEntry *ProfileEntry

	// Save the previous like entry and like count when making an update.
	PrevLikeEntry *LikeEntry
	PrevLikeCount uint64

	// For disconnecting diamonds.
	PrevDiamondEntry *DiamondEntry

	// For disconnecting NFTs.
	PrevNFTEntry              *NFTEntry
	PrevNFTBidEntry           *NFTBidEntry
	DeletedNFTBidEntries      []*NFTBidEntry
	NFTPaymentUtxoKeys        []*UtxoKey
	NFTSpentUtxoEntries       []*UtxoEntry
	PrevAcceptedNFTBidEntries *[]*NFTBidEntry

	// For disconnecting AuthorizeDerivedKey transactions.
	PrevDerivedKeyEntry *DerivedKeyEntry

	// Save the previous repost entry and repost count when making an update.
	PrevRepostEntry *RepostEntry
	PrevRepostCount uint64

	// Save the state of a creator coin prior to updating it due to a
	// buy/sell/add transaction.
	PrevCoinEntry *CoinEntry
	// Save the creator coin balance of both the transactor and the creator.
	// We modify the transactor's balances when they buys/sell a creator coin
	// and we modify the creator's balance when we pay them a founder reward.
	PrevTransactorBalanceEntry *BalanceEntry
	PrevCreatorBalanceEntry    *BalanceEntry
	// We use this to revert founder's reward UTXOs created by creator coin buys.
	FounderRewardUtxoKey *UtxoKey

	// Save balance entries for the sender and receiver when creator coins are transferred.
	PrevSenderBalanceEntry   *BalanceEntry
	PrevReceiverBalanceEntry *BalanceEntry

	// Save the global params when making an update.
	PrevGlobalParamsEntry    *GlobalParamsEntry
	PrevForbiddenPubKeyEntry *ForbiddenPubKeyEntry

	// This value is used by Rosetta to adjust for a bug whereby a ParamUpdater
	// CoinEntry could get clobbered if updating a profile on someone else's
	// behalf. This is super confusing.
	ClobberedProfileBugDESOLockedNanos uint64

	// This value is used by Rosetta to return the amount of DESO that was added
	// or removed from a profile during a CreatorCoin transaction. It's needed
	// in order to avoid having to reconnect all transactions.
	CreatorCoinDESOLockedNanosDiff int64

	// This value is used by Rosetta to create a proper input/output when we
	// encounter a SwapIdentity txn. This makes it so that we don't have to
	// reconnect all txns in order to get these values.
	SwapIdentityFromDESOLockedNanos uint64
	SwapIdentityToDESOLockedNanos   uint64

	// These values are used by Rosetta in order to create input and output
	// operations. They make it so that we don't have to reconnect all txns
	// in order to get these values.
	AcceptNFTBidCreatorPublicKey    []byte
	AcceptNFTBidBidderPublicKey     []byte
	AcceptNFTBidCreatorRoyaltyNanos uint64
}

type UtxoType

type UtxoType uint8
const (
	// UTXOs can come from different sources. We document all of those sources
	// in the UTXOEntry using these types.
	UtxoTypeOutput      UtxoType = 0
	UtxoTypeBlockReward UtxoType = 1
	UtxoTypeBitcoinBurn UtxoType = 2
	// TODO(DELETEME): Remove the StakeReward txn type
	UtxoTypeStakeReward              UtxoType = 3
	UtxoTypeCreatorCoinSale          UtxoType = 4
	UtxoTypeCreatorCoinFounderReward UtxoType = 5
	UtxoTypeNFTSeller                UtxoType = 6
	UtxoTypeNFTBidderChange          UtxoType = 7
	UtxoTypeNFTCreatorRoyalty        UtxoType = 8
)

func (UtxoType) String

func (mm UtxoType) String() string

type UtxoView

type UtxoView struct {
	// Utxo data
	NumUtxoEntries              uint64
	UtxoKeyToUtxoEntry          map[UtxoKey]*UtxoEntry
	PublicKeyToDeSoBalanceNanos map[PublicKey]uint64

	// BitcoinExchange data
	NanosPurchased     uint64
	USDCentsPerBitcoin uint64
	GlobalParamsEntry  *GlobalParamsEntry
	BitcoinBurnTxIDs   map[BlockHash]bool

	// Forbidden block signature pubkeys
	ForbiddenPubKeyToForbiddenPubKeyEntry map[PkMapKey]*ForbiddenPubKeyEntry

	// Messages data
	MessageKeyToMessageEntry map[MessageKey]*MessageEntry

	// Postgres stores message data slightly differently
	MessageMap map[BlockHash]*PGMessage

	// Follow data
	FollowKeyToFollowEntry map[FollowKey]*FollowEntry

	// NFT data
	NFTKeyToNFTEntry              map[NFTKey]*NFTEntry
	NFTBidKeyToNFTBidEntry        map[NFTBidKey]*NFTBidEntry
	NFTKeyToAcceptedNFTBidHistory map[NFTKey]*[]*NFTBidEntry

	// Diamond data
	DiamondKeyToDiamondEntry map[DiamondKey]*DiamondEntry

	// Like data
	LikeKeyToLikeEntry map[LikeKey]*LikeEntry

	// Repost data
	RepostKeyToRepostEntry map[RepostKey]*RepostEntry

	// Post data
	PostHashToPostEntry map[BlockHash]*PostEntry

	// Profile data
	PublicKeyToPKIDEntry map[PkMapKey]*PKIDEntry
	// The PKIDEntry is only used here to store the public key.
	PKIDToPublicKey               map[PKID]*PKIDEntry
	ProfilePKIDToProfileEntry     map[PKID]*ProfileEntry
	ProfileUsernameToProfileEntry map[UsernameMapKey]*ProfileEntry

	// Coin balance entries
	HODLerPKIDCreatorPKIDToBalanceEntry map[BalanceEntryMapKey]*BalanceEntry

	// Derived Key entries. Map key is a combination of owner and derived public keys.
	DerivedKeyToDerivedEntry map[DerivedKeyMapKey]*DerivedKeyEntry

	// The hash of the tip the view is currently referencing. Mainly used
	// for error-checking when doing a bulk operation on the view.
	TipHash *BlockHash

	Handle   *badger.DB
	Postgres *Postgres
	Params   *DeSoParams
}

func NewUtxoView

func NewUtxoView(
	_handle *badger.DB,
	_params *DeSoParams,
	_postgres *Postgres,
) (*UtxoView, error)

func (*UtxoView) ConnectBlock

func (bav *UtxoView) ConnectBlock(
	desoBlock *MsgDeSoBlock, txHashes []*BlockHash, verifySignatures bool, eventManager *EventManager) (
	[][]*UtxoOperation, error)

func (*UtxoView) ConnectTransaction

func (bav *UtxoView) ConnectTransaction(txn *MsgDeSoTxn, txHash *BlockHash,
	txnSizeBytes int64,
	blockHeight uint32, verifySignatures bool, ignoreUtxos bool) (
	_utxoOps []*UtxoOperation, _totalInput uint64, _totalOutput uint64,
	_fees uint64, _err error)

func (*UtxoView) CopyUtxoView

func (bav *UtxoView) CopyUtxoView() (*UtxoView, error)

func (*UtxoView) DisconnectBlock

func (bav *UtxoView) DisconnectBlock(
	desoBlock *MsgDeSoBlock, txHashes []*BlockHash, utxoOps [][]*UtxoOperation) error

func (*UtxoView) DisconnectTransaction

func (bav *UtxoView) DisconnectTransaction(currentTxn *MsgDeSoTxn, txnHash *BlockHash,
	utxoOpsForTxn []*UtxoOperation, blockHeight uint32) error

func (*UtxoView) FlushToDb

func (bav *UtxoView) FlushToDb() error

func (*UtxoView) FlushToDbWithTxn

func (bav *UtxoView) FlushToDbWithTxn(txn *badger.Txn) error

func (*UtxoView) GetAcceptNFTBidHistoryForNFTKey

func (bav *UtxoView) GetAcceptNFTBidHistoryForNFTKey(nftKey *NFTKey) *[]*NFTBidEntry

func (*UtxoView) GetAllDerivedKeyMappingsForOwner

func (bav *UtxoView) GetAllDerivedKeyMappingsForOwner(ownerPublicKey []byte) (
	map[PublicKey]*DerivedKeyEntry, error)

GetAllDerivedKeyMappingsForOwner fetches all derived key mappings belonging to an owner.

func (*UtxoView) GetAllNFTBidEntries

func (bav *UtxoView) GetAllNFTBidEntries(nftPostHash *BlockHash, serialNumber uint64) []*NFTBidEntry

func (*UtxoView) GetAllPosts

func (bav *UtxoView) GetAllPosts() (_corePosts []*PostEntry, _commentsByPostHash map[BlockHash][]*PostEntry, _err error)

Just fetch all the posts from the db and join them with all the posts in the mempool. Then sort them by their timestamp. This can be called on an empty view or a view that already has a lot of transactions applied to it.

func (*UtxoView) GetAllProfiles

func (bav *UtxoView) GetAllProfiles(readerPK []byte) (
	_profiles map[PkMapKey]*ProfileEntry,
	_corePostsByProfilePublicKey map[PkMapKey][]*PostEntry,
	_commentsByProfilePublicKey map[PkMapKey][]*PostEntry,
	_postEntryReaderStates map[BlockHash]*PostEntryReaderState, _err error)

Just fetch all the profiles from the db and join them with all the profiles in the mempool. Then sort them by their DeSo. This can be called on an empty view or a view that already has a lot of transactions applied to it.

func (*UtxoView) GetBalanceEntryForHODLerPubKeyAndCreatorPubKey

func (bav *UtxoView) GetBalanceEntryForHODLerPubKeyAndCreatorPubKey(
	hodlerPubKey []byte, creatorPubKey []byte) (
	_balanceEntry *BalanceEntry, _hodlerPKID *PKID, _creatorPKID *PKID)

func (*UtxoView) GetCommentEntriesForParentStakeID

func (bav *UtxoView) GetCommentEntriesForParentStakeID(parentStakeID []byte) ([]*PostEntry, error)

func (*UtxoView) GetCurrentUSDCentsPerBitcoin

func (bav *UtxoView) GetCurrentUSDCentsPerBitcoin() uint64

The blockchain used to store the USD to BTC exchange rate in bav.USDCentsPerBitcoin, which was set by a UPDATE_BITCOIN_USD_EXCHANGE_RATE txn, but has since moved to the GlobalParamsEntry, which is set by a UPDATE_GLOBAL_PARAMS txn.

func (*UtxoView) GetDBHighAndLowBidEntriesForNFT

func (bav *UtxoView) GetDBHighAndLowBidEntriesForNFT(
	nftHash *BlockHash, serialNumber uint64,
) (_highBidEntry *NFTBidEntry, _lowBidEntry *NFTBidEntry)

This function gets the highest and lowest bids for a specific NFT that have not been deleted in the view. TODO: Postgres

func (*UtxoView) GetDBHighAndLowBidsForNFT

func (bav *UtxoView) GetDBHighAndLowBidsForNFT(nftHash *BlockHash, serialNumber uint64) (_highBid uint64, _lowBid uint64)

TODO: Postgres

func (*UtxoView) GetDeSoBalanceNanosForPublicKey

func (bav *UtxoView) GetDeSoBalanceNanosForPublicKey(publicKey []byte) (uint64, error)

func (*UtxoView) GetDiamondEntriesForSenderToReceiver

func (bav *UtxoView) GetDiamondEntriesForSenderToReceiver(receiverPublicKey []byte, senderPublicKey []byte,
) (_diamondEntries []*DiamondEntry, _err error)

func (*UtxoView) GetDiamondEntryForDiamondKey

func (bav *UtxoView) GetDiamondEntryForDiamondKey(diamondKey *DiamondKey) *DiamondEntry

func (*UtxoView) GetDiamondEntryMapForPublicKey

func (bav *UtxoView) GetDiamondEntryMapForPublicKey(publicKey []byte, fetchYouDiamonded bool,
) (_pkidToDiamondsMap map[PKID][]*DiamondEntry, _err error)

func (*UtxoView) GetDiamondSendersForPostHash

func (bav *UtxoView) GetDiamondSendersForPostHash(postHash *BlockHash) (_pkidToDiamondLevel map[PKID]int64, _err error)

func (*UtxoView) GetFollowEntriesForPublicKey

func (bav *UtxoView) GetFollowEntriesForPublicKey(publicKey []byte, getEntriesFollowingPublicKey bool) (
	_followEntries []*FollowEntry, _err error)

getEntriesFollowingPublicKey == true => Returns FollowEntries for people that follow publicKey getEntriesFollowingPublicKey == false => Returns FollowEntries for people that publicKey follows

func (*UtxoView) GetFollowEntryForFollowerPublicKeyCreatorPublicKey

func (bav *UtxoView) GetFollowEntryForFollowerPublicKeyCreatorPublicKey(followerPublicKey []byte, creatorPublicKey []byte) *FollowEntry

func (*UtxoView) GetHighAndLowBidsForNFTCollection

func (bav *UtxoView) GetHighAndLowBidsForNFTCollection(
	nftHash *BlockHash,
) (_highBid uint64, _lowBid uint64)

TODO: Postgres

func (*UtxoView) GetHighAndLowBidsForNFTSerialNumber

func (bav *UtxoView) GetHighAndLowBidsForNFTSerialNumber(nftHash *BlockHash, serialNumber uint64) (_highBid uint64, _lowBid uint64)

TODO: Postgres

func (*UtxoView) GetHolders

func (bav *UtxoView) GetHolders(pkid *PKID, fetchProfiles bool) ([]*BalanceEntry, []*ProfileEntry, error)

func (*UtxoView) GetHoldings

func (bav *UtxoView) GetHoldings(pkid *PKID, fetchProfiles bool) ([]*BalanceEntry, []*ProfileEntry, error)

func (*UtxoView) GetLikedByReader

func (bav *UtxoView) GetLikedByReader(readerPK []byte, postHash *BlockHash) bool

func (*UtxoView) GetLikesForPostHash

func (bav *UtxoView) GetLikesForPostHash(postHash *BlockHash) (_likerPubKeys [][]byte, _err error)

func (*UtxoView) GetLimitedMessagesForUser

func (bav *UtxoView) GetLimitedMessagesForUser(publicKey []byte) (
	_messageEntries []*MessageEntry, _err error)

TODO: Update for Postgres

func (*UtxoView) GetMessagesForUser

func (bav *UtxoView) GetMessagesForUser(publicKey []byte) (
	_messageEntries []*MessageEntry, _err error)

TODO: Update for Postgres

func (*UtxoView) GetNFTBidEntriesForPKID

func (bav *UtxoView) GetNFTBidEntriesForPKID(bidderPKID *PKID) (_nftBidEntries []*NFTBidEntry)

func (*UtxoView) GetNFTBidEntryForNFTBidKey

func (bav *UtxoView) GetNFTBidEntryForNFTBidKey(nftBidKey *NFTBidKey) *NFTBidEntry

func (*UtxoView) GetNFTEntriesForPKID

func (bav *UtxoView) GetNFTEntriesForPKID(ownerPKID *PKID) []*NFTEntry

func (*UtxoView) GetNFTEntriesForPostHash

func (bav *UtxoView) GetNFTEntriesForPostHash(nftPostHash *BlockHash) []*NFTEntry

func (*UtxoView) GetNFTEntryForNFTKey

func (bav *UtxoView) GetNFTEntryForNFTKey(nftKey *NFTKey) *NFTEntry

func (*UtxoView) GetPKIDForPublicKey

func (bav *UtxoView) GetPKIDForPublicKey(publicKey []byte) *PKIDEntry

func (*UtxoView) GetParentPostEntriesForPostEntry

func (bav *UtxoView) GetParentPostEntriesForPostEntry(postEntry *PostEntry, maxDepth uint32, rootFirst bool,
) (_parentPostEntries []*PostEntry, _truncatedTree bool)

Accepts a postEntry and returns as many parent posts as it can find up to maxDepth. This function never returns an error, only an empty list if it hits a non-post parentStakeID. If "rootFirst" is passed, the root of the tree will be returned first, not the 1st parent. _truncatedTree is a flag that is true when the root post was not reached before the maxDepth was hit.

func (*UtxoView) GetPostEntryForPostHash

func (bav *UtxoView) GetPostEntryForPostHash(postHash *BlockHash) *PostEntry

func (*UtxoView) GetPostEntryReaderState

func (bav *UtxoView) GetPostEntryReaderState(
	readerPK []byte, postEntry *PostEntry) *PostEntryReaderState

func (*UtxoView) GetPostsPaginatedForPublicKeyOrderedByTimestamp

func (bav *UtxoView) GetPostsPaginatedForPublicKeyOrderedByTimestamp(publicKey []byte, startPostHash *BlockHash, limit uint64, mediaRequired bool, nftRequired bool) (_posts []*PostEntry, _err error)

func (*UtxoView) GetProfileEntryForPKID

func (bav *UtxoView) GetProfileEntryForPKID(pkid *PKID) *ProfileEntry

func (*UtxoView) GetProfileEntryForPublicKey

func (bav *UtxoView) GetProfileEntryForPublicKey(publicKey []byte) *ProfileEntry

func (*UtxoView) GetProfileEntryForUsername

func (bav *UtxoView) GetProfileEntryForUsername(nonLowercaseUsername []byte) *ProfileEntry

func (*UtxoView) GetProfilesByCoinValue

func (bav *UtxoView) GetProfilesByCoinValue(startLockedNanos uint64, limit int) []*ProfileEntry

func (*UtxoView) GetProfilesForUsernamePrefixByCoinValue

func (bav *UtxoView) GetProfilesForUsernamePrefixByCoinValue(usernamePrefix string) []*ProfileEntry

func (*UtxoView) GetPublicKeyForPKID

func (bav *UtxoView) GetPublicKeyForPKID(pkid *PKID) []byte

func (*UtxoView) GetQuoteRepostsForPostHash

func (bav *UtxoView) GetQuoteRepostsForPostHash(postHash *BlockHash,
) (_quoteReposterPubKeys [][]byte, _quoteReposterPubKeyToPosts map[PkMapKey][]*PostEntry, _err error)

func (*UtxoView) GetRepostPostEntryStateForReader

func (bav *UtxoView) GetRepostPostEntryStateForReader(readerPK []byte, postHash *BlockHash) (string, bool)

func (*UtxoView) GetRepostsForPostHash

func (bav *UtxoView) GetRepostsForPostHash(postHash *BlockHash) (_reposterPubKeys [][]byte, _err error)

func (*UtxoView) GetSpendableDeSoBalanceNanosForPublicKey

func (bav *UtxoView) GetSpendableDeSoBalanceNanosForPublicKey(pkBytes []byte,
	tipHeight uint32) (_spendableBalance uint64, _err error)

func (*UtxoView) GetUnspentUtxoEntrysForPublicKey

func (bav *UtxoView) GetUnspentUtxoEntrysForPublicKey(pkBytes []byte) ([]*UtxoEntry, error)

GetUnspentUtxoEntrysForPublicKey returns the UtxoEntrys corresponding to the passed-in public key that are currently unspent. It does this while factoring in any transactions that have already been connected to it. This is useful, as an example, when one whats to see what UtxoEntrys are available for spending after factoring in (i.e. connecting) all of the transactions currently in the mempool that are related to this public key.

At a high level, this function allows one to get the utxos that are the union of: - utxos in the db - utxos in the view from previously-connected transactions

func (*UtxoView) GetUtxoEntryForUtxoKey

func (bav *UtxoView) GetUtxoEntryForUtxoKey(utxoKey *UtxoKey) *UtxoEntry

func (*UtxoView) HelpConnectCreatorCoinBuy

func (bav *UtxoView) HelpConnectCreatorCoinBuy(
	txn *MsgDeSoTxn, txHash *BlockHash, blockHeight uint32, verifySignatures bool) (
	_totalInput uint64, _totalOutput uint64, _creatorCoinReturnedNanos uint64, _founderRewardNanos uint64,
	_utxoOps []*UtxoOperation, _err error)

TODO: A lot of duplicate code between buy and sell. Consider factoring out the common code.

func (*UtxoView) HelpConnectCreatorCoinSell

func (bav *UtxoView) HelpConnectCreatorCoinSell(
	txn *MsgDeSoTxn, txHash *BlockHash, blockHeight uint32, verifySignatures bool) (
	_totalInput uint64, _totalOutput uint64, _desoReturnedNanos uint64,
	_utxoOps []*UtxoOperation, _err error)

TODO: A lot of duplicate code between buy and sell. Consider factoring out the common code.

func (*UtxoView) Preload

func (bav *UtxoView) Preload(desoBlock *MsgDeSoBlock) error

Preload tries to fetch all the relevant data needed to connect a block in batches from Postgres. It marks many objects as "nil" in the respective data structures and then fills in the objects it is able to retrieve from the database. It's much faster to fetch data in bulk and cache "nil" values then to query individual records when connecting every transaction. If something is not preloaded the view falls back to individual queries.

func (*UtxoView) ValidateDiamondsAndGetNumCreatorCoinNanos

func (bav *UtxoView) ValidateDiamondsAndGetNumCreatorCoinNanos(
	senderPublicKey []byte,
	receiverPublicKey []byte,
	diamondPostHash *BlockHash,
	diamondLevel int64,
	blockHeight uint32,
) (_numCreatorCoinNanos uint64, _netNewDiamonds int64, _err error)

func (*UtxoView) ValidateDiamondsAndGetNumDeSoNanos

func (bav *UtxoView) ValidateDiamondsAndGetNumDeSoNanos(
	senderPublicKey []byte,
	receiverPublicKey []byte,
	diamondPostHash *BlockHash,
	diamondLevel int64,
	blockHeight uint32,
) (_numDeSoNanos uint64, _netNewDiamonds int64, _err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL