Commit graph

3486 commits

Author SHA1 Message Date
Dave Collins
0d2c5a8ffb Add --simnet option to btcctl.
This flag works similar to the existing --testnet flag does.  That is to
say it selects the default simulation test network RPC port for either
btcd or btcwallet depending on whether or not the --wallet flag is also
present.
2014-05-30 19:05:06 -05:00
David Hill
b40f5a1b24 add missing Lock to FetchTxBySha 2014-05-30 15:03:39 -04:00
Dave Collins
dc967b7cc8 Add params for new simulation testing network.
ok @jrick
2014-05-29 15:22:00 -05:00
Dave Collins
605eb7f4b4 Add a simulation test network via --simnet param.
This commit, along with recent commits to btcnet and btcwire, expose a new
network that is intended to provide a private network useful for
simulation testing.  To that end, it has the special property that it has
no DNS seeds and will actively ignore all addr and getaddr messages.  It
will also not try to connect to any nodes other than those specified via
--connect.  This allows the network to remain private to the specific
nodes involved in the testing and not simply become another public
testnet.

The network difficulty is also set extremely low like the regression test
network so blocks can be created extremely quickly without requiring a lot
of hashing power.
2014-05-29 15:10:12 -05:00
Dave Collins
31ee545aa9 Add bitcoin network type for simulation testing. 2014-05-29 12:50:17 -05:00
Dave Collins
252c022644 Convert to default net ports provided by btcnet.
ok @jrick
2014-05-29 12:47:08 -05:00
Dave Collins
218f8df5ba Add a default net port parameter to each network.
ok @jrick
2014-05-29 12:45:44 -05:00
Dave Collins
c4135db728 Move default network ports to btcnet package.
The default network ports are not really part of the wire protocol rather
they are part of a network parameters.  Thus, this commit moves them to
the btcnet package.
2014-05-29 12:45:11 -05:00
David Hill
e560b6d964 sync bitcoind test data. 2014-05-29 10:56:43 -04:00
David Hill
a591c7ec03 Add new ScriptFlag ScriptStrictMultiSig.
ScriptStrictMultiSig verifies that the stack item used by CHECKMULTISIG
is zero length.
2014-05-29 10:55:35 -04:00
Josh Rickmar
67e94bcaaa Add createencryptedwallet extension support. 2014-05-28 11:33:28 -05:00
Dave Collins
dfdd223223 Move genesis blocks to btcnet package.
The genesis blocks are not really part of the wire protocol rather they
are part of a network parameters.  Thus, this commit moves the all of the
gensis blocks and tests to the btcnet package.

Also, create variables in the test package for the mainnet genesis hash,
merkle root, and coinbase transaction for use throughout the tests since
they the exported values are no longer available.
2014-05-28 09:14:38 -05:00
Dave Collins
01799eeff1 Define genesis blocks internally.
The genesis block for each network is a parameter for the network.  As
such, it makes more sense to define them in this package instead of in the
wire protocol package.

ok @jrick
2014-05-28 09:08:20 -05:00
Dave Collins
75e199ece8 Use btcnet genesis params for examples and tests. 2014-05-28 01:29:51 -05:00
Dave Collins
87bef61b30 Update tests to use btcnet genesis params. 2014-05-28 00:56:57 -05:00
Dave Collins
b0b090009a Update README.md for btcnet changes.
The sample code in doc.go was updated for the recent btcnet changes,
however the sample code in the README.md was not.
2014-05-28 00:56:06 -05:00
Josh Rickmar
6b3e878cd9 Add ISC license.
Spotted by @davecgh.
2014-05-28 00:15:11 -05:00
Josh Rickmar
81c37e551f Fix documentation code examples.
The examples uses a btcutil API that was recently updated from passing
btcwire.BitcoinNet to *btcnet.Params.  This change updates the btcutil
call in the examples, as well as modifying the example in the README
to match that in doc.go (where errors were handled slightly
differently).
2014-05-27 20:41:30 -05:00
Josh Rickmar
18794e4cfc Fix errors after deciding on the Register API.
The ParamsForNet function was removed, so likewise this change removes
ErrUnknownNet error that it used to return.

As network registration is now necessary for correct handling of
alternate network encoding magics, and therefore the ErrDuplicateNet
error returned by Register is here to stay, kill the comment about the
error being removed later.
2014-05-27 20:35:35 -05:00
Josh Rickmar
74303966c0 Updates for btcutil and btcscript's btcnet conversion.
ok @davecgh
2014-05-27 17:44:55 -05:00
Josh Rickmar
be325b9d9c Update API for btcnet and btcutil changes.
ok @davecgh
2014-05-27 17:42:01 -05:00
Josh Rickmar
6f76171a82 Additions for btcutil.
ok @davecgh
2014-05-27 17:39:09 -05:00
Dave Collins
0c586634bd Update for recent btcutil API changes. 2014-05-27 17:03:09 -05:00
Dave Collins
f37a5e76b5 Update tests for recent API changes. 2014-05-27 10:15:35 -05:00
Dave Collins
4328461f36 Update for recent btcchain and btcnet API changes. 2014-05-27 10:12:59 -05:00
Dave Collins
4579cfb71b Refactor several network-specific params to btcnet.
This commit refactors the code to make use of the btcnet package for
network-specific parameters instead of switching on the specific network.

For example, the percentage of the network that needs to run version 2
blocks is different between testnet and mainnet.  Previously the code was
using a switch to choose these values.  With this refactor, those
parameters are part of the network parameters provided when creating a new
chain instance.

Another example is checkpoints, which have been moved to btcnet so they
can be specified by the caller instead of hard coded into this package.
As a result, the checkpoints for the standard networks are now specified
in the btcnet package.

This makes it easier to add new networks such as a testnet4 should it
become needed.  It also allows callers to define their own custom network
parameters without having to modify the code of the package to add new
switch cases for the custom network.
2014-05-27 10:11:55 -05:00
Dave Collins
fb8ab4200f Add more chain-related fields and checkpoints.
This commit adds more chain-related fields to the parameters as a part of
converting btcchain to work with btcnet parameters instead of coding the
network-specific knowledge into the package itself.

It also moves the checkpoints from btcchain since checkpoints are a
network parameter and make more sense here.

ok @jrick
2014-05-27 10:07:19 -05:00
Dave Collins
009c4bcd76 Update findcheckpoint utility to use btcnet. 2014-05-27 00:56:54 -05:00
Dave Collins
dd8265c22c Convert addblock utility to use btcnet. 2014-05-27 00:48:00 -05:00
Dave Collins
7b0116dfd0 Prepare for release 0.8.0. 2014-05-25 15:52:47 -05:00
Dave Collins
aa1d722dd6 Update pre-release and README.me to beta.
This is part of the changes for #130.
2014-05-23 15:51:45 -05:00
Dave Collins
d4082e4f24 Add checkpoint at block height 300255. 2014-05-23 13:44:23 -05:00
Dave Collins
6d8b873923 Raise maxStandardSigScriptSize to 1650.
This commit raises the maximum allowed size for a standard signature
script to cover a 15-of-15 multi-signature pay-to-script-hash with
compressed pubkeys.

This mirrors a recent change to remain compatible with Bitcoin Core.

ok @owinga who also helped verify and correct the script math.

Closes #128.
2014-05-23 12:23:36 -05:00
Josh Rickmar
bcc78565fd Initial pass at updating to btcnet.
This change modifies the params struct to embed a *btcnet.Params,
removing the old parameter fields that are handled by the btcnet
package.

Hardcoded network checks have also been removed in favor of modifying
behavior based on the current active net's parameters.

Not all library packages, notable btcutil and btcchain, have been
updated to use btcnet yet, but with this change, each package can be
updated one at a time since the active net's btcnet.Params are
available at each callsite.

ok @davecgh
2014-05-23 01:02:14 -05:00
Josh Rickmar
536c1e3c29 Add parameters used by btcd.
This change adds two parameters to the Params struct which are used by
btcd to alter behavior based on the active network, rather than
hardcoding checks for a particular network.

The first, ResetMinDifficulty, specifies whether the target difficulty
can change between the retarget intervals.

The second, RelayNonStdTxs, specifies whether standard transaction
checks should not be performed when accepting mempool transactions.

The zero values (false) for both of these bools are the correct
parameter values for mainnet.

While here, rename the test network version 3 to "testnet3", as both
btcd and btcwallet will include additional handling to rename this to
"testnet" for directory names, and a switch to "testnet3" is planned
in the future.
2014-05-23 00:55:21 -05:00
Dave Collins
342d0a536f Correct error message in handleGetWorkSubmission.
Found by go vet.
2014-05-22 23:48:02 -05:00
Dave Collins
b6af0a7a53 Remove extra return statement found by go vet.
The return statement was unreachable and thus this change has no
effect on functionality.
2014-05-22 23:46:41 -05:00
Josh Rickmar
55ef07ca61 Initial commit. 2014-05-22 13:08:32 -05:00
David Hill
0cdaefd4cc export HashMerkleBranches
ok @davecgh
2014-05-22 13:29:39 -04:00
Dave Collins
6af13826ae Convert {Dump,Import}PrivKey to use new WIF type.
The btcutil package recently exposed a WIF type to provide more
functionality and simplify working with WIF strings.  This commit changes
the DumpPrivKey and ImportPrivKey RPCs to use the new WIF type.
2014-05-21 20:00:11 -05:00
Dave Collins
9d9c343247 Make nil pointer handling consistent across RPCs.
There are several RPCs which accept a pointer to a hash, transaction,
block, etc.  Previously not all RPCs handled being passed a nil pointer
consistently.

Closes #4.
2014-05-21 19:53:46 -05:00
Dave Collins
57738b1920 gofmt 2014-05-21 19:24:45 -05:00
Josh Rickmar
cea5e44f2d Add Serialize method to PrivateKey.
ok @davecgh
2014-05-21 17:04:28 -05:00
Josh Rickmar
82e79619a5 Add missing redeemScript to ListUnspentResult.
ok @jcvernaleo
2014-05-21 16:08:19 -05:00
David Hill
27e1ad758b Add new function PushedData.
PushedData returns an array of byte slices containing any pushed data
found in the passed script.  This includes OP_0, but not OP_1 - OP_16.

help from and ok @owainga
2014-05-20 12:24:23 -04:00
Dave Collins
77c02f36ee Cleanup new code introduced by Pull Request #4.
- Keep comments to 80 cols for consistency with the rest of the code base
- Made verify a method off of Signature instead of PublicKey since one
  verifies a signature with a public key as opposed to the other way
  around
- Return new signature from Sign function directly rather than creating a
  local temporary variable
- Modify a couple of comments as recommended by @owainga
- Update sample usage in doc.go for both signing messages and verifying
  signatures

ok @owainga
2014-05-20 10:36:15 -05:00
Geert-Johan Riemer
af82a73fe4 Add tests for sign and verify. 2014-05-20 10:01:40 -05:00
Geert-Johan Riemer
ac7a367950 Add type PrivateKey, (*PrivateKey).Sign() and (*PublicKey).Verify(). 2014-05-20 09:59:29 -05:00
Josh Rickmar
1dbf389ceb Optimize public key serialization.
This change removes the internal pad function in favor a more opimized
paddedAppend function.  Unlike pad, which would always alloate a new
slice of the desired size and copy the bytes into it, paddedAppend
only appends the leading padding when necesary, and uses the builtin
append to copy the remaining source bytes.  pad was also used in
combination with another call to the builtin copy func to copy into a
zeroed byte slice.  As the slice is now created using make with an
initial length of zero, this copy can also be removed.

As confirmed by poking the bytes with the unsafe package, gc does not
zero array elements between the len and cap when allocating slices
with make().  In combination with the paddedAppend func, this results
in only a single copy of each byte, with no unnecssary zeroing, when
creating the serialized pubkeys.  This has not been tested with other
Go compilers (namely, gccgo and llgo), but the new behavior is still
functionally correct regardless of compiler optimizations.

The TestPad function has been removed as the pad func it tested has
likewise been removed.

ok @davecgh
2014-05-19 23:13:48 -05:00
David Hill
225f6d3d06 Add setgenerate to btcctl 2014-05-16 12:06:09 -04:00