Commit graph

3594 commits

Author SHA1 Message Date
Dave Collins
f78d054700 Add struct for DecodeScriptResult. 2014-01-03 18:20:06 -06:00
John C. Vernaleo
258e9ef4c6 Add test for the Cmd.Id() functions. 2014-01-03 17:50:17 -05:00
Dave Collins
a8ff7fecb4 Add createrawtransaction support to btcctl. 2014-01-03 13:45:12 -06:00
Dave Collins
814c920c96 Add tests for new payment script creation funcs. 2014-01-03 13:42:22 -06:00
Dave Collins
3d60bac238 Add new funcs for creating payment scripts.
This commit adds two new functions named PayToScriptHashScript and
PayToAddrScript.  The first one creates and returns a public-key script
which pays to the provided script hash and conforms to BIP0016.

The second function takes the new btcutil.Address interface type and
returns an appropriate script to pay to the address type in the interface.
It currently works for btcutil.AddressPubKeyHash and
btcutil.AddressScriptHash.
2014-01-03 13:35:51 -06:00
Dave Collins
b6b2fd15b3 Add support for createrawtransaction RPC command. 2014-01-03 12:43:13 -06:00
Josh Rickmar
405eca4a44 Remove usage of deprecated address encode/decode API. 2014-01-03 13:22:28 -05:00
John C. Vernaleo
2944ccb86b Update coverage report. 2014-01-03 12:02:41 -05:00
Dave Collins
84cb4c7130 Export new function ConvertCreateRawTxParams.
The inputs to the createrawtransaction command are JSON strings, however
the NewCreateRawTransactionCmd function takes concrete types.  Thus,
callers which deal with the raw JSON need a method to perform the
validation and conversion.  This logic is the same as what needs to happen
when unmashalling a full JSON-RPC command, so this commit factors that
logic out into a separate function and exports it.
2014-01-03 10:25:06 -06:00
Dave Collins
8d7354f45b Gofmt. 2014-01-03 10:22:07 -06:00
Dave Collins
e64e6f0757 Add tests for new BitcoinNet Stringer. 2014-01-03 08:36:11 -06:00
Dave Collins
626662fb5f Add Stringer to BitcoinNet. 2014-01-03 08:32:43 -06:00
Francis Lam
082ad7caf2 Updated createVoutList to support scripthash/multisig outputs
Used updates in btcscript/btcutil to support decoding scripthash and
multisig outputs for display in getrawtransactions/decoderawtransaction
2014-01-02 13:48:50 -06:00
Francis Lam
3a8ec0078b Added another multisig test with compressed pubkey 2014-01-02 13:50:22 -05:00
Francis Lam
3f52f559eb Added tests for multisig scripts and fixed comments
Fixed up bad function comment headers

Added a small set of tests for the ScriptToAddrHashes function to test
functionality of a couple real multisig cases as well as error checking
2014-01-02 13:31:00 -05:00
Francis Lam
a5aaf90687 Added support to decode scripthash/multisig from pkscripts 2014-01-02 00:28:16 -05:00
Dave Collins
aeec39c1ff Add 2014 to copyright dates. 2014-01-01 10:16:15 -06:00
Dave Collins
30802fdd52 Rename RPC handlers map to rpcHandlers.
The name handlers for a package level is a bit too generic and could
easily cause a name collision.  Even though the compiler would catch it,
use something a bit more descriptive.
2013-12-31 15:53:19 -06:00
Dave Collins
835cee229a Move RPC handler maps near the top of file.
Since the command to handler mappings are the most often modified and
referenced code in rpcserver.go and rpcwebsocket.go, move them near the
top of their respective files.
2013-12-31 14:48:50 -06:00
Dave Collins
9b166b3876 Remove wallet notifications chan from std commands.
This commit cleans up the standard RPC command hanlding a bit by removing
the websocket specific notification channel from the handlers.  This was
previously required because the sendrawtransaction, when called from a
websocket enabled connection, needs to add a notification for when the
transaction is mined.

This commit modifies that to instead implement a websocket extended
version of sendrawtransaction which invokes the standard handler and adds
the notification.  In addition, the main send was modified to first look
if the command has a websocket specific handler first, and then falls back
to standard commands, rather than the previous approach of first checking
for a standard command and falling through to websocket commands.  This
essentially allows websockets connections to extend commands with the same
name with additional functionality such as what was done in this commit.
2013-12-31 14:42:15 -06:00
Dave Collins
5ad6d543d6 Move RPC websocket code to its own file.
The rpcserver.go file is starting to get a bit unwieldy.  This commit
moves the separable websocket specific bits into a separate file named
rpcwebsocket.go.
2013-12-31 13:19:07 -06:00
Josh Rickmar
426db5ae21 Add getaccountaddress support to btcctl. 2013-12-31 13:11:01 -05:00
Francis Lam
5d91e16e7c Added MarshalJSON to Vin and changed Vout.ScriptPubKey
Added MarshalJSON method to Vin which properly omits the Vout field
from coinbase Vin's by using anonymous structs with the proper
subsets of fields outputted by bitcoind

Changed Vout.ScriptPubKey to add omitempty for ReqSigs and Addresses:
both fields are not shown when there is an error identifying to
scriptType or parsing addresses in bitcoind
2013-12-30 20:36:46 -06:00
Dave Collins
f2a2744bec Correct error handling from the previous commit. 2013-12-30 20:27:36 -06:00
Francis Lam
28d08f8b16 Small changes to createVinList/createVoutList
Added error checking for script disassembley

Changed vout to handle errors in processing the way bitcoind does: the
type displayed is "nonstandard" when the calculated type is nonstandard
or nulltype and also when there is an error getting the address.

Still doesn't properly support multisig addresses, but now it should
return "nonstandard" since since address lookup fails for those cases.
2013-12-30 20:06:13 -05:00
Dave Collins
c0236b5a2f Change LockTime in TxRawDecodeResult to uint32. 2013-12-30 18:42:46 -06:00
Dave Collins
eb624acfd4 Add support for decoderawtransaction RPC command.
Since the decoderawtransaction result makes use of the same vin and vout
lists, this commit also factors the logic for those out into separate
functions.
2013-12-30 18:33:13 -06:00
Josh Rickmar
bf7c5fa062 Fix a typo. 2013-12-30 16:32:25 -05:00
Josh Rickmar
13868e76ec Add getaccount support to btcctl. 2013-12-30 16:31:47 -05:00
Josh Rickmar
87b7352008 Add getunconfirmedbalance extension. 2013-12-30 15:09:16 -05:00
Dave Collins
d17a97b485 Correct verifychain RPC call return.
The return value should be a boolean for compatibility.
2013-12-30 10:59:14 -06:00
Dave Collins
3bfeabb47a Improve btcctl verifychain usage.
Also, add a comment for makeVerifyChain while here.
2013-12-30 10:35:33 -06:00
Josh Rickmar
86575afa91 Add listaddresstransactions extension. 2013-12-30 11:03:05 -05:00
Josh Rickmar
bd29b12d31 Notify wallets when mempool txs pay to a wallet address. 2013-12-30 09:33:36 -05:00
Dave Collins
2d875b39f9 Bring README.md up-to-date with the current status. 2013-12-28 15:30:33 -06:00
Dave Collins
cc712827da Add tests for pad function.
This brings the overall test coverage up to 99.88%.
2013-12-28 15:30:10 -06:00
Dave Collins
ca14702e5d Correct getpeerinfo JSON marshalling for omitempty.
The fields of the PeerInfo should not have been marked omit as the only
ones that should be omitted to for compatibility are the SyncNode and
BanScore fields.
2013-12-27 19:25:20 -06:00
Dave Collins
3faa256f75 Correct the getpeerinfo RPC services field.
In order to match the Satohsi client, the return is supposed to be an
8-digit string representation of the services instead of the actual
services numeric value.
2013-12-27 17:35:51 -06:00
Dave Collins
674ef590bb No need to cast something is already a uint32. 2013-12-27 13:20:13 -06:00
Dave Collins
f0cc672d23 Update for btcjson sequence number type change. 2013-12-27 12:38:51 -06:00
Dave Collins
11d39125de The sequence num of a tx input is a uint32. 2013-12-27 12:38:11 -06:00
Dave Collins
ca0e38e58b Update for recent btcjson getrawtransaction change.
The ScriptSig field of the Vin type for TxRawResult is now a pointer in
btcjson so it can be properly omitted.  This commit updates the code to
create the new ScriptSig object as needed.
2013-12-27 12:24:03 -06:00
Dave Collins
d3b76da919 Make ScriptSig anonymous struct an exported type.
The previous commit modified the Vin ScriptSig field to be a pointer to an
anonymous struct so it could be properly omitted.  However, the callers
need to be able to create a new object to assign to the field, so this
commit makes the previous anonymous struct an exported type named
ScriptSig.
2013-12-27 12:22:37 -06:00
Dave Collins
509bf830b1 Correct Vin ScriptSig to properly omit when empty.
In order for a field which is a struct to be omitted from JSON
marshal/unmarshal, it must be a pointer so the json package can tell when
it's empty (when it's nil).
2013-12-27 11:27:52 -06:00
Dave Collins
e0fab228a4 Correct getrawtransaction RPC handling and cleanup.
The getrawtransaction RPC call should return a hex-encoded string of the
transaction when verbose is false instead of a TxRawResult object with the
Hex field set to be compatible with the Sathoshi client.  This commit,
along with a recent commit to btcjson corrects this.

Also, while here, do a bit of cleanup, finish a TODO to check for an
invalid hash, and optimize the handling of non-verbose slightly.
2013-12-26 23:30:57 -06:00
Dave Collins
af3609d861 Factor out common message to hex in RPC server. 2013-12-26 22:53:44 -06:00
Dave Collins
8f8eeae962 Add benchmark for adding two Jacobian points. 2013-12-26 21:52:26 -06:00
Dave Collins
1855c19562 Allow getrawtransaction result to be string.
The getrawtransaction command has recently added a verbose flag which
alters the output.  The previous code made use of the "Hex" field of the
TxRawResult to return the information, but this is not consistent with the
original getrawtransaction RPC call which returns a string when verbose is
false and the TxRawResult JSON object when it is true.

This commit corrects that by allowing the result for getrawtransaction to
be either form.
2013-12-26 21:28:57 -06:00
Dave Collins
e3c2b87536 Fix a comment typo. 2013-12-26 18:52:30 -06:00
Dave Collins
8477ef569a Update btcctl getblock for recent changes.
This commit allows btcctl to accept the optional verbosity parameters on
getblock.
2013-12-26 11:19:32 -06:00