Commit graph

58 commits

Author SHA1 Message Date
Pieter Wuille 81e3228fcb Make CTransaction actually immutable 2016-12-02 18:37:43 -08:00
Pieter Wuille b4e4ba475a Introduce convenience type CTransactionRef 2016-11-19 17:53:23 -08:00
Pieter Wuille 1662b437b3 Make CBlock::vtx a vector of shared_ptr<CTransaction> 2016-11-19 17:51:09 -08:00
Pieter Wuille da60506fc8 Add deserializing constructors to CTransaction and CMutableTransaction 2016-11-19 17:50:40 -08:00
Pieter Wuille 528472111b Get rid of nType and nVersion
Remove the nType and nVersion as parameters to all serialization methods
and functions. There is only one place where it's read and has an impact
(in CAddress), and even there it does not impact any of the recursively
invoked serializers.

Instead, the few places that need nType or nVersion are changed to read
it directly from the stream object, through GetType() and GetVersion()
methods which are added to all stream classes.
2016-11-07 13:56:27 -08:00
Pieter Wuille 657e05ab2e Make GetSerializeSize a wrapper on top of CSizeComputer
Given that in default GetSerializeSize implementations created by
ADD_SERIALIZE_METHODS we're already using CSizeComputer(), get rid
of the specialized GetSerializeSize methods everywhere, and just use
CSizeComputer. This removes a lot of code which isn't actually used
anywhere.

For CCompactSize and CVarInt this actually removes a more efficient
size computing algorithm, which is brought back in a later commit.
2016-11-07 13:56:22 -08:00
Matt Corallo 190fd321ad Remove unused CTxOut::GetHash() 2016-11-04 10:50:43 -04:00
Hampus Sjöberg fdf82fba31 Adding method GetTotalSize() to CTransaction
GetTotalSize() returns the total transaction size (including witness) in
bytes.
2016-09-06 22:30:30 +02:00
MarcoFalke fa785d1211 Use __func__ to get function name for output printing 2016-08-19 18:59:00 +02:00
Wladimir J. van der Laan 806b9e7570
Merge #8332: semi trivial: clarify witness branches in transaction.h serialization
e37b16a transaction: clarify witness branches (Daniel Cousens)
2016-07-28 13:00:02 +02:00
Suhas Daftuar 2c06bae39e Rename "block cost" to "block weight" 2016-07-18 13:28:26 -04:00
Daniel Cousens e37b16a75c transaction: clarify witness branches 2016-07-14 13:40:50 +10:00
Bob McElrath 36ae37a9f9 Rename CTxinWitness -> CTxInWitness 2016-07-06 19:46:46 -04:00
Pieter Wuille 2b1f6f9ccf BIP141: Other consensus critical limits, and BIP145
Includes changes by Suhas Daftuar, Luke-jr, and mruddy.
2016-06-22 15:43:00 +02:00
Pieter Wuille 8b49040854 BIP141: Commitment structure and deployment
Includes a fix by Suhas Daftuar and LongShao007
2016-06-22 15:42:59 +02:00
Pieter Wuille 7030d9eb47 BIP144: Serialization, hashes, relay (sender side)
Contains refactorings by Eric Lombrozo.
Contains fixup by Nicolas Dorier.
Contains cleanup of CInv::GetCommand by Alex Morcos
2016-06-22 15:42:59 +02:00
Wladimir J. van der Laan 3081fb9a31
Merge #7763: Put hex-encoded version in UpdateTip
eff736e Reformat version in UpdateTip and other messages (Pieter Wuille)
2016-03-31 13:24:50 +02:00
Pieter Wuille eff736e55e Reformat version in UpdateTip and other messages
Also remove the hardly-readable nBits from UpdateTip's log message.
2016-03-31 12:28:34 +02:00
Wladimir J. van der Laan e8a8f3d4b2
Merge #7648: BIP9 versionbits softfork for BIP68, BIP112 and BIP113
71527a0 Test of BIP9 fork activation of mtp, csv, sequence_lock (NicolasDorier)
19d73d5 Add RPC test for BIP 68/112/113 soft fork. (Alex Morcos)
12c89c9 Policy: allow transaction version 2 relay policy. (BtcDrak)
02c2435 Soft fork logic for BIP68 (BtcDrak)
478fba6 Soft fork logic for BIP113 (BtcDrak)
65751a3 Add CHECKSEQUENCEVERIFY softfork through BIP9 (Pieter Wuille)
2016-03-30 18:59:39 +02:00
Wladimir J. van der Laan 3c27067dd2
Merge #7712: Improve COutPoint less operator
0f17692 Improve COutPoint less operator (João Barbosa)
2016-03-21 12:50:47 +01:00
BtcDrak 12c89c9185 Policy: allow transaction version 2 relay policy.
This commit introduces a way to gracefully bump the default
transaction version in a two step process.
2016-03-18 08:09:06 +00:00
João Barbosa 0f176927f8 Improve COutPoint less operator 2016-03-18 08:03:55 +00:00
Pieter Wuille 6851107b3a BIP9 Implementation
Inspired by former implementations by Eric Lombrozo and Rusty Russell, and
based on code by Jorge Timon.
2016-03-15 16:54:38 +01:00
Wladimir J. van der Laan 80d1f2e483
Merge #7184: Implement SequenceLocks functions for BIP 68
b043c4b fix sdaftuar's nits again (Alex Morcos)
a51c79b Bug fix to RPC test (Alex Morcos)
da6ad5f Add RPC test exercising BIP68 (mempool only) (Suhas Daftuar)
c6c2f0f Implement SequenceLocks functions (Alex Morcos)
2016-02-12 17:03:46 +01:00
Alex Morcos c6c2f0fd78 Implement SequenceLocks functions
SequenceLocks functions are used to evaluate sequence lock times or heights per BIP 68.

The majority of this code is copied from maaku in #6312
Further credit: btcdrak, sipa, NicolasDorier
2016-02-10 15:35:33 -05:00
MarcoFalke fa24439ff3 Bump copyright headers to 2015 2015-12-13 18:08:39 +01:00
Wladimir J. van der Laan 327291af02
Merge pull request #6914
114b581 Prevector type (Pieter Wuille)
2015-12-01 10:22:14 +01:00
Pieter Wuille eece63fa72 Switch blocks to a constant-space Merkle root/branch algorithm.
This switches the Merkle tree logic for blocks to one that runs in constant (small) space.
The old code is moved to tests, and a new test is added that for various combinations of
block sizes, transaction positions to compute a branch for, and mutations:
 * Verifies that the old code and new code agree for the Merkle root.
 * Verifies that the old code and new code agree for the Merkle branch.
 * Verifies that the computed Merkle branch is valid.
 * Verifies that mutations don't change the Merkle root.
 * Verifies that mutations are correctly detected.
2015-11-27 15:36:52 +01:00
Pieter Wuille 114b5812f6 Prevector type 2015-11-13 18:15:20 +01:00
MarcoFalke 5f46a7d068 transaction_tests: Be more strict checking dust
* Don't allow off-by-one or more
* Make clear dust is coupled with minRelayTxFee
* Check rounding for odd values
2015-11-09 21:00:16 +01:00
Peter Todd 287f54fc90 Add CHECKLOCKTIMEVERIFY (BIP65) soft-fork logic
Based on the earlier BIP66 soft-fork logic implemented by Pieter
Wuille's 5a47811da5
2015-10-08 17:23:22 +02:00
Wladimir J. van der Laan 48efbdbe98
Merge pull request #5264
af3208b Resolve issue 3166. These changes decode valid SIGHASH types on signatures in assembly (asm) representations of scriptSig scripts. This squashed commit incorporates substantial helpful feedback from jtimon, laanwj, and sipa. (mruddy)
2015-09-25 19:19:07 +02:00
Pieter Wuille 3b33ec85ed Avoid duplicate CheckBlock checks 2015-09-22 18:51:08 +02:00
Pieter Wuille 391dff16fe Do not store Merkle branches in the wallet.
Assume that when a wallet transaction has a valid block hash and transaction position
in it, the transaction is actually there. We're already trusting wallet data in a
much more fundamental way anyway.

To prevent backward compatibility issues, a new record is used for storing the
block locator in the wallet. Old wallets will see a wallet file synchronized up
to the genesis block, and rescan automatically.
2015-09-22 18:51:07 +02:00
mruddy af3208bfa6 Resolve issue 3166.
These changes decode valid SIGHASH types on signatures in assembly (asm) representations of scriptSig scripts.
This squashed commit incorporates substantial helpful feedback from jtimon, laanwj, and sipa.
2015-07-30 19:56:00 -04:00
Wladimir J. van der Laan 24ce77d775
Merge pull request #6444
0aad1f1 Exempt unspendable transaction outputs from dust checks (zathras-crypto)
2015-07-21 11:47:57 +02:00
Pieter Wuille 9e38d0f745 Separate core memory usage computation in core_memusage.h 2015-07-20 11:17:53 -04:00
zathras-crypto 0aad1f13b2
Exempt unspendable transaction outputs from dust checks
Since unspendable outputs can't be spent, there is no threshold at which it would be uneconomic to spend them.

This primarily targets transaction outputs with `OP_RETURN`.

---

Initially based on:

commit 9cf0ae26350033d43d5dd3c95054c0d1b1641eda
Author: zathras-crypto <zathrasc@gmail.com>
Date:   Wed Mar 25 02:04:02 2015 -0700

Changes:

- cherry-picked on top of bitcoin:master
- added RPC test for fundrawtransaction
2015-07-18 17:31:55 +02:00
Pieter Wuille 5098c47b24 Implement accurate memory accounting for mempool 2015-07-10 10:49:31 -04:00
Wladimir J. van der Laan 5a7304b69d Move recently introduced CTransAction::IsEquivalentTo to CWalletTx
CTransAction::IsEquivalentTo was introduced in #5881.
This functionality is only useful to the wallet, and should never have
been added to the primitive transaction type.
2015-07-02 20:57:39 +02:00
Wladimir J. van der Laan 3203a0832a
Merge pull request #5881
5d34e16 Add txn_clone.py test (Tom Harding)
defd2d5 Better txn_doublespend.py test (Tom Harding)
b2b3619 Implement CTransaction::IsEquivalentTo(...) (Tom Harding)
2015-07-02 19:59:50 +02:00
jtimon 691161d419 Consensus: Create consensus/consensus.h with some constants 2015-04-20 21:27:51 +02:00
Tom Harding b2b3619262 Implement CTransaction::IsEquivalentTo(...)
Define CTransaction::IsEquivalentTo(const CTransaction& tx)

True if only scriptSigs are different.  In other words, true if
the two transactions are malleability clones.  In other words,
true if the two transactions have the same effect on the
outside universe.

In the wallet, only SyncMetaData for equivalent transactions.
2015-04-11 19:03:58 -07:00
Wladimir J. van der Laan df5c246ba3
Merge pull request #5831
1d9b378 qa/rpc-tests/wallet: Tests for sendmany (Luke Dashjr)
40a7573 rpcwallet/sendmany: Just take an array of addresses to subtract fees from, rather than an Object with all values being identical (Luke Dashjr)
292623a Subtract fee from amount (Cozz Lovan)
90a43c1 [Qt] Code-movement-only: Format confirmation message in sendcoinsdialog (Cozz Lovan)
2015-03-16 12:23:14 +01:00
Cozz Lovan 292623adf5 Subtract fee from amount
Fixes #2724 and #1570.

Adds the
automatically-subtract-the-fee-from-the-amount-and-send-whats-left
feature to the GUI and RPC (sendtoaddress,sendmany).
2015-03-13 11:04:18 +01:00
Wladimir J. van der Laan a0ae79d775 Replace CBlockHeader::GetHash with call to SerializeHash
Removes variability between LE and BE.
As suggested by @sipa.
2015-03-06 17:21:59 +01:00
Wladimir J. van der Laan 4f92773f92 src/primitives/transaction.h: endian compatibility in serialization 2015-03-06 17:21:58 +01:00
Wladimir J. van der Laan 81aeb28436 src/primitives/block.cpp: endian compatibility in GetHash 2015-03-06 17:21:58 +01:00
Wladimir J. van der Laan 41e6e4caba
Merge pull request #5713
bf6cdeb Increase coverage of DERSIG edge cases (Pieter Wuille)
819bcf9 Add RPC test for DERSIG BIP switchover logic (Pieter Wuille)
5a47811 BIP66 changeover logic (Pieter Wuille)
092e9fe Example unit tests from BIP66 (Pieter Wuille)
80ad135 Change IsDERSignature to BIP66 implementation (Pieter Wuille)
2015-02-03 10:34:53 +01:00
Pieter Wuille 5a47811da5 BIP66 changeover logic 2015-02-01 17:51:24 -04:00