Mercurial > hg > bitcoin
annotate src/script.h @ 3649:eb986f1e2e93 draft
Ultraprune
This switches bitcoin's transaction/block verification logic to use a
"coin database", which contains all unredeemed transaction output scripts,
amounts and heights.
The name ultraprune comes from the fact that instead of a full transaction
index, we only (need to) keep an index with unspent outputs. For now, the
blocks themselves are kept as usual, although they are only necessary for
serving, rescanning and reorganizing.
The basic datastructures are CCoins (representing the coins of a single
transaction), and CCoinsView (representing a state of the coins database).
There are several implementations for CCoinsView. A dummy, one backed by
the coins database (coins.dat), one backed by the memory pool, and one
that adds a cache on top of it. FetchInputs, ConnectInputs, ConnectBlock,
DisconnectBlock, ... now operate on a generic CCoinsView.
The block switching logic now builds a single cached CCoinsView with
changes to be committed to the database before any changes are made.
This means no uncommitted changes are ever read from the database, and
should ease the transition to another database layer which does not
support transactions (but does support atomic writes), like LevelDB.
For the getrawtransaction() RPC call, access to a txid-to-disk index
would be preferable. As this index is not necessary or even useful
for any other part of the implementation, it is not provided. Instead,
getrawtransaction() uses the coin database to find the block height,
and then scans that block to find the requested transaction. This is
slow, but should suffice for debug purposes.
author | Pieter Wuille <pieter.wuille@gmail.com> |
---|---|
date | Sun, 01 Jul 2012 18:54:00 +0200 |
parents | d489f6576318 |
children |
rev | line source |
---|---|
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
1 // Copyright (c) 2009-2010 Satoshi Nakamoto |
1818
20667468f95b
Update all copyrights to 2012
Gavin Andresen <gavinandresen@gmail.com>
parents:
1769
diff
changeset
|
2 // Copyright (c) 2009-2012 The Bitcoin developers |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
3 // Distributed under the MIT/X11 software license, see the accompanying |
2607 | 4 // file COPYING or http://www.opensource.org/licenses/mit-license.php. |
595
e630bbb11629
make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
575
diff
changeset
|
5 #ifndef H_BITCOIN_SCRIPT |
e630bbb11629
make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
575
diff
changeset
|
6 #define H_BITCOIN_SCRIPT |
e630bbb11629
make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
575
diff
changeset
|
7 |
e630bbb11629
make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
575
diff
changeset
|
8 #include <string> |
e630bbb11629
make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
575
diff
changeset
|
9 #include <vector> |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
10 |
851
d30704f40482
Add missing include to script.h
Vegard Nossum <vegard.nossum@gmail.com>
parents:
814
diff
changeset
|
11 #include <boost/foreach.hpp> |
2688
2c65e5d626eb
Refactor: split CKeyID/CScriptID/CTxDestination from CBitcoinAddress
Pieter Wuille <pieter.wuille@gmail.com>
parents:
2687
diff
changeset
|
12 #include <boost/variant.hpp> |
2c65e5d626eb
Refactor: split CKeyID/CScriptID/CTxDestination from CBitcoinAddress
Pieter Wuille <pieter.wuille@gmail.com>
parents:
2687
diff
changeset
|
13 |
2c65e5d626eb
Refactor: split CKeyID/CScriptID/CTxDestination from CBitcoinAddress
Pieter Wuille <pieter.wuille@gmail.com>
parents:
2687
diff
changeset
|
14 #include "keystore.h" |
2c65e5d626eb
Refactor: split CKeyID/CScriptID/CTxDestination from CBitcoinAddress
Pieter Wuille <pieter.wuille@gmail.com>
parents:
2687
diff
changeset
|
15 #include "bignum.h" |
851
d30704f40482
Add missing include to script.h
Vegard Nossum <vegard.nossum@gmail.com>
parents:
814
diff
changeset
|
16 |
3649 | 17 class CCoins; |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
18 class CTransaction; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
19 |
2096
ee92c87e9cb6
Begin doxygen-compatible comments
Pieter Wuille <pieter.wuille@gmail.com>
parents:
1818
diff
changeset
|
20 /** Signature hash types/flags */ |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
21 enum |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
22 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
23 SIGHASH_ALL = 1, |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
24 SIGHASH_NONE = 2, |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
25 SIGHASH_SINGLE = 3, |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
26 SIGHASH_ANYONECANPAY = 0x80, |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
27 }; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
28 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
29 |
1604
2d635cbb6a2d
Use block times for 'hard' OP_EVAL switchover, and refactored EvalScript
Gavin Andresen <gavinandresen@gmail.com>
parents:
1600
diff
changeset
|
30 enum txnouttype |
1600
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
31 { |
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
32 TX_NONSTANDARD, |
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
33 // 'standard' transaction types: |
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
34 TX_PUBKEY, |
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
35 TX_PUBKEYHASH, |
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
36 TX_SCRIPTHASH, |
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
37 TX_MULTISIG, |
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
38 }; |
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
39 |
2688
2c65e5d626eb
Refactor: split CKeyID/CScriptID/CTxDestination from CBitcoinAddress
Pieter Wuille <pieter.wuille@gmail.com>
parents:
2687
diff
changeset
|
40 class CNoDestination { |
2c65e5d626eb
Refactor: split CKeyID/CScriptID/CTxDestination from CBitcoinAddress
Pieter Wuille <pieter.wuille@gmail.com>
parents:
2687
diff
changeset
|
41 public: |
2c65e5d626eb
Refactor: split CKeyID/CScriptID/CTxDestination from CBitcoinAddress
Pieter Wuille <pieter.wuille@gmail.com>
parents:
2687
diff
changeset
|
42 friend bool operator==(const CNoDestination &a, const CNoDestination &b) { return true; } |
2c65e5d626eb
Refactor: split CKeyID/CScriptID/CTxDestination from CBitcoinAddress
Pieter Wuille <pieter.wuille@gmail.com>
parents:
2687
diff
changeset
|
43 friend bool operator<(const CNoDestination &a, const CNoDestination &b) { return true; } |
2c65e5d626eb
Refactor: split CKeyID/CScriptID/CTxDestination from CBitcoinAddress
Pieter Wuille <pieter.wuille@gmail.com>
parents:
2687
diff
changeset
|
44 }; |
2c65e5d626eb
Refactor: split CKeyID/CScriptID/CTxDestination from CBitcoinAddress
Pieter Wuille <pieter.wuille@gmail.com>
parents:
2687
diff
changeset
|
45 |
2c65e5d626eb
Refactor: split CKeyID/CScriptID/CTxDestination from CBitcoinAddress
Pieter Wuille <pieter.wuille@gmail.com>
parents:
2687
diff
changeset
|
46 /** A txout script template with a specific destination. It is either: |
2c65e5d626eb
Refactor: split CKeyID/CScriptID/CTxDestination from CBitcoinAddress
Pieter Wuille <pieter.wuille@gmail.com>
parents:
2687
diff
changeset
|
47 * * CNoDestination: no destination set |
2c65e5d626eb
Refactor: split CKeyID/CScriptID/CTxDestination from CBitcoinAddress
Pieter Wuille <pieter.wuille@gmail.com>
parents:
2687
diff
changeset
|
48 * * CKeyID: TX_PUBKEYHASH destination |
2c65e5d626eb
Refactor: split CKeyID/CScriptID/CTxDestination from CBitcoinAddress
Pieter Wuille <pieter.wuille@gmail.com>
parents:
2687
diff
changeset
|
49 * * CScriptID: TX_SCRIPTHASH destination |
2c65e5d626eb
Refactor: split CKeyID/CScriptID/CTxDestination from CBitcoinAddress
Pieter Wuille <pieter.wuille@gmail.com>
parents:
2687
diff
changeset
|
50 * A CTxDestination is the internal data type encoded in a CBitcoinAddress |
2c65e5d626eb
Refactor: split CKeyID/CScriptID/CTxDestination from CBitcoinAddress
Pieter Wuille <pieter.wuille@gmail.com>
parents:
2687
diff
changeset
|
51 */ |
2c65e5d626eb
Refactor: split CKeyID/CScriptID/CTxDestination from CBitcoinAddress
Pieter Wuille <pieter.wuille@gmail.com>
parents:
2687
diff
changeset
|
52 typedef boost::variant<CNoDestination, CKeyID, CScriptID> CTxDestination; |
2c65e5d626eb
Refactor: split CKeyID/CScriptID/CTxDestination from CBitcoinAddress
Pieter Wuille <pieter.wuille@gmail.com>
parents:
2687
diff
changeset
|
53 |
1604
2d635cbb6a2d
Use block times for 'hard' OP_EVAL switchover, and refactored EvalScript
Gavin Andresen <gavinandresen@gmail.com>
parents:
1600
diff
changeset
|
54 const char* GetTxnOutputType(txnouttype t); |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
55 |
2096
ee92c87e9cb6
Begin doxygen-compatible comments
Pieter Wuille <pieter.wuille@gmail.com>
parents:
1818
diff
changeset
|
56 /** Script opcodes */ |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
57 enum opcodetype |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
58 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
59 // push value |
2295
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
60 OP_0 = 0x00, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
61 OP_FALSE = OP_0, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
62 OP_PUSHDATA1 = 0x4c, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
63 OP_PUSHDATA2 = 0x4d, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
64 OP_PUSHDATA4 = 0x4e, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
65 OP_1NEGATE = 0x4f, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
66 OP_RESERVED = 0x50, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
67 OP_1 = 0x51, |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
68 OP_TRUE=OP_1, |
2295
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
69 OP_2 = 0x52, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
70 OP_3 = 0x53, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
71 OP_4 = 0x54, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
72 OP_5 = 0x55, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
73 OP_6 = 0x56, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
74 OP_7 = 0x57, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
75 OP_8 = 0x58, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
76 OP_9 = 0x59, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
77 OP_10 = 0x5a, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
78 OP_11 = 0x5b, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
79 OP_12 = 0x5c, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
80 OP_13 = 0x5d, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
81 OP_14 = 0x5e, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
82 OP_15 = 0x5f, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
83 OP_16 = 0x60, |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
84 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
85 // control |
2295
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
86 OP_NOP = 0x61, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
87 OP_VER = 0x62, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
88 OP_IF = 0x63, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
89 OP_NOTIF = 0x64, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
90 OP_VERIF = 0x65, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
91 OP_VERNOTIF = 0x66, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
92 OP_ELSE = 0x67, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
93 OP_ENDIF = 0x68, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
94 OP_VERIFY = 0x69, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
95 OP_RETURN = 0x6a, |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
96 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
97 // stack ops |
2295
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
98 OP_TOALTSTACK = 0x6b, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
99 OP_FROMALTSTACK = 0x6c, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
100 OP_2DROP = 0x6d, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
101 OP_2DUP = 0x6e, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
102 OP_3DUP = 0x6f, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
103 OP_2OVER = 0x70, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
104 OP_2ROT = 0x71, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
105 OP_2SWAP = 0x72, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
106 OP_IFDUP = 0x73, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
107 OP_DEPTH = 0x74, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
108 OP_DROP = 0x75, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
109 OP_DUP = 0x76, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
110 OP_NIP = 0x77, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
111 OP_OVER = 0x78, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
112 OP_PICK = 0x79, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
113 OP_ROLL = 0x7a, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
114 OP_ROT = 0x7b, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
115 OP_SWAP = 0x7c, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
116 OP_TUCK = 0x7d, |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
117 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
118 // splice ops |
2295
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
119 OP_CAT = 0x7e, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
120 OP_SUBSTR = 0x7f, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
121 OP_LEFT = 0x80, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
122 OP_RIGHT = 0x81, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
123 OP_SIZE = 0x82, |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
124 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
125 // bit logic |
2295
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
126 OP_INVERT = 0x83, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
127 OP_AND = 0x84, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
128 OP_OR = 0x85, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
129 OP_XOR = 0x86, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
130 OP_EQUAL = 0x87, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
131 OP_EQUALVERIFY = 0x88, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
132 OP_RESERVED1 = 0x89, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
133 OP_RESERVED2 = 0x8a, |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
134 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
135 // numeric |
2295
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
136 OP_1ADD = 0x8b, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
137 OP_1SUB = 0x8c, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
138 OP_2MUL = 0x8d, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
139 OP_2DIV = 0x8e, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
140 OP_NEGATE = 0x8f, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
141 OP_ABS = 0x90, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
142 OP_NOT = 0x91, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
143 OP_0NOTEQUAL = 0x92, |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
144 |
2295
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
145 OP_ADD = 0x93, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
146 OP_SUB = 0x94, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
147 OP_MUL = 0x95, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
148 OP_DIV = 0x96, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
149 OP_MOD = 0x97, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
150 OP_LSHIFT = 0x98, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
151 OP_RSHIFT = 0x99, |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
152 |
2295
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
153 OP_BOOLAND = 0x9a, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
154 OP_BOOLOR = 0x9b, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
155 OP_NUMEQUAL = 0x9c, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
156 OP_NUMEQUALVERIFY = 0x9d, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
157 OP_NUMNOTEQUAL = 0x9e, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
158 OP_LESSTHAN = 0x9f, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
159 OP_GREATERTHAN = 0xa0, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
160 OP_LESSTHANOREQUAL = 0xa1, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
161 OP_GREATERTHANOREQUAL = 0xa2, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
162 OP_MIN = 0xa3, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
163 OP_MAX = 0xa4, |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
164 |
2295
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
165 OP_WITHIN = 0xa5, |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
166 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
167 // crypto |
2295
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
168 OP_RIPEMD160 = 0xa6, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
169 OP_SHA1 = 0xa7, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
170 OP_SHA256 = 0xa8, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
171 OP_HASH160 = 0xa9, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
172 OP_HASH256 = 0xaa, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
173 OP_CODESEPARATOR = 0xab, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
174 OP_CHECKSIG = 0xac, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
175 OP_CHECKSIGVERIFY = 0xad, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
176 OP_CHECKMULTISIG = 0xae, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
177 OP_CHECKMULTISIGVERIFY = 0xaf, |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
178 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
179 // expansion |
2295
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
180 OP_NOP1 = 0xb0, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
181 OP_NOP2 = 0xb1, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
182 OP_NOP3 = 0xb2, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
183 OP_NOP4 = 0xb3, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
184 OP_NOP5 = 0xb4, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
185 OP_NOP6 = 0xb5, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
186 OP_NOP7 = 0xb6, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
187 OP_NOP8 = 0xb7, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
188 OP_NOP9 = 0xb8, |
42dca4320696
Add explicit numeric constant value for all opcodes
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
2286
diff
changeset
|
189 OP_NOP10 = 0xb9, |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
190 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
191 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
192 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
193 // template matching params |
1600
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
194 OP_SMALLINTEGER = 0xfa, |
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
195 OP_PUBKEYS = 0xfb, |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
196 OP_PUBKEYHASH = 0xfd, |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
197 OP_PUBKEY = 0xfe, |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
198 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
199 OP_INVALIDOPCODE = 0xff, |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
200 }; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
201 |
1600
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
202 const char* GetOpName(opcodetype opcode); |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
203 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
204 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
205 |
595
e630bbb11629
make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
575
diff
changeset
|
206 inline std::string ValueString(const std::vector<unsigned char>& vch) |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
207 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
208 if (vch.size() <= 4) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
209 return strprintf("%d", CBigNum(vch).getint()); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
210 else |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
211 return HexStr(vch); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
212 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
213 |
595
e630bbb11629
make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
575
diff
changeset
|
214 inline std::string StackString(const std::vector<std::vector<unsigned char> >& vStack) |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
215 { |
595
e630bbb11629
make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
575
diff
changeset
|
216 std::string str; |
e630bbb11629
make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
575
diff
changeset
|
217 BOOST_FOREACH(const std::vector<unsigned char>& vch, vStack) |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
218 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
219 if (!str.empty()) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
220 str += " "; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
221 str += ValueString(vch); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
222 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
223 return str; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
224 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
225 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
226 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
227 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
228 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
229 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
230 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
231 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
232 |
2096
ee92c87e9cb6
Begin doxygen-compatible comments
Pieter Wuille <pieter.wuille@gmail.com>
parents:
1818
diff
changeset
|
233 /** Serialized script, used inside transaction inputs and outputs */ |
595
e630bbb11629
make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
575
diff
changeset
|
234 class CScript : public std::vector<unsigned char> |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
235 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
236 protected: |
1616
997b708d15b8
Revert "Use standard C99 (and Qt) types for 64-bit integers"
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
1615
diff
changeset
|
237 CScript& push_int64(int64 n) |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
238 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
239 if (n == -1 || (n >= 1 && n <= 16)) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
240 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
241 push_back(n + (OP_1 - 1)); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
242 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
243 else |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
244 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
245 CBigNum bn(n); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
246 *this << bn.getvch(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
247 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
248 return *this; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
249 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
250 |
1616
997b708d15b8
Revert "Use standard C99 (and Qt) types for 64-bit integers"
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
1615
diff
changeset
|
251 CScript& push_uint64(uint64 n) |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
252 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
253 if (n >= 1 && n <= 16) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
254 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
255 push_back(n + (OP_1 - 1)); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
256 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
257 else |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
258 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
259 CBigNum bn(n); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
260 *this << bn.getvch(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
261 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
262 return *this; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
263 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
264 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
265 public: |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
266 CScript() { } |
595
e630bbb11629
make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
575
diff
changeset
|
267 CScript(const CScript& b) : std::vector<unsigned char>(b.begin(), b.end()) { } |
e630bbb11629
make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
575
diff
changeset
|
268 CScript(const_iterator pbegin, const_iterator pend) : std::vector<unsigned char>(pbegin, pend) { } |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
269 #ifndef _MSC_VER |
595
e630bbb11629
make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
575
diff
changeset
|
270 CScript(const unsigned char* pbegin, const unsigned char* pend) : std::vector<unsigned char>(pbegin, pend) { } |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
271 #endif |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
272 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
273 CScript& operator+=(const CScript& b) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
274 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
275 insert(end(), b.begin(), b.end()); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
276 return *this; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
277 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
278 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
279 friend CScript operator+(const CScript& a, const CScript& b) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
280 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
281 CScript ret = a; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
282 ret += b; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
283 return ret; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
284 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
285 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
286 |
2286
a25079d308ca
Fix bugs on 'unsigned char' platforms.
Dwayne C. Litzenberger <dlitz@dlitz.net>
parents:
2096
diff
changeset
|
287 //explicit CScript(char b) is not portable. Use 'signed char' or 'unsigned char'. |
a25079d308ca
Fix bugs on 'unsigned char' platforms.
Dwayne C. Litzenberger <dlitz@dlitz.net>
parents:
2096
diff
changeset
|
288 explicit CScript(signed char b) { operator<<(b); } |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
289 explicit CScript(short b) { operator<<(b); } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
290 explicit CScript(int b) { operator<<(b); } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
291 explicit CScript(long b) { operator<<(b); } |
1616
997b708d15b8
Revert "Use standard C99 (and Qt) types for 64-bit integers"
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
1615
diff
changeset
|
292 explicit CScript(int64 b) { operator<<(b); } |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
293 explicit CScript(unsigned char b) { operator<<(b); } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
294 explicit CScript(unsigned int b) { operator<<(b); } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
295 explicit CScript(unsigned short b) { operator<<(b); } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
296 explicit CScript(unsigned long b) { operator<<(b); } |
1616
997b708d15b8
Revert "Use standard C99 (and Qt) types for 64-bit integers"
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
1615
diff
changeset
|
297 explicit CScript(uint64 b) { operator<<(b); } |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
298 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
299 explicit CScript(opcodetype b) { operator<<(b); } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
300 explicit CScript(const uint256& b) { operator<<(b); } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
301 explicit CScript(const CBigNum& b) { operator<<(b); } |
595
e630bbb11629
make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
575
diff
changeset
|
302 explicit CScript(const std::vector<unsigned char>& b) { operator<<(b); } |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
303 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
304 |
2286
a25079d308ca
Fix bugs on 'unsigned char' platforms.
Dwayne C. Litzenberger <dlitz@dlitz.net>
parents:
2096
diff
changeset
|
305 //CScript& operator<<(char b) is not portable. Use 'signed char' or 'unsigned char'. |
a25079d308ca
Fix bugs on 'unsigned char' platforms.
Dwayne C. Litzenberger <dlitz@dlitz.net>
parents:
2096
diff
changeset
|
306 CScript& operator<<(signed char b) { return push_int64(b); } |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
307 CScript& operator<<(short b) { return push_int64(b); } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
308 CScript& operator<<(int b) { return push_int64(b); } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
309 CScript& operator<<(long b) { return push_int64(b); } |
1616
997b708d15b8
Revert "Use standard C99 (and Qt) types for 64-bit integers"
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
1615
diff
changeset
|
310 CScript& operator<<(int64 b) { return push_int64(b); } |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
311 CScript& operator<<(unsigned char b) { return push_uint64(b); } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
312 CScript& operator<<(unsigned int b) { return push_uint64(b); } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
313 CScript& operator<<(unsigned short b) { return push_uint64(b); } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
314 CScript& operator<<(unsigned long b) { return push_uint64(b); } |
1616
997b708d15b8
Revert "Use standard C99 (and Qt) types for 64-bit integers"
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
1615
diff
changeset
|
315 CScript& operator<<(uint64 b) { return push_uint64(b); } |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
316 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
317 CScript& operator<<(opcodetype opcode) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
318 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
319 if (opcode < 0 || opcode > 0xff) |
595
e630bbb11629
make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
575
diff
changeset
|
320 throw std::runtime_error("CScript::operator<<() : invalid opcode"); |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
321 insert(end(), (unsigned char)opcode); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
322 return *this; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
323 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
324 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
325 CScript& operator<<(const uint160& b) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
326 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
327 insert(end(), sizeof(b)); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
328 insert(end(), (unsigned char*)&b, (unsigned char*)&b + sizeof(b)); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
329 return *this; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
330 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
331 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
332 CScript& operator<<(const uint256& b) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
333 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
334 insert(end(), sizeof(b)); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
335 insert(end(), (unsigned char*)&b, (unsigned char*)&b + sizeof(b)); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
336 return *this; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
337 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
338 |
2687
2cca172f83a9
Encapsulate public keys in CPubKey
Pieter Wuille <pieter.wuille@gmail.com>
parents:
2607
diff
changeset
|
339 CScript& operator<<(const CPubKey& key) |
2cca172f83a9
Encapsulate public keys in CPubKey
Pieter Wuille <pieter.wuille@gmail.com>
parents:
2607
diff
changeset
|
340 { |
2cca172f83a9
Encapsulate public keys in CPubKey
Pieter Wuille <pieter.wuille@gmail.com>
parents:
2607
diff
changeset
|
341 std::vector<unsigned char> vchKey = key.Raw(); |
2cca172f83a9
Encapsulate public keys in CPubKey
Pieter Wuille <pieter.wuille@gmail.com>
parents:
2607
diff
changeset
|
342 return (*this) << vchKey; |
2cca172f83a9
Encapsulate public keys in CPubKey
Pieter Wuille <pieter.wuille@gmail.com>
parents:
2607
diff
changeset
|
343 } |
2cca172f83a9
Encapsulate public keys in CPubKey
Pieter Wuille <pieter.wuille@gmail.com>
parents:
2607
diff
changeset
|
344 |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
345 CScript& operator<<(const CBigNum& b) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
346 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
347 *this << b.getvch(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
348 return *this; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
349 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
350 |
595
e630bbb11629
make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
575
diff
changeset
|
351 CScript& operator<<(const std::vector<unsigned char>& b) |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
352 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
353 if (b.size() < OP_PUSHDATA1) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
354 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
355 insert(end(), (unsigned char)b.size()); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
356 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
357 else if (b.size() <= 0xff) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
358 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
359 insert(end(), OP_PUSHDATA1); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
360 insert(end(), (unsigned char)b.size()); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
361 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
362 else if (b.size() <= 0xffff) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
363 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
364 insert(end(), OP_PUSHDATA2); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
365 unsigned short nSize = b.size(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
366 insert(end(), (unsigned char*)&nSize, (unsigned char*)&nSize + sizeof(nSize)); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
367 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
368 else |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
369 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
370 insert(end(), OP_PUSHDATA4); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
371 unsigned int nSize = b.size(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
372 insert(end(), (unsigned char*)&nSize, (unsigned char*)&nSize + sizeof(nSize)); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
373 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
374 insert(end(), b.begin(), b.end()); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
375 return *this; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
376 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
377 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
378 CScript& operator<<(const CScript& b) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
379 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
380 // I'm not sure if this should push the script or concatenate scripts. |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
381 // If there's ever a use for pushing a script onto a script, delete this member fn |
3270
ed27f924d951
Update Warning-strings to use a standard-format
Philip Kaufmann <phil.kaufmann@t-online.de>
parents:
3154
diff
changeset
|
382 assert(!"Warning: Pushing a CScript onto a CScript with << is probably not intended, use + to concatenate!"); |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
383 return *this; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
384 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
385 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
386 |
595
e630bbb11629
make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
575
diff
changeset
|
387 bool GetOp(iterator& pc, opcodetype& opcodeRet, std::vector<unsigned char>& vchRet) |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
388 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
389 // Wrapper so it can be called with either iterator or const_iterator |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
390 const_iterator pc2 = pc; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
391 bool fRet = GetOp2(pc2, opcodeRet, &vchRet); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
392 pc = begin() + (pc2 - begin()); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
393 return fRet; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
394 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
395 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
396 bool GetOp(iterator& pc, opcodetype& opcodeRet) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
397 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
398 const_iterator pc2 = pc; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
399 bool fRet = GetOp2(pc2, opcodeRet, NULL); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
400 pc = begin() + (pc2 - begin()); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
401 return fRet; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
402 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
403 |
595
e630bbb11629
make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
575
diff
changeset
|
404 bool GetOp(const_iterator& pc, opcodetype& opcodeRet, std::vector<unsigned char>& vchRet) const |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
405 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
406 return GetOp2(pc, opcodeRet, &vchRet); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
407 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
408 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
409 bool GetOp(const_iterator& pc, opcodetype& opcodeRet) const |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
410 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
411 return GetOp2(pc, opcodeRet, NULL); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
412 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
413 |
595
e630bbb11629
make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
575
diff
changeset
|
414 bool GetOp2(const_iterator& pc, opcodetype& opcodeRet, std::vector<unsigned char>* pvchRet) const |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
415 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
416 opcodeRet = OP_INVALIDOPCODE; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
417 if (pvchRet) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
418 pvchRet->clear(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
419 if (pc >= end()) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
420 return false; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
421 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
422 // Read instruction |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
423 if (end() - pc < 1) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
424 return false; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
425 unsigned int opcode = *pc++; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
426 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
427 // Immediate operand |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
428 if (opcode <= OP_PUSHDATA4) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
429 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
430 unsigned int nSize; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
431 if (opcode < OP_PUSHDATA1) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
432 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
433 nSize = opcode; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
434 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
435 else if (opcode == OP_PUSHDATA1) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
436 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
437 if (end() - pc < 1) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
438 return false; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
439 nSize = *pc++; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
440 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
441 else if (opcode == OP_PUSHDATA2) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
442 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
443 if (end() - pc < 2) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
444 return false; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
445 nSize = 0; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
446 memcpy(&nSize, &pc[0], 2); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
447 pc += 2; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
448 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
449 else if (opcode == OP_PUSHDATA4) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
450 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
451 if (end() - pc < 4) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
452 return false; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
453 memcpy(&nSize, &pc[0], 4); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
454 pc += 4; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
455 } |
3134
39f1cfa4a739
Fix signed/unsigned warnings in {script,serialize}.h (fixes #1541)
Matt Corallo <matt@bluematt.me>
parents:
2688
diff
changeset
|
456 if (end() - pc < 0 || (unsigned int)(end() - pc) < nSize) |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
457 return false; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
458 if (pvchRet) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
459 pvchRet->assign(pc, pc + nSize); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
460 pc += nSize; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
461 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
462 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
463 opcodeRet = (opcodetype)opcode; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
464 return true; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
465 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
466 |
1600
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
467 // Encode/decode small integers: |
1598
057a59e89d51
Support 3 new multisignature IsStandard transactions
Gavin Andresen <gavinandresen@gmail.com>
parents:
1264
diff
changeset
|
468 static int DecodeOP_N(opcodetype opcode) |
057a59e89d51
Support 3 new multisignature IsStandard transactions
Gavin Andresen <gavinandresen@gmail.com>
parents:
1264
diff
changeset
|
469 { |
057a59e89d51
Support 3 new multisignature IsStandard transactions
Gavin Andresen <gavinandresen@gmail.com>
parents:
1264
diff
changeset
|
470 if (opcode == OP_0) |
057a59e89d51
Support 3 new multisignature IsStandard transactions
Gavin Andresen <gavinandresen@gmail.com>
parents:
1264
diff
changeset
|
471 return 0; |
057a59e89d51
Support 3 new multisignature IsStandard transactions
Gavin Andresen <gavinandresen@gmail.com>
parents:
1264
diff
changeset
|
472 assert(opcode >= OP_1 && opcode <= OP_16); |
057a59e89d51
Support 3 new multisignature IsStandard transactions
Gavin Andresen <gavinandresen@gmail.com>
parents:
1264
diff
changeset
|
473 return (int)opcode - (int)(OP_1 - 1); |
057a59e89d51
Support 3 new multisignature IsStandard transactions
Gavin Andresen <gavinandresen@gmail.com>
parents:
1264
diff
changeset
|
474 } |
1600
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
475 static opcodetype EncodeOP_N(int n) |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
476 { |
1600
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
477 assert(n >= 0 && n <= 16); |
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
478 if (n == 0) |
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
479 return OP_0; |
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
480 return (opcodetype)(OP_1+n-1); |
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
481 } |
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
482 |
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
483 int FindAndDelete(const CScript& b) |
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
484 { |
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
485 int nFound = 0; |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
486 if (b.empty()) |
1600
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
487 return nFound; |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
488 iterator pc = begin(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
489 opcodetype opcode; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
490 do |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
491 { |
2311
20e40ae0d404
Add casts for unavoidable signed/unsigned comparisons
Jeff Garzik <jgarzik@exmulti.com>
parents:
2309
diff
changeset
|
492 while (end() - pc >= (long)b.size() && memcmp(&pc[0], &b[0], b.size()) == 0) |
1600
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
493 { |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
494 erase(pc, pc + b.size()); |
1600
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
495 ++nFound; |
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
496 } |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
497 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
498 while (GetOp(pc, opcode)); |
1600
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
499 return nFound; |
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
500 } |
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
501 int Find(opcodetype op) const |
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
502 { |
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
503 int nFound = 0; |
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
504 opcodetype opcode; |
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
505 for (const_iterator pc = begin(); pc != end() && GetOp(pc, opcode);) |
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
506 if (opcode == op) |
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
507 ++nFound; |
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
508 return nFound; |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
509 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
510 |
1752
7b4383bddf3b
Replace OP_EVAL (BIP 12) with Pay-to-script-hash (BIP 16).
Gavin Andresen <gavinandresen@gmail.com>
parents:
1751
diff
changeset
|
511 // Pre-version-0.6, Bitcoin always counted CHECKMULTISIGs |
7b4383bddf3b
Replace OP_EVAL (BIP 12) with Pay-to-script-hash (BIP 16).
Gavin Andresen <gavinandresen@gmail.com>
parents:
1751
diff
changeset
|
512 // as 20 sigops. With pay-to-script-hash, that changed: |
7b4383bddf3b
Replace OP_EVAL (BIP 12) with Pay-to-script-hash (BIP 16).
Gavin Andresen <gavinandresen@gmail.com>
parents:
1751
diff
changeset
|
513 // CHECKMULTISIGs serialized in scriptSigs are |
7b4383bddf3b
Replace OP_EVAL (BIP 12) with Pay-to-script-hash (BIP 16).
Gavin Andresen <gavinandresen@gmail.com>
parents:
1751
diff
changeset
|
514 // counted more accurately, assuming they are of the form |
7b4383bddf3b
Replace OP_EVAL (BIP 12) with Pay-to-script-hash (BIP 16).
Gavin Andresen <gavinandresen@gmail.com>
parents:
1751
diff
changeset
|
515 // ... OP_N CHECKMULTISIG ... |
2309
ce4d0278e085
SigOp and orphan-tx constants and counts are always unsigned.
Jeff Garzik <jeff@garzik.org>
parents:
2295
diff
changeset
|
516 unsigned int GetSigOpCount(bool fAccurate) const; |
1752
7b4383bddf3b
Replace OP_EVAL (BIP 12) with Pay-to-script-hash (BIP 16).
Gavin Andresen <gavinandresen@gmail.com>
parents:
1751
diff
changeset
|
517 |
7b4383bddf3b
Replace OP_EVAL (BIP 12) with Pay-to-script-hash (BIP 16).
Gavin Andresen <gavinandresen@gmail.com>
parents:
1751
diff
changeset
|
518 // Accurately count sigOps, including sigOps in |
7b4383bddf3b
Replace OP_EVAL (BIP 12) with Pay-to-script-hash (BIP 16).
Gavin Andresen <gavinandresen@gmail.com>
parents:
1751
diff
changeset
|
519 // pay-to-script-hash transactions: |
2309
ce4d0278e085
SigOp and orphan-tx constants and counts are always unsigned.
Jeff Garzik <jeff@garzik.org>
parents:
2295
diff
changeset
|
520 unsigned int GetSigOpCount(const CScript& scriptSig) const; |
1752
7b4383bddf3b
Replace OP_EVAL (BIP 12) with Pay-to-script-hash (BIP 16).
Gavin Andresen <gavinandresen@gmail.com>
parents:
1751
diff
changeset
|
521 |
7b4383bddf3b
Replace OP_EVAL (BIP 12) with Pay-to-script-hash (BIP 16).
Gavin Andresen <gavinandresen@gmail.com>
parents:
1751
diff
changeset
|
522 bool IsPayToScriptHash() const; |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
523 |
1600
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
524 // Called by CTransaction::IsStandard |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
525 bool IsPushOnly() const |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
526 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
527 const_iterator pc = begin(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
528 while (pc < end()) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
529 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
530 opcodetype opcode; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
531 if (!GetOp(pc, opcode)) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
532 return false; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
533 if (opcode > OP_16) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
534 return false; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
535 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
536 return true; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
537 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
538 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
539 |
2688
2c65e5d626eb
Refactor: split CKeyID/CScriptID/CTxDestination from CBitcoinAddress
Pieter Wuille <pieter.wuille@gmail.com>
parents:
2687
diff
changeset
|
540 void SetDestination(const CTxDestination& address); |
1600
dc663e46a784
OP_EVAL implementation
Gavin Andresen <gavinandresen@gmail.com>
parents:
1598
diff
changeset
|
541 void SetMultisig(int nRequired, const std::vector<CKey>& keys); |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
542 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
543 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
544 void PrintHex() const |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
545 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
546 printf("CScript(%s)\n", HexStr(begin(), end(), true).c_str()); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
547 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
548 |
595
e630bbb11629
make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
575
diff
changeset
|
549 std::string ToString() const |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
550 { |
595
e630bbb11629
make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
575
diff
changeset
|
551 std::string str; |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
552 opcodetype opcode; |
595
e630bbb11629
make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
575
diff
changeset
|
553 std::vector<unsigned char> vch; |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
554 const_iterator pc = begin(); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
555 while (pc < end()) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
556 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
557 if (!str.empty()) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
558 str += " "; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
559 if (!GetOp(pc, opcode, vch)) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
560 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
561 str += "[error]"; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
562 return str; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
563 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
564 if (0 <= opcode && opcode <= OP_PUSHDATA4) |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
565 str += ValueString(vch); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
566 else |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
567 str += GetOpName(opcode); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
568 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
569 return str; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
570 } |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
571 |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
572 void print() const |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
573 { |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
574 printf("%s\n", ToString().c_str()); |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
575 } |
2688
2c65e5d626eb
Refactor: split CKeyID/CScriptID/CTxDestination from CBitcoinAddress
Pieter Wuille <pieter.wuille@gmail.com>
parents:
2687
diff
changeset
|
576 |
2c65e5d626eb
Refactor: split CKeyID/CScriptID/CTxDestination from CBitcoinAddress
Pieter Wuille <pieter.wuille@gmail.com>
parents:
2687
diff
changeset
|
577 CScriptID GetID() const |
2c65e5d626eb
Refactor: split CKeyID/CScriptID/CTxDestination from CBitcoinAddress
Pieter Wuille <pieter.wuille@gmail.com>
parents:
2687
diff
changeset
|
578 { |
2c65e5d626eb
Refactor: split CKeyID/CScriptID/CTxDestination from CBitcoinAddress
Pieter Wuille <pieter.wuille@gmail.com>
parents:
2687
diff
changeset
|
579 return CScriptID(Hash160(*this)); |
2c65e5d626eb
Refactor: split CKeyID/CScriptID/CTxDestination from CBitcoinAddress
Pieter Wuille <pieter.wuille@gmail.com>
parents:
2687
diff
changeset
|
580 } |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
581 }; |
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
582 |
3641
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
583 /** Compact serializer for scripts. |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
584 * |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
585 * It detects common cases and encodes them much more efficiently. |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
586 * 3 special cases are defined: |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
587 * * Pay to pubkey hash (encoded as 21 bytes) |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
588 * * Pay to script hash (encoded as 21 bytes) |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
589 * * Pay to pubkey starting with 0x02, 0x03 or 0x04 (encoded as 33 bytes) |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
590 * |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
591 * Other scripts up to 121 bytes require 1 byte + script length. Above |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
592 * that, scripts up to 16505 bytes require 2 bytes + script length. |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
593 */ |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
594 class CScriptCompressor |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
595 { |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
596 private: |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
597 // make this static for now (there are only 6 special scripts defined) |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
598 // this can potentially be extended together with a new nVersion for |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
599 // transactions, in which case this value becomes dependent on nVersion |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
600 // and nHeight of the enclosing transaction. |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
601 static const unsigned int nSpecialScripts = 6; |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
602 |
3641
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
603 CScript &script; |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
604 protected: |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
605 // These check for scripts for which a special case with a shorter encoding is defined. |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
606 // They are implemented separately from the CScript test, as these test for exact byte |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
607 // sequence correspondences, and are more strict. For example, IsToPubKey also verifies |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
608 // whether the public key is valid (as invalid ones cannot be represented in compressed |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
609 // form). |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
610 bool IsToKeyID(CKeyID &hash) const; |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
611 bool IsToScriptID(CScriptID &hash) const; |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
612 bool IsToPubKey(std::vector<unsigned char> &pubkey) const; |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
613 |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
614 bool Compress(std::vector<unsigned char> &out) const; |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
615 unsigned int GetSpecialSize(unsigned int nSize) const; |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
616 bool Decompress(unsigned int nSize, const std::vector<unsigned char> &out); |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
617 public: |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
618 CScriptCompressor(CScript &scriptIn) : script(scriptIn) { } |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
619 |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
620 unsigned int GetSerializeSize(int nType, int nVersion) const { |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
621 std::vector<unsigned char> compr; |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
622 if (Compress(compr)) |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
623 return compr.size(); |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
624 unsigned int nSize = script.size() + nSpecialScripts; |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
625 return script.size() + VARINT(nSize).GetSerializeSize(nType, nVersion); |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
626 } |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
627 |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
628 template<typename Stream> |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
629 void Serialize(Stream &s, int nType, int nVersion) const { |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
630 std::vector<unsigned char> compr; |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
631 if (Compress(compr)) { |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
632 s << CFlatData(&compr[0], &compr[compr.size()]); |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
633 return; |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
634 } |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
635 unsigned int nSize = script.size() + nSpecialScripts; |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
636 s << VARINT(nSize); |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
637 s << CFlatData(&script[0], &script[script.size()]); |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
638 } |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
639 |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
640 template<typename Stream> |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
641 void Unserialize(Stream &s, int nType, int nVersion) { |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
642 unsigned int nSize; |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
643 s >> VARINT(nSize); |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
644 if (nSize < nSpecialScripts) { |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
645 std::vector<unsigned char> vch(GetSpecialSize(nSize), 0x00); |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
646 s >> REF(CFlatData(&vch[0], &vch[vch.size()])); |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
647 Decompress(nSize, vch); |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
648 return; |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
649 } |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
650 nSize -= nSpecialScripts; |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
651 script.resize(nSize); |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
652 s >> REF(CFlatData(&script[0], &script[script.size()])); |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
653 } |
d489f6576318
Compact serialization for scripts
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3520
diff
changeset
|
654 }; |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
655 |
3520
ce8540bec751
Check for canonical public keys and signatures
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3270
diff
changeset
|
656 bool IsCanonicalPubKey(const std::vector<unsigned char> &vchPubKey); |
ce8540bec751
Check for canonical public keys and signatures
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3270
diff
changeset
|
657 bool IsCanonicalSignature(const std::vector<unsigned char> &vchSig); |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
658 |
3520
ce8540bec751
Check for canonical public keys and signatures
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3270
diff
changeset
|
659 bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript& script, const CTransaction& txTo, unsigned int nIn, bool fStrictEncodings, int nHashType); |
1604
2d635cbb6a2d
Use block times for 'hard' OP_EVAL switchover, and refactored EvalScript
Gavin Andresen <gavinandresen@gmail.com>
parents:
1600
diff
changeset
|
660 bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<std::vector<unsigned char> >& vSolutionsRet); |
1769
73e4f1828765
Make transactions with extra data in their scriptSig's non-standard.
Gavin Andresen <gavinandresen@gmail.com>
parents:
1752
diff
changeset
|
661 int ScriptSigArgsExpected(txnouttype t, const std::vector<std::vector<unsigned char> >& vSolutions); |
575
1a0476fe825f
directory re-organization (keeps the old build system)
Jaromil <jaromil@dyne.org>
parents:
diff
changeset
|
662 bool IsStandard(const CScript& scriptPubKey); |
690 | 663 bool IsMine(const CKeyStore& keystore, const CScript& scriptPubKey); |
2688
2c65e5d626eb
Refactor: split CKeyID/CScriptID/CTxDestination from CBitcoinAddress
Pieter Wuille <pieter.wuille@gmail.com>
parents:
2687
diff
changeset
|
664 bool IsMine(const CKeyStore& keystore, const CTxDestination &dest); |
2c65e5d626eb
Refactor: split CKeyID/CScriptID/CTxDestination from CBitcoinAddress
Pieter Wuille <pieter.wuille@gmail.com>
parents:
2687
diff
changeset
|
665 bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet); |
2c65e5d626eb
Refactor: split CKeyID/CScriptID/CTxDestination from CBitcoinAddress
Pieter Wuille <pieter.wuille@gmail.com>
parents:
2687
diff
changeset
|
666 bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<CTxDestination>& addressRet, int& nRequiredRet); |
3152
bf716647e542
Refactor: SignSignature/VerifyScript
Gavin Andresen <gavinandresen@gmail.com>
parents:
3134
diff
changeset
|
667 bool SignSignature(const CKeyStore& keystore, const CScript& fromPubKey, CTransaction& txTo, unsigned int nIn, int nHashType=SIGHASH_ALL); |
1751
ec000d0b853b
Remove not-used-anywhere scriptPrereq from SignSignature()
Gavin Andresen <gavinandresen@gmail.com>
parents:
1618
diff
changeset
|
668 bool SignSignature(const CKeyStore& keystore, const CTransaction& txFrom, CTransaction& txTo, unsigned int nIn, int nHashType=SIGHASH_ALL); |
3152
bf716647e542
Refactor: SignSignature/VerifyScript
Gavin Andresen <gavinandresen@gmail.com>
parents:
3134
diff
changeset
|
669 bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn, |
3520
ce8540bec751
Check for canonical public keys and signatures
Pieter Wuille <pieter.wuille@gmail.com>
parents:
3270
diff
changeset
|
670 bool fValidatePayToScriptHash, bool fStrictEncodings, int nHashType); |
3649 | 671 bool VerifySignature(const CCoins& txFrom, const CTransaction& txTo, unsigned int nIn, bool fValidatePayToScriptHash, bool fStrictEncodings, int nHashType); |
595
e630bbb11629
make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
575
diff
changeset
|
672 |
3154
6c1eeeb7e4c2
Implement raw transaction RPC calls
Gavin Andresen <gavinandresen@gmail.com>
parents:
3152
diff
changeset
|
673 // Given two sets of signatures for scriptPubKey, possibly with OP_0 placeholders, |
6c1eeeb7e4c2
Implement raw transaction RPC calls
Gavin Andresen <gavinandresen@gmail.com>
parents:
3152
diff
changeset
|
674 // combine them intelligently and return the result. |
6c1eeeb7e4c2
Implement raw transaction RPC calls
Gavin Andresen <gavinandresen@gmail.com>
parents:
3152
diff
changeset
|
675 CScript CombineSignatures(CScript scriptPubKey, const CTransaction& txTo, unsigned int nIn, const CScript& scriptSig1, const CScript& scriptSig2); |
6c1eeeb7e4c2
Implement raw transaction RPC calls
Gavin Andresen <gavinandresen@gmail.com>
parents:
3152
diff
changeset
|
676 |
595
e630bbb11629
make bitcoin include files more modular
Wladimir J. van der Laan <laanwj@gmail.com>
parents:
575
diff
changeset
|
677 #endif |