Commit graph

95 commits

Author SHA1 Message Date
Daniel Cousens
99a1b7274c Transaction: use the type embedded in the signature 2014-05-18 17:52:48 +10:00
Daniel Cousens
0468c4710c Transaction: rename (de)serialize to [to/from]Buffer 2014-05-17 00:09:13 +10:00
Daniel Cousens
e033a872c9 Transaction: rename hashTransactionForSignature to hashForSignature 2014-05-17 00:09:13 +10:00
Daniel Cousens
e27c97a791 ECPubKey/ECKey: separate to two files 2014-05-13 16:51:06 +10:00
Daniel Cousens
05e0d08098 BufferExt: rename to bufferutils 2014-05-13 16:46:12 +10:00
Daniel Cousens
614a213d44 Transaction: remove untested hash array support 2014-05-12 10:17:38 +10:00
Daniel Cousens
708aa03390 Transaction/Script: bitcoin network no longer implied
A Transaction (and its subsequent scripts) do not carry any network
specific information in the Bitcoin protocol.
Therefore they can not (without further context) produce the network
specific constants for the generation of the base58 Addresses.

As TransactionOut.address is used heavily throughout Wallet and other
areas of the library, this could not be entirely removed without a large
number of changes.
For now, TransactionOut.address is only defined in the case of
Tx.addOutput being used directly:

      Transaction.addOutput(address, value)
2014-05-08 10:59:58 +10:00
Daniel Cousens
0822def7e0 Script: add standard Script.create*ScriptPubKey
Extracts the two Script types out of Script.createOutputScript, and puts
them both under test.

Also renames Script.createMultiSigOutputScript to adhere to the same
convention.
2014-05-08 10:59:58 +10:00
Daniel Cousens
57b8afbdab Network: rename Network to Networks
This change removes the most common ambiguities.
As the network module is not representative of a class, the lower case
has been used.
2014-05-08 10:59:58 +10:00
Daniel Cousens
74e53b49a5 Script/Transaction: remove untested functions
These functions are not under test, and are unnecessary bloat due to a
confusing API.

Script.from*(asmStr) were two functions that attempted to parse ASM
codes and produce a script from this.
While useful, an parser can be introduced later under a single function
and under test... removed.

Although Script.extractPublicKeys implementation is likely to be correct,
it is not absolute in that what it returns is even strictly a set of
public keys.
It is a useful function, but can be done in a better way later,
probably checking against the Script templates instead.

Transaction.signWithKeys has some inherent undocumented behaviour, and it is not
clear when you would use it over just Transaction.addOutput and
Transaction.sign individually.  Nor does it mimic anything in the
bitcoind API... removed.
2014-05-08 10:59:58 +10:00
Daniel Cousens
76323a07d0 Transaction: restrict TxIn/TxOut constructor params
To keep this change minimal, both TxIn/TxOut still use the parameter
object for initialization.  TxOut accepts only the types it uses
internally, and not hex or byte arrays for scripts.

The clone is unnecessary as a TransactionOut is never mutated after its
creation.

This resulted in TransactionOut.scriptPubKey no longer being needed,
and was removed.  To access the scriptPubKey as a byte buffer, a user
can simply use:

	TransactionOut.script.toBuffer()

Unfortunately, this leaves TransactionOut in a sorry state of test.
Something that needs to be fixed.
2014-05-08 10:59:58 +10:00
Daniel Cousens
9a7e291d70 Transaction: fix incorrect outIndex type 2014-05-08 08:52:07 +10:00
Daniel Cousens
a77846701f Fixes network support for TxOut 2014-05-06 15:40:40 +10:00
Daniel Cousens
4012b82bec Fixes Transaction.addOutput(Address, Number) 2014-05-06 15:40:40 +10:00
Daniel Cousens
695eb64a3a Clarifies Transaction.addOutput param documentation 2014-05-06 15:40:40 +10:00
Daniel Cousens
baa568697b Transaction.deserialize no longer mutates input 2014-05-05 09:11:37 +10:00
Daniel Cousens
02013beda9 Renames variables to be more verbose 2014-05-05 09:11:37 +10:00
Daniel Cousens
b860daf70b Corrects endianness comments 2014-05-04 17:31:47 +10:00
Daniel Cousens
87048d3b4e Adds performance notes 2014-05-04 17:31:47 +10:00
Daniel Cousens
a8cf2fdd9e Changes internal serialization to use Buffers instead 2014-05-04 17:31:22 +10:00
Daniel Cousens
10ee5532c3 Serialize now returns a buffer 2014-05-04 15:37:25 +10:00
Daniel Cousens
09c6a787d9 Changes sequence number to an actual Number 2014-05-04 15:37:25 +10:00
Daniel Cousens
bb80eda218 Merge pull request #165 from bitcoinjs/bigi-monkey-patching-no-more
Upgrade bigi & remove monkey patching
2014-05-04 07:39:19 +10:00
Wei Lu
1e6b283f9a Remove Number.isFinite check on tx input index 2014-05-03 10:19:38 +08:00
Wei Lu
af1f121fd4 upgrade bigi & remove monkey patching 2014-05-03 10:04:54 +08:00
Daniel Cousens
69c0497038 Renames createInputScript to createPubKeyHashScriptSig 2014-04-26 04:04:19 +10:00
Daniel Cousens
a4e68d142d Adds assertions for types in signScriptSig 2014-04-26 04:04:16 +10:00
Daniel Cousens
8ad8f6f169 Renames p2shsign to signScriptSig 2014-04-26 03:51:13 +10:00
Daniel Cousens
5546cae928 Removes type coercion for a stricter TX API 2014-04-26 03:51:13 +10:00
Daniel Cousens
9af8d95daf Removes applyMultisigs and adds setScriptSig 2014-04-26 03:51:13 +10:00
Daniel Cousens
ae60e6eb95 Replacse JSBN with bigi 2014-04-22 02:19:30 +10:00
Daniel Cousens
c44af2109e Uses typeof address === 'string' instead 2014-04-20 04:54:50 +10:00
Daniel Cousens
92f1c3e319 Fixes Transaction.addOutput() param handling to match documentation
Now (horrendously) supports other networks
2014-04-20 04:47:56 +10:00
Daniel Cousens
1d1306b054 Removes Address.fromPubKey and improves test vectors 2014-04-20 04:38:33 +10:00
Daniel Cousens
682ec133bb Migrates Address to stricter API subset 2014-04-18 17:12:29 +10:00
Daniel Cousens
b4f70dcdde Migrates ECKey to stricter API 2014-04-18 06:36:27 +10:00
Daniel Cousens
6de94856e3 Makes ECDSA capitalization consistent 2014-04-09 04:11:13 +10:00
Daniel Cousens
c99a576fbd Migrates all usage of crypto-js/sha256 to ./crypto 2014-04-08 23:07:46 +10:00
Daniel Cousens
81d9c8e759 Renames util.js to crypto.js 2014-04-08 22:00:28 +10:00
Wei Lu
93fe1b4c78 cosmetic standardization
[closes #56]
2014-03-31 11:47:47 +08:00
Daniel Cousens
8f7f50d555 Removes deprecated ECKey.export function 2014-03-29 18:12:02 +11:00
Daniel Cousens
63dd7c7dec Now uses varIntToNum 2014-03-26 19:11:37 +11:00
Wei Lu
8d2525dba1 allow feePerKb to be set to zero 2014-03-26 08:43:34 +08:00
Wei Lu
75218e784f Transaction fee calculation does not need BigInteger 2014-03-26 08:43:33 +08:00
Wei Lu
7bd312de71 get rid of magic numbers in fee estimation 2014-03-26 08:43:33 +08:00
Wei Lu
3d12d3b038 implement and use txOut.scriptPubKey 2014-03-26 08:43:32 +08:00
Wei Lu
b7d65fb757 Transaction is able to estimate fees 2014-03-26 08:43:31 +08:00
Wei Lu
c3880c0cdf script.toAddress -> script.getToAddress 2014-03-26 08:43:31 +08:00
Daniel Cousens
36af0223de Strict comparison operators with 0 2014-03-24 06:22:26 +11:00
Daniel Cousens
a062297be2 Uses Array.prototype.foreach for stricter scoping 2014-03-24 06:22:26 +11:00