From a9234850e7ebe24144e75b317e4102722f80de94 Mon Sep 17 00:00:00 2001 From: David Hill Date: Wed, 31 May 2017 23:27:29 -0400 Subject: [PATCH] remove deadcode --- addrmgr/addrmanager.go | 2 - blockchain/chainio.go | 20 --- blockchain/chainio_test.go | 9 ++ blockchain/checkpoints.go | 9 -- blockchain/fullblocktests/generate.go | 9 -- blockmanager.go | 9 -- config.go | 2 - database/ffldb/dbcache.go | 13 -- dcrec/edwards/const.go | 49 +------- dcrec/edwards/primitives.go | 19 --- dcrec/secp256k1/field.go | 6 +- dcrec/secp256k1/schnorr/primitives.go | 25 ---- ipc.go | 1 - mining.go | 47 ------- mining_test.go | 174 -------------------------- rpcserver.go | 21 ---- rpcwebsocket.go | 34 ----- txscript/opcode.go | 11 -- wire/msgtx.go | 19 +-- 19 files changed, 12 insertions(+), 467 deletions(-) diff --git a/addrmgr/addrmanager.go b/addrmgr/addrmanager.go index 29ffbb6f1a..cc5de858c9 100644 --- a/addrmgr/addrmanager.go +++ b/addrmgr/addrmanager.go @@ -97,8 +97,6 @@ const ( // address manager will claim to need more addresses. needAddressThreshold = 1000 - newAddressBufferSize = 50 - // dumpAddressInterval is the interval used to dump the address // cache to disk for future use. dumpAddressInterval = time.Minute * 10 diff --git a/blockchain/chainio.go b/blockchain/chainio.go index e3eb497b3c..e50a55700d 100644 --- a/blockchain/chainio.go +++ b/blockchain/chainio.go @@ -24,26 +24,6 @@ import ( ) var ( - // hashIndexBucketName is the name of the db bucket used to house to the - // block hash -> block height index. - hashIndexBucketName = []byte("hashidx") - - // heightIndexBucketName is the name of the db bucket used to house to - // the block height -> block hash index. - heightIndexBucketName = []byte("heightidx") - - // chainStateKeyName is the name of the db key used to store the best - // chain state. - chainStateKeyName = []byte("chainstate") - - // spendJournalBucketName is the name of the db bucket used to house - // transactions outputs that are spent in each block. - spendJournalBucketName = []byte("spendjournal") - - // utxoSetBucketName is the name of the db bucket used to house the - // unspent transaction output set. - utxoSetBucketName = []byte("utxoset") - // thresholdBucketName is the name of the db bucket used to house cached // threshold states. thresholdBucketName = []byte("thresholdstate") diff --git a/blockchain/chainio_test.go b/blockchain/chainio_test.go index 4f7692d75b..29e9fd0ecf 100644 --- a/blockchain/chainio_test.go +++ b/blockchain/chainio_test.go @@ -18,6 +18,15 @@ import ( "github.com/decred/dcrd/wire" ) +// newHashFromStr converts the passed big-endian hex string into a +// chainhash.Hash. It only differs from the one available in chainhash in that +// it ignores the error since it will only (and must only) be called with +// hard-coded, and therefore known good, hashes. +func newHashFromStr(hexStr string) *chainhash.Hash { + hash, _ := chainhash.NewHashFromStr(hexStr) + return hash +} + // DoStxoTest does a test on a simulated blockchain to ensure that the data // stored in the STXO buckets is not corrupt. func (b *BlockChain) DoStxoTest() error { diff --git a/blockchain/checkpoints.go b/blockchain/checkpoints.go index d3f1a3612a..126fdf73b3 100644 --- a/blockchain/checkpoints.go +++ b/blockchain/checkpoints.go @@ -19,15 +19,6 @@ import ( // best block chain that a good checkpoint candidate must be. const CheckpointConfirmations = 4096 -// newHashFromStr converts the passed big-endian hex string into a -// chainhash.Hash. It only differs from the one available in chainhash in that -// it ignores the error since it will only (and must only) be called with -// hard-coded, and therefore known good, hashes. -func newHashFromStr(hexStr string) *chainhash.Hash { - hash, _ := chainhash.NewHashFromStr(hexStr) - return hash -} - // DisableCheckpoints provides a mechanism to disable validation against // checkpoints which you DO NOT want to do in production. It is provided only // for debug purposes. diff --git a/blockchain/fullblocktests/generate.go b/blockchain/fullblocktests/generate.go index 9a3cdeee05..5aba726ab6 100644 --- a/blockchain/fullblocktests/generate.go +++ b/blockchain/fullblocktests/generate.go @@ -210,15 +210,6 @@ func replaceStakeSigScript(sigScript []byte) func(*wire.MsgBlock) { } } -// replaceDevOrgScript returns a function that itself takes a block and modifies -// it by replacing the public key script of the dev org payout in the coinbase -// transaction. -func replaceDevOrgScript(pkScript []byte) func(*wire.MsgBlock) { - return func(b *wire.MsgBlock) { - b.Transactions[0].TxOut[0].PkScript = pkScript - } -} - // additionalPoWTx returns a function that itself takes a block and modifies it // by adding the the provided transaction to the regular transaction tree. func additionalPoWTx(tx *wire.MsgTx) func(*wire.MsgBlock) { diff --git a/blockmanager.go b/blockmanager.go index 1e041f74a8..8b0bc84155 100644 --- a/blockmanager.go +++ b/blockmanager.go @@ -27,8 +27,6 @@ import ( ) const ( - chanBufferSize = 50 - // minInFlightBlocks is the minimum number of blocks that should be // in the request queue for headers-first mode before requesting // more. @@ -151,13 +149,6 @@ type calcNextReqDifficultyMsg struct { reply chan calcNextReqDifficultyResponse } -// calcNextReqDiffNodeResponse is a response sent to the reply channel of a -// calcNextReqDiffNodeMsg query. -type calcNextReqDiffNodeResponse struct { - difficulty uint32 - err error -} - // calcNextReqDiffNodeMsg is a message type to be sent across the message // channel for requesting the required difficulty for some block building on // the given block hash. diff --git a/config.go b/config.go index b52955ed1a..e9deada97f 100644 --- a/config.go +++ b/config.go @@ -44,7 +44,6 @@ const ( defaultMaxRPCClients = 10 defaultMaxRPCWebsockets = 25 defaultMaxRPCConcurrentReqs = 20 - defaultVerifyEnabled = false defaultDbType = "ffldb" defaultFreeTxRelayLimit = 15.0 defaultBlockMinSize = 0 @@ -53,7 +52,6 @@ const ( blockMaxSizeMax = wire.MaxBlockPayload - 1000 defaultAddrIndex = false defaultGenerate = false - defaultNonAggressive = false defaultNoMiningStateSync = false defaultAllowOldVotes = false defaultMaxOrphanTransactions = 1000 diff --git a/database/ffldb/dbcache.go b/database/ffldb/dbcache.go index 40a7a86e2b..81758645a1 100644 --- a/database/ffldb/dbcache.go +++ b/database/ffldb/dbcache.go @@ -25,19 +25,6 @@ const ( // threshold in between database cache flushes when the cache size has // not been exceeded. defaultFlushSecs = 300 // 5 minutes - - // ldbBatchHeaderSize is the size of a leveldb batch header which - // includes the sequence header and record counter. - // - // ldbRecordIKeySize is the size of the ikey used internally by leveldb - // when appending a record to a batch. - // - // These are used to help preallocate space needed for a batch in one - // allocation instead of letting leveldb itself constantly grow it. - // This results in far less pressure on the GC and consequently helps - // prevent the GC from allocating a lot of extra unneeded space. - ldbBatchHeaderSize = 12 - ldbRecordIKeySize = 8 ) // ldbCacheIter wraps a treap iterator to provide the additional functionality diff --git a/dcrec/edwards/const.go b/dcrec/edwards/const.go index 88a0c030cf..b201023e40 100644 --- a/dcrec/edwards/const.go +++ b/dcrec/edwards/const.go @@ -22,17 +22,9 @@ var ( // fieldIntSize is the size of a field element encoded // as bytes. - fieldIntSize = 32 - fieldElementSize = 10 - fieldElementBytesSize = 40 + fieldIntSize = 32 ) -// feZero is the field element representation of zero. -var feZero = edwards25519.FieldElement{ - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, -} - // feOne is the field element representation of one. This is // also the neutral (null) element. var feOne = edwards25519.FieldElement{ @@ -40,18 +32,6 @@ var feOne = edwards25519.FieldElement{ 0, 0, 0, 0, 0, } -// feTwo is the field element representation of one. -var feTwo = edwards25519.FieldElement{ - 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, -} - -// feThree is the field element representation of one. -var feThree = edwards25519.FieldElement{ - 3, 0, 0, 0, 0, - 0, 0, 0, 0, 0, -} - // feA is the field element representation of one. var feA = edwards25519.FieldElement{ 486662, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -69,35 +49,8 @@ var fed2 = edwards25519.FieldElement{ 15978800, -12551817, -6495438, 29715968, 9444199, } -// feSqrtM1 is the field element representation of M^(1/2). -var feSqrtM1 = edwards25519.FieldElement{ - -32595792, -7943725, 9377950, 3500415, 12389472, - -272473, -25146209, -2005654, 326686, 11406482, -} - // feI is the field element representation of I. var feI = edwards25519.FieldElement{ -32595792, -7943725, 9377950, 3500415, 12389472, -272473, -25146209, -2005654, 326686, 11406482, } - -// feExtBasePoint is the base point of the curve represented -// in projective extended format with field elements. -var feExtBasePoint = edwards25519.ExtendedGroupElement{ - X: edwards25519.FieldElement{ - 25485296, 5318399, 8791791, -8299916, -14349720, - 6939349, -3324311, -7717049, 7287234, -6577708, - }, - Y: edwards25519.FieldElement{ - -758052, -1832720, 13046421, -4857925, 6576754, - 14371947, -13139572, 6845540, -2198883, -4003719, - }, - Z: edwards25519.FieldElement{ - -947565, 6097708, -469190, 10704810, -8556274, - -15589498, -16424464, -16608899, 14028613, -5004649, - }, - T: edwards25519.FieldElement{ - 6966464, -2456167, 7033433, 6781840, 28785542, - 12262365, -2659449, 13959020, -21013759, -5262166, - }, -} diff --git a/dcrec/edwards/primitives.go b/dcrec/edwards/primitives.go index a5e931ec53..376aadadc6 100644 --- a/dcrec/edwards/primitives.go +++ b/dcrec/edwards/primitives.go @@ -5,7 +5,6 @@ package edwards import ( - "bytes" "fmt" "math/big" @@ -85,15 +84,6 @@ func copyBytes64(aB []byte) *[64]byte { return s } -// zeroArray zeroes the memory of a scalar array. -func zeroArray(a *[PrivScalarSize]byte) { - for i := 0; i < PrivScalarSize; i++ { - a[i] = 0x00 - } - - return -} - // zeroSlice zeroes the memory of a scalar byte slice. func zeroSlice(s []byte) { for i := 0; i < PrivScalarSize; i++ { @@ -297,15 +287,6 @@ func FieldElementToEncodedBytes(fe *edwards25519.FieldElement) *[32]byte { return s } -// feEqual checks if two field elements equate. -func feEqual(a, b *edwards25519.FieldElement) bool { - aB := new([32]byte) - edwards25519.FeToBytes(aB, a) - bB := new([32]byte) - edwards25519.FeToBytes(bB, b) - return bytes.Equal(aB[:], bB[:]) -} - // invert inverts a big integer over the Ed25519 curve. func (curve *TwistedEdwardsCurve) invert(a *big.Int) *big.Int { sub2 := new(big.Int).Sub(curve.P, two) diff --git a/dcrec/secp256k1/field.go b/dcrec/secp256k1/field.go index b758df53a2..28fce19c2d 100644 --- a/dcrec/secp256k1/field.go +++ b/dcrec/secp256k1/field.go @@ -77,10 +77,6 @@ const ( // 2^(fieldBase*i) where i is the word position. fieldBase = 26 - // fieldOverflowBits is the minimum number of "overflow" bits for each - // word in the field value. - fieldOverflowBits = 32 - fieldBase - // fieldBaseMask is the mask for the bits in each word needed to // represent the numeric base of each word (except the most significant // word). @@ -581,7 +577,7 @@ func (f *fieldVal) Add2(val *fieldVal, val2 *fieldVal) *fieldVal { // f.MulInt(2).Add(f2) so that f = 2 * f + f2. func (f *fieldVal) MulInt(val uint) *fieldVal { // Since each word of the field representation can hold up to - // fieldOverflowBits extra bits which will be normalized out, it's safe + // 32 - fieldBase extra bits which will be normalized out, it's safe // to multiply each word without using a larger type or carry // propagation so long as the values won't overflow a uint32. This // could obviously be done in a loop, but the unrolled version is diff --git a/dcrec/secp256k1/schnorr/primitives.go b/dcrec/secp256k1/schnorr/primitives.go index 2261b6f8e4..ed39bdc88d 100644 --- a/dcrec/secp256k1/schnorr/primitives.go +++ b/dcrec/secp256k1/schnorr/primitives.go @@ -32,31 +32,6 @@ func copyBytes(aB []byte) *[32]byte { return s } -// copyBytes64 copies a byte slice to a 64 byte array. -func copyBytes64(aB []byte) *[64]byte { - if aB == nil { - return nil - } - - s := new([64]byte) - - // If we have a short byte string, expand - // it so that it's long enough. - aBLen := len(aB) - if aBLen < 64 { - diff := 64 - aBLen - for i := 0; i < diff; i++ { - aB = append([]byte{0x00}, aB...) - } - } - - for i := 0; i < 64; i++ { - s[i] = aB[i] - } - - return s -} - // BigIntToEncodedBytes converts a big integer into its corresponding // 32 byte little endian representation. func BigIntToEncodedBytes(a *big.Int) *[32]byte { diff --git a/ipc.go b/ipc.go index b1d8e3c86c..7d5793e80d 100644 --- a/ipc.go +++ b/ipc.go @@ -163,7 +163,6 @@ type lifetimeAction byte const ( lifetimeEventDBOpen lifetimeAction = iota - lifetimeEventTicketDB lifetimeEventP2PServer ) diff --git a/mining.go b/mining.go index 6cd240d27e..b9ab8701af 100644 --- a/mining.go +++ b/mining.go @@ -26,10 +26,6 @@ import ( ) const ( - // minHighPriority is the minimum priority value that allows a - // transaction to be considered high priority. - minHighPriority = dcrutil.AtomsPerCoin * 144.0 / 250 - // generatedBlockVersion is the version of the block being generated for // the main network. It is defined as a constant here rather than using // the wire.BlockVersion constant since a change in the block version @@ -167,49 +163,6 @@ func compareStakePriority(i, j *txPrioItem) int { return 0 } -// txPQByPriority sorts a txPriorityQueue by transaction priority and then fees -// per kilobyte. -func txPQByPriority(pq *txPriorityQueue, i, j int) bool { - // Using > here so that pop gives the highest priority item as opposed - // to the lowest. Sort by priority first, then fee. - if pq.items[i].priority == pq.items[j].priority { - return pq.items[i].feePerKB > pq.items[j].feePerKB - } - return pq.items[i].priority > pq.items[j].priority -} - -// txPQByStakeAndPriority sorts a txPriorityQueue by stake priority then -// transaction priority, and then fees per kilobyte. -func txPQByStakeAndPriority(pq *txPriorityQueue, i, j int) bool { - // Sort by stake priority, continue if they're the same stake priority. - cmp := compareStakePriority(pq.items[i], pq.items[j]) - if cmp == 1 { - return true - } - if cmp == -1 { - return false - } - - // Using > here so that pop gives the highest priority item as opposed - // to the lowest. Sort by priority first, then fee. - if pq.items[i].priority == pq.items[j].priority { - return pq.items[i].feePerKB > pq.items[j].feePerKB - } - - return pq.items[i].priority > pq.items[j].priority -} - -// txPQByFee sorts a txPriorityQueue by fees per kilobyte and then transaction -// priority. -func txPQByFee(pq *txPriorityQueue, i, j int) bool { - // Using > here so that pop gives the highest fee item as opposed - // to the lowest. Sort by fee first, then priority. - if pq.items[i].feePerKB == pq.items[j].feePerKB { - return pq.items[i].priority > pq.items[j].priority - } - return pq.items[i].feePerKB > pq.items[j].feePerKB -} - // txPQByStakeAndFee sorts a txPriorityQueue by stake priority, followed by // fees per kilobyte, and then transaction priority. func txPQByStakeAndFee(pq *txPriorityQueue, i, j int) bool { diff --git a/mining_test.go b/mining_test.go index a2dece9653..d841706b7f 100644 --- a/mining_test.go +++ b/mining_test.go @@ -11,147 +11,8 @@ import ( "testing" "github.com/decred/dcrd/blockchain/stake" - "github.com/decred/dcrutil" ) -// TestTxFeePrioHeap ensures the priority queue for transaction fees and -// priorities works as expected. It doesn't set anything for the stake -// priority, so this test only tests sorting by fee and then priority. -func TestTxFeePrioHeap(t *testing.T) { - // Create some fake priority items that exercise the expected sort - // edge conditions. - testItems := []*txPrioItem{ - {feePerKB: 5678, priority: 1}, - {feePerKB: 5678, priority: 1}, // Duplicate fee and prio - {feePerKB: 5678, priority: 5}, - {feePerKB: 5678, priority: 2}, - {feePerKB: 1234, priority: 3}, - {feePerKB: 1234, priority: 1}, - {feePerKB: 1234, priority: 5}, - {feePerKB: 1234, priority: 5}, // Duplicate fee and prio - {feePerKB: 1234, priority: 2}, - {feePerKB: 10000, priority: 0}, // Higher fee, smaller prio - {feePerKB: 0, priority: 10000}, // Higher prio, lower fee - } - numItems := len(testItems) - - // Add random data in addition to the edge conditions already manually - // specified. - randSeed := rand.Int63() - defer func() { - if t.Failed() { - t.Logf("Random numbers using seed: %v", randSeed) - } - }() - prng := rand.New(rand.NewSource(randSeed)) - for i := 0; i < 1000; i++ { - testItems = append(testItems, &txPrioItem{ - feePerKB: prng.Float64() * dcrutil.AtomsPerCoin, - priority: prng.Float64() * 100, - }) - } - - // Test sorting by fee per KB then priority. - var highest *txPrioItem - priorityQueue := newTxPriorityQueue(len(testItems), txPQByFee) - for i := 0; i < len(testItems); i++ { - prioItem := testItems[i] - if highest == nil { - highest = prioItem - } - if prioItem.feePerKB >= highest.feePerKB { - highest = prioItem - - if prioItem.feePerKB == highest.feePerKB { - if prioItem.priority >= highest.priority { - highest = prioItem - } - } - } - heap.Push(priorityQueue, prioItem) - } - - for i := 0; i < len(testItems); i++ { - prioItem := heap.Pop(priorityQueue).(*txPrioItem) - feesEqual := false - switch { - case prioItem.feePerKB > highest.feePerKB: - t.Fatalf("priority sort: item (fee per KB: %v, "+ - "priority: %v) higher than than prev "+ - "(fee per KB: %v, priority %v)", - prioItem.feePerKB, prioItem.priority, - highest.feePerKB, highest.priority) - case prioItem.feePerKB == highest.feePerKB: - feesEqual = true - default: - } - if feesEqual { - switch { - case prioItem.priority > highest.priority: - t.Fatalf("priority sort: item (fee per KB: %v, "+ - "priority: %v) higher than than prev "+ - "(fee per KB: %v, priority %v)", - prioItem.feePerKB, prioItem.priority, - highest.feePerKB, highest.priority) - case prioItem.priority == highest.priority: - default: - } - } - - highest = prioItem - } - - // Test sorting by priority then fee per KB. - highest = nil - priorityQueue = newTxPriorityQueue(numItems, txPQByPriority) - for i := 0; i < len(testItems); i++ { - prioItem := testItems[i] - if highest == nil { - highest = prioItem - } - if prioItem.priority >= highest.priority { - highest = prioItem - - if prioItem.priority == highest.priority { - if prioItem.feePerKB >= highest.feePerKB { - highest = prioItem - } - } - } - heap.Push(priorityQueue, prioItem) - } - - for i := 0; i < len(testItems); i++ { - prioItem := heap.Pop(priorityQueue).(*txPrioItem) - prioEqual := false - switch { - case prioItem.priority > highest.priority: - t.Fatalf("priority sort: item (fee per KB: %v, "+ - "priority: %v) higher than than prev "+ - "(fee per KB: %v, priority %v)", - prioItem.feePerKB, prioItem.priority, - highest.feePerKB, highest.priority) - case prioItem.priority == highest.priority: - prioEqual = true - default: - } - if prioEqual { - switch { - case prioItem.feePerKB > highest.feePerKB: - t.Fatalf("priority sort: item (fee per KB: %v, "+ - "priority: %v) higher than than prev "+ - "(fee per KB: %v, priority %v)", - prioItem.feePerKB, prioItem.priority, - highest.feePerKB, highest.priority) - case prioItem.priority == highest.priority: - default: - } - } - - highest = prioItem - } -} - // TestStakeTxFeePrioHeap tests the priority heaps including the stake types for // both transaction fees per KB and transaction priority. It ensures that the // primary sorting is first by stake type, and then by the latter chosen priority @@ -194,41 +55,6 @@ func TestStakeTxFeePrioHeap(t *testing.T) { } } - ph = newTxPriorityQueue(numElements, txPQByStakeAndPriority) - for i := 0; i < numElements; i++ { - randType := stake.TxType(rand.Intn(4)) - randPrio := rand.Float64() * 100 - randFeePerKB := rand.Float64() * 10 - prioItem := &txPrioItem{ - tx: nil, - txType: randType, - priority: randPrio, - feePerKB: randFeePerKB, - } - heap.Push(ph, prioItem) - } - - // Test sorting by stake and priority. - last = &txPrioItem{ - tx: nil, - txType: stake.TxTypeSSGen, - priority: 10000.0, - feePerKB: 10000.0, - } - for i := 0; i < numElements; i++ { - prioItem := heap.Pop(ph) - txpi, ok := prioItem.(*txPrioItem) - if ok { - if txpi.priority > last.priority && - compareStakePriority(txpi, last) >= 0 { - t.Errorf("bad pop: %v fee per KB was more than last of %v "+ - "while the txtype was %v but last was %v", - txpi.feePerKB, last.feePerKB, txpi.txType, last.txType) - } - last = txpi - } - } - ph = newTxPriorityQueue(numElements, txPQByStakeAndFeeAndThenPriority) for i := 0; i < numElements; i++ { randType := stake.TxType(rand.Intn(4)) diff --git a/rpcserver.go b/rpcserver.go index c6dbae360b..8d4c37d7b3 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -1254,16 +1254,6 @@ func createVinList(mtx *wire.MsgTx) []dcrjson.Vin { return vinList } -// stringInSlice returns true if string a is found in array list. -func stringInSlice(a string, list []string) bool { - for _, b := range list { - if b == a { - return true - } - } - return false -} - // createVoutList returns a slice of JSON objects for the outputs of the passed // transaction. func createVoutList(mtx *wire.MsgTx, chainParams *chaincfg.Params, filterAddrMap map[string]struct{}) []dcrjson.Vout { @@ -3969,17 +3959,6 @@ func bigToLEUint256(n *big.Int) [uint256Size]byte { return buf } -// reverseUint32Array treats the passed bytes as a series of uint32s and -// reverses the byte order of each uint32. The passed byte slice must be a -// multiple of 4 for a correct result. The passed bytes slice is modified. -func reverseUint32Array(b []byte) { - blen := len(b) - for i := 0; i < blen; i += 4 { - b[i], b[i+3] = b[i+3], b[i] - b[i+1], b[i+2] = b[i+2], b[i+1] - } -} - // handleGetTxOut handles gettxout commands. func handleGetTxOut(s *rpcServer, cmd interface{}, closeChan <-chan struct{}) (interface{}, error) { c := cmd.(*dcrjson.GetTxOutCmd) diff --git a/rpcwebsocket.go b/rpcwebsocket.go index 45adb43063..bccf4a1b86 100644 --- a/rpcwebsocket.go +++ b/rpcwebsocket.go @@ -1839,40 +1839,6 @@ func handleStopNotifyNewTransactions(wsc *wsClient, icmd interface{}) (interface return nil, nil } -// checkAddressValidity checks the validity of each address in the passed -// string slice. It does this by attempting to decode each address using the -// current active network parameters. If any single address fails to decode -// properly, the function returns an error. Otherwise, nil is returned. -func checkAddressValidity(addrs []string) error { - for _, addr := range addrs { - _, err := dcrutil.DecodeAddress(addr, activeNetParams.Params) - if err != nil { - return &dcrjson.RPCError{ - Code: dcrjson.ErrRPCInvalidAddressOrKey, - Message: fmt.Sprintf("Invalid address or key: %v", - addr), - } - } - } - return nil -} - -// deserializeOutpoints deserializes each serialized outpoint. -func deserializeOutpoints(serializedOuts []dcrjson.OutPoint) ([]*wire.OutPoint, error) { - outpoints := make([]*wire.OutPoint, 0, len(serializedOuts)) - for i := range serializedOuts { - blockHash, err := chainhash.NewHashFromStr(serializedOuts[i].Hash) - if err != nil { - return nil, rpcDecodeHexError(serializedOuts[i].Hash) - } - index := serializedOuts[i].Index - tree := serializedOuts[i].Tree - outpoints = append(outpoints, wire.NewOutPoint(blockHash, index, tree)) - } - - return outpoints, nil -} - // rescanBlock rescans a block for any relevant transactions for the passed // lookup keys. Any discovered transactions are returned hex encoded as a // string slice. diff --git a/txscript/opcode.go b/txscript/opcode.go index 0d2d4faf83..90daade2e1 100644 --- a/txscript/opcode.go +++ b/txscript/opcode.go @@ -2299,16 +2299,6 @@ func opcodeHash256(op *parsedOpcode, vm *Engine) error { return nil } -// opcodeCodeSeparator stores the current script offset as the most recently -// seen OP_CODESEPARATOR which is used during signature checking. -// -// This opcode does not change the contents of the data stack. -// This opcode is disabled in Decred, as it always returns an engine error. -func opcodeCodeSeparator(op *parsedOpcode, vm *Engine) error { - vm.lastCodeSep = vm.scriptOff - return nil -} - // opcodeCheckSig treats the top 2 items on the stack as a public key and a // signature and replaces them with a bool which indicates if the signature was // successfully verified. @@ -2656,7 +2646,6 @@ func opcodeCheckMultiSigVerify(op *parsedOpcode, vm *Engine) error { // sign function to indicate the type of signature to generate. type sigTypes uint8 -var secp = sigTypes(chainec.ECTypeSecp256k1) var edwards = sigTypes(chainec.ECTypeEdwards) var secSchnorr = sigTypes(chainec.ECTypeSecSchnorr) diff --git a/wire/msgtx.go b/wire/msgtx.go index b90971fed8..83b1cdc79f 100644 --- a/wire/msgtx.go +++ b/wire/msgtx.go @@ -429,14 +429,7 @@ func (msg *MsgTx) AddTxOut(to *TxOut) { msg.TxOut = append(msg.TxOut, to) } -// msgTxVersionToBytes converts an int32 version into a 4 byte slice. -func msgTxVersionToBytes(version int32) []byte { - mVerBytes := make([]byte, 4, 4) - binary.LittleEndian.PutUint32(mVerBytes[0:4], uint32(version)) - return mVerBytes -} - -// msgTxVersionDecode converts an int32 version into serialization types and +// msgTxVersionToVars converts an int32 version into serialization types and // actual version. func msgTxVersionToVars(version int32) (uint16, TxSerializeType) { mVerBytes := make([]byte, 4, 4) @@ -446,16 +439,6 @@ func msgTxVersionToVars(version int32) (uint16, TxSerializeType) { return mVer, TxSerializeType(mType) } -// msgTxVersionDecode converts a 4 byte slice into an int32 version. -func msgTxVersionDecode(verBytes []byte) (int32, error) { - if len(verBytes) != 4 { - return 0, messageError("msgTxVersionDecode", "tx version wrong size") - } - ver := binary.LittleEndian.Uint32(verBytes) - - return int32(ver), nil -} - // shallowCopyForSerializing make a shallow copy of a tx with a new // version, so that it can be hashed or serialized accordingly. func (msg *MsgTx) shallowCopyForSerializing(version int32) *MsgTx {