Commit graph

2083 commits

Author SHA1 Message Date
Dave Collins
c8332cc9a7 Correct num expected inputs calc for multisig.
This commit corrects the number of expected inputs for a multi-sig script
to include the additional item that is popped from the stack due to the
OP_CHECKMULTISIG consensus bug (which is required and properly performed).

Note this issue did NOT affect the consensus critical code and hence would
not cause a chain fork.  It did however, cause standard p2sh multisig txns
to be rejected from the mempool as nonstandard.

The tx rejected as non-standard which prompted this was spotted by
@mbelshe on IRC.

ok @owainga
2014-03-17 10:47:02 -05:00
Dave Collins
a87e6fbdea Change rate limit debug messages to trace level. 2014-03-17 00:23:08 -05:00
Dave Collins
93140802ba Improve non-standard tx error message.
This commit removes the word "only" from the non-standard transaction
error message when the number of items on the stack does not match the
number of expected items.

This was suggested by @mbelshe.
2014-03-17 00:19:53 -05:00
Francis Lam
24028ad37f Updated getinfo to return new RelayFee and use btcjson.InfoResult 2014-03-16 13:31:17 -05:00
John C. Vernaleo
71e31f03a2 Update coverage report. 2014-03-16 14:18:43 -04:00
Dave Collins
3c2a3e9f54 Update install command to also install utilities.
This commit updates the install command under the Installation section in
README.md to include all subdirectories thereby including the utilities
such as addblock and btcctl.
2014-03-15 22:32:45 -05:00
Dave Collins
96f9b88935 Export CalcPastMedianTime function.
This commit makes a slight variant of the existing calcPastMedianTime
function available to external callers.  The new exported version
calculates the past median time from the end of the current main chain
versus an arbitrary block node.
2014-03-15 15:04:59 -05:00
Dave Collins
6dd7785276 Export coinbase script length limits.
This commit exports the MinCoinbaseScriptLen and MaxCoinbaseScriptLen
constants.
2014-03-15 15:03:03 -05:00
Francis Lam
8f69a0bf69 Added new RelayFee field and missing TimeOffset field to InfoResult 2014-03-15 15:34:55 -04:00
Owain G. Ainsworth
9375c8dc48 move data extraction fof OP_PUSHDATA into main function.
This allows us to centralise the error checking to simplify things a bit.
2014-03-14 22:46:41 +00:00
Owain G. Ainsworth
02ee7762e4 AddData([]byte{}) is valid and should push empty to the stack.
Doing so is perfectly idiomatic.  Fixes the last of the valid bitcoind
script tests. (by fixing the script parser :)
2014-03-14 22:46:15 +00:00
Owain G. Ainsworth
299dcc2fad PushDataN with a 0 length is valid, we were too tight here.
Found by bitcoind positive tests. (but of course that is noncanonical
anyway, it should be OP_0 ;).
2014-03-14 22:46:14 +00:00
Owain G. Ainsworth
42f6576b02 Enforce max script length of 10000.
Detected by bitcoind negative script tests. Note that this length is only for
*executing* scripts, this is why it is in NewScript.
2014-03-14 22:45:14 +00:00
Owain G. Ainsworth
dec16d7ff2 Enforce a combined max stack depth of 1000 after every opcode.
This limit is for the sum of main and alt stacks. Found by bitcoind
negative tests.
2014-03-14 21:06:08 +00:00
Owain G. Ainsworth
d6d755e411 Always return reserved opcode for always-illegal ops. 2014-03-14 21:06:08 +00:00
Owain G. Ainsworth
8beb0dec54 Make opcode.Exec run a bunch of unconditional checks
Add push length and number of operations to this to match bitcoind behaviour.
found that we differed here by their negative tests.
2014-03-14 21:06:05 +00:00
Owain G. Ainsworth
f80c3255a3 PopInt now guarantees that number will be 32 bit.
So remove later checks that need this.
2014-03-14 21:05:29 +00:00
Owain G. Ainsworth
c7d5102954 Alt stack should be purged between scripts.
Found by bitcoind negative scripts.
2014-03-14 21:05:25 +00:00
Owain G. Ainsworth
a5e7e9ebb6 Disabled opcodes are `fail if pc passes' not fail if execute.
Detected by bitcoind negative tests.
2014-03-14 21:04:59 +00:00
Owain G. Ainsworth
c1a6e47f38 Conditionals must not straddle two scripts.
Found by tests dhill is working on. We checked that ifs were closed at the end
of execution but not at script switching time, we now move this to just after
finishing a single script.
2014-03-14 21:04:37 +00:00
Owain G. Ainsworth
8df0af32d6 Encountering OP_VERIF and OP_VERNOTIF in execution is always an error.
I honestly thought we already handled this, but some tests dhill is
working on shows that we didn't.
2014-03-14 20:28:23 +00:00
jolan
1bc63bfd5d recieve->receive 2014-03-14 15:08:51 -05:00
Owain G. Ainsworth
201d6651c9 Fix tests after IsForNet addition to btcutil.Address interface.
dhill pointed this out to me.
2014-03-13 17:20:45 +00:00
Dave Collins
510a44bdd9 Fix some comment typos. 2014-03-13 08:45:41 -05:00
Dave Collins
b661dd3693 Convert block manager block handler to pure FIFO.
Rather than having a separate query channel for the block manager, use the
same channel so the block handler acts as a pure FIFO queue.  This
prevents possible starvation of query related messages.

ok @owainga
2014-03-12 13:26:06 -05:00
Dave Collins
f65ea832de Export a couple of peer-to-peer client errors.
ok @jcvernaleo
2014-03-12 10:11:18 -05:00
David Hill
936b4eaa2d add unit testing for BigToCompact, CompactToBig, and CalcWork 2014-03-11 22:33:56 -04:00
Dave Collins
0e1f6a6628 Export MaxBlockHeaderPayload. 2014-03-11 20:22:32 -05:00
Dave Collins
e5d15b0fa8 Export MaxVarIntPayload. 2014-03-11 20:09:55 -05:00
Dave Collins
1676ecd7a6 Export CheckConnectBlock function.
This commit makes a slight variant of the existing checkConnectBlock
function available to external callers.  The new exported version checks
if the passed block will connect to the end of the current main chain.

In order to support this, a few other small modifications have been made
to the initial index generation and the existing checkConnectBlock since
it previously made some assumptions about the state of genesis block which
can no longer be assumed due accepting blocks from callers directly.

Also, add a quick test to ensure the new function fails when checking if
the genesis block will connect again when it's already inserted.
2014-03-11 13:18:27 -05:00
Dave Collins
acdce27f9f Defer unlock of orphan mutex in addOrphanBlock.
This was pointed out by saracen on the btcd IRC channel.
2014-03-09 11:05:12 -05:00
Francis Lam
33af740985 Added missing notificationMsg types to notificationHandler 2014-03-04 21:36:48 -05:00
David Hill
b452acdde2 remove link 2014-03-04 13:00:06 -05:00
David Hill
5549b99e19 mention IRC server 2014-03-04 12:58:59 -05:00
Josh Rickmar
27f3d916ec Do not block removing clients if notification manager quit. 2014-03-04 11:31:44 -05:00
Josh Rickmar
a7d5b365b1 Retain order when processing client notifications.
This change modifies the RPC server's notifiation manager from a
struct with requests, protected by a mutux, to two goroutines.  The
first maintains a queue of all notifications and control requests
(registering/unregistering notifications), while the second reads from
the queue and processes notifications and requests one at a time.

Previously, to prevent slowing down block and mempool processing, each
notification would be handled by spawning a new goroutine.  This lead
to cases where notifications would end up being sent to clients in a
different order than they were created.  Adding a queue keeps the
order of notifications originating from the same goroutine, while also
not slowing down processing while waiting for notifications to be
processed and sent.

ok @davecgh
2014-03-04 11:15:25 -05:00
Owain G. Ainsworth
aff33f1e3c Consistently use the peer stringer to print the peer address.
This provides more information than using the address directly.
2014-03-04 15:47:20 +00:00
Dave Collins
2a42cc134f Lower min transaction relay fee to 1000 satoshi.
This mirrors a recent change in the reference implementation.  Since the
vast majority of the network still uses it and transactions which aren't
considered standard won't be relayed, the rules for standard transactions
need to be kept consistent.

Ideally this should be handled via floating fees, but we're rather limited
until we have miner support and a larger network share so the probability
of a transaction being relayed and confirmed is high.

Closes #100.

ok @owainga
2014-03-04 09:40:57 -06:00
Dave Collins
b9c21bd518 Export VarIntSerializeSize function.
This commit exports the VarIntSerializeSize function to provide callers
with an easy method to determine how many bytes it would take to serialize
the passed value as a variable length integer.
2014-03-03 18:43:09 -06:00
Dave Collins
b041971ca8 Export CalcNextRequiredDifficutly function.
This commit exports a new variant of the existing internal
calcNextRequiredDifficulty function which calculates and returns the next
required difficulty for a block after the end of the current best chain
based on the difficulty retarget rules.

In order to support the exported function the internal one was slightly
modified to accept the block timestamp instead of an entire block since
the timestamp is all that is needed and the caller of the exported
function might next have a full block yet.
2014-03-02 18:43:41 -06:00
David Hill
cbb5c5b424 recieve -> receive 2014-03-02 13:28:29 -05:00
Dave Collins
b59a15d07e Export CountP2SHSigOps. 2014-03-01 21:50:11 -06:00
Dave Collins
ec641751a8 Change BuildMerkleTreeStore to accept transactions.
This commit modifies the BuildMerkleTreeStore function to accept a slice
of btcutil.Tx transactions as opposed to a full block.  This allows more
flexibility when calculating merkle roots since a full block may not be
created yet (particularly when generating blocks that need to be solved in
mining).

Previously, the BuildMerkleTreeStore function accepted a btcutil.Block
because originally the block itself cached the transaction hashes and it
was necessary to have access to the block to make use of the cached
transactions.  However, the code has since been improved such that it
caches transaction hashes directly in each btcutil.Tx.  This means the
code can remain as efficient as before while allowing the individual
transacitons to be passed.
2014-03-01 21:16:19 -06:00
Dave Collins
d2bfd3d98b Alphabetize subsystem loggers.
This commit simply alphabetizes the subsystem logger variables, map, and
use switch so the order in the code is consistent with the sorted output
displayed when using --debuglevel.
2014-03-01 16:08:21 -06:00
Dave Collins
82edb203e5 Export MaxSigOpsPerBlock. 2014-02-28 12:24:05 -06:00
Dave Collins
87ecac2072 Export CountSigOps function. 2014-02-28 12:16:56 -06:00
Dave Collins
91e563edaa Add IP address to a few more peer error messages.
This commit adds the peer IP to a few more error messages as originally
noted by #102.
2014-02-28 10:59:35 -06:00
Dave Collins
ce2f68a982 Fix typo on previous commit.
The peer and error were reversed for the regression test error message
case.

Spotted by @dajohi.
2014-02-28 10:55:25 -06:00
Dave Collins
29b790b9c8 Add IP address to peer error messages.
Closes #102.
2014-02-28 10:48:50 -06:00
Dave Collins
178e60a66e Update sample conf regarding debuglevel subsystems.
The debuglevel parameter has accepted subsystems in additional to an
overall level for quite some time, but the sample config file was not
updated to reflect that.

This commit updates the sample config file accordingly.
2014-02-28 09:54:34 -06:00