diff -Nru libbitcoin0-1.0.10+nmu1/0001-Added-missing-build-dependency-automake.patch libbitcoin0-1.0.10+nmu2/0001-Added-missing-build-dependency-automake.patch --- libbitcoin0-1.0.10+nmu1/0001-Added-missing-build-dependency-automake.patch 1970-01-01 00:00:00.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/0001-Added-missing-build-dependency-automake.patch 2013-10-06 16:31:31.000000000 +0000 @@ -0,0 +1,29 @@ +From aba753a569f99d1ce17928f1d5cfe92577f52611 Mon Sep 17 00:00:00 2001 +From: Pablo Castellano +Date: Sun, 6 Oct 2013 13:57:40 +0200 +Subject: [PATCH] Added missing build-dependency automake + +Build for PPA: +$ dpkg-buildpackage -S -rfakeroot -k463F919C +or +$ debuild -S -k463F919C +--- + debian/control | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/debian/control b/debian/control +index b93415f..1d09fd1 100644 +--- a/debian/control ++++ b/debian/control +@@ -2,7 +2,7 @@ Source: libbitcoin0 + Section: libs + Priority: optional + Maintainer: Pablo Castellano +-Build-Depends: debhelper (>= 8.1.3~), pkg-config, autoconf, autotools-dev, libtool, libboost-all-dev, libdb++-dev, libcurl4-openssl-dev, libleveldb-dev ++Build-Depends: debhelper (>= 8.1.3~), pkg-config, autoconf, automake, autotools-dev, libtool, libboost-all-dev, libdb++-dev, libcurl4-openssl-dev, libleveldb-dev + Standards-Version: 3.9.4 + Vcs-Git: https://github.com/spesmilo/libbitcoin.git + Vcs-Browser: https://github.com/spesmilo/libbitcoin +-- +1.8.1.2 + diff -Nru libbitcoin0-1.0.10+nmu1/LICENSE libbitcoin0-1.0.10+nmu2/LICENSE --- libbitcoin0-1.0.10+nmu1/LICENSE 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/LICENSE 2013-12-13 00:01:54.000000000 +0000 @@ -21,6 +21,13 @@ Additional permission under the GNU Affero GPL version 3 section 7: +If the covered work has no means of communicating an offer to provide +Corresponding Source to the users interacting with it remotely over a +computer network, then you may comply with this requirement by making +the Corresponding Source for your version available for anyone to copy, +free of charge and under the terms of this License, through a publicly +available network server or other readily accessible means. + If you modify this Program, or any covered work, by linking or combining it with other code, such other code is not for that reason alone subject to any of the requirements of the GNU Affero GPL @@ -405,13 +412,6 @@ additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. - If the covered work has no means of communicating an offer to provide -Corresponding Source to the users interacting with it remotely over a -computer network, then you may comply with this requirement by making -the Corresponding Source for your version available for anyone to copy, -free of charge and under the terms of this License, through a publicly -available network server or other readily accessible means. - Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: diff -Nru libbitcoin0-1.0.10+nmu1/LICENSE.1 libbitcoin0-1.0.10+nmu2/LICENSE.1 --- libbitcoin0-1.0.10+nmu1/LICENSE.1 1970-01-01 00:00:00.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/LICENSE.1 2013-11-17 10:54:09.000000000 +0000 @@ -0,0 +1,662 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. + diff -Nru libbitcoin0-1.0.10+nmu1/Makefile.am libbitcoin0-1.0.10+nmu2/Makefile.am --- libbitcoin0-1.0.10+nmu1/Makefile.am 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/Makefile.am 2013-12-12 22:10:31.000000000 +0000 @@ -31,8 +31,6 @@ # doc/sphinx/examples/display-last.rst \ # doc/sphinx/examples/proto.rst -bin_SCRIPTS = bin/download-blockchain.sh - pkgconfig_DATA = libbitcoin.pc SUBDIRS = include/bitcoin src diff -Nru libbitcoin0-1.0.10+nmu1/Makefile.in libbitcoin0-1.0.10+nmu2/Makefile.in --- libbitcoin0-1.0.10+nmu1/Makefile.in 2013-10-06 10:32:01.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/Makefile.in 2013-12-13 00:02:42.000000000 +0000 @@ -15,7 +15,6 @@ @SET_MAKE@ - VPATH = @srcdir@ am__make_dryrun = \ { \ @@ -72,6 +71,26 @@ mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = libbitcoin.pc CONFIG_CLEAN_VPATH_FILES = +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +SOURCES = +DIST_SOURCES = +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-dvi-recursive install-exec-recursive \ + install-html-recursive install-info-recursive \ + install-pdf-recursive install-ps-recursive install-recursive \ + installcheck-recursive installdirs-recursive pdf-recursive \ + ps-recursive uninstall-recursive +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ @@ -99,23 +118,7 @@ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } -am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(docdir)" \ - "$(DESTDIR)$(pkgconfigdir)" -SCRIPTS = $(bin_SCRIPTS) -SOURCES = -DIST_SOURCES = -RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ - html-recursive info-recursive install-data-recursive \ - install-dvi-recursive install-exec-recursive \ - install-html-recursive install-info-recursive \ - install-pdf-recursive install-ps-recursive install-recursive \ - installcheck-recursive installdirs-recursive pdf-recursive \ - ps-recursive uninstall-recursive -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac +am__installdirs = "$(DESTDIR)$(docdir)" "$(DESTDIR)$(pkgconfigdir)" DATA = $(doc_DATA) $(pkgconfig_DATA) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive @@ -167,6 +170,8 @@ distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ +AM_CXXFLAGS = @AM_CXXFLAGS@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ @@ -282,7 +287,6 @@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ -my_CXXFLAGS = @my_CXXFLAGS@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgconfigdir = @pkgconfigdir@ @@ -329,7 +333,6 @@ # doc/sphinx/examples/fullnode.rst \ # doc/sphinx/examples/display-last.rst \ # doc/sphinx/examples/proto.rst -bin_SCRIPTS = bin/download-blockchain.sh pkgconfig_DATA = libbitcoin.pc SUBDIRS = include/bitcoin src ACLOCAL_AMFLAGS = -I m4 @@ -372,41 +375,6 @@ $(am__aclocal_m4_deps): libbitcoin.pc: $(top_builddir)/config.status $(srcdir)/libbitcoin.pc.in cd $(top_builddir) && $(SHELL) ./config.status $@ -install-binSCRIPTS: $(bin_SCRIPTS) - @$(NORMAL_INSTALL) - @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ - fi; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \ - done | \ - sed -e 'p;s,.*/,,;n' \ - -e 'h;s|.*|.|' \ - -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \ - $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \ - { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ - if ($$2 == $$4) { files[d] = files[d] " " $$1; \ - if (++n[d] == $(am__install_max)) { \ - print "f", d, files[d]; n[d] = 0; files[d] = "" } } \ - else { print "f", d "/" $$4, $$1 } } \ - END { for (d in files) print "f", d, files[d] }' | \ - while read type dir files; do \ - if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ - test -z "$$files" || { \ - echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(bindir)$$dir'"; \ - $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ - } \ - ; done - -uninstall-binSCRIPTS: - @$(NORMAL_UNINSTALL) - @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || exit 0; \ - files=`for p in $$list; do echo "$$p"; done | \ - sed -e 's,.*/,,;$(transform)'`; \ - dir='$(DESTDIR)$(bindir)'; $(am__uninstall_files_from_dir) mostlyclean-libtool: -rm -f *.lo @@ -783,10 +751,10 @@ exit 1; } >&2 check-am: all-am check: check-recursive -all-am: Makefile $(SCRIPTS) $(DATA) +all-am: Makefile $(DATA) installdirs: installdirs-recursive installdirs-am: - for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(docdir)" "$(DESTDIR)$(pkgconfigdir)"; do \ + for dir in "$(DESTDIR)$(docdir)" "$(DESTDIR)$(pkgconfigdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-recursive @@ -847,7 +815,7 @@ install-dvi-am: -install-exec-am: install-binSCRIPTS +install-exec-am: install-html: install-html-recursive @@ -887,8 +855,7 @@ ps-am: -uninstall-am: uninstall-binSCRIPTS uninstall-docDATA \ - uninstall-pkgconfigDATA +uninstall-am: uninstall-docDATA uninstall-pkgconfigDATA .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \ install-am install-strip tags-recursive @@ -900,16 +867,16 @@ dist-zip distcheck distclean distclean-generic \ distclean-libtool distclean-tags distcleancheck distdir \ distuninstallcheck dvi dvi-am html html-am info info-am \ - install install-am install-binSCRIPTS install-data \ - install-data-am install-docDATA install-dvi install-dvi-am \ - install-exec install-exec-am install-html install-html-am \ - install-info install-info-am install-man install-pdf \ - install-pdf-am install-pkgconfigDATA install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - installdirs-am maintainer-clean maintainer-clean-generic \ - mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ - ps ps-am tags tags-recursive uninstall uninstall-am \ - uninstall-binSCRIPTS uninstall-docDATA uninstall-pkgconfigDATA + install install-am install-data install-data-am \ + install-docDATA install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-pkgconfigDATA install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs installdirs-am \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags tags-recursive uninstall uninstall-am uninstall-docDATA \ + uninstall-pkgconfigDATA # Tell versions [3.59,3.63) of GNU make to not export all variables. diff -Nru libbitcoin0-1.0.10+nmu1/README libbitcoin0-1.0.10+nmu2/README --- libbitcoin0-1.0.10+nmu1/README 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/README 2013-12-13 00:29:16.000000000 +0000 @@ -8,11 +8,13 @@ Debian/Ubuntu Instructions ========================== +Note that you need g++ 4.7 or higher. For this reason Ubuntu 12.04 and older are not supported. + VVVVVVVVVVV > Start Here! < ^^^^^^^^^^^ - $ sudo apt-get install build-essential autoconf libtool libboost-all-dev pkg-config libcurl4-openssl-dev libleveldb-dev + $ sudo apt-get install build-essential autoconf automake libtool libboost-all-dev pkg-config libcurl4-openssl-dev libleveldb-dev $ autoreconf -i $ ./configure --enable-leveldb $ make @@ -63,6 +65,10 @@ export LD_LIBRARY_PATH=~/usr/lib/ export PKG_CONFIG_PATH=~/usr/lib/pkgconfig/ +'./configure' also accepts the following flags: + --enable-testnet (enables the alternative blockchain used for testing) + --enable-debug (verbose output) + Compile/Build Flags ------------------- diff -Nru libbitcoin0-1.0.10+nmu1/aclocal.m4 libbitcoin0-1.0.10+nmu2/aclocal.m4 --- libbitcoin0-1.0.10+nmu1/aclocal.m4 2013-10-06 10:32:00.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/aclocal.m4 2013-12-13 00:02:41.000000000 +0000 @@ -1044,6 +1044,63 @@ fi AC_MSG_RESULT(yes)]) +# Copyright (C) 2009, 2011 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 2 + +# AM_SILENT_RULES([DEFAULT]) +# -------------------------- +# Enable less verbose build rules; with the default set to DEFAULT +# (`yes' being less verbose, `no' or empty being verbose). +AC_DEFUN([AM_SILENT_RULES], +[AC_ARG_ENABLE([silent-rules], +[ --enable-silent-rules less verbose build output (undo: `make V=1') + --disable-silent-rules verbose build output (undo: `make V=0')]) +case $enable_silent_rules in +yes) AM_DEFAULT_VERBOSITY=0;; +no) AM_DEFAULT_VERBOSITY=1;; +*) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; +esac +dnl +dnl A few `make' implementations (e.g., NonStop OS and NextStep) +dnl do not support nested variable expansions. +dnl See automake bug#9928 and bug#10237. +am_make=${MAKE-make} +AC_CACHE_CHECK([whether $am_make supports nested variables], + [am_cv_make_support_nested_variables], + [if AS_ECHO([['TRUE=$(BAR$(V)) +BAR0=false +BAR1=true +V=1 +am__doit: + @$(TRUE) +.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then + am_cv_make_support_nested_variables=yes +else + am_cv_make_support_nested_variables=no +fi]) +if test $am_cv_make_support_nested_variables = yes; then + dnl Using `$V' instead of `$(V)' breaks IRIX make. + AM_V='$(V)' + AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' +else + AM_V=$AM_DEFAULT_VERBOSITY + AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY +fi +AC_SUBST([AM_V])dnl +AM_SUBST_NOTMAKE([AM_V])dnl +AC_SUBST([AM_DEFAULT_V])dnl +AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl +AC_SUBST([AM_DEFAULT_VERBOSITY])dnl +AM_BACKSLASH='\' +AC_SUBST([AM_BACKSLASH])dnl +_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl +]) + # Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation diff -Nru libbitcoin0-1.0.10+nmu1/bin/download-blockchain.sh libbitcoin0-1.0.10+nmu2/bin/download-blockchain.sh --- libbitcoin0-1.0.10+nmu1/bin/download-blockchain.sh 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/bin/download-blockchain.sh 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -#!/bin/bash -# If you know a better download method, then please let me know. -# You can also use http too: -# wget http://46.4.92.107/blockchain.tar.bz2 -if [ $# -ne 1 ]; then - echo "Usage: `basename $0` DOWNLOAD_DIRECTORY" - exit $E_BADARGS -fi -echo "Type 'public' at the password prompt." -COMMAND="rsync -avz public@46.4.92.107:/var/www/blockchain/ $1/blockchain/" -echo "> $COMMAND" -$COMMAND - diff -Nru libbitcoin0-1.0.10+nmu1/bin/tests/scrjson.py libbitcoin0-1.0.10+nmu2/bin/tests/scrjson.py --- libbitcoin0-1.0.10+nmu1/bin/tests/scrjson.py 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/bin/tests/scrjson.py 2013-12-13 00:01:54.000000000 +0000 @@ -1,10 +1,38 @@ +#!/usr/bin/env python +# +# Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) +# +# This file is part of libbitcoin. +# +# libbitcoin is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License with +# additional permissions to the one published by the Free Software +# Foundation, either version 3 of the License, or (at your option) +# any later version. For more information see LICENSE. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# import json import os import sys +import subprocess -bpath = "/home/genjix/src/bitcoin/src/test/data/" +bpath = "/path/to/bitcoind/src/test/data/" +# Try valid or invalid json? +check_valid = False -with open(bpath + "script_valid.json") as f: +def call(command): + return subprocess.call(command, shell=True) + +json_path = "script_valid.json" if check_valid else "script_invalid.json" + +with open(bpath + json_path) as f: tests = json.loads(f.read()) prefix_path = os.path.dirname(sys.argv[0]) @@ -16,12 +44,15 @@ print "====", (counter + 1), "of", len(tests), "====" test = (test[0], test[1], test[2] if len(test) == 3 else "") arguments = '"%s" "%s" "%s"' % test - retcode = os.system(scritp + " " + arguments) - success = bool(int(open("/tmp/script_status").read())) + retcode = call(scritp + " " + arguments) + success = bool(retcode == 0) if success: print "Status: pass" else: print (counter + 1), "Status: fail", test - assert success + if check_valid: + assert success + else: + assert not success print diff -Nru libbitcoin0-1.0.10+nmu1/configure libbitcoin0-1.0.10+nmu2/configure --- libbitcoin0-1.0.10+nmu1/configure 2013-10-06 11:27:46.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/configure 2013-12-13 00:03:14.000000000 +0000 @@ -640,7 +640,7 @@ CURL_CFLAGS SSL_LIBS SSL_CFLAGS -my_CXXFLAGS +AM_CXXFLAGS CFLAG_LEVELDB LDFLAG_LEVELDB PKG_CONFIG_LIBDIR @@ -648,10 +648,12 @@ PKG_CONFIG BOOST_LDFLAGS BOOST_CPPFLAGS -DEBUG_FALSE -DEBUG_TRUE DO_LEVELDB_FALSE DO_LEVELDB_TRUE +AM_BACKSLASH +AM_DEFAULT_VERBOSITY +AM_DEFAULT_V +AM_V HAVE_CXX11 CXXCPP OTOOL64 @@ -779,8 +781,8 @@ with_gnu_ld with_sysroot enable_libtool_lock +enable_silent_rules enable_leveldb -enable_debug enable_testnet with_boost with_boost_libdir @@ -1431,8 +1433,9 @@ --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) + --enable-silent-rules less verbose build output (undo: `make V=1') + --disable-silent-rules verbose build output (undo: `make V=0') --enable-leveldb Build LevelDB support. - --enable-debug Turn on debugging --enable-testnet Enable testnet Optional Packages: @@ -15658,6 +15661,7 @@ + ax_cxx_compile_cxx11_required=truednl ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' @@ -15780,7 +15784,46 @@ fi -#CXXFLAGS="-Wall -Wno-unused-parameter -pedantic -pthread -Wextra -fstack-protector-all" + +# Check whether --enable-silent-rules was given. +if test "${enable_silent_rules+set}" = set; then : + enableval=$enable_silent_rules; +fi + +case $enable_silent_rules in +yes) AM_DEFAULT_VERBOSITY=0;; +no) AM_DEFAULT_VERBOSITY=1;; +*) AM_DEFAULT_VERBOSITY=0;; +esac +am_make=${MAKE-make} +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 +$as_echo_n "checking whether $am_make supports nested variables... " >&6; } +if ${am_cv_make_support_nested_variables+:} false; then : + $as_echo_n "(cached) " >&6 +else + if $as_echo 'TRUE=$(BAR$(V)) +BAR0=false +BAR1=true +V=1 +am__doit: + @$(TRUE) +.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then + am_cv_make_support_nested_variables=yes +else + am_cv_make_support_nested_variables=no +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 +$as_echo "$am_cv_make_support_nested_variables" >&6; } +if test $am_cv_make_support_nested_variables = yes; then + AM_V='$(V)' + AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' +else + AM_V=$AM_DEFAULT_VERBOSITY + AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY +fi +AM_BACKSLASH='\' + # Check whether --enable-leveldb was given. if test "${enable_leveldb+set}" = set; then : @@ -15798,26 +15841,6 @@ fi -# Check whether --enable-debug was given. -if test "${enable_debug+set}" = set; then : - enableval=$enable_debug; case "${enableval}" in - yes) debug=true ;; - no) debug=false ;; - *) as_fn_error $? "bad value ${enableval} for --enable-debug" "$LINENO" 5 ;; -esac -else - debug=false -fi - - if test x$debug = xtrue; then - DEBUG_TRUE= - DEBUG_FALSE='#' -else - DEBUG_TRUE='#' - DEBUG_FALSE= -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking --enable-testnet argument" >&5 $as_echo_n "checking --enable-testnet argument... " >&6; } # Check whether --enable-testnet was given. @@ -16230,10 +16253,8 @@ CFLAG_LEVELDB="-DLEVELDB_ENABLED" fi -if test x$debug = xtrue; then - my_CXXFLAGS="-g3 -DDEBUG" +AM_CXXFLAGS="-ggdb -g3 -Wall -Wno-missing-braces -pedantic -Wextra -fstack-protector-all -DDEBUG" -fi pkg_failed=no @@ -16603,10 +16624,6 @@ as_fn_error $? "conditional \"DO_LEVELDB\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${DEBUG_TRUE}" && test -z "${DEBUG_FALSE}"; then - as_fn_error $? "conditional \"DEBUG\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 diff -Nru libbitcoin0-1.0.10+nmu1/configure.ac libbitcoin0-1.0.10+nmu2/configure.ac --- libbitcoin0-1.0.10+nmu1/configure.ac 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/configure.ac 2013-12-12 22:10:31.000000000 +0000 @@ -7,9 +7,11 @@ AM_PROG_AR LT_INIT AC_PROG_CXX +AC_PROG_LIBTOOL AC_GNU_SOURCE AX_CXX_COMPILE_STDCXX_11(noext,mandatory) -#CXXFLAGS="-Wall -Wno-unused-parameter -pedantic -pthread -Wextra -fstack-protector-all" + +m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) AC_ARG_ENABLE(leveldb, [AC_HELP_STRING([--enable-leveldb], @@ -17,15 +19,6 @@ [bld_leveldb="$enable_leveldb"], [bld_leveldb="no"]) AM_CONDITIONAL([DO_LEVELDB], [test "$enable_leveldb" = "yes"]) -AC_ARG_ENABLE([debug], -[ --enable-debug Turn on debugging], -[case "${enableval}" in - yes) debug=true ;; - no) debug=false ;; - *) AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;; -esac],[debug=false]) -AM_CONDITIONAL([DEBUG], [test x$debug = xtrue]) - AC_MSG_CHECKING(--enable-testnet argument) AC_ARG_ENABLE(testnet, [ --enable-testnet Enable testnet], @@ -49,10 +42,8 @@ CFLAG_LEVELDB="-DLEVELDB_ENABLED" fi -if test x$debug = xtrue; then - my_CXXFLAGS="-g3 -DDEBUG" - AC_SUBST([my_CXXFLAGS]) -fi +AM_CXXFLAGS="-ggdb -g3 -Wall -Wno-missing-braces -pedantic -Wextra -fstack-protector-all -DDEBUG" +AC_SUBST([AM_CXXFLAGS]) PKG_CHECK_MODULES([SSL], [libssl >= 0.9]) PKG_CHECK_MODULES([CURL], [libcurl]) diff -Nru libbitcoin0-1.0.10+nmu1/cosos.txt libbitcoin0-1.0.10+nmu2/cosos.txt --- libbitcoin0-1.0.10+nmu1/cosos.txt 1970-01-01 00:00:00.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/cosos.txt 2013-12-13 10:56:02.000000000 +0000 @@ -0,0 +1,113 @@ +hay LICENSE y COPYING +Añadir cabeceras (licensecheck) +Añadirme como contributor +Vale la licencia esa con cláusula que dice en README para Debian? pq es? +-dev debe incluir doc también? +binary debe incluir .a y .la? + +LICENSE says +This license applies to all works under this directory. + +$ git log | grep "^Author" | sort | uniq -c + 276 Author: Amir Taaki + 499 Author: genjix + 7 Author: genjix + 9 Author: genjix + 4 Author: Jan Engelhardt + 32 Author: Kamil Domanski + 26 Author: phantomcircuit + +git log | grep "^Author: Kamil" -B 1 | grep "^commit" +git log | grep "^Author: Kamil" -B 1 | grep "^commit" | awk '{print $2}' +git show $(git log | grep "^Author: Kamil" -B 1 | grep "^commit" | awk '{print $2}') + +git show $(git log|grep "^Author: Jan" -B 1|grep "^commit"|awk '{print $2}') | grep '+++' | sort | uniq -c +git show $(git log|grep "^Author: Kamil" -B 1|grep "^commit"|awk '{print $2}') | grep '+++' | sort | uniq -c +git show $(git log|grep "^Author: phantomcircuit" -B 1|grep "^commit"|awk '{print $2}') | grep '+++' | sort | uniq -c +git show $(git log|grep "^Author: [genjix|Amir]" -B 1|grep "^commit"|awk '{print $2}') | grep '+++' | sort | uniq -c + +License users per file or something like see AUTHORS / libbitcoin developers / Bitcoin Consultancy ? + +La libreria va en +/usr/lib/x86_64-linux-gnu/libbitcoin.so.0 +o en +/usr/lib/libbitcoin.so.0 +? + +Faltan includes y muchos tests no compilan: +for i in `ls *cpp`; do echo $i; g++ $i `pkg-config --cflags --libs libbitcoin`; done +for i in `ls *cpp`; do echo $i; g++ -o $i.out $i `pkg-config --cflags --libs libbitcoin`; done + + +./priv sign 123o1l3k12hj312h3j12pepepe < key111 +priv: /usr/include/bitcoin/format.hpp:84: HashType libbitcoin::decode_hex_digest(std::string) [with HashType = std::array; std::string = std::basic_string]: Assertion `raw_bytes.size() == result.size()' failed. +Abortado (`core' generado) + +./fullnode me dice: +ERROR: Error storing memory pool transaction 6454c3957d23057fe909143967fa12b792f2a3ce191c9cc4b7686e9f15a1be77: Spent input not found +ERROR: Error storing memory pool transaction edbde6264e856d0d637101183a043c1e6ddffa722dbdf944b3fcb71259e9fa84: Spent input not found +ERROR: Error storing memory pool transaction 59af12d1db638c33fd2863a3b623309d81431135f91d1f3c7dfff42e81a75d96: Spent input not found +ERROR: Error storing memory pool transaction 35c0446f15d45491c81b3f36a349d768300775240aad16dfb5f01388c38c54fb: Spent input not found +ERROR: Error storing memory pool transaction 8adb41bcded4006137d6b38ecc3f64be0741478ececde994a28f2ee33290d5db: Spent input not found +ERROR: Error storing memory pool transaction 8e3ad0bf3357d263335be665973c52280215866e731d4b97ae70423514e478b3: Spent input not found +ERROR: Error storing memory pool transaction 515656b9930b8085b4ca5bed0e95778e8ce5761924f26b5d649cbe93d3d8ca5c: Spent input not found +ERROR: Error storing memory pool transaction 5e7ee43c9fd66ea50eda081d3ce03d24200b467257cebeddb49b25e398666a1d: Spent input not found + + +No se puede compilar con -j2 :( + +Que es LT_VERSION de Makefile? (no tiene, libcaca0 sí) + +-- +$ sudo dpkg -i libbitcoin-dev_1.0.10+nmu1_amd64.deb +[sudo] password for pablo: +Seleccionando el paquete libbitcoin-dev previamente no seleccionado. +(Leyendo la base de datos ... 224470 ficheros o directorios instalados actualmente.) +Desempaquetando libbitcoin-dev (de libbitcoin-dev_1.0.10+nmu1_amd64.deb) ... +dpkg: problemas de dependencias impiden la configuración de libbitcoin-dev: + libbitcoin-dev depende de libbitcoin (= 1.0.10+nmu1); sin embargo: + El paquete `libbitcoin' no está instalado. + +dpkg: error al procesar libbitcoin-dev (--install): + problemas de dependencias - se deja sin configurar +Se encontraron errores al procesar: + libbitcoin-dev + + +Header: + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + + +------------------ +17-11-2013 + +dh_install --sourcedir=debian/tmp --list-missing +dh_install: usr/lib/x86_64-linux-gnu/libbitcoin.la exists in debian/tmp but is not installed to anywhere +dh_install: usr/share/doc/libbitcoin/COPYING exists in debian/tmp but is not installed to anywhere +dh_install: usr/share/doc/libbitcoin/README.tutorial exists in debian/tmp but is not installed to anywhere +dh_install: usr/share/doc/libbitcoin/INSTALL exists in debian/tmp but is not installed to anywhere +dh_install: usr/share/doc/libbitcoin/README exists in debian/tmp but is not installed to anywhere + + +--- +PPA + +debuild -S -k463F919C +rm *.upload +dput ppa:pablocastellano/libbitcoin0/ppa libbitcoin0_1.0.10+nmu1_source.changes + diff -Nru libbitcoin0-1.0.10+nmu1/debian/changelog libbitcoin0-1.0.10+nmu2/debian/changelog --- libbitcoin0-1.0.10+nmu1/debian/changelog 2013-10-06 11:11:51.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/debian/changelog 2013-12-13 23:24:33.000000000 +0000 @@ -1,4 +1,4 @@ -libbitcoin0 (1.0.10+nmu1) raring; urgency=low +libbitcoin0 (1.0.10+nmu2) raring; urgency=low * Non-maintainer upload. * Initial release. diff -Nru libbitcoin0-1.0.10+nmu1/debian/control libbitcoin0-1.0.10+nmu2/debian/control --- libbitcoin0-1.0.10+nmu1/debian/control 2013-10-06 11:57:29.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/debian/control 2013-12-13 00:01:57.000000000 +0000 @@ -12,7 +12,7 @@ Section: libdevel Architecture: any Depends: libbitcoin0 (= ${binary:Version}), ${misc:Depends} -Description: development files for libbitcoin +Description: Asynchronous C++ Bitcoin library - development files libbitcoin is a bitcoin library targeted towards high end use. The library places a heavy focus around asychronicity. This enables a big scope for future scalability as each component has its own thread pool. @@ -34,7 +34,7 @@ Pre-Depends: ${misc:Pre-Depends} Depends: ${shlibs:Depends}, ${misc:Depends} Multi-Arch: same -Description: bitcoin library +Description: Asynchronous C++ Bitcoin library libbitcoin is a bitcoin library targeted towards high end use. The library places a heavy focus around asychronicity. This enables a big scope for future scalability as each component has its own thread pool. diff -Nru libbitcoin0-1.0.10+nmu1/debian/copyright libbitcoin0-1.0.10+nmu2/debian/copyright --- libbitcoin0-1.0.10+nmu1/debian/copyright 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/debian/copyright 2013-12-13 10:32:09.000000000 +0000 @@ -8,7 +8,10 @@ 2011 Jan Engelhardt (se7) 2011 Patrick Strateman (phantomcircuit) License: AGPL3 - Note that this is AGPLv3 with an extra clause + Note that this is AGPLv3 with additional permissions. + . + For more information, see: + Files: debian/* Copyright: 2013 Pablo Castellano diff -Nru libbitcoin0-1.0.10+nmu1/debian/libbitcoin-dev.install libbitcoin0-1.0.10+nmu2/debian/libbitcoin-dev.install --- libbitcoin0-1.0.10+nmu1/debian/libbitcoin-dev.install 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/debian/libbitcoin-dev.install 2013-12-13 10:16:57.000000000 +0000 @@ -1,8 +1,8 @@ usr/include/bitcoin/*.hpp usr/include/bitcoin/blockchain/*.hpp -usr/include/bitcoin/network/*.hpp usr/include/bitcoin/impl/serialize/*.ipp +usr/include/bitcoin/network/*.hpp usr/include/bitcoin/utility/*.hpp -usr/lib/*/lib*.so usr/lib/*/lib*.a +usr/lib/*/lib*.so usr/lib/*/pkgconfig/*.pc diff -Nru libbitcoin0-1.0.10+nmu1/debian_build.txt libbitcoin0-1.0.10+nmu2/debian_build.txt --- libbitcoin0-1.0.10+nmu1/debian_build.txt 1970-01-01 00:00:00.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/debian_build.txt 2013-08-31 20:29:47.000000000 +0000 @@ -0,0 +1,38 @@ +dh_install --sourcedir=debian/tmp --list-missing +dh_install: usr/lib/x86_64-linux-gnu/libbitcoin.la exists in debian/tmp but is not installed to anywhere +dh_install: usr/include/bitcoin/impl/serialize/misc.ipp exists in debian/tmp but is not installed to anywhere +dh_install: usr/include/bitcoin/impl/serialize/block.ipp exists in debian/tmp but is not installed to anywhere +dh_install: usr/bin/download-blockchain.sh exists in debian/tmp but is not installed to anywhere +dh_install: usr/share/doc/libbitcoin/COPYING exists in debian/tmp but is not installed to anywhere +dh_install: usr/share/doc/libbitcoin/README.tutorial exists in debian/tmp but is not installed to anywhere +dh_install: usr/share/doc/libbitcoin/INSTALL exists in debian/tmp but is not installed to anywhere +dh_install: usr/share/doc/libbitcoin/README exists in debian/tmp but is not installed to anywhere +dh_testdir +dh_testroot +dh_installdocs -p libbitcoin-dev -A README AUTHORS NEWS +dh_installdocs -p libbitcoin +dh_installmenu +dh_installcron +dh_installinfo +dh_installmime +dh_installchangelogs -p libbitcoin-dev ChangeLog +dh_installchangelogs -p libbitcoin ChangeLog +dh_link +dh_strip +dh_compress +dh_fixperms +dh_makeshlibs -p libbitcoin -V 'libbitcoin' +dh_installdeb +dh_shlibdeps -L libbitcoin -l debian/libbitcoin/usr/lib/x86_64-linux-gnu/ -X /usr/lib/x86_64-linux-gnu/bitcoin/ +dpkg-shlibdeps: warning: symbol _ZN7leveldb10WriteBatchD1Ev used by debian/libbitcoin/usr/lib/x86_64-linux-gnu/libbitcoin.so.0.0.0 found in none of the libraries +dpkg-shlibdeps: warning: symbol EC_KEY_copy used by debian/libbitcoin/usr/lib/x86_64-linux-gnu/libbitcoin.so.0.0.0 found in none of the libraries +dpkg-shlibdeps: warning: symbol EC_KEY_generate_key used by debian/libbitcoin/usr/lib/x86_64-linux-gnu/libbitcoin.so.0.0.0 found in none of the libraries +dpkg-shlibdeps: warning: symbol _ZN7leveldb2DB4OpenERKNS_7OptionsERKSsPPS0_ used by debian/libbitcoin/usr/lib/x86_64-linux-gnu/libbitcoin.so.0.0.0 found in none of the libraries +dpkg-shlibdeps: warning: symbol BN_set_word used by debian/libbitcoin/usr/lib/x86_64-linux-gnu/libbitcoin.so.0.0.0 found in none of the libraries +dpkg-shlibdeps: warning: symbol _ZN7leveldb10WriteBatchC1Ev used by debian/libbitcoin/usr/lib/x86_64-linux-gnu/libbitcoin.so.0.0.0 found in none of the libraries +dpkg-shlibdeps: warning: symbol _ZN5boost11filesystem34pathdVERKS1_ used by debian/libbitcoin/usr/lib/x86_64-linux-gnu/libbitcoin.so.0.0.0 found in none of the libraries +dpkg-shlibdeps: warning: symbol BN_add used by debian/libbitcoin/usr/lib/x86_64-linux-gnu/libbitcoin.so.0.0.0 found in none of the libraries +dpkg-shlibdeps: warning: symbol _ZN5boost9re_detail14verify_optionsEjNS_15regex_constants12_match_flagsE used by debian/libbitcoin/usr/lib/x86_64-linux-gnu/libbitcoin.so.0.0.0 found in none of the libraries +dpkg-shlibdeps: warning: symbol BN_bin2bn used by debian/libbitcoin/usr/lib/x86_64-linux-gnu/libbitcoin.so.0.0.0 found in none of the libraries +dpkg-shlibdeps: warning: 82 other similar warnings have been skipped (use -v to see them all) + diff -Nru libbitcoin0-1.0.10+nmu1/doc/sphinx/blockchain.rst libbitcoin0-1.0.10+nmu2/doc/sphinx/blockchain.rst --- libbitcoin0-1.0.10+nmu1/doc/sphinx/blockchain.rst 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/doc/sphinx/blockchain.rst 2013-11-17 11:59:08.000000000 +0000 @@ -221,7 +221,7 @@ // Completion handler for when the blockchain has finished initializing. void blockchain_started(const std::error_code& ec); - // Fetch tbe last block now that we have the height. + // Fetch the last block now that we have the height. void height_fetched(const std::error_code& ec, size_t last_height); // Result: print the block header. void display_block_header(const std::error_code& ec, diff -Nru libbitcoin0-1.0.10+nmu1/doc/sphinx/crypto.rst libbitcoin0-1.0.10+nmu2/doc/sphinx/crypto.rst --- libbitcoin0-1.0.10+nmu1/doc/sphinx/crypto.rst 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/doc/sphinx/crypto.rst 2013-11-17 11:59:08.000000000 +0000 @@ -89,7 +89,7 @@ seed. Also, multiple devices could host the same wallet based off of the same seed and -automatically stay in sync with eachother. Non-critical information such as +automatically stay in sync with each other. Non-critical information such as address books would need to be stored and copied between wallets. libbitcoin implements the same compatible deterministic wallet algorithm as `Electrum `_. diff -Nru libbitcoin0-1.0.10+nmu1/doc/sphinx/examples/accept.rst libbitcoin0-1.0.10+nmu2/doc/sphinx/examples/accept.rst --- libbitcoin0-1.0.10+nmu1/doc/sphinx/examples/accept.rst 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/doc/sphinx/examples/accept.rst 2013-12-13 00:01:54.000000000 +0000 @@ -3,6 +3,8 @@ examples/accept.cpp ##################### +Accept connections from Bitcoin nodes on port 8333. + :: #include diff -Nru libbitcoin0-1.0.10+nmu1/doc/sphinx/examples/balance.rst libbitcoin0-1.0.10+nmu2/doc/sphinx/examples/balance.rst --- libbitcoin0-1.0.10+nmu1/doc/sphinx/examples/balance.rst 1970-01-01 00:00:00.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/doc/sphinx/examples/balance.rst 2013-12-13 00:01:54.000000000 +0000 @@ -0,0 +1,77 @@ +.. _examples_balance: + +examples/balance.cpp +##################### + +:: + + #include + using namespace bc; + + blockchain* c = nullptr; + std::string addr; + + void blockchain_started(const std::error_code& ec); + void history_fetched(const std::error_code& ec, + const blockchain::history_list& history); + + void blockchain_started(const std::error_code& ec) + { + if (ec) + { + log_error() << "Blockchain failed to start: " << ec.message(); + return; + } + log_info() << "Blockchain started."; + payment_address payaddr; + if (!payaddr.set_encoded(addr)) + { + log_fatal() << "Invalid address"; + return; + } + c->fetch_history(payaddr, history_fetched); + } + + void history_fetched(const std::error_code& ec, + const blockchain::history_list& history) + { + if (ec) + { + log_error() << "Failed to fetch history: " << ec.message(); + return; + } + #define LOG_RESULT "result" + uint64_t total_recv = 0, balance = 0; + for (const auto& row: history) + { + uint64_t value = row.value; + BITCOIN_ASSERT(value >= 0); + total_recv += value; + if (row.spend.hash == null_hash) + balance += value; + } + log_debug(LOG_RESULT) << "Queried " << history.size() + << " outpoints, values and their spends."; + log_debug(LOG_RESULT) << "Total received: " << total_recv; + log_debug(LOG_RESULT) << "Balance: " << balance; + log_info(LOG_RESULT) << "History fetched"; + } + + int main(int argc, char** argv) + { + if (argc != 2) + { + log_info() << "Usage: balance ADDRESS"; + return -1; + } + addr = argv[1]; + threadpool pool(1); + leveldb_blockchain chain(pool); + c = &chain; + chain.start("blockchain", blockchain_started); + pool.shutdown(); + pool.join(); + chain.stop(); + return 0; + } + diff -Nru libbitcoin0-1.0.10+nmu1/doc/sphinx/examples/connect.rst libbitcoin0-1.0.10+nmu2/doc/sphinx/examples/connect.rst --- libbitcoin0-1.0.10+nmu1/doc/sphinx/examples/connect.rst 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/doc/sphinx/examples/connect.rst 2013-12-13 00:01:54.000000000 +0000 @@ -3,6 +3,8 @@ examples/connect.cpp ##################### +Connect to a Bitcoin node on localhost, port 8333. + :: #include diff -Nru libbitcoin0-1.0.10+nmu1/doc/sphinx/examples/determ.rst libbitcoin0-1.0.10+nmu2/doc/sphinx/examples/determ.rst --- libbitcoin0-1.0.10+nmu1/doc/sphinx/examples/determ.rst 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/doc/sphinx/examples/determ.rst 2013-12-13 00:01:54.000000000 +0000 @@ -3,6 +3,8 @@ examples/determ.cpp ################### +Demonstration of deterministic wallet. + :: #include @@ -18,8 +20,7 @@ // Get an address from wallet... data_chunk pubkey = wallet.generate_public_key(2); payment_address addr; - if (!set_public_key(addr, pubkey)) - log_error() << "Error setting public key."; + set_public_key(addr, pubkey); assert(addr.encoded() == "1E4vM9q25xsyDwWwdqHUWnwshdWC9PykmL"); // ... Get the corresponding private key. diff -Nru libbitcoin0-1.0.10+nmu1/doc/sphinx/examples/display-last.rst libbitcoin0-1.0.10+nmu2/doc/sphinx/examples/display-last.rst --- libbitcoin0-1.0.10+nmu1/doc/sphinx/examples/display-last.rst 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/doc/sphinx/examples/display-last.rst 2013-12-13 00:01:54.000000000 +0000 @@ -3,26 +3,27 @@ examples/display-last.cpp ######################### -Fetches and displays info about the last block in a blockchain. +Display info from the last block in our blockchain at "./blockchain/" You will need to call initchain on the database first before using this. -Maybe even download a few blocks into the database. +Maybe even download a few blocks into the database. See the section on +the blockchain in the docs. :: #include using namespace bc; - + blockchain* chain = nullptr; - + // Completion handler for when the blockchain has finished initializing. void blockchain_started(const std::error_code& ec); - // Fetch tbe last block now that we have the height. + // Fetch the last block now that we have the height. void height_fetched(const std::error_code& ec, size_t last_height); // Result: print the block header. void display_block_header(const std::error_code& ec, const block_header_type& header); - + void blockchain_started(const std::error_code& ec) { // std::error_code's can be tested like bools, and @@ -40,7 +41,7 @@ // Begin fetching the last height number. chain->fetch_last_height(height_fetched); } - + void height_fetched(const std::error_code& ec, size_t last_height) { if (ec) @@ -54,7 +55,7 @@ // Begin fetching the block header. chain->fetch_block_header(last_height, display_block_header); } - + // This is not the full block, only the header. // For the full block use fetch_block() instead. void display_block_header(const std::error_code& ec, @@ -82,7 +83,7 @@ // A goodbye message. log_info() << "Finished."; } - + int main() { // Define a threadpool with 1 thread. @@ -92,14 +93,9 @@ // Initialize our global 'chain' pointer from above. chain = &ldb_chain; // Start the database using its implementation specific method. - ldb_chain.start("database", blockchain_started); - // Keep running until the user presses enter. - // Since libbitcoin is asynchronous, you need to synchronise with - // them to know when to exit safely. - // For these examples we just pause until enter for simplicity sake. - std::cin.get(); - // Begin stopping the threadpools in parallel (only 1 here). - pool.stop(); + ldb_chain.start("blockchain", blockchain_started); + // Don't wait after all current operations have completed. + pool.shutdown(); // Join them one by one. pool.join(); // Finally stop the blockchain safely now everything has stopped. diff -Nru libbitcoin0-1.0.10+nmu1/doc/sphinx/examples/fullnode.rst libbitcoin0-1.0.10+nmu2/doc/sphinx/examples/fullnode.rst --- libbitcoin0-1.0.10+nmu1/doc/sphinx/examples/fullnode.rst 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/doc/sphinx/examples/fullnode.rst 2013-12-13 00:01:54.000000000 +0000 @@ -3,6 +3,9 @@ examples/fullnode.cpp ##################### +Full node implementation. Expects the blockchain to be present in +"./blockchain/" and initialized using ./initchain + :: #include @@ -13,7 +16,7 @@ using std::placeholders::_2; using std::placeholders::_3; - void output_to_file(std::ofstream& file, log_level level, + void log_to_file(std::ofstream& file, log_level level, const std::string& domain, const std::string& body) { if (body.empty()) @@ -23,7 +26,7 @@ file << " [" << domain << "]"; file << ": " << body << std::endl; } - void output_cerr_and_file(std::ofstream& file, log_level level, + void log_to_both(std::ostream& device, std::ofstream& file, log_level level, const std::string& domain, const std::string& body) { if (body.empty()) @@ -33,7 +36,30 @@ if (!domain.empty()) output << " [" << domain << "]"; output << ": " << body; - std::cerr << output.str() << std::endl; + device << output.str() << std::endl; + file << output.str() << std::endl; + } + + void output_file(std::ofstream& file, log_level level, + const std::string& domain, const std::string& body) + { + log_to_file(file, level, domain, body); + } + void output_both(std::ofstream& file, log_level level, + const std::string& domain, const std::string& body) + { + log_to_both(std::cout, file, level, domain, body); + } + + void error_file(std::ofstream& file, log_level level, + const std::string& domain, const std::string& body) + { + log_to_file(file, level, domain, body); + } + void error_both(std::ofstream& file, log_level level, + const std::string& domain, const std::string& body) + { + log_to_both(std::cerr, file, level, domain, body); } class fullnode @@ -45,6 +71,9 @@ // It's an error to join() a thread from inside it. void stop(); + blockchain& chain(); + transaction_indexer& indexer(); + private: void handle_start(const std::error_code& ec); @@ -70,6 +99,7 @@ leveldb_blockchain chain_; poller poller_; transaction_pool txpool_; + transaction_indexer txidx_; // Mac OSX needs the bc:: namespace qualifier to compile. // Other systems should be OK. bc::session session_; @@ -85,7 +115,7 @@ // Blockchain database service. chain_(disk_pool_), // Poll new blocks, and transaction memory pool. - poller_(mem_pool_, chain_), txpool_(mem_pool_, chain_), + poller_(mem_pool_, chain_), txpool_(mem_pool_, chain_), txidx_(mem_pool_), // Session manager service. Convenience wrapper. session_(net_pool_, { handshake_, protocol_, chain_, poller_, txpool_}) @@ -99,14 +129,14 @@ std::bind(&fullnode::connection_started, this, _1, _2)); // Start blockchain. Must finish before any operations // are performed on the database (or they will fail). - std::promise ec_chain; + std::promise ec_promise; auto blockchain_started = - [&](const std::error_code& ec) + [&ec_promise](const std::error_code& ec) { - ec_chain.set_value(ec); + ec_promise.set_value(ec); }; - chain_.start("database", blockchain_started); - std::error_code ec = ec_chain.get_future().get(); + chain_.start("blockchain", blockchain_started); + std::error_code ec = ec_promise.get_future().get(); if (ec) { log_error() << "Problem starting blockchain: " << ec.message(); @@ -122,7 +152,16 @@ void fullnode::stop() { - session_.stop([](const std::error_code&) {}); + std::promise ec_promise; + auto session_stopped = + [&ec_promise](const std::error_code& ec) + { + ec_promise.set_value(ec); + }; + session_.stop(session_stopped); + std::error_code ec = ec_promise.get_future().get(); + if (ec) + log_error() << "Problem stopping session: " << ec.message(); // Stop threadpools. net_pool_.stop(); @@ -137,6 +176,15 @@ chain_.stop(); } + blockchain& fullnode::chain() + { + return chain_; + } + transaction_indexer& fullnode::indexer() + { + return txidx_; + } + void fullnode::handle_start(const std::error_code& ec) { if (ec) @@ -166,11 +214,21 @@ log_error() << "Receive transaction: " << ec.message(); return; } + auto handle_deindex = [](const std::error_code& ec) + { + if (ec) + log_error() << "Deindex error: " << ec.message(); + }; // Called when the transaction becomes confirmed in a block. - auto handle_confirm = [](const std::error_code& ec) + auto handle_confirm = [this, tx, handle_deindex]( + const std::error_code& ec) { + log_debug() << "handle_confirm ec = " << ec.message() + << " " << hash_transaction(tx); if (ec) - log_error() << "Confirm error: " << ec.message(); + log_error() << "Confirm error (" + << hash_transaction(tx) << "): " << ec.message(); + txidx_.deindex(tx, handle_deindex); }; // Validate the transaction from the network. // Attempt to store in the transaction pool and check the result. @@ -185,16 +243,21 @@ const std::error_code& ec, const index_list& unconfirmed, const transaction_type& tx) { + auto handle_index = [](const std::error_code& ec) + { + if (ec) + log_error() << "Index error: " << ec.message(); + }; const hash_digest& tx_hash = hash_transaction(tx); if (ec) { - log_error() + log_warning() << "Error storing memory pool transaction " << tx_hash << ": " << ec.message(); } else { - auto l = log_info(); + auto l = log_debug(); l << "Accepted transaction "; if (!unconfirmed.empty()) { @@ -204,6 +267,30 @@ l << ") "; } l << tx_hash; + txidx_.index(tx, handle_index); + } + } + + void history_fetched(const std::error_code& ec, + const blockchain::history_list& history) + { + if (ec) + { + log_error() << "Failed to fetch history: " << ec.message(); + return; + } + log_info() << "Query fine."; + for (const auto& row: history) + { + log_info() << "output: " << row.output + << " height: " << row.output_height; + log_info() << "value: " << row.value; + auto l = log_info(); + l << "spend: "; + if (row.spend.hash == null_hash) + l << "Unspent"; + else + l << row.spend << " height: " << row.spend_height; } } @@ -211,19 +298,33 @@ { std::ofstream outfile("debug.log"), errfile("error.log"); log_debug().set_output_function( - std::bind(output_to_file, std::ref(outfile), _1, _2, _3)); + std::bind(output_file, std::ref(outfile), _1, _2, _3)); log_info().set_output_function( - std::bind(output_to_file, std::ref(outfile), _1, _2, _3)); + std::bind(output_both, std::ref(outfile), _1, _2, _3)); log_warning().set_output_function( - std::bind(output_to_file, std::ref(errfile), _1, _2, _3)); + std::bind(error_file, std::ref(errfile), _1, _2, _3)); log_error().set_output_function( - std::bind(output_cerr_and_file, std::ref(errfile), _1, _2, _3)); + std::bind(error_both, std::ref(errfile), _1, _2, _3)); log_fatal().set_output_function( - std::bind(output_cerr_and_file, std::ref(errfile), _1, _2, _3)); + std::bind(error_both, std::ref(errfile), _1, _2, _3)); fullnode app; app.start(); - std::cin.get(); + while (true) + { + std::string addr; + std::getline(std::cin, addr); + if (addr == "stop") + break; + payment_address payaddr; + if (!payaddr.set_encoded(addr)) + { + log_error() << "Skipping invalid Bitcoin address."; + continue; + } + fetch_history(app.chain(), app.indexer(), + payaddr, history_fetched); + } app.stop(); return 0; diff -Nru libbitcoin0-1.0.10+nmu1/doc/sphinx/examples/initchain.rst libbitcoin0-1.0.10+nmu2/doc/sphinx/examples/initchain.rst --- libbitcoin0-1.0.10+nmu1/doc/sphinx/examples/initchain.rst 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/doc/sphinx/examples/initchain.rst 2013-12-13 00:01:54.000000000 +0000 @@ -3,6 +3,8 @@ examples/initchain.cpp ###################### +Create a new leveldb blockchain database. + :: #include @@ -43,7 +45,8 @@ log_error() << "Importing genesis block failed: " << ec.message(); return -1; } - log_info() << "Imported genesis block " << hash_block_header(first_block); + log_info() << "Imported genesis block " + << hash_block_header(first_block.header); // All threadpools stopping in parallel... pool.stop(); // ... Make them all join main thread and wait until they finish. diff -Nru libbitcoin0-1.0.10+nmu1/doc/sphinx/examples/priv.rst libbitcoin0-1.0.10+nmu2/doc/sphinx/examples/priv.rst --- libbitcoin0-1.0.10+nmu1/doc/sphinx/examples/priv.rst 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/doc/sphinx/examples/priv.rst 2013-12-13 00:01:54.000000000 +0000 @@ -3,11 +3,13 @@ examples/priv.cpp ################# +Demonstration of private keys. + :: #include #include - + #include using namespace bc; @@ -68,8 +70,7 @@ private_data(raw_private_key.begin(), raw_private_key.end()))) error_exit("bad private key"); payment_address address; - if (!set_public_key(address, ec.public_key())) - error_exit("set public key on address"); + set_public_key(address, ec.public_key()); log_info() << address.encoded(); return 0; } @@ -103,7 +104,7 @@ { if (number_args != 2) error_exit("verify requires argument data and signature"); - std::string input_data = argv[arg_index], + std::string input_data = argv[arg_index], signature = argv[arg_index + 1]; return verify(input_data, signature, read_private_key()); } diff -Nru libbitcoin0-1.0.10+nmu1/doc/sphinx/examples/proto.rst libbitcoin0-1.0.10+nmu2/doc/sphinx/examples/proto.rst --- libbitcoin0-1.0.10+nmu1/doc/sphinx/examples/proto.rst 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/doc/sphinx/examples/proto.rst 2013-12-13 00:01:54.000000000 +0000 @@ -3,6 +3,8 @@ examples/proto.cpp ##################### +Join the Bitcoin network. + :: #include diff -Nru libbitcoin0-1.0.10+nmu1/doc/sphinx/examples/satoshiwords.rst libbitcoin0-1.0.10+nmu2/doc/sphinx/examples/satoshiwords.rst --- libbitcoin0-1.0.10+nmu1/doc/sphinx/examples/satoshiwords.rst 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/doc/sphinx/examples/satoshiwords.rst 2013-12-13 00:01:54.000000000 +0000 @@ -3,6 +3,8 @@ examples/satoshiwords.cpp ######################### +Display the genesis block message by Satoshi. + :: #include diff -Nru libbitcoin0-1.0.10+nmu1/doc/sphinx/examples/txrad.rst libbitcoin0-1.0.10+nmu2/doc/sphinx/examples/txrad.rst --- libbitcoin0-1.0.10+nmu1/doc/sphinx/examples/txrad.rst 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/doc/sphinx/examples/txrad.rst 2013-12-13 00:01:54.000000000 +0000 @@ -3,6 +3,8 @@ examples/txrad.cpp ##################### +Transaction radar. + :: #include diff -Nru libbitcoin0-1.0.10+nmu1/doc/sphinx/introduction.rst libbitcoin0-1.0.10+nmu2/doc/sphinx/introduction.rst --- libbitcoin0-1.0.10+nmu1/doc/sphinx/introduction.rst 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/doc/sphinx/introduction.rst 2013-12-13 00:01:54.000000000 +0000 @@ -124,6 +124,8 @@ blank new database and adding the genesis block at height 0. * :ref:`display-last.cpp ` fetches and displays the last block in a blockchain database. +* :ref:`balance.cpp ` displays the balance of an address + passed in as a command line argument. * :ref:`satoshiwords.cpp ` displays the genesis block message from Satoshi. * :ref:`accept.cpp ` listens for connections on port 8333, diff -Nru libbitcoin0-1.0.10+nmu1/doc/sphinx/overview.rst libbitcoin0-1.0.10+nmu2/doc/sphinx/overview.rst --- libbitcoin0-1.0.10+nmu1/doc/sphinx/overview.rst 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/doc/sphinx/overview.rst 2013-12-12 22:10:31.000000000 +0000 @@ -29,7 +29,7 @@ to services and upon completion, your program will be notified. Services are self contained units and are locally encapsulated. They implement an interface for which various implementations may exist- the blockchain service has an -implementation for BerkeleyDB and LevelDB. +implementation for `LevelDB `_. There are two basic service actions in libbitcoin: @@ -122,13 +122,14 @@ // This blockchain service will submit work to disk_pool blockchain chain(disk_pool); // Completion handler. - auto blockchain_started = [](const std::error_code&) - { - // Check whether the status was successful. - if (ec) - log_error() << "Starting blockchain: " << ec.message(); - // ... do stuff - }; + auto blockchain_started = []( + const std::error_code&) + { + // Check whether the status was successful. + if (ec) + log_error() << "Starting blockchain: " << ec.message(); + // ... do stuff + }; // Invoke the call. Returns immediately. chain.start("database/", blockchain_started); diff -Nru libbitcoin0-1.0.10+nmu1/examples/Makefile libbitcoin0-1.0.10+nmu2/examples/Makefile --- libbitcoin0-1.0.10+nmu1/examples/Makefile 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/examples/Makefile 2013-11-17 11:59:08.000000000 +0000 @@ -71,3 +71,6 @@ all: balance priv determ initchain fullnode display-last satoshiwords connect accept proto txrad +clean: + rm -f accept balance connect determ display-last fullnode initchain priv proto satoshiwords txrad + rm -f *.o diff -Nru libbitcoin0-1.0.10+nmu1/examples/accept.cpp libbitcoin0-1.0.10+nmu2/examples/accept.cpp --- libbitcoin0-1.0.10+nmu1/examples/accept.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/examples/accept.cpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,4 +1,23 @@ /* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +/* Accept connections from Bitcoin nodes on port 8333. */ #include diff -Nru libbitcoin0-1.0.10+nmu1/examples/balance.cpp libbitcoin0-1.0.10+nmu2/examples/balance.cpp --- libbitcoin0-1.0.10+nmu1/examples/balance.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/examples/balance.cpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include using namespace bc; diff -Nru libbitcoin0-1.0.10+nmu1/examples/blocks.sh libbitcoin0-1.0.10+nmu2/examples/blocks.sh --- libbitcoin0-1.0.10+nmu1/examples/blocks.sh 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/examples/blocks.sh 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ #!/bin/bash +# +# Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) +# +# This file is part of libbitcoin. +# +# libbitcoin is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License with +# additional permissions to the one published by the Free Software +# Foundation, either version 3 of the License, or (at your option) +# any later version. For more information see LICENSE. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# watch -n 0.5 "grep Block debug.log | tail -n 20" diff -Nru libbitcoin0-1.0.10+nmu1/examples/connect.cpp libbitcoin0-1.0.10+nmu2/examples/connect.cpp --- libbitcoin0-1.0.10+nmu1/examples/connect.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/examples/connect.cpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,4 +1,23 @@ /* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +/* Connect to a Bitcoin node on localhost, port 8333. */ #include diff -Nru libbitcoin0-1.0.10+nmu1/examples/determ.cpp libbitcoin0-1.0.10+nmu2/examples/determ.cpp --- libbitcoin0-1.0.10+nmu1/examples/determ.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/examples/determ.cpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,4 +1,23 @@ /* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +/* Demonstration of deterministic wallet. */ #include diff -Nru libbitcoin0-1.0.10+nmu1/examples/display-last.cpp libbitcoin0-1.0.10+nmu2/examples/display-last.cpp --- libbitcoin0-1.0.10+nmu1/examples/display-last.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/examples/display-last.cpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,4 +1,23 @@ /* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +/* Display info from the last block in our blockchain at "./blockchain/" */ #include @@ -8,7 +27,7 @@ // Completion handler for when the blockchain has finished initializing. void blockchain_started(const std::error_code& ec); -// Fetch tbe last block now that we have the height. +// Fetch the last block now that we have the height. void height_fetched(const std::error_code& ec, size_t last_height); // Result: print the block header. void display_block_header(const std::error_code& ec, diff -Nru libbitcoin0-1.0.10+nmu1/examples/fullnode.cpp libbitcoin0-1.0.10+nmu2/examples/fullnode.cpp --- libbitcoin0-1.0.10+nmu1/examples/fullnode.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/examples/fullnode.cpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,4 +1,23 @@ /* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +/* Full node implementation. Expects the blockchain to be present in "./blockchain/" and initialized using ./initchain */ @@ -123,14 +142,14 @@ std::bind(&fullnode::connection_started, this, _1, _2)); // Start blockchain. Must finish before any operations // are performed on the database (or they will fail). - std::promise ec_chain; + std::promise ec_promise; auto blockchain_started = - [&](const std::error_code& ec) + [&ec_promise](const std::error_code& ec) { - ec_chain.set_value(ec); + ec_promise.set_value(ec); }; chain_.start("blockchain", blockchain_started); - std::error_code ec = ec_chain.get_future().get(); + std::error_code ec = ec_promise.get_future().get(); if (ec) { log_error() << "Problem starting blockchain: " << ec.message(); @@ -146,7 +165,16 @@ void fullnode::stop() { - session_.stop([](const std::error_code&) {}); + std::promise ec_promise; + auto session_stopped = + [&ec_promise](const std::error_code& ec) + { + ec_promise.set_value(ec); + }; + session_.stop(session_stopped); + std::error_code ec = ec_promise.get_future().get(); + if (ec) + log_error() << "Problem stopping session: " << ec.message(); // Stop threadpools. net_pool_.stop(); @@ -208,10 +236,12 @@ auto handle_confirm = [this, tx, handle_deindex]( const std::error_code& ec) { + log_debug() << "handle_confirm ec = " << ec.message() + << " " << hash_transaction(tx); if (ec) - log_error() << "Confirm error: " << ec.message(); - else - txidx_.deindex(tx, handle_deindex); + log_error() << "Confirm error (" + << hash_transaction(tx) << "): " << ec.message(); + txidx_.deindex(tx, handle_deindex); }; // Validate the transaction from the network. // Attempt to store in the transaction pool and check the result. diff -Nru libbitcoin0-1.0.10+nmu1/examples/initchain.cpp libbitcoin0-1.0.10+nmu2/examples/initchain.cpp --- libbitcoin0-1.0.10+nmu1/examples/initchain.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/examples/initchain.cpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,4 +1,23 @@ /* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +/* Create a new leveldb blockchain database. */ #include diff -Nru libbitcoin0-1.0.10+nmu1/examples/priv.cpp libbitcoin0-1.0.10+nmu2/examples/priv.cpp --- libbitcoin0-1.0.10+nmu1/examples/priv.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/examples/priv.cpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,4 +1,23 @@ /* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +/* Demonstration of private keys. */ #include diff -Nru libbitcoin0-1.0.10+nmu1/examples/proto.cpp libbitcoin0-1.0.10+nmu2/examples/proto.cpp --- libbitcoin0-1.0.10+nmu1/examples/proto.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/examples/proto.cpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,4 +1,23 @@ /* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +/* Join the Bitcoin network. */ #include diff -Nru libbitcoin0-1.0.10+nmu1/examples/satoshiwords.cpp libbitcoin0-1.0.10+nmu2/examples/satoshiwords.cpp --- libbitcoin0-1.0.10+nmu1/examples/satoshiwords.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/examples/satoshiwords.cpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,4 +1,23 @@ /* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +/* Display the genesis block message by Satoshi. */ #include diff -Nru libbitcoin0-1.0.10+nmu1/examples/txrad.cpp libbitcoin0-1.0.10+nmu2/examples/txrad.cpp --- libbitcoin0-1.0.10+nmu1/examples/txrad.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/examples/txrad.cpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,4 +1,23 @@ /* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +/* Transaction radar. */ #include diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/Makefile.am libbitcoin0-1.0.10+nmu2/include/bitcoin/Makefile.am --- libbitcoin0-1.0.10+nmu1/include/bitcoin/Makefile.am 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/Makefile.am 2013-12-13 00:01:54.000000000 +0000 @@ -2,7 +2,6 @@ bitcoin_include_HEADERS = \ transaction_indexer.hpp \ satoshi_serialize.hpp \ - deterministic_wallet.hpp \ getx_responder.hpp \ error.hpp \ validate.hpp \ @@ -47,6 +46,7 @@ bitcoin_util_includedir = $(includedir)/bitcoin/utility bitcoin_util_include_HEADERS = \ + utility/async_parallel.hpp \ utility/elliptic_curve_key.hpp \ utility/sha256.hpp \ utility/serializer.hpp \ @@ -58,5 +58,6 @@ utility/logger.hpp \ utility/weak_bind.hpp \ utility/key_formats.hpp \ - utility/mnemonic.hpp + utility/mnemonic.hpp \ + utility/timed_section.hpp diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/Makefile.in libbitcoin0-1.0.10+nmu2/include/bitcoin/Makefile.in --- libbitcoin0-1.0.10+nmu1/include/bitcoin/Makefile.in 2013-10-06 10:32:01.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/Makefile.in 2013-12-13 00:02:42.000000000 +0000 @@ -71,6 +71,12 @@ mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ SOURCES = DIST_SOURCES = am__can_run_installinfo = \ @@ -122,6 +128,8 @@ DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ +AM_CXXFLAGS = @AM_CXXFLAGS@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ @@ -237,7 +245,6 @@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ -my_CXXFLAGS = @my_CXXFLAGS@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgconfigdir = @pkgconfigdir@ @@ -256,7 +263,6 @@ bitcoin_include_HEADERS = \ transaction_indexer.hpp \ satoshi_serialize.hpp \ - deterministic_wallet.hpp \ getx_responder.hpp \ error.hpp \ validate.hpp \ @@ -294,6 +300,7 @@ bitcoin_util_includedir = $(includedir)/bitcoin/utility bitcoin_util_include_HEADERS = \ + utility/async_parallel.hpp \ utility/elliptic_curve_key.hpp \ utility/sha256.hpp \ utility/serializer.hpp \ @@ -305,7 +312,8 @@ utility/logger.hpp \ utility/weak_bind.hpp \ utility/key_formats.hpp \ - utility/mnemonic.hpp + utility/mnemonic.hpp \ + utility/timed_section.hpp all: all-am diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/address.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/address.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/address.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/address.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_ADDRESS_HPP #define LIBBITCOIN_ADDRESS_HPP @@ -32,14 +51,16 @@ #ifdef ENABLE_TESTNET enum { - pubkey_version = 0x6f, - script_version = 5 + pubkey_version = 0x6F, + script_version = 0xC4, + wif_version = 0xEF }; #else enum { pubkey_version = 0x00, - script_version = 5 + script_version = 0x05, + wif_version = 0x80 }; #endif payment_address(); diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/bitcoin.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/bitcoin.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/bitcoin.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/bitcoin.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_BITCOIN_HPP #define LIBBITCOIN_BITCOIN_HPP @@ -88,7 +107,6 @@ * * @subsection wallet Wallet * - * - @link libbitcoin::deterministic_wallet deterministic_wallet @endlink * - @link libbitcoin::secret_to_wif secret_to_wif @endlink * - @link libbitcoin::wif_to_secret wif_to_secret @endlink * - @link libbitcoin::minikey_to_secret minikey_to_secret @endlink @@ -150,7 +168,6 @@ // Not to be used internally. For API users. #include #include -#include #include #include #include @@ -167,6 +184,7 @@ #include #include #include +#include #include #include #include diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/block.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/block.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/block.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/block.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_BLOCK_HPP #define LIBBITCOIN_BLOCK_HPP diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/blockchain/blockchain.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/blockchain/blockchain.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/blockchain/blockchain.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/blockchain/blockchain.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_BLOCKCHAIN_BLOCKCHAIN_HPP #define LIBBITCOIN_BLOCKCHAIN_BLOCKCHAIN_HPP @@ -191,7 +210,7 @@ virtual void fetch_last_height(fetch_handler_last_height handle_fetch) = 0; /** - * Fetches a transaction by hash + * Fetches a transaction by hash. * * @param[in] transaction_hash Transaction's hash * @param[in] handle_fetch Completion handler for fetch operation. diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/blockchain/leveldb_blockchain.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/blockchain/leveldb_blockchain.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/blockchain/leveldb_blockchain.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/blockchain/leveldb_blockchain.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_BLOCKCHAIN_LEVELDB_BLOCKCHAIN_HPP #define LIBBITCOIN_BLOCKCHAIN_LEVELDB_BLOCKCHAIN_HPP diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/blockchain/organizer.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/blockchain/organizer.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/blockchain/organizer.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/blockchain/organizer.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_BLOCKCHAIN_ORGANIZER_HPP #define LIBBITCOIN_BLOCKCHAIN_ORGANIZER_HPP diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/constants.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/constants.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/constants.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/constants.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_CONSTANTS_HPP #define LIBBITCOIN_CONSTANTS_HPP @@ -16,10 +35,8 @@ constexpr size_t coinbase_maturity = 100; #ifdef ENABLE_TESTNET -constexpr uint32_t magic_value = 0x0709110b; constexpr uint32_t protocol_port = 18333; #else -constexpr uint32_t magic_value = 0xd9b4bef9; constexpr uint32_t protocol_port = 8333; #endif @@ -51,7 +68,7 @@ constexpr uint32_t max_bits = 0x1d00ffff; big_number max_target(); - +uint32_t magic_value(); constexpr uint32_t max_index = std::numeric_limits::max(); // Every two weeks we readjust target diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/deterministic_wallet.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/deterministic_wallet.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/deterministic_wallet.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/deterministic_wallet.hpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ -#ifndef LIBBITCOIN_DETERMINISTIC_WALLET_HPP -#define LIBBITCOIN_DETERMINISTIC_WALLET_HPP - -#include -#include - -namespace libbitcoin { - -/** - * Electrum compatible deterministic wallet. - */ -class deterministic_wallet -{ -public: - static constexpr size_t seed_size = 32; - - /** - * Generate a new seed. - * - * @code - * deterministic_wallet wallet; - * wallet.new_seed(); - * log_info() << "new seed: " << wallet.seed(); - * @endcode - */ - void new_seed(); - - /** - * Restore wallet from seed. - * - * @code - * if (!wallet.set_seed("...")) - * // Error... - * @endcode - */ - bool set_seed(std::string seed); - - /** - * Return the wallet seed. The seed should always be - * deterministic_wallet::seed_size in length. - * - * @return Wallet seed. Empty string if not existant. - */ - const std::string& seed() const; - - bool set_master_public_key(const data_chunk& mpk); - const data_chunk& master_public_key() const; - - /** - * Generate the n'th public key. A seed or master_public_key must be set. - * - * @code - * payment_address addr; - * set_public_key(addr, wallet.generate_public_key(2)); - * btc_address = addr.encoded(); - * @endcode - */ - data_chunk generate_public_key(size_t n, bool for_change=false) const; - - /** - * Generate the n'th secret. A seed must be set. - * - * The secret can be used to get the corresponding private key, - * and also the public key. If just the public key is desired then - * use generate_public_key() instead. - * - * @code - * elliptic_curve_key privkey; - * privkey.set_secret(wallet.generate_secret(2)); - * @endcode - */ - secret_parameter generate_secret(size_t n, bool for_change=false) const; - -private: - hash_digest get_sequence(size_t n, bool for_change) const; - - std::string seed_; - secret_parameter stretched_seed_; - data_chunk master_public_key_; -}; - -} // namespace libbitcoin - -#endif - diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/error.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/error.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/error.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/error.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_STORAGE_ERRORS_HPP #define LIBBITCOIN_STORAGE_ERRORS_HPP @@ -26,7 +45,8 @@ bad_stream, channel_timeout, // transaction pool - forced_removal, + blockchain_reorganized, + pool_filled, // validate tx coinbase_transaction, is_not_standard, @@ -64,7 +84,8 @@ enum error_condition_t { // validate - validate_failed = 1 + validate_failed = 1, + forced_removal }; std::error_code make_error_code(error_code_t e); diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/format.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/format.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/format.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/format.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_FORMAT_HPP #define LIBBITCOIN_FORMAT_HPP diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/getx_responder.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/getx_responder.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/getx_responder.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/getx_responder.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_GETX_RESPONDER_HPP #define LIBBITCOIN_GETX_RESPONDER_HPP diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/impl/serialize/block.ipp libbitcoin0-1.0.10+nmu2/include/bitcoin/impl/serialize/block.ipp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/impl/serialize/block.ipp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/impl/serialize/block.ipp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_IMPL_SERIALIZE_BLOCK_IPP #define LIBBITCOIN_IMPL_SERIALIZE_BLOCK_IPP @@ -15,14 +34,24 @@ script_type read_script(Deserializer& deserial) { data_chunk raw_script = read_raw_script(deserial); + // Output scripts can be empty so we attempt to parse them. + // If unsuccessful then they can't be spent and we just return + // a raw_data script. + script_type result; + try + { + result = parse_script(raw_script); + } + catch (end_of_stream) + { + return raw_data_script(raw_script); + } #ifndef BITCOIN_DISABLE_ASSERTS std::string assert_msg = encode_hex(raw_script); -#endif BITCOIN_ASSERT_MSG( - raw_script == save_script(parse_script(raw_script)), - assert_msg.c_str()); - // Eventually plan to move parse_script to inside here - return parse_script(raw_script); + raw_script == save_script(result), assert_msg.c_str()); +#endif + return result; } template @@ -37,7 +66,7 @@ input.previous_output.hash = deserial.read_hash(); input.previous_output.index = deserial.read_4_bytes(); if (previous_output_is_null(input.previous_output)) - input.script = coinbase_script(read_raw_script(deserial)); + input.script = raw_data_script(read_raw_script(deserial)); else input.script = read_script(deserial); input.sequence = deserial.read_4_bytes(); diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/impl/serialize/misc.ipp libbitcoin0-1.0.10+nmu2/include/bitcoin/impl/serialize/misc.ipp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/impl/serialize/misc.ipp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/impl/serialize/misc.ipp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_IMPL_SATOSHI_SERIALIZE_IPP #define LIBBITCOIN_IMPL_SATOSHI_SERIALIZE_IPP @@ -26,7 +45,6 @@ head.command = deserial.read_fixed_string(command_size); head.payload_length = deserial.read_4_bytes(); head.checksum = 0; - BITCOIN_ASSERT(satoshi_raw_size(head) == std::distance(first, last)); } // version messages @@ -72,7 +90,6 @@ } packet.start_height = deserial.read_4_bytes(); BITCOIN_ASSERT(std::distance(first, last) >= 81 + 4); - //BITCOIN_ASSERT(satoshi_raw_size(packet) <= std::distance(first, last)); } // verack messages @@ -83,8 +100,7 @@ return result; } template -void satoshi_load(const Iterator first, const Iterator last, - verack_type& packet) +void satoshi_load(const Iterator, const Iterator, verack_type& packet) { BITCOIN_ASSERT(satoshi_raw_size(packet) == 0); } @@ -115,7 +131,8 @@ addr.timestamp = timestamp; packet.addresses.push_back(addr); } - BITCOIN_ASSERT(satoshi_raw_size(packet) == std::distance(first, last)); + BITCOIN_ASSERT(deserial.iterator() == first + satoshi_raw_size(packet)); + BITCOIN_ASSERT(deserial.iterator() == last); } // getaddr messages @@ -126,8 +143,7 @@ return result; } template -void satoshi_load(const Iterator first, const Iterator last, - get_address_type& packet) +void satoshi_load(const Iterator, const Iterator, get_address_type& packet) { BITCOIN_ASSERT(satoshi_raw_size(packet) == 0); } @@ -169,7 +185,8 @@ inv.hash = deserial.read_hash(); packet.inventories.push_back(inv); } - BITCOIN_ASSERT(satoshi_raw_size(packet) == std::distance(first, last)); + BITCOIN_ASSERT(deserial.iterator() == first + satoshi_raw_size(packet)); + BITCOIN_ASSERT(deserial.iterator() == last); } // inv messages @@ -226,7 +243,8 @@ packet.start_hashes.push_back(start_hash); } packet.hash_stop = deserial.read_hash(); - BITCOIN_ASSERT(satoshi_raw_size(packet) == std::distance(first, last)); + BITCOIN_ASSERT(deserial.iterator() == first + satoshi_raw_size(packet)); + BITCOIN_ASSERT(deserial.iterator() == last); } // ping messages @@ -245,7 +263,8 @@ { auto deserial = make_deserializer(first, last); packet.nonce = deserial.read_8_bytes(); - BITCOIN_ASSERT(satoshi_raw_size(packet) == std::distance(first, last)); + BITCOIN_ASSERT(deserial.iterator() == first + satoshi_raw_size(packet)); + BITCOIN_ASSERT(deserial.iterator() == last); } // pong messages @@ -264,7 +283,8 @@ { auto deserial = make_deserializer(first, last); packet.nonce = deserial.read_8_bytes(); - BITCOIN_ASSERT(satoshi_raw_size(packet) == std::distance(first, last)); + BITCOIN_ASSERT(deserial.iterator() == first + satoshi_raw_size(packet)); + BITCOIN_ASSERT(deserial.iterator() == last); } } // libbitcoin diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/network/channel.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/network/channel.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/network/channel.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/network/channel.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_NET_CHANNEL_HPP #define LIBBITCOIN_NET_CHANNEL_HPP @@ -30,7 +49,7 @@ satoshi_save(packet, payload.begin()); // Make the header packet and serialise it header_type head; - head.magic = magic_value; + head.magic = magic_value(); head.command = satoshi_command(packet); head.payload_length = payload.size(); head.checksum = generate_sha256_checksum(payload); @@ -232,13 +251,12 @@ void stop_impl(); void clear_subscriptions(); - // We keep the service alive for lifetime rules io_service::strand strand_; + socket_ptr socket_; + // We keep the service alive for lifetime rules boost::asio::deadline_timer timeout_, heartbeat_; - std::atomic stopped_; - socket_ptr socket_; channel_stream_loader loader_; // Header minus checksum is 4 + 12 + 4 = 20 bytes diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/network/handshake.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/network/handshake.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/network/handshake.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/network/handshake.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_NETWORK_HANDSHAKE_HPP #define LIBBITCOIN_NETWORK_HANDSHAKE_HPP @@ -6,6 +25,7 @@ #include #include #include +#include namespace libbitcoin { @@ -47,15 +67,12 @@ channel_ptr node, network::connect_handler handle_connect); void handle_message_sent(const std::error_code& ec, - atomic_counter_ptr counter, handshake::handshake_handler completion_callback); - void receive_version(const std::error_code& ec, - const version_type&, channel_ptr node, atomic_counter_ptr counter, - handshake::handshake_handler completion_callback); + void receive_version(const std::error_code& ec, const version_type&, + channel_ptr node, handshake::handshake_handler completion_callback); - void receive_verack(const std::error_code& ec, - const verack_type&, atomic_counter_ptr counter, + void receive_verack(const std::error_code& ec, const verack_type&, handshake::handshake_handler completion_callback); bool lookup_external(const std::string& website, diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/network/hosts.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/network/hosts.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/network/hosts.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/network/hosts.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_HPPOSTS_HPP #define LIBBITCOIN_HPPOSTS_HPP diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/network/network.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/network/network.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/network/network.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/network/network.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_NETWORK_NETWORK_HPP #define LIBBITCOIN_NETWORK_NETWORK_HPP diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/network/protocol.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/network/protocol.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/network/protocol.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/network/protocol.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_PROTOCOL_HPP #define LIBBITCOIN_PROTOCOL_HPP @@ -6,9 +25,10 @@ #include #include -#include #include #include +#include +#include namespace libbitcoin { @@ -40,6 +60,17 @@ void set_max_outbound(size_t max_outbound); /** + * Set the filename to load the hosts file from. + */ + void set_hosts_filename(const std::string& hosts_filename); + + /** + * If called, then this service will not listen for incoming + * connections. Must be called before start(). + */ + void disable_listener(); + + /** * Perform full initialization sequence. * Internally calls bootstrap() and then run(). * @@ -97,6 +128,15 @@ fetch_connection_count_handler handle_fetch); /** + * Create a manual connection to a specific node. If disconnected + * this service will keep attempting to reconnect until successful. + * + * @param[in] hostname // Hostname + * @param[in] port // Port + */ + void maintain_connection(const std::string& hostname, uint16_t port); + + /** * Subscribe to new connections established to other nodes. * This method must be called again to stay subscribed as * handlers are deregistered after being called. @@ -142,6 +182,16 @@ channel_ptr node; }; typedef std::vector connection_list; + enum class connect_state + { + none, + finding_peer, + connecting, + established, + stopped + }; + typedef std::vector connect_state_list; + typedef size_t slot_index; // Accepted connections typedef std::vector channel_ptr_list; @@ -198,11 +248,26 @@ // run loop // Connect outwards - void try_connect(); + void try_outbound_connects(); + // This function is called in these places: + // + // 1. try_outbound_connects() calls it n times. + // Called by run() at the start. + // 2. If we fetch a random node address that we are already + // connected to in attempt_connect(). + // 3. If we fail to connect to said address in handle_connect(). + // 4. If the channel is stopped manually or there is an error + // (such as a disconnect). See setup_new_channel() for the + // subscribe call. + void try_connect_once(slot_index slot); void attempt_connect(const std::error_code& ec, - const network_address_type& packet); + const network_address_type& packet, slot_index slot); void handle_connect(const std::error_code& ec, channel_ptr node, - const network_address_type& address); + const network_address_type& address, slot_index slot); + + // Manual connections + void handle_manual_connect(const std::error_code& ec, channel_ptr node, + const std::string& hostname, uint16_t port); // Accept inwards connections void handle_listen(const std::error_code& ec, acceptor_ptr accept); @@ -211,8 +276,15 @@ // Channel setup void setup_new_channel(channel_ptr node); - void channel_stopped(const std::error_code& ec, - channel_ptr which_node); + + // Remove channels from lists when disconnected. + void outbound_channel_stopped( + const std::error_code& ec, channel_ptr which_node, slot_index slot); + void manual_channel_stopped( + const std::error_code& ec, channel_ptr which_node, + const std::string& hostname, uint16_t port); + void inbound_channel_stopped( + const std::error_code& ec, channel_ptr which_node); void subscribe_address(channel_ptr node); void receive_address_message(const std::error_code& ec, @@ -237,13 +309,21 @@ io_service::strand strand_; - const std::string hosts_filename_; + std::string hosts_filename_ = "hosts"; hosts& hosts_; handshake& handshake_; network& network_; + // There's a fixed number of slots that are always trying to reconnect. size_t max_outbound_ = 8; connection_list connections_; + // Simply a debugging tool to enforce correct state transition behaviour + // for maintaining connections. + connect_state_list connect_states_; + // Manual connections created by user themselves. + channel_ptr_list manual_connections_; + // Inbound connections from the p2p network. + bool listen_is_enabled_ = true; channel_ptr_list accepted_channels_; channel_subscriber_type::ptr channel_subscribe_; diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/network/shared_const_buffer.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/network/shared_const_buffer.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/network/shared_const_buffer.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/network/shared_const_buffer.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_NET_SHARED_CONST_BUFFER_HPP #define LIBBITCOIN_NET_SHARED_CONST_BUFFER_HPP diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/poller.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/poller.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/poller.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/poller.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_BLOCKS_POLLER_HPP #define LIBBITCOIN_BLOCKS_POLLER_HPP diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/primitives.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/primitives.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/primitives.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/primitives.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_PRIMITIVES_HPP #define LIBBITCOIN_PRIMITIVES_HPP diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/satoshi_serialize.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/satoshi_serialize.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/satoshi_serialize.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/satoshi_serialize.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_SATOSHI_SERIALIZE_HPP #define LIBBITCOIN_SATOSHI_SERIALIZE_HPP @@ -12,8 +31,6 @@ namespace libbitcoin { -size_t variable_uint_size(uint64_t v); - constexpr size_t command_size = 12; // message headers diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/script.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/script.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/script.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/script.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_SCRIPT_HPP #define LIBBITCOIN_SCRIPT_HPP @@ -55,7 +74,7 @@ op_2rot = 113, op_2swap = 114, ifdup = 115, - height = 116, + depth = 116, drop = 117, dup = 118, nip = 119, @@ -219,7 +238,7 @@ bool op_2rot(); bool op_2swap(); bool op_ifdup(); - bool op_height(); + bool op_depth(); bool op_drop(); bool op_dup(); bool op_nip(); @@ -283,7 +302,7 @@ std::string pretty(const script_type& script); std::ostream& operator<<(std::ostream& stream, const script_type& script); -script_type coinbase_script(const data_chunk& raw_script); +script_type raw_data_script(const data_chunk& raw_script); script_type parse_script(const data_chunk& raw_script); data_chunk save_script(const script_type& script); size_t script_size(const script_type& script); diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/session.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/session.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/session.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/session.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_SESSION_HPP #define LIBBITCOIN_SESSION_HPP diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/threadpool.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/threadpool.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/threadpool.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/threadpool.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_THREADPOOL_HPP #define LIBBITCOIN_THREADPOOL_HPP @@ -44,9 +63,9 @@ void operator=(const threadpool&) = delete; /** - * Add a thread to this threadpool. + * Add n threads to this threadpool. */ - void spawn(); + void spawn(size_t number_threads=1); /** * Stop the threadpool. All remaining operations on the queue are dropped. @@ -102,6 +121,8 @@ const io_service& service() const; private: + void spawn_once(); + io_service ios_; io_service::work* work_; std::vector threads_; diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/transaction.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/transaction.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/transaction.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/transaction.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_TRANSACTION_HPP #define LIBBITCOIN_TRANSACTION_HPP diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/transaction_indexer.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/transaction_indexer.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/transaction_indexer.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/transaction_indexer.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_TRANSACTION_INDEXER_HPP #define LIBBITCOIN_TRANSACTION_INDEXER_HPP @@ -28,7 +47,7 @@ typedef std::function completion_handler; typedef std::function + const output_info_list& outputs, const spend_info_list& spends)> query_handler; transaction_indexer(threadpool& pool); @@ -46,22 +65,22 @@ * @code * void handle_query( * const std::error_code& ec, // Status of operation - * const spend_info_list& spends, // Inputs - * const output_info_list& outputs // Outputs + * const output_info_list& outputs, // Outputs + * const spend_info_list& spends // Inputs * ); * @endcode * @code - * struct spend_info_type - * { - * input_point point; - * output_point previous_output; - * }; - * * struct output_info_type * { * output_point point; * uint64_t value; * }; + * + * struct spend_info_type + * { + * input_point point; + * output_point previous_output; + * }; * @endcode */ void query(const payment_address& payaddr, diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/transaction_pool.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/transaction_pool.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/transaction_pool.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/transaction_pool.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_TRANSACTION_POOL_HPP #define LIBBITCOIN_TRANSACTION_POOL_HPP @@ -177,7 +196,7 @@ size_t fork_point, const blockchain::block_list& new_blocks, const blockchain::block_list& replaced_blocks); - void resubmit_all(); + void invalidate_pool(); void takeout_confirmed(const blockchain::block_list& new_blocks); void try_delete(const hash_digest& tx_hash); diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/types.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/types.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/types.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/types.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,9 +1,27 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_TYPES_HPP #define LIBBITCOIN_TYPES_HPP #include #include -#include #include #include #include @@ -22,9 +40,6 @@ #undef DECLARE_PTR_TYPE -typedef std::atomic atomic_counter; -typedef std::shared_ptr atomic_counter_ptr; - typedef std::shared_ptr socket_ptr; constexpr size_t hash_digest_size = 32; diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/utility/assert.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/utility/assert.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/utility/assert.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/utility/assert.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_ASSERT_HPP #define LIBBITCOIN_ASSERT_HPP diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/utility/async_parallel.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/utility/async_parallel.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/utility/async_parallel.hpp 1970-01-01 00:00:00.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/utility/async_parallel.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#ifndef LIBBITCOIN_ASYNC_PARALLEL_HPP +#define LIBBITCOIN_ASYNC_PARALLEL_HPP + +#include +#include +#include +#include + +namespace libbitcoin { + +/* + * async_parallel(completion_handler, clearance_count) + * + * Returns a callback that will stop when: + * + * 1. An error is passed as the first argument. + * 2. It has been called clearance_count number of times. + * + * This is useful when we have a piece of code that forks into several + * asynchronous code paths. This utility ensures that all code paths + * are completed before calling the completion_handler. + * + * auto complete = [](std::error_code ec, std::string s) { ... }; + * auto cb = async_parallel(complete, 3); + * cb(std::error_code, "hello"); + * // Calling cb(error::service_stopped, "") here will + * // call complete(error::service_stopped, "") + * cb(std::error_code, "world"); + * // Calls complete(std::error_code, "final") + * cb(std::error_code, "final"); + */ + +typedef std::atomic atomic_counter; +typedef std::shared_ptr atomic_counter_ptr; + +template +struct async_parallel_dispatch +{ + Handler handler; + size_t clearance_count; + atomic_counter_ptr counter; + + template + void operator()(const std::error_code& ec, Args&&... args) + { + BITCOIN_ASSERT(*counter <= clearance_count); + if (*counter == clearance_count) + return; + if (ec) + { + // Stop because of failure. + *counter = clearance_count; + handler(ec, std::forward(args)...); + } + else if (++(*counter) == clearance_count) + // Finished executing multiple async paths. + handler(ec, std::forward(args)...); + } +}; + +template +async_parallel_dispatch< + typename std::decay::type +> +async_parallel(Handler&& handler, size_t clearance_count) +{ + return {handler, clearance_count, + std::make_shared(0)}; +} + +} // libbitcoin + +#endif + diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/utility/base58.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/utility/base58.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/utility/base58.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/utility/base58.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_BASE58_HPP #define LIBBITCOIN_BASE58_HPP diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/utility/big_number.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/utility/big_number.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/utility/big_number.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/utility/big_number.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_BIG_NUMBER_HPP #define LIBBITCOIN_BIG_NUMBER_HPP diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/utility/decorator.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/utility/decorator.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/utility/decorator.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/utility/decorator.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,6 +1,29 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_UTILITY_DECORATOR_HPP #define LIBBITCOIN_UTILITY_DECORATOR_HPP +#include + +namespace libbitcoin { + /* * Defines a function decorator ala Python * @@ -11,8 +34,6 @@ * f(); */ -#include - template struct decorator_dispatch { @@ -37,5 +58,7 @@ return {wrapper, handler}; } +} // namespace libbitcoin + #endif diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/utility/elliptic_curve_key.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/utility/elliptic_curve_key.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/utility/elliptic_curve_key.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/utility/elliptic_curve_key.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_ELLIPTIC_CURVE_KEY_HPP #define LIBBITCOIN_ELLIPTIC_CURVE_KEY_HPP diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/utility/key_formats.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/utility/key_formats.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/utility/key_formats.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/utility/key_formats.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_KEY_FORMATS_HPP #define LIBBITCOIN_KEY_FORMATS_HPP diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/utility/logger.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/utility/logger.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/utility/logger.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/utility/logger.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_LOGGER_HPP #define LIBBITCOIN_LOGGER_HPP @@ -14,6 +33,8 @@ #define LOG_POLLER "poller" #define LOG_SESSION "session" #define LOG_SCRIPT "script" +#define LOG_TXPOOL "transaction_pool" +#define LOG_TXIDX "transaction_indexer" enum class log_level { diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/utility/mnemonic.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/utility/mnemonic.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/utility/mnemonic.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/utility/mnemonic.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_MNEMONIC_HPP #define LIBBITCOIN_MNEMONIC_HPP diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/utility/ripemd.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/utility/ripemd.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/utility/ripemd.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/utility/ripemd.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_RIPEMD_HPP #define LIBBITCOIN_RIPEMD_HPP diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/utility/serializer.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/utility/serializer.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/utility/serializer.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/utility/serializer.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_SERIALIZER_HPP #define LIBBITCOIN_SERIALIZER_HPP @@ -11,6 +30,8 @@ namespace libbitcoin { +size_t variable_uint_size(uint64_t v); + /** * Serializer that uses iterators and is oblivious to the underlying * container type. Is not threadsafe. @@ -120,6 +141,15 @@ return iter_; } + /** + * Useful if you want to serialize some data using another + * routine and then continue with this serializer. + */ + void set_iterator(Iterator iter) + { + iter_ = iter; + } + private: template void write_data_impl(T value) @@ -203,16 +233,14 @@ uint64_t read_variable_uint() { uint8_t length = read_byte(); - uint64_t value = 0; if (length < 0xfd) - value = length; + return length; else if (length == 0xfd) - value += read_2_bytes(); + return read_2_bytes(); else if (length == 0xfe) - value += read_4_bytes(); - else if (length == 0xff) - value += read_8_bytes(); - return value; + return read_4_bytes(); + // length should be 0xff + return read_8_bytes(); } data_chunk read_data(uint64_t n_bytes) @@ -311,13 +339,13 @@ std::array& byte_array, bool reverse=false) { check_distance(begin, end, byte_array.size()); - #ifdef BOOST_LITTLE_ENDIAN - // do nothing - #elif BOOST_BIG_ENDIAN - reverse = !reverse; - #else - #error "Endian isn't defined!" - #endif + #ifdef BOOST_LITTLE_ENDIAN + // do nothing + #elif BOOST_BIG_ENDIAN + reverse = !reverse; + #else + #error "Endian isn't defined!" + #endif if (reverse) std::reverse_copy( diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/utility/sha256.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/utility/sha256.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/utility/sha256.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/utility/sha256.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_SHA256_HPP #define LIBBITCOIN_SHA256_HPP @@ -11,8 +30,8 @@ constexpr size_t sha256_digest_size = SHA256_DIGEST_LENGTH; static_assert(sha256_digest_size == 32, "SHA256_DIGEST_LENGTH not defined correctly!"); -hash_digest generate_sha256_hash(const data_chunk& chunk); -uint32_t generate_sha256_checksum(const data_chunk& chunk); +hash_digest generate_sha256_hash(const data_chunk& data); +uint32_t generate_sha256_checksum(const data_chunk& data); } // namespace libbitcoin diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/utility/subscriber.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/utility/subscriber.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/utility/subscriber.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/utility/subscriber.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_UTILITY_SUBSCRIBER_HPP #define LIBBITCOIN_UTILITY_SUBSCRIBER_HPP diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/utility/timed_section.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/utility/timed_section.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/utility/timed_section.hpp 1970-01-01 00:00:00.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/utility/timed_section.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#ifndef LIBBITCOIN_UTILITY_TIMED_SECTION_HPP +#define LIBBITCOIN_UTILITY_TIMED_SECTION_HPP + +#include +#include + +namespace libbitcoin { + +class timed_section +{ +public: + timed_section(const std::string& context, const std::string& section); + ~timed_section(); + double elapsed() const; +private: + const std::string context_, section_; + timespec start_; +}; + +} // namespace libbitcoin + +#endif + diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/utility/weak_bind.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/utility/weak_bind.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/utility/weak_bind.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/utility/weak_bind.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_UTILITY_WEAK_BIND_HPP #define LIBBITCOIN_UTILITY_WEAK_BIND_HPP diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/validate.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/validate.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/validate.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/validate.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_VALIDATE_HPP #define LIBBITCOIN_VALIDATE_HPP @@ -81,7 +100,9 @@ class validate_block { public: - std::error_code start(); + std::error_code check_block(); + std::error_code accept_block(); + std::error_code connect_block(); protected: validate_block(size_t height, const block_type& current_block); @@ -105,18 +126,18 @@ virtual block_header_type fetch_block(size_t fetch_height) = 0; private: - std::error_code check_block(); + // check_block() bool check_proof_of_work(hash_digest hash, uint32_t bits); bool check_transaction(const transaction_type& tx); size_t legacy_sigops_count(); - std::error_code accept_block(); + // accept_block() uint32_t work_required(); bool passes_checkpoints(); bool coinbase_height_match(); - std::error_code connect_block(); + // connect_block() bool not_duplicate_or_spent(const transaction_type& tx); const size_t height_; diff -Nru libbitcoin0-1.0.10+nmu1/include/bitcoin/version.hpp libbitcoin0-1.0.10+nmu2/include/bitcoin/version.hpp --- libbitcoin0-1.0.10+nmu1/include/bitcoin/version.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/include/bitcoin/version.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_VERSION_HPP #define LIBBITCOIN_VERSION_HPP @@ -10,14 +29,14 @@ // LIBBITCOIN_VERSION / 100 % 1000 is the minor version // LIBBITCOIN_VERSION / 100000 is the major version -#define LIBBITCOIN_VERSION 100010 +#define LIBBITCOIN_VERSION 100400 // LIBBITCOIN_LIB_VERSION is defined to be the same as LIBBITCOIN_VERSION // but as a *string* in the form "x.y[.z]" where x is the major version // number, y is the minor version number, and z is the patch level if not 0. // This is used for the user agent string during the connection handshake. -#define LIBBITCOIN_LIB_VERSION "1.0.10" +#define LIBBITCOIN_LIB_VERSION "1.4.0" #endif diff -Nru libbitcoin0-1.0.10+nmu1/linti libbitcoin0-1.0.10+nmu2/linti --- libbitcoin0-1.0.10+nmu1/linti 1970-01-01 00:00:00.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/linti 2013-08-31 21:13:14.000000000 +0000 @@ -0,0 +1,23 @@ +E: libbitcoin changes: file-size-mismatch-in-changes-file libbitcoin_1.0.10-1.tar.gz 5620453 != 787617 +E: libbitcoin changes: checksum-mismatch-in-changes-file md5 libbitcoin_1.0.10-1.tar.gz +E: libbitcoin changes: checksum-mismatch-in-changes-file sha1 libbitcoin_1.0.10-1.tar.gz +E: libbitcoin changes: checksum-mismatch-in-changes-file sha256 libbitcoin_1.0.10-1.tar.gz +E: libbitcoin changes: file-size-mismatch-in-changes-file libbitcoin_1.0.10-1.dsc 831 != 828 +E: libbitcoin changes: checksum-mismatch-in-changes-file md5 libbitcoin_1.0.10-1.dsc +E: libbitcoin changes: checksum-mismatch-in-changes-file sha1 libbitcoin_1.0.10-1.dsc +E: libbitcoin changes: checksum-mismatch-in-changes-file sha256 libbitcoin_1.0.10-1.dsc +W: libbitcoin source: no-section-field-for-source +W: libbitcoin source: native-package-with-dash-version +P: libbitcoin source: package-lacks-versioned-build-depends-on-debhelper 8 +I: libbitcoin source: missing-debian-source-format +E: libbitcoin source: build-depends-on-build-essential build-depends +W: libbitcoin source: changelog-should-mention-nmu +W: libbitcoin source: source-nmu-has-incorrect-version-number 1.0.10-1 +P: libbitcoin source: unversioned-copyright-format-uri http://dep.debian.net/deps/dep5 +W: libbitcoin source: missing-field-in-dep5-copyright license (paragraph at line 5) +I: libbitcoin source: unused-license-paragraph-in-dep5-copyright agpl3 (paragraph at line 11) +W: libbitcoin source: out-of-date-standards-version 3.9.3 (current is 3.9.4) +I: libbitcoin-dev: using-first-person-in-description line 10: we +W: libbitcoin: package-name-doesnt-match-sonames libbitcoin0 +I: libbitcoin: using-first-person-in-description line 10: we +I: libbitcoin: no-symbols-control-file usr/lib/x86_64-linux-gnu/libbitcoin.so.0.0.0 diff -Nru libbitcoin0-1.0.10+nmu1/linti2 libbitcoin0-1.0.10+nmu2/linti2 --- libbitcoin0-1.0.10+nmu1/linti2 1970-01-01 00:00:00.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/linti2 2013-08-31 21:42:44.000000000 +0000 @@ -0,0 +1,11 @@ +I: libbitcoin source: binary-control-field-duplicates-source field "section" in package libbitcoin +W: libbitcoin source: native-package-with-dash-version +W: libbitcoin source: outdated-autotools-helper-file build-aux/config.guess 2012-02-10 +P: libbitcoin source: package-lacks-versioned-build-depends-on-debhelper 8 +W: libbitcoin source: changelog-should-mention-nmu +P: libbitcoin source: unversioned-copyright-format-uri http://dep.debian.net/deps/dep5 +W: libbitcoin source: missing-license-paragraph-in-dep5-copyright agpl3 (paragraph at line 7) +I: libbitcoin-dev: using-first-person-in-description line 10: we +W: libbitcoin: package-name-doesnt-match-sonames libbitcoin0 +I: libbitcoin: using-first-person-in-description line 10: we +I: libbitcoin: no-symbols-control-file usr/lib/x86_64-linux-gnu/libbitcoin.so.0.0.0 diff -Nru libbitcoin0-1.0.10+nmu1/linti3 libbitcoin0-1.0.10+nmu2/linti3 --- libbitcoin0-1.0.10+nmu1/linti3 1970-01-01 00:00:00.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/linti3 2013-08-31 22:00:35.000000000 +0000 @@ -0,0 +1,15 @@ +E: libbitcoin changes: file-size-mismatch-in-changes-file libbitcoin_1.0.10-1+nmu1.dsc 843 != 855 +E: libbitcoin changes: checksum-mismatch-in-changes-file md5 libbitcoin_1.0.10-1+nmu1.dsc +E: libbitcoin changes: checksum-mismatch-in-changes-file sha1 libbitcoin_1.0.10-1+nmu1.dsc +E: libbitcoin changes: checksum-mismatch-in-changes-file sha256 libbitcoin_1.0.10-1+nmu1.dsc +E: libbitcoin changes: file-size-mismatch-in-changes-file libbitcoin_1.0.10-1+nmu1.tar.gz 1132970 != 1133426 +E: libbitcoin changes: checksum-mismatch-in-changes-file md5 libbitcoin_1.0.10-1+nmu1.tar.gz +E: libbitcoin changes: checksum-mismatch-in-changes-file sha1 libbitcoin_1.0.10-1+nmu1.tar.gz +E: libbitcoin changes: checksum-mismatch-in-changes-file sha256 libbitcoin_1.0.10-1+nmu1.tar.gz +W: libbitcoin source: native-package-with-dash-version +W: libbitcoin source: outdated-autotools-helper-file build-aux/config.guess 2012-02-10 +W: libbitcoin source: changelog-should-mention-nmu +I: libbitcoin-dev: using-first-person-in-description line 10: we +W: libbitcoin: package-name-doesnt-match-sonames libbitcoin0 +I: libbitcoin: using-first-person-in-description line 10: we +I: libbitcoin: no-symbols-control-file usr/lib/x86_64-linux-gnu/libbitcoin.so.0.0.0 diff -Nru libbitcoin0-1.0.10+nmu1/linti4 libbitcoin0-1.0.10+nmu2/linti4 --- libbitcoin0-1.0.10+nmu1/linti4 1970-01-01 00:00:00.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/linti4 2013-08-31 22:03:03.000000000 +0000 @@ -0,0 +1,5 @@ +W: libbitcoin source: native-package-with-dash-version +W: libbitcoin source: outdated-autotools-helper-file build-aux/config.guess 2012-02-10 +W: libbitcoin source: changelog-should-mention-nmu +W: libbitcoin: package-name-doesnt-match-sonames libbitcoin0 +I: libbitcoin: no-symbols-control-file usr/lib/x86_64-linux-gnu/libbitcoin.so.0.0.0 diff -Nru libbitcoin0-1.0.10+nmu1/linti5 libbitcoin0-1.0.10+nmu2/linti5 --- libbitcoin0-1.0.10+nmu1/linti5 1970-01-01 00:00:00.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/linti5 2013-08-31 22:17:10.000000000 +0000 @@ -0,0 +1,2 @@ +W: libbitcoin: package-name-doesnt-match-sonames libbitcoin0 +I: libbitcoin: no-symbols-control-file usr/lib/x86_64-linux-gnu/libbitcoin.so.0.0.0 diff -Nru libbitcoin0-1.0.10+nmu1/lintian_1.txt libbitcoin0-1.0.10+nmu2/lintian_1.txt --- libbitcoin0-1.0.10+nmu1/lintian_1.txt 1970-01-01 00:00:00.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/lintian_1.txt 2013-08-31 21:12:56.000000000 +0000 @@ -0,0 +1,23 @@ +E: libbitcoin changes: file-size-mismatch-in-changes-file libbitcoin_1.0.10-1.tar.gz 5620453 != 787617 +E: libbitcoin changes: checksum-mismatch-in-changes-file md5 libbitcoin_1.0.10-1.tar.gz +E: libbitcoin changes: checksum-mismatch-in-changes-file sha1 libbitcoin_1.0.10-1.tar.gz +E: libbitcoin changes: checksum-mismatch-in-changes-file sha256 libbitcoin_1.0.10-1.tar.gz +E: libbitcoin changes: file-size-mismatch-in-changes-file libbitcoin_1.0.10-1.dsc 831 != 828 +E: libbitcoin changes: checksum-mismatch-in-changes-file md5 libbitcoin_1.0.10-1.dsc +E: libbitcoin changes: checksum-mismatch-in-changes-file sha1 libbitcoin_1.0.10-1.dsc +E: libbitcoin changes: checksum-mismatch-in-changes-file sha256 libbitcoin_1.0.10-1.dsc +W: libbitcoin source: no-section-field-for-source +W: libbitcoin source: native-package-with-dash-version +P: libbitcoin source: package-lacks-versioned-build-depends-on-debhelper 8 +I: libbitcoin source: missing-debian-source-format +E: libbitcoin source: build-depends-on-build-essential build-depends +W: libbitcoin source: changelog-should-mention-nmu +W: libbitcoin source: source-nmu-has-incorrect-version-number 1.0.10-1 +P: libbitcoin source: unversioned-copyright-format-uri http://dep.debian.net/deps/dep5 +W: libbitcoin source: missing-field-in-dep5-copyright license (paragraph at line 5) +I: libbitcoin source: unused-license-paragraph-in-dep5-copyright agpl3 (paragraph at line 11) +W: libbitcoin source: out-of-date-standards-version 3.9.3 (current is 3.9.4) +I: libbitcoin-dev: using-first-person-in-description line 10: we +W: libbitcoin: package-name-doesnt-match-sonames libbitcoin0 +I: libbitcoin: using-first-person-in-description line 10: we +I: libbitcoin: no-symbols-control-file usr/lib/x86_64-linux-gnu/libbitcoin.so.0.0.0 diff -Nru libbitcoin0-1.0.10+nmu1/some_changes.diff libbitcoin0-1.0.10+nmu2/some_changes.diff --- libbitcoin0-1.0.10+nmu1/some_changes.diff 1970-01-01 00:00:00.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/some_changes.diff 2013-09-01 21:13:12.000000000 +0000 @@ -0,0 +1,171 @@ +diff --git a/.gitignore b/.gitignore +index 04f492d..1270c7f 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -23,19 +23,5 @@ obj + /config.* + /configure + /libtool +- +-/examples/accept +-/examples/connect +-/examples/determ +-/examples/display-last +-/examples/fullnode +-/examples/initchain +-/examples/priv +-/examples/proto +-/examples/satoshiwords +-/examples/txrad +-/examples/error.log +-/examples/debug.log +- + .dirstamp + libbitcoin_1.0.10-1_amd64.deb +diff --git a/bin/download-blockchain.sh b/bin/download-blockchain.sh +index c1e5e31..12e3b66 100755 +--- a/bin/download-blockchain.sh ++++ b/bin/download-blockchain.sh +@@ -10,3 +10,4 @@ echo "Type 'public' at the password prompt." + COMMAND="rsync -avz public@46.4.92.107:/var/www/blockchain/ $1/blockchain/" + echo "> $COMMAND" + $COMMAND ++ +diff --git a/configure.ac b/configure.ac +index ec5f0d2..e23b15b 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -11,8 +11,6 @@ AC_GNU_SOURCE + AX_CXX_COMPILE_STDCXX_11(noext,mandatory) + #CXXFLAGS="-Wall -Wno-unused-parameter -pedantic -pthread -Wextra -fstack-protector-all" + +-m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) +- + AC_ARG_ENABLE(leveldb, + [AC_HELP_STRING([--enable-leveldb], + [Build LevelDB support.])], +diff --git a/doc/README.tutorial b/doc/README.tutorial +index 1045548..00cd4eb 100644 +--- a/doc/README.tutorial ++++ b/doc/README.tutorial +@@ -10,3 +10,4 @@ If you prefer to generate the documentation install python-sphinx. + The documentation will be built in sphinx/_build/html/ + It's also possible to generate man pages or other formats. + Type 'make' by itself to see a list of the possible output formats. ++ +diff --git a/doc/sphinx/blockchain.rst b/doc/sphinx/blockchain.rst +index 44e4ceb..6372cf9 100644 +--- a/doc/sphinx/blockchain.rst ++++ b/doc/sphinx/blockchain.rst +@@ -221,7 +221,7 @@ block header to the screen. + + // Completion handler for when the blockchain has finished initializing. + void blockchain_started(const std::error_code& ec); +- // Fetch the last block now that we have the height. ++ // Fetch tbe last block now that we have the height. + void height_fetched(const std::error_code& ec, size_t last_height); + // Result: print the block header. + void display_block_header(const std::error_code& ec, +diff --git a/doc/sphinx/crypto.rst b/doc/sphinx/crypto.rst +index d23d381..37c5bf3 100644 +--- a/doc/sphinx/crypto.rst ++++ b/doc/sphinx/crypto.rst +@@ -89,7 +89,7 @@ ever gets lost, all private and public keys can be regenerated from the initial + seed. + + Also, multiple devices could host the same wallet based off of the same seed and +-automatically stay in sync with each other. Non-critical information such as ++automatically stay in sync with eachother. Non-critical information such as + address books would need to be stored and copied between wallets. + + libbitcoin implements the same compatible deterministic wallet algorithm as `Electrum `_. +diff --git a/doc/sphinx/examples/display-last.rst b/doc/sphinx/examples/display-last.rst +index 068180b..a15d921 100644 +--- a/doc/sphinx/examples/display-last.rst ++++ b/doc/sphinx/examples/display-last.rst +@@ -17,7 +17,7 @@ Maybe even download a few blocks into the database. + + // Completion handler for when the blockchain has finished initializing. + void blockchain_started(const std::error_code& ec); +- // Fetch the last block now that we have the height. ++ // Fetch tbe last block now that we have the height. + void height_fetched(const std::error_code& ec, size_t last_height); + // Result: print the block header. + void display_block_header(const std::error_code& ec, +diff --git a/doc/sphinx/overview.rst b/doc/sphinx/overview.rst +index 6a693ed..16dee81 100644 +--- a/doc/sphinx/overview.rst ++++ b/doc/sphinx/overview.rst +@@ -29,7 +29,7 @@ Services implement thread-safe interfaces as a strict rule. Tasks are submitted + to services and upon completion, your program will be notified. Services are + self contained units and are locally encapsulated. They implement an interface + for which various implementations may exist- the blockchain service has an +-implementation for `LevelDB `_. ++implementation for BerkeleyDB and LevelDB. + + There are two basic service actions in libbitcoin: + +diff --git a/examples/Makefile b/examples/Makefile +index 3010395..cc7279d 100644 +--- a/examples/Makefile ++++ b/examples/Makefile +@@ -71,6 +71,3 @@ proto: proto.o + + all: balance priv determ initchain fullnode display-last satoshiwords connect accept proto txrad + +-clean: +- rm -f accept connect determ display-last fullnode initchain priv proto satoshiwords txrad +- rm -f *.o +diff --git a/examples/display-last.cpp b/examples/display-last.cpp +index 16ab536..59ce1de 100644 +--- a/examples/display-last.cpp ++++ b/examples/display-last.cpp +@@ -8,7 +8,7 @@ blockchain* chain = nullptr; + + // Completion handler for when the blockchain has finished initializing. + void blockchain_started(const std::error_code& ec); +-// Fetch the last block now that we have the height. ++// Fetch tbe last block now that we have the height. + void height_fetched(const std::error_code& ec, size_t last_height); + // Result: print the block header. + void display_block_header(const std::error_code& ec, +diff --git a/include/bitcoin/transaction_indexer.hpp b/include/bitcoin/transaction_indexer.hpp +index d42a1b8..798c6d1 100644 +--- a/include/bitcoin/transaction_indexer.hpp ++++ b/include/bitcoin/transaction_indexer.hpp +@@ -129,3 +129,4 @@ void fetch_history(blockchain& chain, transaction_indexer& indexer, + } // namespace libbitcoin + + #endif ++ +diff --git a/src/utility/elliptic_curve_key.cpp b/src/utility/elliptic_curve_key.cpp +index 1dda26f..0ce94f7 100644 +--- a/src/utility/elliptic_curve_key.cpp ++++ b/src/utility/elliptic_curve_key.cpp +@@ -59,7 +59,7 @@ bool elliptic_curve_key::verify(hash_digest hash, const data_chunk& signature) + // SSL likes a reversed hash + std::reverse(hash.begin(), hash.end()); + // -1 = error, 0 = bad sig, 1 = good +- if (ECDSA_verify(0, hash.data(), hash.size(), ++ if (ECDSA_verify(0, hash.data(), hash.size(), + signature.data(), signature.size(), key_) == 1) + return true; + return false; +@@ -103,7 +103,7 @@ data_chunk elliptic_curve_key::sign(hash_digest hash) const + std::reverse(hash.begin(), hash.end()); + data_chunk signature(ECDSA_size(key_)); + unsigned int signature_length = signature.size(); +- if (!ECDSA_sign(0, hash.data(), hash.size(), ++ if (!ECDSA_sign(0, hash.data(), hash.size(), + signature.data(), &signature_length, key_)) + return data_chunk(); + signature.resize(signature_length); +diff --git a/test/deterministic_wallet.cpp b/test/deterministic_wallet.cpp +index ce696fc..8ec986d 100644 +--- a/test/deterministic_wallet.cpp ++++ b/test/deterministic_wallet.cpp +@@ -46,3 +46,4 @@ BOOST_AUTO_TEST_CASE(nullbyte) + secret_parameter secret = wallet.generate_secret(10); + BOOST_REQUIRE(secret[0] == 0x00); + } ++ diff -Nru libbitcoin0-1.0.10+nmu1/src/Makefile.am libbitcoin0-1.0.10+nmu2/src/Makefile.am --- libbitcoin0-1.0.10+nmu1/src/Makefile.am 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/Makefile.am 2013-12-13 00:01:54.000000000 +0000 @@ -2,10 +2,8 @@ lib_LTLIBRARIES = libbitcoin.la AM_CPPFLAGS = -I$(srcdir)/../include -AM_CXXFLAGS = ${my_CXXFLAGS} libbitcoin_la_SOURCES = \ satoshi_serialize.cpp \ - deterministic_wallet.cpp \ getx_responder.cpp \ threadpool.cpp \ network/network.cpp \ @@ -29,6 +27,7 @@ utility/base58.cpp \ utility/big_number.cpp \ utility/key_formats.cpp \ + utility/timed_section.cpp \ utility/mnemonic.cpp \ constants.cpp \ blockchain/organizer.cpp \ @@ -45,3 +44,7 @@ blockchain/leveldb/leveldb_common.cpp endif +libbitcoin_la_LIBADD = \ + -lboost_thread -lboost_system -lboost_regex -lboost_filesystem -lpthread \ + -lcurl @LDFLAG_LEVELDB@ -lcrypto -ldl -lz + diff -Nru libbitcoin0-1.0.10+nmu1/src/Makefile.in libbitcoin0-1.0.10+nmu2/src/Makefile.in --- libbitcoin0-1.0.10+nmu1/src/Makefile.in 2013-10-06 10:32:01.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/Makefile.in 2013-12-13 00:02:42.000000000 +0000 @@ -100,16 +100,16 @@ } am__installdirs = "$(DESTDIR)$(libdir)" LTLIBRARIES = $(lib_LTLIBRARIES) -libbitcoin_la_LIBADD = +libbitcoin_la_DEPENDENCIES = am__libbitcoin_la_SOURCES_DIST = satoshi_serialize.cpp \ - deterministic_wallet.cpp getx_responder.cpp threadpool.cpp \ - network/network.cpp network/handshake.cpp network/channel.cpp \ - network/hosts.cpp network/protocol.cpp poller.cpp \ - utility/logger.cpp utility/sha256.cpp address.cpp format.cpp \ - script.cpp utility/ripemd.cpp block.cpp \ - utility/elliptic_curve_key.cpp transaction.cpp error.cpp \ - validate.cpp session.cpp utility/base58.cpp \ - utility/big_number.cpp utility/key_formats.cpp \ + getx_responder.cpp threadpool.cpp network/network.cpp \ + network/handshake.cpp network/channel.cpp network/hosts.cpp \ + network/protocol.cpp poller.cpp utility/logger.cpp \ + utility/sha256.cpp address.cpp format.cpp script.cpp \ + utility/ripemd.cpp block.cpp utility/elliptic_curve_key.cpp \ + transaction.cpp error.cpp validate.cpp session.cpp \ + utility/base58.cpp utility/big_number.cpp \ + utility/key_formats.cpp utility/timed_section.cpp \ utility/mnemonic.cpp constants.cpp blockchain/organizer.cpp \ blockchain/blockchain.cpp transaction_pool.cpp \ transaction_indexer.cpp \ @@ -125,31 +125,47 @@ @DO_LEVELDB_TRUE@ blockchain/leveldb/leveldb_organizer.lo \ @DO_LEVELDB_TRUE@ blockchain/leveldb/leveldb_validate_block.lo \ @DO_LEVELDB_TRUE@ blockchain/leveldb/leveldb_common.lo -am_libbitcoin_la_OBJECTS = satoshi_serialize.lo \ - deterministic_wallet.lo getx_responder.lo threadpool.lo \ - network/network.lo network/handshake.lo network/channel.lo \ - network/hosts.lo network/protocol.lo poller.lo \ - utility/logger.lo utility/sha256.lo address.lo format.lo \ - script.lo utility/ripemd.lo block.lo \ +am_libbitcoin_la_OBJECTS = satoshi_serialize.lo getx_responder.lo \ + threadpool.lo network/network.lo network/handshake.lo \ + network/channel.lo network/hosts.lo network/protocol.lo \ + poller.lo utility/logger.lo utility/sha256.lo address.lo \ + format.lo script.lo utility/ripemd.lo block.lo \ utility/elliptic_curve_key.lo transaction.lo error.lo \ validate.lo session.lo utility/base58.lo utility/big_number.lo \ - utility/key_formats.lo utility/mnemonic.lo constants.lo \ - blockchain/organizer.lo blockchain/blockchain.lo \ - transaction_pool.lo transaction_indexer.lo $(am__objects_1) + utility/key_formats.lo utility/timed_section.lo \ + utility/mnemonic.lo constants.lo blockchain/organizer.lo \ + blockchain/blockchain.lo transaction_pool.lo \ + transaction_indexer.lo $(am__objects_1) libbitcoin_la_OBJECTS = $(am_libbitcoin_la_OBJECTS) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ - --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ - $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CXXFLAGS) $(CXXFLAGS) +AM_V_CXX = $(am__v_CXX_@AM_V@) +am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) +am__v_CXX_0 = @echo " CXX " $@; +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ CXXLD = $(CXX) -CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ - --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ - $(LDFLAGS) -o $@ +CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) +am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) +am__v_CXXLD_0 = @echo " CXXLD " $@; +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(libbitcoin_la_SOURCES) DIST_SOURCES = $(am__libbitcoin_la_SOURCES_DIST) am__can_run_installinfo = \ @@ -162,6 +178,8 @@ DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ +AM_CXXFLAGS = @AM_CXXFLAGS@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ @@ -277,7 +295,6 @@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ -my_CXXFLAGS = @my_CXXFLAGS@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgconfigdir = @pkgconfigdir@ @@ -295,18 +312,21 @@ AUTOMAKE_OPTIONS = subdir-objects lib_LTLIBRARIES = libbitcoin.la AM_CPPFLAGS = -I$(srcdir)/../include -AM_CXXFLAGS = ${my_CXXFLAGS} -libbitcoin_la_SOURCES = satoshi_serialize.cpp deterministic_wallet.cpp \ - getx_responder.cpp threadpool.cpp network/network.cpp \ - network/handshake.cpp network/channel.cpp network/hosts.cpp \ - network/protocol.cpp poller.cpp utility/logger.cpp \ - utility/sha256.cpp address.cpp format.cpp script.cpp \ - utility/ripemd.cpp block.cpp utility/elliptic_curve_key.cpp \ - transaction.cpp error.cpp validate.cpp session.cpp \ - utility/base58.cpp utility/big_number.cpp \ - utility/key_formats.cpp utility/mnemonic.cpp constants.cpp \ +libbitcoin_la_SOURCES = satoshi_serialize.cpp getx_responder.cpp \ + threadpool.cpp network/network.cpp network/handshake.cpp \ + network/channel.cpp network/hosts.cpp network/protocol.cpp \ + poller.cpp utility/logger.cpp utility/sha256.cpp address.cpp \ + format.cpp script.cpp utility/ripemd.cpp block.cpp \ + utility/elliptic_curve_key.cpp transaction.cpp error.cpp \ + validate.cpp session.cpp utility/base58.cpp \ + utility/big_number.cpp utility/key_formats.cpp \ + utility/timed_section.cpp utility/mnemonic.cpp constants.cpp \ blockchain/organizer.cpp blockchain/blockchain.cpp \ transaction_pool.cpp transaction_indexer.cpp $(am__append_1) +libbitcoin_la_LIBADD = \ + -lboost_thread -lboost_system -lboost_regex -lboost_filesystem -lpthread \ + -lcurl @LDFLAG_LEVELDB@ -lcrypto -ldl -lz + all: all-am .SUFFIXES: @@ -409,6 +429,8 @@ utility/$(DEPDIR)/$(am__dirstamp) utility/key_formats.lo: utility/$(am__dirstamp) \ utility/$(DEPDIR)/$(am__dirstamp) +utility/timed_section.lo: utility/$(am__dirstamp) \ + utility/$(DEPDIR)/$(am__dirstamp) utility/mnemonic.lo: utility/$(am__dirstamp) \ utility/$(DEPDIR)/$(am__dirstamp) blockchain/$(am__dirstamp): @@ -443,7 +465,7 @@ blockchain/leveldb/$(am__dirstamp) \ blockchain/leveldb/$(DEPDIR)/$(am__dirstamp) libbitcoin.la: $(libbitcoin_la_OBJECTS) $(libbitcoin_la_DEPENDENCIES) $(EXTRA_libbitcoin_la_DEPENDENCIES) - $(CXXLINK) -rpath $(libdir) $(libbitcoin_la_OBJECTS) $(libbitcoin_la_LIBADD) $(LIBS) + $(AM_V_CXXLD)$(CXXLINK) -rpath $(libdir) $(libbitcoin_la_OBJECTS) $(libbitcoin_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -487,6 +509,8 @@ -rm -f utility/ripemd.lo -rm -f utility/sha256.$(OBJEXT) -rm -f utility/sha256.lo + -rm -f utility/timed_section.$(OBJEXT) + -rm -f utility/timed_section.lo distclean-compile: -rm -f *.tab.c @@ -494,7 +518,6 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/address.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/block.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/constants.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/deterministic_wallet.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/error.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/format.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getx_responder.Plo@am__quote@ @@ -527,30 +550,31 @@ @AMDEP_TRUE@@am__include@ @am__quote@utility/$(DEPDIR)/mnemonic.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@utility/$(DEPDIR)/ripemd.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@utility/$(DEPDIR)/sha256.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@utility/$(DEPDIR)/timed_section.Plo@am__quote@ .cpp.o: -@am__fastdepCXX_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: -@am__fastdepCXX_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: -@am__fastdepCXX_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo diff -Nru libbitcoin0-1.0.10+nmu1/src/address.cpp libbitcoin0-1.0.10+nmu2/src/address.cpp --- libbitcoin0-1.0.10+nmu1/src/address.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/address.cpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include diff -Nru libbitcoin0-1.0.10+nmu1/src/block.cpp libbitcoin0-1.0.10+nmu2/src/block.cpp --- libbitcoin0-1.0.10+nmu1/src/block.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/block.cpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include @@ -88,7 +107,7 @@ coinbase_input.previous_output.index = std::numeric_limits::max(); // The Times 03/Jan/2009 Chancellor on brink of second bailout for banks - coinbase_input.script = coinbase_script( + coinbase_input.script = raw_data_script( data_chunk{0x04, 0xff, 0xff, 0x00, 0x1d, 0x01, 0x04, 0x45, 0x54, 0x68, 0x65, 0x20, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x20, 0x30, 0x33, 0x2f, 0x4a, 0x61, 0x6e, diff -Nru libbitcoin0-1.0.10+nmu1/src/blockchain/blockchain.cpp libbitcoin0-1.0.10+nmu2/src/blockchain/blockchain.cpp --- libbitcoin0-1.0.10+nmu1/src/blockchain/blockchain.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/blockchain/blockchain.cpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,7 +1,27 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include #include +#include namespace libbitcoin { @@ -168,8 +188,8 @@ std::bind(&fetch_locator::append, this_ptr, _1, _2, height)); } - void append(const std::error_code& ec, const block_header_type& blk_header, - size_t height) + void append(const std::error_code& ec, + const block_header_type& blk_header, size_t /* height */) { if (stop_on_error(ec)) return; diff -Nru libbitcoin0-1.0.10+nmu1/src/blockchain/leveldb/leveldb_blockchain.cpp libbitcoin0-1.0.10+nmu2/src/blockchain/leveldb/leveldb_blockchain.cpp --- libbitcoin0-1.0.10+nmu1/src/blockchain/leveldb/leveldb_blockchain.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/blockchain/leveldb/leveldb_blockchain.cpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,6 +1,26 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include +#include #include #include #include @@ -259,15 +279,6 @@ }); } -bool get_block_header_impl(size_t height, - leveldb_common_ptr common, leveldb_block_info& blk) -{ -} -bool get_block_header_impl(const hash_digest& hash, - leveldb_common_ptr common, leveldb_block_info& blk) -{ -} - void leveldb_blockchain::fetch_block_header(size_t height, fetch_handler_block_header handle_fetch) { @@ -474,12 +485,12 @@ load_data(it_->value()); } - void operator++() + void next() { it_->Next(); } - uint32_t checksum() const + uint64_t checksum() const { return checksum_; } @@ -509,16 +520,16 @@ { const uint8_t* begin = slice_begin(key.data()); const uint8_t* end = begin + key.size(); - BITCOIN_ASSERT(key.size() == 1 + short_hash_size + 4); + BITCOIN_ASSERT(key.size() == 1 + short_hash_size + 8); auto deserial = make_deserializer(begin + 1 + short_hash_size, end); - checksum_ = deserial.read_4_bytes(); + checksum_ = deserial.read_8_bytes(); BITCOIN_ASSERT(deserial.iterator() == end); } leveldb_iterator it_; data_chunk raw_address_; - uint32_t checksum_; + uint64_t checksum_; }; class outpoint_iterator @@ -568,38 +579,15 @@ inpoint_iterator(database_ptr& db, const payment_address& address) : point_iterator(db, address) {} - input_point next_inpoint(uint32_t credit_checksum) + input_point inpoint() { - // Check if there's an equivalent spend for this credit. - if (!valid()) - return {null_hash, max_index}; - // Valid iterator so load the data. - if (dirty_) - { - load(); - dirty_ = false; - } - // The next spend in the iterator is not for this output point. - if (checksum() != credit_checksum) - return {null_hash, max_index}; - // Checksums match. Spend for this output exists. - input_point result = inpoint_; - ++(*this); - return result; + return inpoint_; } - uint32_t height(uint32_t credit_checksum) const + uint32_t height() const { - if (checksum() != credit_checksum) - return 0; return height_; } - void make_dirty() - { - // Dirty so we reload next time. - dirty_ = true; - } - protected: void load_data(leveldb::Slice data) { @@ -614,7 +602,6 @@ } private: - bool dirty_ = true; input_point inpoint_; uint32_t height_ = max_index; }; @@ -629,33 +616,57 @@ bool leveldb_blockchain::do_fetch_history(const payment_address& address, fetch_handler_history handle_fetch, size_t from_height, size_t slock) { + constexpr uint32_t max_height = std::numeric_limits::max(); + struct spend_data + { + input_point point; + uint32_t height; + }; + typedef std::unordered_map spend_map; + + // First we create map of spends... + spend_map spends; + for (inpoint_iterator debit_it(db_debit_, address); + debit_it.valid(); debit_it.next()) + { + debit_it.load(); + uint64_t checksum = debit_it.checksum(); + spends.emplace(checksum, + spend_data{debit_it.inpoint(), debit_it.height()}); + } + // ... Then we load outputs. history_list history; - // Load output data - inpoint_iterator debit_it(db_debit_, address); for (outpoint_iterator credit_it(db_credit_, address); - credit_it.valid(); ++credit_it) + credit_it.valid(); credit_it.next()) { credit_it.load(); - uint32_t checksum = credit_it.checksum(); + // Row with no spend (yet) history_row row{ credit_it.outpoint(), credit_it.height(), credit_it.value(), - debit_it.next_inpoint(checksum), - debit_it.height(checksum) + input_point{null_hash, max_index}, + max_height }; - debit_it.make_dirty(); - BITCOIN_ASSERT(row.spend.hash == null_hash || - row.spend_height >= row.output_height); + // Now search for the spend. If it exists, + // then load and add it to the row. + uint64_t checksum = credit_it.checksum(); + auto it = spends.find(checksum); + const bool spend_exists = it != spends.end(); + if (spend_exists) + { + const spend_data& data = it->second; + row.spend = data.point; + row.spend_height = data.height; + BITCOIN_ASSERT(row.spend_height >= row.output_height); + } // Filter entries below the from_height. if (row.output_height >= from_height || - row.spend_height >= from_height) + (spend_exists && row.spend_height >= from_height)) { history.push_back(row); } } - // All the debits should have been loaded. - BITCOIN_ASSERT(!debit_it.valid()); // Finish. return finish_fetch(slock, handle_fetch, std::error_code(), history); } diff -Nru libbitcoin0-1.0.10+nmu1/src/blockchain/leveldb/leveldb_chain_keeper.cpp libbitcoin0-1.0.10+nmu2/src/blockchain/leveldb/leveldb_chain_keeper.cpp --- libbitcoin0-1.0.10+nmu1/src/blockchain/leveldb/leveldb_chain_keeper.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/blockchain/leveldb/leveldb_chain_keeper.cpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include "leveldb_chain_keeper.hpp" #include @@ -47,10 +66,11 @@ data_chunk raw_height = uncast_type(slice_begin_index); for (it->Seek(slice(raw_height)); it->Valid(); it->Next()) { - constexpr size_t bits_offset = 4 + 2 * hash_digest_size + 4; + constexpr size_t bits_field_offset = 4 + 2 * hash_digest_size + 4; BITCOIN_ASSERT(it->value().size() >= 84); // Deserialize only the bits field of block header. - std::string raw_bits(it->value().data(), 4); + const char* bits_field_begin = it->value().data() + bits_field_offset; + std::string raw_bits(bits_field_begin, 4); auto deserial = make_deserializer(raw_bits.begin(), raw_bits.end()); uint32_t bits = deserial.read_4_bytes(); // Accumulate the total work. diff -Nru libbitcoin0-1.0.10+nmu1/src/blockchain/leveldb/leveldb_chain_keeper.hpp libbitcoin0-1.0.10+nmu2/src/blockchain/leveldb/leveldb_chain_keeper.hpp --- libbitcoin0-1.0.10+nmu1/src/blockchain/leveldb/leveldb_chain_keeper.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/blockchain/leveldb/leveldb_chain_keeper.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_BLOCKCHAIN_LEVELDB_CHAIN_KEEPER_H #define LIBBITCOIN_BLOCKCHAIN_LEVELDB_CHAIN_KEEPER_H diff -Nru libbitcoin0-1.0.10+nmu1/src/blockchain/leveldb/leveldb_common.cpp libbitcoin0-1.0.10+nmu2/src/blockchain/leveldb/leveldb_common.cpp --- libbitcoin0-1.0.10+nmu1/src/blockchain/leveldb/leveldb_common.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/blockchain/leveldb/leveldb_common.cpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include "leveldb_common.hpp" #include @@ -97,9 +116,9 @@ } serial_hashes.write_hash(tx_hash); } - BITCOIN_ASSERT( - std::distance(raw_block_data.begin(), serial_hashes.iterator()) == - 80 + 4 + serial_block.transactions.size() * hash_digest_size); + BITCOIN_ASSERT(serial_hashes.iterator() == + raw_block_data.begin() + 80 + 4 + + serial_block.transactions.size() * hash_digest_size); data_chunk raw_height = uncast_type(height); hash_digest block_hash = hash_block_header(serial_block.header); // Write block header @@ -110,11 +129,19 @@ return true; } +// There are 2 duplicated transactions in the blockchain. +// Since then this part of Bitcoin was changed to disallow duplicates. +bool is_special_duplicate(uint32_t block_height, uint32_t tx_index) +{ + return (block_height == 91842 || block_height == 91880) && + tx_index == 0; +} + bool leveldb_common::save_transaction(leveldb_transaction_batch& batch, uint32_t block_height, uint32_t tx_index, const hash_digest& tx_hash, const transaction_type& block_tx) { - if (duplicate_exists(tx_hash, block_height, tx_index)) + if (is_special_duplicate(block_height, tx_index)) return true; data_chunk tx_data(8 + satoshi_raw_size(block_tx)); // Serialize tx. @@ -124,8 +151,7 @@ // Actual tx data. auto end_iter = satoshi_save(block_tx, serial.iterator()); BITCOIN_ASSERT( - std::distance(tx_data.begin(), end_iter) == - 8 + satoshi_raw_size(block_tx)); + tx_data.begin() + 8 + satoshi_raw_size(block_tx) == end_iter); // Save tx to leveldb batch.tx.Put(slice(tx_hash), slice(tx_data)); // Add inputs to spends database. @@ -157,16 +183,6 @@ return true; } -bool leveldb_common::duplicate_exists(const hash_digest& tx_hash, - uint32_t block_height, uint32_t tx_index) -{ - leveldb_tx_info tx; - if (!get_transaction(tx, tx_hash, false, false)) - return false; - BITCOIN_ASSERT(block_height == 91842 || block_height == 91880); - return true; -} - bool mark_spent_outputs(leveldb::WriteBatch& spend_batch, const output_point& previous_output, const input_point& spent_inpoint) { @@ -328,28 +344,26 @@ reinterpret_cast(block_hash.data() + 16), 16); } -uint32_t addr_key_checksum(const output_point& outpoint) +uint64_t addr_key_checksum(const output_point& outpoint) { - data_chunk chksum_data(hash_digest_size + 4); - auto serial = make_serializer(chksum_data.begin()); + data_chunk checksum_data(hash_digest_size + 4); + auto serial = make_serializer(checksum_data.begin()); serial.write_hash(outpoint.hash); serial.write_4_bytes(outpoint.index); - BITCOIN_ASSERT( - std::distance(chksum_data.begin(), serial.iterator()) == - hash_digest_size + 4); - return generate_sha256_checksum(chksum_data); + BITCOIN_ASSERT(serial.iterator() == checksum_data.end()); + hash_digest hash = generate_sha256_hash(checksum_data); + data_chunk raw_checksum(hash.begin(), hash.begin() + 8); + return cast_chunk(raw_checksum); } data_chunk create_address_key( const payment_address& address, const output_point& outpoint) { - data_chunk result(1 + short_hash_size + 4); + data_chunk result(1 + short_hash_size + 8); auto serial = make_serializer(result.begin()); serial.write_byte(address.version()); serial.write_short_hash(address.hash()); - serial.write_4_bytes(addr_key_checksum(outpoint)); - BITCOIN_ASSERT( - std::distance(result.begin(), serial.iterator()) == - 1 + short_hash_size + 4); + serial.write_8_bytes(addr_key_checksum(outpoint)); + BITCOIN_ASSERT(serial.iterator() == result.end()); return result; } diff -Nru libbitcoin0-1.0.10+nmu1/src/blockchain/leveldb/leveldb_common.hpp libbitcoin0-1.0.10+nmu2/src/blockchain/leveldb/leveldb_common.hpp --- libbitcoin0-1.0.10+nmu1/src/blockchain/leveldb/leveldb_common.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/blockchain/leveldb/leveldb_common.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_BLOCKCHAIN_LEVELDB_COMMON_H #define LIBBITCOIN_BLOCKCHAIN_LEVELDB_COMMON_H @@ -74,8 +93,6 @@ bool save_transaction(leveldb_transaction_batch& batch, uint32_t block_height, uint32_t tx_index, const hash_digest& tx_hash, const transaction_type& block_tx); - bool duplicate_exists(const hash_digest& tx_hash, - uint32_t block_height, uint32_t tx_index); leveldb_databases db_; }; diff -Nru libbitcoin0-1.0.10+nmu1/src/blockchain/leveldb/leveldb_organizer.cpp libbitcoin0-1.0.10+nmu2/src/blockchain/leveldb/leveldb_organizer.cpp --- libbitcoin0-1.0.10+nmu1/src/blockchain/leveldb/leveldb_organizer.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/blockchain/leveldb/leveldb_organizer.cpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include "leveldb_organizer.hpp" #include @@ -16,13 +35,26 @@ std::error_code leveldb_organizer::verify(int fork_index, const block_detail_list& orphan_chain, int orphan_index) { + BITCOIN_ASSERT(orphan_index >= 0); BITCOIN_ASSERT(orphan_index < orphan_chain.size()); const block_type& current_block = orphan_chain[orphan_index]->actual(); size_t height = fork_index + orphan_index + 1; BITCOIN_ASSERT(height != 0); leveldb_validate_block validate(common_, fork_index, orphan_chain, orphan_index, height, current_block); - return validate.start(); + // Perform checks. + std::error_code ec; + ec = validate.check_block(); + if (ec) + return ec; + ec = validate.accept_block(); + if (ec) + return ec; + // Skip non-essential checks if before last checkpoint. + if (fork_index < 262835) + return std::error_code(); + // Perform strict but slow tests - connect_block() + return validate.connect_block(); } void leveldb_organizer::reorganize_occured( size_t fork_point, diff -Nru libbitcoin0-1.0.10+nmu1/src/blockchain/leveldb/leveldb_organizer.hpp libbitcoin0-1.0.10+nmu2/src/blockchain/leveldb/leveldb_organizer.hpp --- libbitcoin0-1.0.10+nmu1/src/blockchain/leveldb/leveldb_organizer.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/blockchain/leveldb/leveldb_organizer.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_BLOCKCHAIN_LEVELDB_ORGANIZER_H #define LIBBITCOIN_BLOCKCHAIN_LEVELDB_ORGANIZER_H diff -Nru libbitcoin0-1.0.10+nmu1/src/blockchain/leveldb/leveldb_validate_block.cpp libbitcoin0-1.0.10+nmu2/src/blockchain/leveldb/leveldb_validate_block.cpp --- libbitcoin0-1.0.10+nmu1/src/blockchain/leveldb/leveldb_validate_block.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/blockchain/leveldb/leveldb_validate_block.cpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include "leveldb_validate_block.hpp" #include diff -Nru libbitcoin0-1.0.10+nmu1/src/blockchain/leveldb/leveldb_validate_block.hpp libbitcoin0-1.0.10+nmu2/src/blockchain/leveldb/leveldb_validate_block.hpp --- libbitcoin0-1.0.10+nmu1/src/blockchain/leveldb/leveldb_validate_block.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/blockchain/leveldb/leveldb_validate_block.hpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef LIBBITCOIN_BLOCKCHAIN_LEVELDB_VALIDATE_BLOCK_H #define LIBBITCOIN_BLOCKCHAIN_LEVELDB_VALIDATE_BLOCK_H diff -Nru libbitcoin0-1.0.10+nmu1/src/blockchain/organizer.cpp libbitcoin0-1.0.10+nmu2/src/blockchain/organizer.cpp --- libbitcoin0-1.0.10+nmu1/src/blockchain/organizer.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/blockchain/organizer.cpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include @@ -162,6 +181,7 @@ { big_number orphan_work = 0; // Starting from beginning of the chain, validate blocks + // Q: Why am I using an int here? TODO: investigate. for (int orphan_index = 0; orphan_index < orphan_chain.size(); ++orphan_index) { diff -Nru libbitcoin0-1.0.10+nmu1/src/constants.cpp libbitcoin0-1.0.10+nmu2/src/constants.cpp --- libbitcoin0-1.0.10+nmu1/src/constants.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/constants.cpp 2013-12-13 00:01:54.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include namespace libbitcoin { @@ -9,5 +28,13 @@ return max_target; } +uint32_t magic_value() +{ + #ifdef ENABLE_TESTNET + return 0x0709110b; + #else + return 0xd9b4bef9; + #endif +} } // namespace libbitcoin diff -Nru libbitcoin0-1.0.10+nmu1/src/deterministic_wallet.cpp libbitcoin0-1.0.10+nmu2/src/deterministic_wallet.cpp --- libbitcoin0-1.0.10+nmu1/src/deterministic_wallet.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/deterministic_wallet.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,214 +0,0 @@ -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace libbitcoin { - -template -struct ssl_wrapper -{ - ssl_wrapper(ssl_type* obj) - : obj(obj) {} - virtual ~ssl_wrapper() - { - } - operator ssl_type*() - { - return obj; - } - - ssl_type* obj; -}; - -struct ssl_bignum - : public ssl_wrapper -{ - ssl_bignum() - : ssl_wrapper(BN_new()) {} - ~ssl_bignum() - { - BN_free(obj); - } -}; - -#define SSL_TYPE(name, ssl_type, free_func) \ - struct name \ - : public ssl_wrapper \ - { \ - name(ssl_type* obj) \ - : ssl_wrapper(obj) {} \ - ~name() \ - { \ - free_func(obj); \ - } \ - }; - -SSL_TYPE(ec_group, EC_GROUP, EC_GROUP_free) -SSL_TYPE(ec_point, EC_POINT, EC_POINT_free) -SSL_TYPE(bn_ctx, BN_CTX, BN_CTX_free) - -const std::string bignum_hex(BIGNUM* bn) -{ - char* repr = BN_bn2hex(bn); - std::string result = repr; - OPENSSL_free(repr); - boost::algorithm::to_lower(result); - return result; -} - -const data_chunk bignum_data(BIGNUM* bn) -{ - data_chunk result(BN_num_bytes(bn)); - BN_bn2bin(bn, result.data()); - return result; -} - -void deterministic_wallet::new_seed() -{ - constexpr size_t bits_needed = 8 * seed_size / 2; - ssl_bignum rand_value; - BN_rand(rand_value, bits_needed, 0, 0); - bool set_success = set_seed(bignum_hex(rand_value)); - BITCOIN_ASSERT(set_success); -} - -secret_parameter stretch_seed(const std::string& seed) -{ - BITCOIN_ASSERT(seed.size() == deterministic_wallet::seed_size); - secret_parameter stretched; - std::copy(seed.begin(), seed.end(), stretched.begin()); - secret_parameter oldseed = stretched; - for (size_t i = 0; i < 100000; ++i) - { - SHA256_CTX ctx; - SHA256_Init(&ctx); - SHA256_Update(&ctx, stretched.data(), stretched.size()); - SHA256_Update(&ctx, oldseed.data(), oldseed.size()); - SHA256_Final(stretched.data(), &ctx); - } - return stretched; -} - -data_chunk pubkey_from_secret(const secret_parameter& secret) -{ - elliptic_curve_key privkey; - if (!privkey.set_secret(secret)) - return data_chunk(); - return privkey.public_key(); -} - -bool deterministic_wallet::set_seed(std::string seed) -{ - // Trim spaces and newlines around the string. - boost::algorithm::trim(seed); - if (seed.size() != seed_size) - return false; - seed_ = seed; - stretched_seed_ = stretch_seed(seed); - master_public_key_ = pubkey_from_secret(stretched_seed_); - // Snip the beginning 04 byte for compat reasons. - master_public_key_.erase(master_public_key_.begin()); - if (master_public_key_.empty()) - return false; - return true; -} -const std::string& deterministic_wallet::seed() const -{ - return seed_; -} - -bool deterministic_wallet::set_master_public_key(const data_chunk& mpk) -{ - master_public_key_ = mpk; - return true; -} -const data_chunk& deterministic_wallet::master_public_key() const -{ - return master_public_key_; -} - -data_chunk deterministic_wallet::generate_public_key( - size_t n, bool for_change) const -{ - hash_digest sequence = get_sequence(n, for_change); - - ssl_bignum x, y, z; - BN_bin2bn(sequence.data(), sequence.size(), z); - BN_bin2bn(master_public_key_.data(), 32, x); - BN_bin2bn(master_public_key_.data() + 32, 32, y); - - // Create a point. - ec_group group(EC_GROUP_new_by_curve_name(NID_secp256k1)); - ec_point mpk(EC_POINT_new(group)); - bn_ctx ctx(BN_CTX_new()); - EC_POINT_set_affine_coordinates_GFp(group, mpk, x, y, ctx); - ec_point result(EC_POINT_new(group)); - - // result pubkey_point = mpk_pubkey_point + z*curve.generator - ssl_bignum one; - BN_one(one); - EC_POINT_mul(group, result, z, mpk, one, ctx); - - // Create the actual public key. - EC_POINT_get_affine_coordinates_GFp(group, result, x, y, ctx); - // 04 + x + y - data_chunk raw_pubkey{0x04}; - extend_data(raw_pubkey, bignum_data(x)); - extend_data(raw_pubkey, bignum_data(y)); - return raw_pubkey; -} - -secret_parameter deterministic_wallet::generate_secret( - size_t n, bool for_change) const -{ - if (seed_.empty()) - return null_hash; - - ssl_bignum z; - hash_digest sequence = get_sequence(n, for_change); - BN_bin2bn(sequence.data(), sequence.size(), z); - - ec_group group(EC_GROUP_new_by_curve_name(NID_secp256k1)); - ssl_bignum order; - bn_ctx ctx(BN_CTX_new()); - EC_GROUP_get_order(group, order, ctx); - - // secexp = (stretched_seed + z) % order - ssl_bignum secexp; - BN_bin2bn(stretched_seed_.data(), stretched_seed_.size(), secexp); - BN_add(secexp, secexp, z); - BN_mod(secexp, secexp, order, ctx); - - secret_parameter secret; - BITCOIN_ASSERT(BN_num_bytes(secexp) <= secret.size()); - // If bignum value begins with 0x00, then - // SSL will skip to the first significant digit. - size_t copy_offset = secret.size() - BN_num_bytes(secexp); - BN_bn2bin(secexp, secret.data() + copy_offset); - return secret; -} - -hash_digest deterministic_wallet::get_sequence( - size_t n, bool for_change) const -{ - data_chunk chunk; - extend_data(chunk, std::to_string(n)); - chunk.push_back(':'); - chunk.push_back(for_change ? '1' : '0'); - chunk.push_back(':'); - extend_data(chunk, master_public_key_); - hash_digest result = generate_sha256_hash(chunk); - std::reverse(result.begin(), result.end()); - return result; -} - -} // namespace libbitcoin - diff -Nru libbitcoin0-1.0.10+nmu1/src/error.cpp libbitcoin0-1.0.10+nmu2/src/error.cpp --- libbitcoin0-1.0.10+nmu1/src/error.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/error.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include namespace libbitcoin { @@ -50,8 +69,11 @@ return "Bad stream"; case error::channel_timeout: return "Channel timed out"; - case error::forced_removal: - return "Forced removal of transaction"; + // transaction pool + case error::blockchain_reorganized: + return "Transactions invalidated from blockchain reorganization"; + case error::pool_filled: + return "Forced removal of old transaction from full pool"; // validate tx case error::coinbase_transaction: return "Memory pool coinbase transaction"; @@ -153,6 +175,9 @@ case error::fees_out_of_range: case error::coinbase_too_large: return error::validate_failed; + case error::blockchain_reorganized: + case error::pool_filled: + return error::forced_removal; default: return std::error_condition(ev, *this); } diff -Nru libbitcoin0-1.0.10+nmu1/src/format.cpp libbitcoin0-1.0.10+nmu2/src/format.cpp --- libbitcoin0-1.0.10+nmu1/src/format.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/format.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include diff -Nru libbitcoin0-1.0.10+nmu1/src/getx_responder.cpp libbitcoin0-1.0.10+nmu2/src/getx_responder.cpp --- libbitcoin0-1.0.10+nmu1/src/getx_responder.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/getx_responder.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include diff -Nru libbitcoin0-1.0.10+nmu1/src/network/channel.cpp libbitcoin0-1.0.10+nmu2/src/network/channel.cpp --- libbitcoin0-1.0.10+nmu1/src/network/channel.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/network/channel.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include namespace libbitcoin { @@ -68,8 +87,8 @@ } channel_proxy::channel_proxy(threadpool& pool, socket_ptr socket) - : strand_(pool.service()), stopped_(false), socket_(socket), - timeout_(pool.service()), heartbeat_(pool.service()) + : strand_(pool.service()), socket_(socket), + timeout_(pool.service()), heartbeat_(pool.service()), stopped_(false) { #define CHANNEL_TRANSPORT_MECHANISM(MESSAGE_TYPE) \ MESSAGE_TYPE##_subscriber_ = \ @@ -255,14 +274,9 @@ bool verify_header(const header_type& header_msg) { - if (header_msg.magic != magic_value) + if (header_msg.magic != magic_value()) return false; - if (header_msg.command == "version") - { - if (header_msg.payload_length < 85) - return false; - } - else if (header_msg.command == "verack" + if (header_msg.command == "verack" || header_msg.command == "getaddr") { if (header_msg.payload_length != 0) @@ -274,7 +288,8 @@ if (header_msg.payload_length != 8) return false; } - else if (header_msg.command == "inv" + else if (header_msg.command == "version" + || header_msg.command == "inv" || header_msg.command == "addr" || header_msg.command == "getdata" || header_msg.command == "getblocks" @@ -324,7 +339,7 @@ return; BITCOIN_ASSERT(bytes_transferred == header_checksum_size); data_chunk checksum_stream = data_chunk( - inbound_checksum_.begin(), inbound_checksum_.end()); + inbound_checksum_.begin(), inbound_checksum_.end()); BITCOIN_ASSERT(checksum_stream.size() == header_checksum_size); header_msg.checksum = cast_chunk(checksum_stream); read_payload(header_msg); diff -Nru libbitcoin0-1.0.10+nmu1/src/network/handshake.cpp libbitcoin0-1.0.10+nmu2/src/network/handshake.cpp --- libbitcoin0-1.0.10+nmu1/src/network/handshake.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/network/handshake.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include @@ -13,8 +32,6 @@ using std::placeholders::_1; using std::placeholders::_2; -const size_t clearance_count = 3; - handshake::handshake(threadpool& pool) : strand_(pool.service()) { @@ -44,52 +61,45 @@ void handshake::ready(channel_ptr node, handshake::handshake_handler handle_handshake) { - atomic_counter_ptr counter = std::make_shared(0); + auto completion_callback = async_parallel(handle_handshake, 3); version_type session_version = template_version_; session_version.timestamp = time(NULL); node->send(session_version, strand_.wrap(std::bind(&handshake::handle_message_sent, - this, _1, counter, handle_handshake))); + this, _1, completion_callback))); node->subscribe_version( strand_.wrap(std::bind(&handshake::receive_version, - this, _1, _2, node, counter, handle_handshake))); + this, _1, _2, node, completion_callback))); node->subscribe_verack( strand_.wrap(std::bind(&handshake::receive_verack, - this, _1, _2, counter, handle_handshake))); + this, _1, _2, completion_callback))); } void handshake::handle_message_sent(const std::error_code& ec, - atomic_counter_ptr counter, handshake::handshake_handler completion_callback) { - if (ec) - completion_callback(ec); - else if (++(*counter) == clearance_count) - completion_callback(std::error_code()); + completion_callback(ec); } -void handshake::receive_version(const std::error_code& ec, - const version_type&, channel_ptr node, atomic_counter_ptr counter, - handshake::handshake_handler completion_callback) +void handshake::receive_version( + const std::error_code& ec, const version_type&, + channel_ptr node, handshake::handshake_handler completion_callback) { if (ec) completion_callback(ec); else node->send(verack_type(), strand_.wrap(std::bind(&handshake::handle_message_sent, - this, _1, counter, completion_callback))); + this, _1, completion_callback))); } -void handshake::receive_verack(const std::error_code& ec, - const verack_type&, atomic_counter_ptr counter, +void handshake::receive_verack( + const std::error_code& ec, const verack_type&, handshake::handshake_handler completion_callback) { - if (ec) - completion_callback(ec); - else if (++(*counter) == clearance_count) - completion_callback(std::error_code()); + completion_callback(ec); } int writer(char* data, size_t size, size_t count, std::string* buffer) diff -Nru libbitcoin0-1.0.10+nmu1/src/network/hosts.cpp libbitcoin0-1.0.10+nmu2/src/network/hosts.cpp --- libbitcoin0-1.0.10+nmu1/src/network/hosts.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/network/hosts.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include diff -Nru libbitcoin0-1.0.10+nmu1/src/network/network.cpp libbitcoin0-1.0.10+nmu2/src/network/network.cpp --- libbitcoin0-1.0.10+nmu1/src/network/network.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/network/network.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include @@ -62,7 +81,7 @@ private: void call_connect_handler(const boost::system::error_code& ec, - tcp::resolver::iterator next, network::connect_handler handle_connect) + tcp::resolver::iterator, network::connect_handler handle_connect) { if (ec) { diff -Nru libbitcoin0-1.0.10+nmu1/src/network/protocol.cpp libbitcoin0-1.0.10+nmu2/src/network/protocol.cpp --- libbitcoin0-1.0.10+nmu1/src/network/protocol.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/network/protocol.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include @@ -19,8 +38,7 @@ protocol::protocol(threadpool& pool, hosts& hsts, handshake& shake, network& net) - : strand_(pool.service()), hosts_filename_("hosts"), - hosts_(hsts), handshake_(shake), network_(net) + : strand_(pool.service()), hosts_(hsts), handshake_(shake), network_(net) { channel_subscribe_ = std::make_shared(pool); } @@ -29,6 +47,14 @@ { max_outbound_ = max_outbound; } +void protocol::set_hosts_filename(const std::string& hosts_filename) +{ + hosts_filename_ = hosts_filename; +} +void protocol::disable_listener() +{ + listen_is_enabled_ = false; +} void protocol::start(completion_handler handle_complete) { @@ -253,69 +279,126 @@ void protocol::run() { - strand_.dispatch(std::bind(&protocol::try_connect, this)); - network_.listen(protocol_port, - strand_.wrap(std::bind(&protocol::handle_listen, - this, _1, _2))); -} -void protocol::try_connect() -{ - if (connections_.size() >= max_outbound_) - return; - for (size_t i = connections_.size(); i < max_outbound_; ++i) - hosts_.fetch_address( - strand_.wrap(std::bind(&protocol::attempt_connect, - this, _1, _2))); + strand_.dispatch(std::bind(&protocol::try_outbound_connects, this)); + if (listen_is_enabled_) + network_.listen(protocol_port, + strand_.wrap(std::bind(&protocol::handle_listen, this, _1, _2))); +} +void protocol::try_outbound_connects() +{ + BITCOIN_ASSERT(connections_.empty()); + BITCOIN_ASSERT(connect_states_.empty()); + connect_states_.resize(max_outbound_); + for (size_t i = 0; i < max_outbound_; ++i) + try_connect_once(i); +} +void protocol::try_connect_once(slot_index slot) +{ + BITCOIN_ASSERT(connections_.size() <= max_outbound_); + // Any state can call this method. + connect_states_[slot] = connect_state::finding_peer; + hosts_.fetch_address( + strand_.wrap(std::bind(&protocol::attempt_connect, + this, _1, _2, slot))); +} + +template +bool already_connected( + const network_address_type& address, + const ConnectionList& connections) +{ + // Are we already connected to this address? + for (const auto& connection: connections) + { + if (connection.address.ip == address.ip && + connection.address.port == address.port) + { + return true; + } + } + return false; } + void protocol::attempt_connect(const std::error_code& ec, - const network_address_type& address) + const network_address_type& address, slot_index slot) { + BITCOIN_ASSERT(connect_states_[slot] == connect_state::finding_peer); + connect_states_[slot] = connect_state::connecting; if (ec) { log_error(LOG_PROTOCOL) << "Problem fetching random address: " << ec.message(); return; } - // Are we already connected to shared_from_this() address? - for (const connection_info& connection: connections_) + if (already_connected(address, connections_)) { - if (connection.address.ip == address.ip && - connection.address.port == address.port) - { - log_debug(LOG_PROTOCOL) - << "Already connected to " << encode_hex(address.ip); - // Retry another connection - strand_.post( - std::bind(&protocol::try_connect, this)); - return; - } + log_debug(LOG_PROTOCOL) + << "Already connected to " << encode_hex(address.ip); + // Retry another connection + // Still in same strand. + try_connect_once(slot); + return; } log_debug(LOG_PROTOCOL) << "Trying " << pretty(address.ip) << ":" << address.port; connect(handshake_, network_, pretty(address.ip), address.port, strand_.wrap(std::bind(&protocol::handle_connect, - this, _1, _2, address))); + this, _1, _2, address, slot))); } -void protocol::handle_connect(const std::error_code& ec, channel_ptr node, - const network_address_type& address) -{ +void protocol::handle_connect( + const std::error_code& ec, channel_ptr node, + const network_address_type& address, slot_index slot) +{ + BITCOIN_ASSERT(connect_states_[slot] == connect_state::connecting); + connect_states_[slot] = connect_state::established; + BITCOIN_ASSERT(connections_.size() <= max_outbound_); if (ec) { log_warning(LOG_PROTOCOL) << "Unable to connect to " << pretty(address.ip) << ":" << address.port << " - " << ec.message(); - hosts_.fetch_address( - strand_.wrap(std::bind(&protocol::attempt_connect, - this, _1, _2))); + // Retry another connection + // Still in same strand. + try_connect_once(slot); + return; } - else + connections_.push_back({address, node}); + log_info(LOG_PROTOCOL) << "Connected to " + << pretty(address.ip) << ":" << address.port + << " (" << connections_.size() << " connections)"; + // Remove channel from list of connections + node->subscribe_stop( + strand_.wrap(std::bind(&protocol::outbound_channel_stopped, + this, _1, node, slot))); + setup_new_channel(node); +} + +void protocol::maintain_connection(const std::string& hostname, uint16_t port) +{ + connect(handshake_, network_, hostname, port, + strand_.wrap(std::bind(&protocol::handle_manual_connect, + this, _1, _2, hostname, port))); +} +void protocol::handle_manual_connect( + const std::error_code& ec, channel_ptr node, + const std::string& hostname, uint16_t port) +{ + if (ec) { - connections_.push_back({address, node}); - log_info(LOG_PROTOCOL) << "Connected to " - << pretty(address.ip) << ":" << address.port - << " (" << connections_.size() << " connections)"; - setup_new_channel(node); + log_warning(LOG_PROTOCOL) << "Manual connection to " + << hostname << ":" << port << " failed with " << ec.message(); + maintain_connection(hostname, port); + return; } + manual_connections_.push_back(node); + // Connected! + log_info(LOG_PROTOCOL) << "Manual connection established: " + << hostname << ":" << port; + // Remove channel from list of connections + node->subscribe_stop( + strand_.wrap(std::bind(&protocol::manual_channel_stopped, + this, _1, node, hostname, port))); + setup_new_channel(node); } void protocol::handle_listen(const std::error_code& ec, acceptor_ptr accept) @@ -350,10 +433,16 @@ auto handshake_complete = [this, node](const std::error_code& ec) { if (ec) + { log_error(LOG_PROTOCOL) << "Problem with handshake: " << ec.message(); - else - setup_new_channel(node); + return; + } + // Remove channel from list of connections + node->subscribe_stop( + strand_.wrap(std::bind(&protocol::inbound_channel_stopped, + this, _1, node))); + setup_new_channel(node); }; handshake_.ready(node, handshake_complete); } @@ -366,33 +455,76 @@ } void protocol::setup_new_channel(channel_ptr node) { - // Remove channel from list of connections - node->subscribe_stop( - strand_.wrap(std::bind(&protocol::channel_stopped, - this, _1, node))); subscribe_address(node); node->send(get_address_type(), handle_send); // Notify subscribers channel_subscribe_->relay(std::error_code(), node); } -void protocol::channel_stopped(const std::error_code& ec, - channel_ptr which_node) + +template +void remove_connection(ConnectionsList& connections, channel_ptr which_node) { - auto it = connections_.begin(); - for (; it != connections_.end(); ++it) + auto it = connections.begin(); + for (; it != connections.end(); ++it) if (it->node == which_node) break; - if (it != connections_.end()) + BITCOIN_ASSERT(it != connections.end()); + connections.erase(it); +} +void protocol::outbound_channel_stopped( + const std::error_code& ec, channel_ptr which_node, slot_index slot) +{ + // We must always attempt a reconnection if this was an + // outbound connection. + if (ec) + log_error(LOG_PROTOCOL) + << "Channel stopped (outbound): " << ec.message(); + // Erase this channel from our connections list. + // And then attempt a reconnection. + remove_connection(connections_, which_node); + BITCOIN_ASSERT(connect_states_[slot] == connect_state::established); + connect_states_[slot] = connect_state::stopped; + // Attempt a reconnection. + // Recreate 1 new connection always. + // Still in same strand. + try_connect_once(slot); +} + +template +void remove_channel(ChannelsList& channels, channel_ptr which_node) +{ + auto it = std::find(channels.begin(), channels.end(), which_node); + BITCOIN_ASSERT(it != channels.end()); + channels.erase(it); +} + +void protocol::manual_channel_stopped( + const std::error_code& ec, channel_ptr which_node, + const std::string& hostname, uint16_t port) +{ + // We must always attempt a reconnection if this was an + // outbound connection. + if (ec) + log_error(LOG_PROTOCOL) + << "Channel stopped (manual): " << ec.message(); + // Remove from list and try to reconnect. + // Timeout logic would go here if we ever need it. + remove_channel(manual_connections_, which_node); + // Reconnect again. + maintain_connection(hostname, port); +} +void protocol::inbound_channel_stopped( + const std::error_code& ec, channel_ptr which_node) +{ + // We must always attempt a reconnection if this was an + // outbound connection. + if (ec) { - connections_.erase(it); - // Recreate connections if need be - try_connect(); - } - auto acc_it = std::find( - accepted_channels_.begin(), - accepted_channels_.end(), which_node); - if (acc_it != accepted_channels_.end()) - accepted_channels_.erase(acc_it); + log_error(LOG_PROTOCOL) + << "Channel stopped (inbound): " << ec.message(); + } + // Remove from accepted connections. + remove_channel(accepted_channels_, which_node); } void protocol::subscribe_address(channel_ptr node) @@ -408,15 +540,16 @@ { log_error(LOG_PROTOCOL) << "Problem receiving addresses: " << ec.message(); + return; } - else - { - log_debug(LOG_PROTOCOL) << "Storing addresses."; - for (const network_address_type& net_address: packet.addresses) - hosts_.store(net_address, - strand_.wrap(std::bind(&protocol::handle_store_address, - this, _1))); - } + log_debug(LOG_PROTOCOL) << "Storing addresses."; + for (const network_address_type& net_address: packet.addresses) + hosts_.store(net_address, + strand_.wrap(std::bind(&protocol::handle_store_address, + this, _1))); + node->subscribe_address( + strand_.wrap(std::bind(&protocol::receive_address_message, + this, _1, _2, node))); } void protocol::handle_store_address(const std::error_code& ec) { diff -Nru libbitcoin0-1.0.10+nmu1/src/poller.cpp libbitcoin0-1.0.10+nmu2/src/poller.cpp --- libbitcoin0-1.0.10+nmu1/src/poller.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/poller.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include diff -Nru libbitcoin0-1.0.10+nmu1/src/satoshi_serialize.cpp libbitcoin0-1.0.10+nmu2/src/satoshi_serialize.cpp --- libbitcoin0-1.0.10+nmu1/src/satoshi_serialize.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/satoshi_serialize.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include namespace libbitcoin { @@ -34,7 +53,7 @@ { return "verack"; } -size_t satoshi_raw_size(const verack_type& packet) +size_t satoshi_raw_size(const verack_type&) { return 0; } @@ -53,7 +72,7 @@ { return "getaddr"; } -size_t satoshi_raw_size(const get_address_type& packet) +size_t satoshi_raw_size(const get_address_type&) { return 0; } @@ -145,7 +164,7 @@ return tx_size; } -size_t satoshi_raw_size(const block_header_type& packet) +size_t satoshi_raw_size(const block_header_type&) { return 80; } @@ -166,7 +185,7 @@ { return "ping"; } -size_t satoshi_raw_size(const ping_type& packet) +size_t satoshi_raw_size(const ping_type&) { return 8; } @@ -175,7 +194,7 @@ { return "pong"; } -size_t satoshi_raw_size(const pong_type& packet) +size_t satoshi_raw_size(const pong_type&) { return 8; } diff -Nru libbitcoin0-1.0.10+nmu1/src/script.cpp libbitcoin0-1.0.10+nmu2/src/script.cpp --- libbitcoin0-1.0.10+nmu1/src/script.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/script.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include @@ -456,7 +475,7 @@ return true; } -bool script_type::op_height() +bool script_type::op_depth() { big_number stack_size(stack_.size()); stack_.push_back(stack_size.data()); @@ -939,6 +958,8 @@ if (!key.set_public_key(pubkey)) return false; + if (signature.empty()) + return false; uint32_t hash_type = 0; hash_type = signature.back(); signature.pop_back(); @@ -1151,8 +1172,8 @@ case opcode::ifdup: return op_ifdup(); - case opcode::height: - return op_height(); + case opcode::depth: + return op_depth(); case opcode::drop: return op_drop(); @@ -1367,7 +1388,7 @@ ops[1].data.size() == 20 && ops[2].code == opcode::equal; } -bool is_multisig_type(const operation_stack& ops) +bool is_multisig_type(const operation_stack&) { return false; } @@ -1512,8 +1533,8 @@ return "2swap"; case opcode::ifdup: return "ifdup"; - case opcode::height: - return "height"; + case opcode::depth: + return "depth"; case opcode::drop: return "drop"; case opcode::dup: @@ -1748,8 +1769,8 @@ return opcode::op_2swap; else if (code_repr == "ifdup") return opcode::ifdup; - else if (code_repr == "height") - return opcode::height; + else if (code_repr == "depth") + return opcode::depth; else if (code_repr == "drop") return opcode::drop; else if (code_repr == "dup") @@ -1917,7 +1938,7 @@ return stream; } -script_type coinbase_script(const data_chunk& raw_script) +script_type raw_data_script(const data_chunk& raw_script) { script_type script_object; operation op; @@ -1951,8 +1972,11 @@ return deserial.read_2_bytes(); case opcode::pushdata4: return deserial.read_4_bytes(); + default: + break; } BITCOIN_ASSERT_MSG(false, "Invalid opcode passed to function."); + return 0; } script_type parse_script(const data_chunk& raw_script) @@ -1996,6 +2020,7 @@ data_chunk save_script(const script_type& script) { const operation_stack& operations = script.operations(); + // Nedded otherwise the next conditional would crash. if (operations.empty()) return data_chunk(); else if (operations[0].code == opcode::raw_data) diff -Nru libbitcoin0-1.0.10+nmu1/src/session.cpp libbitcoin0-1.0.10+nmu2/src/session.cpp --- libbitcoin0-1.0.10+nmu1/src/session.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/session.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include namespace libbitcoin { @@ -27,7 +46,9 @@ protocol_.subscribe_channel( [this](const std::error_code& ec, channel_ptr node) { - poll_.query(node); + BITCOIN_ASSERT(!ec || ec == error::service_stopped); + if (!ec) + poll_.query(node); }); protocol_.subscribe_channel( std::bind(&session::new_channel, this, _1, _2)); @@ -67,8 +88,13 @@ void session::set_start_height(const std::error_code& ec, size_t fork_point, const blockchain::block_list& new_blocks, - const blockchain::block_list& replaced_blocks) + const blockchain::block_list& /* replaced_blocks */) { + if (ec) + { + BITCOIN_ASSERT(ec == error::service_stopped); + return; + } size_t last_height = fork_point + new_blocks.size(); handshake_.set_start_height(last_height, handle_set_start_height); chain_.subscribe_reorganize( @@ -131,6 +157,7 @@ log_error(LOG_SESSION) << "get_data: " << ec.message(); return; } + // TODO: Implement. // simple stuff node->subscribe_get_data( std::bind(&session::get_data, this, _1, _2, node)); @@ -144,6 +171,7 @@ log_error(LOG_SESSION) << "get_blocks: " << ec.message(); return; } + // TODO: Implement. // send 500 invs from last fork point // have memory of last inv, ready to trigger send next 500 once // getdata done for it. diff -Nru libbitcoin0-1.0.10+nmu1/src/threadpool.cpp libbitcoin0-1.0.10+nmu2/src/threadpool.cpp --- libbitcoin0-1.0.10+nmu1/src/threadpool.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/threadpool.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include namespace libbitcoin { @@ -10,8 +29,7 @@ threadpool::threadpool(size_t number_threads) : work_(nullptr) { - for (size_t i = 0; i < number_threads; ++i) - spawn(); + spawn(number_threads); } threadpool::~threadpool() @@ -19,7 +37,12 @@ delete work_; } -void threadpool::spawn() +void threadpool::spawn(size_t number_threads) +{ + for (size_t i = 0; i < number_threads; ++i) + spawn_once(); +} +void threadpool::spawn_once() { if (!work_) work_ = new io_service::work(ios_); diff -Nru libbitcoin0-1.0.10+nmu1/src/transaction.cpp libbitcoin0-1.0.10+nmu2/src/transaction.cpp --- libbitcoin0-1.0.10+nmu1/src/transaction.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/transaction.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include diff -Nru libbitcoin0-1.0.10+nmu1/src/transaction_indexer.cpp libbitcoin0-1.0.10+nmu2/src/transaction_indexer.cpp --- libbitcoin0-1.0.10+nmu1/src/transaction_indexer.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/transaction_indexer.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include @@ -37,8 +56,8 @@ query_handler handle_query) { handle_query(std::error_code(), - get_info_list(payaddr, spends_map_), - get_info_list(payaddr, outputs_map_)); + get_info_list(payaddr, outputs_map_), + get_info_list(payaddr, spends_map_)); } template @@ -101,6 +120,7 @@ outputs_map_.emplace(payaddr, output_info_type{point, output.value}); } + handle_index(std::error_code()); } void transaction_indexer::deindex(const transaction_type& tx, @@ -146,6 +166,7 @@ index_does_not_exist(payaddr, point, outputs_map_), "Transaction is indexed duplicate times!"); } + handle_deindex(std::error_code()); } void blockchain_history_fetched(const std::error_code& ec, @@ -153,7 +174,7 @@ transaction_indexer& indexer, const payment_address& address, blockchain::fetch_handler_history handle_fetch); void indexer_history_fetched(const std::error_code& ec, - const spend_info_list& spends, const output_info_list& outputs, + const output_info_list& outputs, const spend_info_list& spends, blockchain::history_list history, blockchain::fetch_handler_history handle_fetch); // Fetch the history first from the blockchain and then from the indexer. @@ -178,10 +199,11 @@ history, handle_fetch)); } void indexer_history_fetched(const std::error_code& ec, - const spend_info_list& spends, const output_info_list& outputs, + const output_info_list& outputs, const spend_info_list& spends, blockchain::history_list history, blockchain::fetch_handler_history handle_fetch) { + constexpr uint32_t max_height = std::numeric_limits::max(); if (ec) { handle_fetch(ec, blockchain::history_list()); @@ -190,21 +212,37 @@ // Just add in outputs. for (const output_info_type& output_info: outputs) { - // Compiler should be smart enough to optimise this out - // if contains an empty body. + // There is always a chance of inconsistency. + // So we resolve these and move on. + // This can happen when new blocks arrive in, and indexer.query() + // is called midway through a bunch of txpool.try_delete() + // operations. + // If do_query() is queued before the last do_doindex() and there's + // a transaction in our query in that block, then we will have + // a conflict. + bool is_conflict = false; for (const blockchain::history_row& row: history) { - // If the indexer and memory pool are working properly, - // then there shouldn't be any transactions indexed - // that are already confirmed and in the blockchain. - BITCOIN_ASSERT(row.output != output_info.point); + // Usually the indexer and memory doesn't have any + // transactions indexed that are already confirmed + // and in the blockchain. + // This is a rare corner case. + if (row.output == output_info.point) + { + is_conflict = true; + break; + } + //BITCOIN_ASSERT(row.output != output_info.point); } + if (is_conflict) + continue; + // Everything OK. Insert outpoint. history.emplace_back(blockchain::history_row{ output_info.point, 0, output_info.value, {null_hash, max_index}, - 0 + max_height }); } // Now mark spends. @@ -216,14 +254,26 @@ { if (row.output != spend_info.previous_output) continue; - BITCOIN_ASSERT(row.spend_height == 0); + // Another consistency check. This time for spends. + // We just avoid this spend and assume the blockchain + // one is the correct one. + if (row.spend_height != max_height) + { + // Don't insert. + found = true; + break; + } BITCOIN_ASSERT((row.spend == input_point{null_hash, max_index})); + // Everything OK. Insert spend. row.spend = spend_info.point; row.spend_height = 0; found = true; break; } - BITCOIN_ASSERT_MSG(found, "Couldn't find output for adding spend"); + // This assert can be triggered if the pool fills and starts + // dropping transactions. + // In practice this should not happen often and isn't a problem. + //BITCOIN_ASSERT_MSG(found, "Couldn't find output for adding spend"); } handle_fetch(std::error_code(), history); } diff -Nru libbitcoin0-1.0.10+nmu1/src/transaction_pool.cpp libbitcoin0-1.0.10+nmu2/src/transaction_pool.cpp --- libbitcoin0-1.0.10+nmu1/src/transaction_pool.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/transaction_pool.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include @@ -26,8 +45,7 @@ void transaction_pool::start() { chain_.subscribe_reorganize( - strand_.wrap(&transaction_pool::reorganize, - this, _1, _2, _3, _4)); + std::bind(&transaction_pool::reorganize, this, _1, _2, _3, _4)); } void transaction_pool::validate(const transaction_type& tx, @@ -69,7 +87,7 @@ } else { - handle_validate(std::error_code(), index_list()); + handle_validate(std::error_code(), unconfirmed); } } @@ -84,29 +102,27 @@ void transaction_pool::store(const transaction_type& tx, confirm_handler handle_confirm, validate_handler handle_validate) { - auto perform_store = - [this, tx, handle_confirm] - { - // When new tx are added to the circular buffer, - // any tx at the front will be droppped. - // We notify the API user of this through the handler. - if (pool_.size() == pool_.capacity()) - { - auto handle_confirm = pool_.front().handle_confirm; - handle_confirm(error::forced_removal); - } - // We store a precomputed tx hash to make lookups faster. - pool_.push_back( - {hash_transaction(tx), tx, handle_confirm}); - }; - auto wrap_handle_validate = - [perform_store, handle_validate]( - const std::error_code& ec, const index_list& unconfirmed) + auto perform_store = [this, tx, handle_confirm] + { + // When new tx are added to the circular buffer, + // any tx at the front will be droppped. + // We notify the API user of this through the handler. + if (pool_.size() == pool_.capacity()) { - if (!ec) - perform_store(); - handle_validate(ec, unconfirmed); - }; + auto handle_confirm = pool_.front().handle_confirm; + handle_confirm(error::pool_filled); + } + // We store a precomputed tx hash to make lookups faster. + pool_.push_back( + {hash_transaction(tx), tx, handle_confirm}); + }; + auto wrap_handle_validate = [perform_store, handle_validate]( + const std::error_code& ec, const index_list& unconfirmed) + { + if (!ec) + perform_store(); + handle_validate(ec, unconfirmed); + }; validate(tx, wrap_handle_validate); } @@ -137,32 +153,32 @@ } void transaction_pool::reorganize(const std::error_code& ec, - size_t fork_point, + size_t /* fork_point */, const blockchain::block_list& new_blocks, const blockchain::block_list& replaced_blocks) { + if (ec) + { + BITCOIN_ASSERT(ec == error::service_stopped); + return; + } if (!replaced_blocks.empty()) - resubmit_all(); + strand_.queue(&transaction_pool::invalidate_pool, this); else - takeout_confirmed(new_blocks); + strand_.queue(&transaction_pool::takeout_confirmed, this, new_blocks); // new blocks come in - remove txs in new // old blocks taken out - resubmit txs in old chain_.subscribe_reorganize( - strand_.wrap(&transaction_pool::reorganize, - this, _1, _2, _3, _4)); + std::bind(&transaction_pool::reorganize, this, _1, _2, _3, _4)); } -void handle_resubmit(const std::error_code& ec, - transaction_pool::confirm_handler handle_confirm) -{ - if (ec) - handle_confirm(ec); -} -void transaction_pool::resubmit_all() +void transaction_pool::invalidate_pool() { + // See http://www.jwz.org/doc/worse-is-better.html + // for why we take this approach. + // We return with an error_code and don't handle this case. for (const transaction_entry_info& entry: pool_) - store(entry.tx, entry.handle_confirm, - std::bind(handle_resubmit, _1, entry.handle_confirm)); + entry.handle_confirm(error::blockchain_reorganized); pool_.clear(); } diff -Nru libbitcoin0-1.0.10+nmu1/src/utility/base58.cpp libbitcoin0-1.0.10+nmu2/src/utility/base58.cpp --- libbitcoin0-1.0.10+nmu1/src/utility/base58.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/utility/base58.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include diff -Nru libbitcoin0-1.0.10+nmu1/src/utility/big_number.cpp libbitcoin0-1.0.10+nmu2/src/utility/big_number.cpp --- libbitcoin0-1.0.10+nmu1/src/utility/big_number.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/utility/big_number.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include @@ -162,18 +181,19 @@ int32_t big_number::int32() const { + constexpr uint32_t max_int32 = std::numeric_limits::max(); uint32_t value = uint32(); if (!BN_is_negative(&bignum_)) { - if (value > std::numeric_limits::max()) - return std::numeric_limits::max(); + if (value > max_int32) + return max_int32; else return value; } else { - if (value > std::numeric_limits::max()) - return std::numeric_limits::min(); + if (value > max_int32) + return max_int32; else return -value; } diff -Nru libbitcoin0-1.0.10+nmu1/src/utility/elliptic_curve_key.cpp libbitcoin0-1.0.10+nmu2/src/utility/elliptic_curve_key.cpp --- libbitcoin0-1.0.10+nmu1/src/utility/elliptic_curve_key.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/utility/elliptic_curve_key.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include diff -Nru libbitcoin0-1.0.10+nmu1/src/utility/key_formats.cpp libbitcoin0-1.0.10+nmu2/src/utility/key_formats.cpp --- libbitcoin0-1.0.10+nmu1/src/utility/key_formats.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/utility/key_formats.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,15 +1,35 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include #include #include +#include namespace libbitcoin { std::string secret_to_wif(const secret_parameter& secret) { private_data unencoded_data(secret.begin(), secret.end()); - unencoded_data.insert(unencoded_data.begin(), 0x80); + unencoded_data.insert(unencoded_data.begin(), payment_address::wif_version); uint32_t checksum = generate_sha256_checksum(unencoded_data); extend_data(unencoded_data, uncast_type(checksum)); return encode_base58(unencoded_data); @@ -22,7 +42,7 @@ if (decoded.size() != 1 + sha256_digest_size + 4) return secret_parameter(); // Check first byte is valid and remove it - if (decoded[0] != 0x80) + if (decoded[0] != payment_address::wif_version) return secret_parameter(); // Proceed to verify the checksum private_data checksum_bytes(decoded.end() - 4, decoded.end()); diff -Nru libbitcoin0-1.0.10+nmu1/src/utility/logger.cpp libbitcoin0-1.0.10+nmu2/src/utility/logger.cpp --- libbitcoin0-1.0.10+nmu1/src/utility/logger.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/utility/logger.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include @@ -27,14 +46,14 @@ void output_ostream(std::ostream& ostr, log_level level, const std::string& domain, const std::string& body) { - std::cerr << level_repr(level); + ostr << level_repr(level); if (!domain.empty()) - std::cerr << " [" << domain << "]"; - std::cerr << ": " << body << std::endl; + ostr << " [" << domain << "]"; + ostr << ": " << body << std::endl; } -void ignore_output(log_level level, - const std::string& domain, const std::string& body) +void ignore_output(log_level, + const std::string&, const std::string&) { } void output_cout(log_level level, @@ -45,14 +64,14 @@ void output_cerr(log_level level, const std::string& domain, const std::string& body) { - output_ostream(std::cout, level, domain, body); + output_ostream(std::cerr, level, domain, body); } logger_wrapper::destination_map logger_wrapper::dests_{ #ifdef DEBUG - std::make_pair(log_level::debug, ignore_output), -#else std::make_pair(log_level::debug, output_cout), +#else + std::make_pair(log_level::debug, ignore_output), #endif std::make_pair(log_level::info, output_cout), std::make_pair(log_level::warning, output_cerr), @@ -68,8 +87,8 @@ // It should be: stream_(std::move(other.stream_)) // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54316 logger_wrapper::logger_wrapper(logger_wrapper&& other) - : level_(other.level_), stream_(other.stream_.str()), - domain_(std::move(other.domain_)) + : level_(other.level_), domain_(std::move(other.domain_)), + stream_(other.stream_.str()) { } logger_wrapper::~logger_wrapper() diff -Nru libbitcoin0-1.0.10+nmu1/src/utility/mnemonic.cpp libbitcoin0-1.0.10+nmu2/src/utility/mnemonic.cpp --- libbitcoin0-1.0.10+nmu1/src/utility/mnemonic.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/utility/mnemonic.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include diff -Nru libbitcoin0-1.0.10+nmu1/src/utility/ripemd.cpp libbitcoin0-1.0.10+nmu2/src/utility/ripemd.cpp --- libbitcoin0-1.0.10+nmu1/src/utility/ripemd.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/utility/ripemd.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include diff -Nru libbitcoin0-1.0.10+nmu1/src/utility/sha256.cpp libbitcoin0-1.0.10+nmu2/src/utility/sha256.cpp --- libbitcoin0-1.0.10+nmu1/src/utility/sha256.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/utility/sha256.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,16 +1,35 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include -#include #include +#include namespace libbitcoin { -hash_digest generate_sha256_hash(const data_chunk& chunk) +hash_digest generate_sha256_hash(const data_chunk& data) { SHA256_CTX ctx; hash_digest digest; SHA256_Init(&ctx); - SHA256_Update(&ctx, &chunk[0], chunk.size()); + SHA256_Update(&ctx, &data[0], data.size()); SHA256_Final(digest.data(), &ctx); SHA256_Init(&ctx); SHA256_Update(&ctx, digest.data(), sha256_digest_size); @@ -20,9 +39,9 @@ return digest; } -uint32_t generate_sha256_checksum(const data_chunk& chunk) +uint32_t generate_sha256_checksum(const data_chunk& data) { - hash_digest hash = generate_sha256_hash(chunk); + hash_digest hash = generate_sha256_hash(data); data_chunk begin_bytes(hash.rbegin(), hash.rbegin() + 4); return cast_chunk(begin_bytes); } diff -Nru libbitcoin0-1.0.10+nmu1/src/utility/timed_section.cpp libbitcoin0-1.0.10+nmu2/src/utility/timed_section.cpp --- libbitcoin0-1.0.10+nmu1/src/utility/timed_section.cpp 1970-01-01 00:00:00.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/utility/timed_section.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#include + +#include + +#ifdef __MACH__ +#include +#include +#define CLOCK_REALTIME 0 + +void clock_gettime(int ign, struct timespec * ts) +{ + clock_serv_t cclock; + mach_timespec_t mts; + host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock); + clock_get_time(cclock, &mts); + mach_port_deallocate(mach_task_self(), cclock); + ts->tv_sec = mts.tv_sec; + ts->tv_nsec = mts.tv_nsec; +} +#endif + +namespace libbitcoin { + +timed_section::timed_section( + const std::string& context, const std::string& section) + : context_(context), section_(section) +{ + clock_gettime(CLOCK_REALTIME, &start_); +} + +timed_section::~timed_section() +{ + log_debug(context_) << section_ << " " << std::fixed << elapsed(); +} + +double timed_section::elapsed() const +{ + timespec end; + clock_gettime(CLOCK_REALTIME, &end); + return 1e3 * (end.tv_sec - start_.tv_sec) + + 1e-6 * (end.tv_nsec - start_.tv_nsec); +} + +} // namespace libbitcoin + diff -Nru libbitcoin0-1.0.10+nmu1/src/validate.cpp libbitcoin0-1.0.10+nmu2/src/validate.cpp --- libbitcoin0-1.0.10+nmu1/src/validate.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/src/validate.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include @@ -333,21 +352,6 @@ { } -std::error_code validate_block::start() -{ - std::error_code ec; - ec = check_block(); - if (ec) - return ec; - ec = accept_block(); - if (ec) - return ec; - ec = connect_block(); - if (ec) - return ec; - return std::error_code(); -} - std::error_code validate_block::check_block() { // CheckBlock() @@ -424,10 +428,25 @@ return true; } +inline bool within_op_n(opcode code) +{ + uint8_t raw_code = static_cast(code); + return static_cast(opcode::op_1) <= raw_code && + raw_code <= static_cast(opcode::op_16); +} +inline uint8_t decode_op_n(opcode code) +{ + uint8_t raw_code = static_cast(code); + BITCOIN_ASSERT(within_op_n(code)); + // Add 1 because we minus opcode::op_1, not the value before. + return raw_code - static_cast(opcode::op_1) + 1; +} + inline size_t count_script_sigops( const operation_stack& operations, bool accurate) { - size_t total_sigs = 0, last_number = 0; + size_t total_sigs = 0; + opcode last_opcode = opcode::bad_operation; for (const operation& op: operations) { if (op.code == opcode::checksig || @@ -438,17 +457,12 @@ else if (op.code == opcode::checkmultisig || op.code == opcode::checkmultisigverify) { - if (accurate && last_number != 0) - total_sigs += last_number; + if (accurate && within_op_n(last_opcode)) + total_sigs += decode_op_n(last_opcode); else total_sigs += 20; } - uint8_t raw_code = static_cast(op.code); - if (static_cast(opcode::op_1) <= raw_code && - static_cast(opcode::op_16) >= raw_code) - { - last_number = raw_code; - } + last_opcode = op.code; } return total_sigs; } @@ -671,6 +685,20 @@ 0x97, 0xf0, 0x65, 0xb1, 0x30, 0x57, 0x59, 0x32}) return false; + if (height_ == 250000 && block_hash != + hash_digest{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, + 0x87, 0xdf, 0x1f, 0x29, 0x02, 0x4b, 0x06, 0xfc, + 0x22, 0x00, 0xb5, 0x5f, 0x8a, 0xf8, 0xf3, 0x54, + 0x53, 0xd7, 0xbe, 0x29, 0x4d, 0xf2, 0xd2, 0x14}) + return false; + + if (height_ == 262835 && block_hash != + hash_digest{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, + 0x0f, 0x09, 0x60, 0x2f, 0xce, 0x52, 0x7f, 0x5d, + 0x82, 0xe6, 0x80, 0x68, 0xaf, 0xd5, 0x4f, 0xfa, + 0xa6, 0x45, 0x23, 0xca, 0x6f, 0x79, 0x82, 0x00}) + return false; + return true; #endif } @@ -828,7 +856,10 @@ BITCOIN_ASSERT(previous_height <= height_); uint32_t height_difference = height_ - previous_height; if (height_difference < coinbase_maturity) + { + log_warning(LOG_VALIDATE) << "Spends immature coinbase"; return false; + } } // Pay to script hash BIP 16 scripts // block 170060 contains an invalid BIP 16 transaction diff -Nru libbitcoin0-1.0.10+nmu1/test/deterministic_wallet.cpp libbitcoin0-1.0.10+nmu2/test/deterministic_wallet.cpp --- libbitcoin0-1.0.10+nmu1/test/deterministic_wallet.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/deterministic_wallet.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include using namespace bc; diff -Nru libbitcoin0-1.0.10+nmu1/test/fakechain/Makefile libbitcoin0-1.0.10+nmu2/test/fakechain/Makefile --- libbitcoin0-1.0.10+nmu1/test/fakechain/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/fakechain/Makefile 2013-12-12 22:10:31.000000000 +0000 @@ -0,0 +1,12 @@ +CXXFLAGS=$(shell pkg-config --cflags libbitcoin) -ggdb +LIBS=$(shell pkg-config --libs libbitcoin) + +default: all + +fake.o: fake.cpp step.hpp + $(CXX) -o $@ -c $< $(CXXFLAGS) + +fake: fake.o + $(CXX) -o $@ $< $(LIBS) + +all: fake diff -Nru libbitcoin0-1.0.10+nmu1/test/fakechain/fake.cpp libbitcoin0-1.0.10+nmu2/test/fakechain/fake.cpp --- libbitcoin0-1.0.10+nmu1/test/fakechain/fake.cpp 1970-01-01 00:00:00.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/fakechain/fake.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -0,0 +1,444 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#include + +using namespace bc; +using std::placeholders::_1; +using std::placeholders::_2; +using std::placeholders::_3; +using std::placeholders::_4; + +// This should be a public libbitcoin method. +// And a few others from too, but definitely this one. +bool check_proof_of_work(hash_digest block_hash, uint32_t bits) +{ + big_number target; + target.set_compact(bits); + + if (target <= 0 || target > max_target()) + return false; + + big_number our_value; + our_value.set_hash(block_hash); + if (our_value > target) + return false; + + return true; +} + +block_type mine_next(const block_type& current_block, + const transaction_list& transactions) +{ + block_type next_block; + next_block.header.version = 1; + next_block.header.previous_block_hash = + hash_block_header(current_block.header); + next_block.header.merkle = generate_merkle_root(transactions); + //next_block.header.timestamp = time(nullptr); + next_block.header.timestamp = current_block.header.timestamp + (10 * 60); + next_block.header.bits = current_block.header.bits; + next_block.header.nonce = 0; + next_block.transactions = transactions; + while (!check_proof_of_work( + hash_block_header(next_block.header), next_block.header.bits)) + { + ++next_block.header.nonce; + BITCOIN_ASSERT(next_block.header.nonce != + std::numeric_limits::max()); + } + return next_block; +} + +std::error_code store(blockchain& chain, const block_type& blk) +{ + std::error_code ec; + block_info info; + bool finished = false; + + auto block_stored = [&ec, &info, &finished]( + const std::error_code& cec, const block_info blk_info) + { + info = blk_info; + ec = cec; + finished = true; + }; + + chain.store(blk, block_stored); + + while (!finished) + usleep(1000); + + hash_digest block_hash = hash_block_header(blk.header); + switch (info.status) + { + // There should be no orphans + case block_status::orphan: + log_error() << "Orphan block " << block_hash; + break; + + case block_status::rejected: + log_error() << "Rejected block " << block_hash; + break; + + case block_status::confirmed: + log_info() << "Block #" << info.height << " " << block_hash; + break; + } + + return ec; +} + +// Maybe should also be in libbitcoin too? +script_type build_pubkey_hash_script(const short_hash& pubkey_hash) +{ + script_type result; + result.push_operation({opcode::dup, data_chunk()}); + result.push_operation({opcode::hash160, data_chunk()}); + result.push_operation({opcode::special, + data_chunk(pubkey_hash.begin(), pubkey_hash.end())}); + result.push_operation({opcode::equalverify, data_chunk()}); + result.push_operation({opcode::checksig, data_chunk()}); + return result; +} + +script_type build_script_hash_script(const short_hash& script_hash) +{ + script_type result; + result.push_operation({opcode::hash160, data_chunk()}); + result.push_operation({opcode::special, + data_chunk(script_hash.begin(), script_hash.end())}); + result.push_operation({opcode::equal, data_chunk()}); + return result; +} + +bool build_output_script( + script_type& out_script, const payment_address& payaddr) +{ + switch (payaddr.version()) + { + case payment_address::pubkey_version: + out_script = build_pubkey_hash_script(payaddr.hash()); + return true; + + case payment_address::script_version: + out_script = build_script_hash_script(payaddr.hash()); + return true; + } + return false; +} + +bool make_signature(transaction_type& tx, size_t input_index, + const elliptic_curve_key& key, const script_type& script_code) +{ + transaction_input_type& input = tx.inputs[input_index]; + + const data_chunk public_key = key.public_key(); + if (public_key.empty()) + return false; + hash_digest tx_hash = + script_type::generate_signature_hash(tx, input_index, script_code, 1); + if (tx_hash == null_hash) + return false; + data_chunk signature = key.sign(tx_hash); + signature.push_back(0x01); + //std::cout << signature << std::endl; + script_type& script = tx.inputs[input_index].script; + // signature + script.push_operation({opcode::special, signature}); + // public key + script.push_operation({opcode::special, public_key}); + return true; +} + +transaction_type create_coinbase(const data_chunk& public_key) +{ + transaction_type coinbase_tx; + transaction_input_type null_input; + null_input.previous_output.hash = null_hash; + null_input.previous_output.index = std::numeric_limits::max(); + static uint8_t coinbase_nonce = 0; + ++coinbase_nonce; + null_input.script = coinbase_script(data_chunk{0x00, coinbase_nonce}); + null_input.sequence = std::numeric_limits::max(); + coinbase_tx.inputs.push_back(null_input); + transaction_output_type output; + // Ahh the good old days! + output.value = coin_price(50); + payment_address addr; + set_public_key(addr, public_key); + bool build_output_success = build_output_script(output.script, addr); + BITCOIN_ASSERT(build_output_success); + coinbase_tx.outputs.push_back(output); + return coinbase_tx; +} + +struct block_point +{ + typedef std::vector block_point_list; + typedef std::vector block_list; + + // Only used in root node. + block_list prefix_chain; + + int i = -1; // Disregard field if -1 + block_point* parent = nullptr; + block_type blk; + block_point_list children; + std::error_code ec; +}; + +void display_full_chain(const block_point& point, + size_t offset=0, size_t indent=0) +{ + for (size_t i = 0; i < point.prefix_chain.size(); ++i) + std::cout << i << ": " + << hash_block_header(point.prefix_chain[i].header) << std::endl; + offset += point.prefix_chain.size(); + if (point.i != -1) + std::cout << point.i; + for (size_t i = 0; i < indent; ++i) + std::cout << " "; + std::cout << (offset + indent) << ": " + << hash_block_header(point.blk.header); + if (point.ec) + std::cout << " [" << point.ec.message() << "]"; + std::cout << std::endl; + for (size_t i = 0; i < point.blk.transactions.size(); ++i) + { + const transaction_type& tx = point.blk.transactions[i]; + std::cout << " "; + for (size_t i = 0; i < indent; ++i) + std::cout << " "; + std::cout << "* " << hash_transaction(tx) << " (spending " + << tx.inputs[0].previous_output.hash << ")" << std::endl; + } + for (const auto& child: point.children) + display_full_chain(child, offset, indent + 1); +} + +typedef std::vector point_coord; + +const block_type* lookup(const block_point& root, const point_coord& coord) +{ + const block_point* result = &root; + for (size_t idx: coord) + { + BITCOIN_ASSERT(idx < result->children.size()); + result = &result->children[idx]; + } + return &result->blk; +} + +const std::string private_key = + "5KL628YQwEi1Czo9e2CFTcSMmaZXpqLgmEofyhpFqTvkgzv4MbG"; + +const data_chunk public_key() +{ + elliptic_curve_key key; + const secret_parameter secret = wif_to_secret(private_key); + BITCOIN_ASSERT(secret != null_hash); + bool set_secret_success = key.set_secret(secret); + BITCOIN_ASSERT(set_secret_success); + return key.public_key(); +} + +transaction_type construct_transaction(const output_point& prevout) +{ + transaction_type tx; + tx.version = 1; + tx.locktime = 0; + // Outputs + transaction_output_type output; + output.value = coin_price(50); + payment_address addr; + set_public_key(addr, public_key()); + bool build_output_success = build_output_script(output.script, addr); + BITCOIN_ASSERT(build_output_success); + tx.outputs.push_back(output); + // Inputs + transaction_input_type input; + input.previous_output = prevout; + input.sequence = 4294967295; + tx.inputs.push_back(input); + // Sign inputs + for (size_t i = 0; i < tx.inputs.size(); ++i) + { + bc::transaction_input_type& input = tx.inputs[i]; + const secret_parameter secret = wif_to_secret(private_key); + elliptic_curve_key key; + bool set_secret_success = key.set_secret(secret); + BITCOIN_ASSERT(set_secret_success); + payment_address address; + set_public_key(address, key.public_key()); + script_type prevout_script_code; + bool prevout_script_code_success = + build_output_script(prevout_script_code, address); + BITCOIN_ASSERT(prevout_script_code_success); + bool sign_success = make_signature(tx, i, key, prevout_script_code); + } + return tx; +} + +#include "step.hpp" + +block_point* find_parent(block_point& root, const block_type child) +{ + if (child.header.previous_block_hash == hash_block_header(root.blk.header)) + return &root; + for (auto& root_child: root.children) + { + block_point* maybe_parent = find_parent(root_child, child); + if (maybe_parent) + return maybe_parent; + } + return nullptr; +} + +void reorganize( + const std::error_code& ec, size_t fork_point, + const bc::blockchain::block_list& new_blocks, + const bc::blockchain::block_list& replaced_blocks, + blockchain& chain) +{ + log_info() << "fork_point: " << fork_point; + big_number new_work = 0, old_work = 0; + for (size_t i = 0; i < new_blocks.size(); ++i) + { + size_t height = fork_point + i + 1; + const block_type& blk = *new_blocks[i]; + log_info() << "-> " << hash_block_header(blk.header) + << " (prev = " << blk.header.previous_block_hash << ")"; + new_work += block_work(blk.header.bits); + } + for (size_t i = 0; i < replaced_blocks.size(); ++i) + { + size_t height = fork_point + i + 1; + const block_type& blk = *replaced_blocks[i]; + log_info() << "<- " << hash_block_header(blk.header); + old_work += block_work(blk.header.bits); + } + BITCOIN_ASSERT(old_work < new_work); + chain.subscribe_reorganize( + std::bind(reorganize, _1, _2, _3, _4, std::ref(chain))); +} + +void full_test() +{ + block_point root_block, *head_block = &root_block; + // Init blockchain. + threadpool pool(1); + leveldb_blockchain chain(pool); + auto blockchain_start = [](const std::error_code& ec) {}; + chain.start("blockchain", blockchain_start); + chain.subscribe_reorganize( + std::bind(reorganize, _1, _2, _3, _4, std::ref(chain))); + // Now create blocks and store them in the database. + block_type current_block = genesis_block(); + for (size_t i = 0; i < 100; ++i) + { + root_block.prefix_chain.push_back(current_block); + transaction_type coinbase_tx = create_coinbase(public_key()); + current_block = mine_next(current_block, {coinbase_tx}); + std::error_code ec = store(chain, current_block); + BITCOIN_ASSERT(!ec); + } + // Steal the last block as our new root + root_block.blk = current_block; + for (size_t i = 0; i < 30; ++i) + { + current_block = step(root_block, *head_block, i); + std::error_code ec = store(chain, current_block); + if (ec) + log_error() << ec.message(); + // Add to index + block_point new_point; + new_point.i = i; + new_point.parent = head_block; + new_point.blk = current_block; + new_point.ec = ec; + block_point* parent = find_parent(root_block, current_block); + BITCOIN_ASSERT(parent != nullptr); + parent->children.push_back(new_point); + if (!ec) + head_block = &parent->children.back(); + } + display_full_chain(root_block); + pool.stop(); + pool.join(); + chain.stop(); +} + +void generate_only() +{ + block_point root_block, *head_block = &root_block; + // Init blockchain. + //threadpool pool(1); + //leveldb_blockchain chain(pool); + //auto blockchain_start = [](const std::error_code& ec) {}; + //chain.start("blockchain", blockchain_start); + //chain.subscribe_reorganize( + // std::bind(reorganize, _1, _2, _3, _4, std::ref(chain))); + // Now create blocks and store them in the database. + block_type current_block = genesis_block(); + for (size_t i = 0; i < 100; ++i) + { + root_block.prefix_chain.push_back(current_block); + transaction_type coinbase_tx = create_coinbase(public_key()); + current_block = mine_next(current_block, {coinbase_tx}); + //std::error_code ec = store(chain, current_block); + //BITCOIN_ASSERT(!ec); + } + // Steal the last block as our new root + root_block.blk = current_block; + for (size_t i = 0; i < 30; ++i) + { + current_block = step(root_block, *head_block, i); + std::cout << "FOO" << std::endl; + //std::error_code ec = store(chain, current_block); + //if (ec) + // log_error() << ec.message(); + // Add to index + block_point new_point; + new_point.i = i; + new_point.parent = head_block; + new_point.blk = current_block; + //new_point.ec = ec; + block_point* parent = find_parent(root_block, current_block); + BITCOIN_ASSERT(parent != nullptr); + parent->children.push_back(new_point); + //if (!ec) + // head_block = &parent->children.back(); + // Risky business - beware that in full test this might not + // get set if there's a validation error with the block. + head_block = &parent->children.back(); + } + display_full_chain(root_block); + //pool.stop(); + //pool.join(); + //chain.stop(); +} + +int main() +{ + //generate_only(); + full_test(); + return 0; +} + diff -Nru libbitcoin0-1.0.10+nmu1/test/fakechain/privkey libbitcoin0-1.0.10+nmu2/test/fakechain/privkey --- libbitcoin0-1.0.10+nmu1/test/fakechain/privkey 1970-01-01 00:00:00.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/fakechain/privkey 2013-11-17 11:59:08.000000000 +0000 @@ -0,0 +1 @@ +5KL628YQwEi1Czo9e2CFTcSMmaZXpqLgmEofyhpFqTvkgzv4MbG diff -Nru libbitcoin0-1.0.10+nmu1/test/fakechain/run.sh libbitcoin0-1.0.10+nmu2/test/fakechain/run.sh --- libbitcoin0-1.0.10+nmu1/test/fakechain/run.sh 1970-01-01 00:00:00.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/fakechain/run.sh 2013-12-13 00:01:55.000000000 +0000 @@ -0,0 +1,25 @@ +#!/bin/bash +# +# Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) +# +# This file is part of libbitcoin. +# +# libbitcoin is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License with +# additional permissions to the one published by the Free Software +# Foundation, either version 3 of the License, or (at your option) +# any later version. For more information see LICENSE. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +mkdir -p blockchain/ +rm -fr blockchain/* +sx initchain blockchain/ +make && ./fake + diff -Nru libbitcoin0-1.0.10+nmu1/test/fakechain/step.hpp libbitcoin0-1.0.10+nmu2/test/fakechain/step.hpp --- libbitcoin0-1.0.10+nmu1/test/fakechain/step.hpp 1970-01-01 00:00:00.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/fakechain/step.hpp 2013-12-13 00:01:55.000000000 +0000 @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +block_type step(const block_point& root, const block_point& head, size_t n) +{ + std::cout << "Stepping " << n << std::endl; + transaction_type coinbase_tx = create_coinbase(public_key()); + const block_type* prev_blk = &head.blk; + static hash_digest txh6 = null_hash; + if (n == 4) + { + prev_blk = lookup(root, {0, 0, 0}); + output_point prevout{ + hash_transaction(root.prefix_chain[2].transactions[0]), 0}; + transaction_type tx = construct_transaction(prevout); + txh6 = hash_transaction(tx); + return mine_next(*prev_blk, {coinbase_tx, tx}); + } + else if (n == 5) + { + prev_blk = lookup(root, {0, 0, 0, 0}); + } + else if (n == 6) + { + output_point prevout{ + hash_transaction(root.prefix_chain[1].transactions[0]), 0}; + transaction_type tx = construct_transaction(prevout); + txh6 = hash_transaction(tx); + return mine_next(*prev_blk, {coinbase_tx, tx}); + } + else if (n == 7) + { + BITCOIN_ASSERT(txh6 != null_hash); + output_point prevout{txh6, 0}; + transaction_type tx = construct_transaction(prevout); + return mine_next(*prev_blk, {coinbase_tx, tx}); + } + else if (n == 8) + { + prev_blk = lookup(root, {0, 0, 0}); + } + else if (n == 9) + { + BITCOIN_ASSERT(txh6 != null_hash); + output_point prevout{txh6, 0}; + transaction_type tx = construct_transaction(prevout); + return mine_next(*prev_blk, {coinbase_tx, tx}); + } + else if (n == 11) + { + prev_blk = lookup(root, {0, 0, 0, 1}); + } + else if (n == 15) + { + // Attempt double spend. + output_point prevout{ + hash_transaction(root.prefix_chain[2].transactions[0]), 0}; + transaction_type tx = construct_transaction(prevout); + txh6 = hash_transaction(tx); + return mine_next(*prev_blk, {coinbase_tx, tx}); + } + else if (n == 16) + { + prev_blk = lookup(root, {0, 0, 0, 2, 0}); + } + else if (n == 20) + { + BITCOIN_ASSERT(txh6 != null_hash); + output_point prevout{txh6, 0}; + transaction_type tx = construct_transaction(prevout); + return mine_next(*prev_blk, {coinbase_tx, tx}); + } + return mine_next(*prev_blk, {coinbase_tx}); +} + diff -Nru libbitcoin0-1.0.10+nmu1/test/format.cpp libbitcoin0-1.0.10+nmu2/test/format.cpp --- libbitcoin0-1.0.10+nmu1/test/format.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/format.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include using namespace bc; diff -Nru libbitcoin0-1.0.10+nmu1/test/main.cpp libbitcoin0-1.0.10+nmu2/test/main.cpp --- libbitcoin0-1.0.10+nmu1/test/main.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/main.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #define BOOST_TEST_DYN_LINK #define BOOST_TEST_MODULE libbitcoin tests #include diff -Nru libbitcoin0-1.0.10+nmu1/test/make.sh libbitcoin0-1.0.10+nmu2/test/make.sh --- libbitcoin0-1.0.10+nmu1/test/make.sh 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/make.sh 2013-12-13 00:01:55.000000000 +0000 @@ -1,4 +1,23 @@ #!/bin/bash +# +# Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) +# +# This file is part of libbitcoin. +# +# libbitcoin is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License with +# additional permissions to the one published by the Free Software +# Foundation, either version 3 of the License, or (at your option) +# any later version. For more information see LICENSE. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# TESTBINARY=test_libbitcoin CXX=g++ CXXFLAGS=$(pkg-config --cflags libbitcoin) diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/1vaynert.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/1vaynert.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/1vaynert.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/1vaynert.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include using namespace bc; diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/addr.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/addr.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/addr.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/addr.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include using namespace libbitcoin; diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/base58-test.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/base58-test.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/base58-test.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/base58-test.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include Binary files /tmp/Zw1Cyzdh50/libbitcoin0-1.0.10+nmu1/test/oldtests/base58-test.cpp.out and /tmp/9iuVW3BQTE/libbitcoin0-1.0.10+nmu2/test/oldtests/base58-test.cpp.out differ diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/bdb-last.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/bdb-last.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/bdb-last.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/bdb-last.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include using namespace libbitcoin; Binary files /tmp/Zw1Cyzdh50/libbitcoin0-1.0.10+nmu1/test/oldtests/bdb-last.cpp.out and /tmp/9iuVW3BQTE/libbitcoin0-1.0.10+nmu2/test/oldtests/bdb-last.cpp.out differ diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/bdb-test.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/bdb-test.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/bdb-test.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/bdb-test.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include #include diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/big-number-test.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/big-number-test.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/big-number-test.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/big-number-test.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include using namespace bc; Binary files /tmp/Zw1Cyzdh50/libbitcoin0-1.0.10+nmu1/test/oldtests/big-number-test.cpp.out and /tmp/9iuVW3BQTE/libbitcoin0-1.0.10+nmu2/test/oldtests/big-number-test.cpp.out differ diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/bip16/hachem.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/bip16/hachem.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/bip16/hachem.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/bip16/hachem.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include using namespace bc; diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/bip16/make.sh libbitcoin0-1.0.10+nmu2/test/oldtests/bip16/make.sh --- libbitcoin0-1.0.10+nmu1/test/oldtests/bip16/make.sh 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/bip16/make.sh 2013-12-13 00:01:55.000000000 +0000 @@ -1 +1,21 @@ +#!/bin/bash +# +# Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) +# +# This file is part of libbitcoin. +# +# libbitcoin is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License with +# additional permissions to the one published by the Free Software +# Foundation, either version 3 of the License, or (at your option) +# any later version. For more information see LICENSE. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# g++ hachem.cpp raw_block4498*.o `pkg-config --libs --cflags libbitcoin` diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/bip16/raw_block44987.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/bip16/raw_block44987.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/bip16/raw_block44987.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/bip16/raw_block44987.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include using namespace bc; data_chunk raw_block44987{ diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/bip16/raw_block44989.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/bip16/raw_block44989.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/bip16/raw_block44989.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/bip16/raw_block44989.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include using namespace bc; data_chunk raw_block44989{ diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/block-hash.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/block-hash.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/block-hash.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/block-hash.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include using namespace bc; diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/blockchain.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/blockchain.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/blockchain.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/blockchain.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include "../src/storage/postgresql_blockchain.hpp" #include #include diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/chanstop.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/chanstop.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/chanstop.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/chanstop.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include using namespace libbitcoin; diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/checksig.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/checksig.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/checksig.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/checksig.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include using namespace bc; diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/clock-test.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/clock-test.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/clock-test.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/clock-test.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include using namespace libbitcoin; diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/corot.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/corot.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/corot.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/corot.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include using namespace bc; diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/crap/main.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/crap/main.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/crap/main.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/crap/main.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/determ.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/determ.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/determ.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/determ.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include using namespace bc; diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/ec-key.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/ec-key.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/ec-key.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/ec-key.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include using namespace bc; diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/echo.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/echo.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/echo.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/echo.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include using namespace libbitcoin; diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/exporter-test.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/exporter-test.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/exporter-test.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/exporter-test.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include using namespace libbitcoin; diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/feeder.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/feeder.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/feeder.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/feeder.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include using namespace bc; diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/gengen.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/gengen.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/gengen.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/gengen.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include #include diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/getx.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/getx.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/getx.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/getx.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include using namespace bc; diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/hmac512.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/hmac512.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/hmac512.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/hmac512.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include using namespace bc; diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/hosts-test.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/hosts-test.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/hosts-test.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/hosts-test.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include using namespace libbitcoin; diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/import-test.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/import-test.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/import-test.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/import-test.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include using namespace bc; diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/irc.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/irc.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/irc.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/irc.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/kyot.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/kyot.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/kyot.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/kyot.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include using namespace bc; diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/logtst.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/logtst.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/logtst.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/logtst.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include using namespace bc; Binary files /tmp/Zw1Cyzdh50/libbitcoin0-1.0.10+nmu1/test/oldtests/logtst.cpp.out and /tmp/9iuVW3BQTE/libbitcoin0-1.0.10+nmu2/test/oldtests/logtst.cpp.out differ diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/memcheck/begin.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/memcheck/begin.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/memcheck/begin.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/memcheck/begin.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include using namespace bc; diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/memcheck/make.sh libbitcoin0-1.0.10+nmu2/test/oldtests/memcheck/make.sh --- libbitcoin0-1.0.10+nmu1/test/oldtests/memcheck/make.sh 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/memcheck/make.sh 2013-12-13 00:01:55.000000000 +0000 @@ -1,4 +1,23 @@ #!/bin/bash +# +# Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) +# +# This file is part of libbitcoin. +# +# libbitcoin is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License with +# additional permissions to the one published by the Free Software +# Foundation, either version 3 of the License, or (at your option) +# any later version. For more information see LICENSE. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# g++ begin.cpp `pkg-config --cflags --libs libbitcoin` valgrind --tool=memcheck --leak-check=yes ./a.out diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/mempool.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/mempool.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/mempool.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/mempool.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include using namespace bc; diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/merkle.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/merkle.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/merkle.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/merkle.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ //#include #include #include diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/minikey.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/minikey.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/minikey.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/minikey.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include using namespace libbitcoin; Binary files /tmp/Zw1Cyzdh50/libbitcoin0-1.0.10+nmu1/test/oldtests/minikey.cpp.out and /tmp/9iuVW3BQTE/libbitcoin0-1.0.10+nmu2/test/oldtests/minikey.cpp.out differ diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/net.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/net.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/net.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/net.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include #include Binary files /tmp/Zw1Cyzdh50/libbitcoin0-1.0.10+nmu1/test/oldtests/net.cpp.out and /tmp/9iuVW3BQTE/libbitcoin0-1.0.10+nmu2/test/oldtests/net.cpp.out differ diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/pol.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/pol.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/pol.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/pol.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include using namespace libbitcoin; diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/priv.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/priv.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/priv.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/priv.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include using namespace bc; Binary files /tmp/Zw1Cyzdh50/libbitcoin0-1.0.10+nmu1/test/oldtests/priv.cpp.out and /tmp/9iuVW3BQTE/libbitcoin0-1.0.10+nmu2/test/oldtests/priv.cpp.out differ diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/protst.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/protst.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/protst.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/protst.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include using namespace libbitcoin; diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/psql.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/psql.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/psql.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/psql.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include #include diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/reorg/chains.hpp libbitcoin0-1.0.10+nmu2/test/oldtests/reorg/chains.hpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/reorg/chains.hpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/reorg/chains.hpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #ifndef REORG_CHAINS_HPP #define REORG_CHAINS_HPP diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/reorg/main.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/reorg/main.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/reorg/main.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/reorg/main.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include using namespace bc; diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/reorg/reorg.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/reorg/reorg.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/reorg/reorg.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/reorg/reorg.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/script-test.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/script-test.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/script-test.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/script-test.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include #include diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/scritp.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/scritp.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/scritp.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/scritp.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include @@ -53,12 +72,12 @@ switch (value) { case -1: - raw_script.push_back(static_cast(opcode::negative_1)); + raw_script.push_back(static_cast(opcode::negative_1)); return; #define PUSH_X(n) \ case n: \ - raw_script.push_back(static_cast(opcode::op_##n)); \ + raw_script.push_back(static_cast(opcode::op_##n)); \ return; PUSH_X(1); @@ -98,7 +117,7 @@ op.code = opcode::pushdata4; } op.data = data; - script tmp_script; + script_type tmp_script; tmp_script.push_operation(op); extend_data(raw_script, save_script(tmp_script)); } @@ -144,7 +163,7 @@ else if (is_opcode(token)) { opcode tokenized_opcode = token_to_opcode(token); - raw_script.push_back(static_cast(tokenized_opcode)); + raw_script.push_back(static_cast(tokenized_opcode)); } else { @@ -154,7 +173,7 @@ return true; } -bool parse(script& result_script, const std::string& format) +bool parse(script_type& result_script, const std::string& format) { if (format.empty()) return true; @@ -171,12 +190,6 @@ return true; } -void write_out(bool success) -{ - std::ofstream result_file("/tmp/script_status"); - result_file << (success ? "1" : "0"); -} - int main(int argc, char** argv) { BITCOIN_ASSERT(argc == 4); @@ -187,19 +200,17 @@ std::string output_string = argv[2]; std::string description = argv[3]; - script input_script; + script_type input_script; if (!parse(input_script, input_string)) { log_error() << "Error parsing input: " << input_string; - write_out(false); return -1; } - script output_script; + script_type output_script; if (!parse(output_script, output_string)) { log_error() << "Error parsing output: " << output_string; - write_out(false); return -1; } @@ -210,11 +221,9 @@ if (!output_script.run(input_script, tx, 0)) { log_error() << "Error running scripts"; - write_out(false); return 1; } - write_out(true); return 0; } Binary files /tmp/Zw1Cyzdh50/libbitcoin0-1.0.10+nmu1/test/oldtests/scritp.cpp.out and /tmp/9iuVW3BQTE/libbitcoin0-1.0.10+nmu2/test/oldtests/scritp.cpp.out differ diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/serial-test.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/serial-test.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/serial-test.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/serial-test.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include using namespace libbitcoin; Binary files /tmp/Zw1Cyzdh50/libbitcoin0-1.0.10+nmu1/test/oldtests/serial-test.cpp.out and /tmp/9iuVW3BQTE/libbitcoin0-1.0.10+nmu2/test/oldtests/serial-test.cpp.out differ diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/sesh.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/sesh.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/sesh.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/sesh.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include using namespace libbitcoin; diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/subscribe.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/subscribe.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/subscribe.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/subscribe.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include using boost::asio::io_service; diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/tx-hash.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/tx-hash.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/tx-hash.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/tx-hash.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include using namespace bc; diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/types-test.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/types-test.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/types-test.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/types-test.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include #include diff -Nru libbitcoin0-1.0.10+nmu1/test/oldtests/verify-block.cpp libbitcoin0-1.0.10+nmu2/test/oldtests/verify-block.cpp --- libbitcoin0-1.0.10+nmu1/test/oldtests/verify-block.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/oldtests/verify-block.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include #include diff -Nru libbitcoin0-1.0.10+nmu1/test/serial.cpp libbitcoin0-1.0.10+nmu2/test/serial.cpp --- libbitcoin0-1.0.10+nmu1/test/serial.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/test/serial.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include #include using namespace bc; Binary files /tmp/Zw1Cyzdh50/libbitcoin0-1.0.10+nmu1/test/test_libbitcoin and /tmp/9iuVW3BQTE/libbitcoin0-1.0.10+nmu2/test/test_libbitcoin differ diff -Nru libbitcoin0-1.0.10+nmu1/tools/Makefile libbitcoin0-1.0.10+nmu2/tools/Makefile --- libbitcoin0-1.0.10+nmu1/tools/Makefile 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/tools/Makefile 2013-12-12 22:10:31.000000000 +0000 @@ -9,4 +9,20 @@ bootstrap: bootstrap.o $(CXX) -o $@ $< $(LIBS) -all: bootstrap +bootstrap-fast.o: bootstrap-fast.cpp + $(CXX) -o $@ -c $< $(CXXFLAGS) + +bootstrap-fast: bootstrap-fast.o + $(CXX) -o $@ $< $(LIBS) + +detect-network.o: detect-network.cpp + $(CXX) -o $@ -c $< $(CXXFLAGS) + +detect-network: detect-network.o + $(CXX) -o $@ $< $(LIBS) + +all: bootstrap bootstrap-fast detect-network + +clean: + rm -f bootstrap bootstrap-fast detect-network + rm -f *.o diff -Nru libbitcoin0-1.0.10+nmu1/tools/bootstrap-fast.cpp libbitcoin0-1.0.10+nmu2/tools/bootstrap-fast.cpp --- libbitcoin0-1.0.10+nmu1/tools/bootstrap-fast.cpp 1970-01-01 00:00:00.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/tools/bootstrap-fast.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +/* + Imports blocks from bootstrap.dat + bootstrap.dat is the raw blocks in the format + [magic bytes] [block length] [serialized block] + + No validation is performed on the blocks, ensure the data is correct. +*/ +#include +#include +#include + +#define LOG_BOOTSTRAP "bootstrap" + +using namespace bc; +using std::placeholders::_1; +using std::placeholders::_2; + +bool stopped = false; + +void signal_handler(int signal) +{ + log_info(LOG_BOOTSTRAP) << "Caught signal: " << signal; + stopped = true; +} + +int main(int argc, char** argv) +{ + if (argc != 3) + { + std::cout << "Usage: " + "bootstrap-fast BLOCKCHAIN_DIR BOOTSTRAP_DATFILE" << std::endl << + "Ensure the BLOCKCHAIN_DIR is empty and the " << std::endl << + "BOOTSTRAP_DATFILE is correct, no validation is done" << std::endl; + return 1; + } + + const std::string dbpath = argv[1]; + const std::string bootstrapfile = argv[2]; + + // Threadpool context containing 1 thread. + threadpool pool(1); + // leveldb_blockchain operations execute in pool's thread. + leveldb_blockchain chain(pool); + // Completion handler for starting the leveldb_blockchain. + // Does nothing. + auto blockchain_start = [](const std::error_code& ec) {}; + // Start blockchain with a database path. + chain.start(dbpath, blockchain_start); + // First block is the genesis block. + block_type first_block = genesis_block(); + const hash_digest genesis_hash = hash_block_header(first_block.header); + + // Total number of blocks parsed from the bootstrap.dat + int blocks_parsed = 0; + + // position of the pointer in the buffer + int buffer_position = 0; + + std::ifstream fin(bootstrapfile, std::ios::in | std::ios::binary); + + if (!fin) + { + log_error(LOG_BOOTSTRAP) << "Could not open bootstrap.dat file"; + fin.close(); + + pool.stop(); + pool.join(); + chain.stop(); + return -1; + } + + constexpr size_t max_block_size = 1000000; + // Allocate a 2 * max_block_size buffer, so we are sure to read at least + // one full block into the buffer, or many smaller ones. + constexpr size_t buffer_size = 10 * max_block_size; + + int block_size; + data_chunk buffer(buffer_size); + + // The total size of the block is endian reversed + // This lambda function will read the chunk from its + // first byte at position pos in the buffer and return + // the integer representation of the block size in bytes. + auto get_block_size = + [](const data_chunk& buffer, const int pos) + { + return (int) (buffer[pos + 3] << 24) + + (int) (buffer[pos + 2] << 16) + + (int) (buffer[pos + 1] << 8) + + (int) (buffer[pos]); + }; + + // This will return false when there are not enough bytes left + // in the file to fill the buffer, meaning we may miss the last block + while(!stopped) + { + fin.read((char*) &buffer[0], buffer_size); + buffer_position = 0; + + while(buffer_position < buffer_size - 8 && !stopped) + { + // Check we have the magic bytes. This will automatically exit + // if reach an incorrect part or the end of the file. + // Serialized format has its bytes reversed. + uint32_t bootstrap_magic_value = buffer[buffer_position] + + (buffer[buffer_position + 1] << 8) + + (buffer[buffer_position + 2] << 16) + + (buffer[buffer_position + 3] << 24); + + if (bootstrap_magic_value != magic_value()) + { + stopped = true; + break; + } + // Get the block size from the reversed endain field. + block_size = get_block_size(buffer, buffer_position + 4); + + // If the rest of the block isn't inside the buffer break out + if (buffer_position + block_size + 8 > buffer_size) + break; + + auto begin_iter = buffer.begin() + buffer_position + 8; + auto end_iter = begin_iter + block_size; + block_type blk; + satoshi_load(begin_iter, end_iter, blk); + + // Assert we match the genesis block hash + BITCOIN_ASSERT(blocks_parsed != 0 || + hash_block_header(blk.header) == genesis_hash); + + std::error_code ec; + block_info info; + bool finished = false; + + auto block_imported = [&ec, &blocks_parsed, &finished]( + const std::error_code& cec) + { + log_debug(LOG_BOOTSTRAP) << blocks_parsed << " Block imported."; + // info = blk_info; + ec = cec; + finished = true; + }; + + chain.import(blk, blocks_parsed ,block_imported); + + struct timespec ts; + ts.tv_sec = 0; + ts.tv_nsec = 10; + + while (!finished) + nanosleep(&ts, NULL); + + hash_digest block_hash = hash_block_header(blk.header); + + buffer_position += block_size + 8; + blocks_parsed++; + } + log_info(LOG_BOOTSTRAP) + << "Rewinding file buffer"; + // Rewind to the last good magic bytes, which didn't have enough space + // left in the buffer for the block + fin.seekg(buffer_position - buffer_size, std::ios::cur); + } + + fin.close(); + // All threadpools stopping in parallel... + pool.stop(); + // ... Make them all join main thread and wait until they finish. + pool.join(); + // Now safely close leveldb_blockchain. + chain.stop(); + return 0; +} diff -Nru libbitcoin0-1.0.10+nmu1/tools/bootstrap.cpp libbitcoin0-1.0.10+nmu2/tools/bootstrap.cpp --- libbitcoin0-1.0.10+nmu1/tools/bootstrap.cpp 2013-10-06 10:31:45.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/tools/bootstrap.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -1,10 +1,30 @@ /* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +/* Imports blocks from bootstrap.dat bootstrap.dat is the raw blocks in the format [magic bytes] [block length] [serialized block] */ #include #include +#include #define LOG_BOOTSTRAP "bootstrap" @@ -113,7 +133,7 @@ constexpr size_t max_block_size = 1000000; // Allocate a 2 * max_block_size buffer, so we are sure to read at least // one full block into the buffer, or many smaller ones. - constexpr size_t buffer_size = 2 * max_block_size; + constexpr size_t buffer_size = 10 * max_block_size; int block_size; data_chunk buffer(buffer_size); @@ -133,26 +153,26 @@ // This will return false when there are not enough bytes left // in the file to fill the buffer, meaning we may miss the last block - std::cout << "entering loop" << std::endl; - while(!stopped) { - std::cout << "started1" << std::endl; - fin.read((char*) &buffer[0], buffer_size); buffer_position = 0; - std::cout << "started" << std::endl; - while(buffer_position < buffer_size - 8 && !stopped) { - // Assert we have the magic bytes. - BITCOIN_ASSERT( - buffer[buffer_position] == 0xf9 && - buffer[buffer_position + 1] == 0xbe && - buffer[buffer_position + 2] == 0xb4 && - buffer[buffer_position + 3] == 0xd9); - + // Check we have the magic bytes. This will automatically exit + // if reach an incorrect part or the end of the file. + // Serialized format has its bytes reversed. + uint32_t bootstrap_magic_value = buffer[buffer_position] + + (buffer[buffer_position + 1] << 8) + + (buffer[buffer_position + 2] << 16) + + (buffer[buffer_position + 3] << 24); + + if (bootstrap_magic_value != magic_value()) + { + stopped = true; + break; + } // Get the block size from the reversed endain field. block_size = get_block_size(buffer, buffer_position + 4); @@ -182,12 +202,14 @@ finished = true; }; - log_debug(LOG_BOOTSTRAP) << "Storing block. Parse count = " - << blocks_parsed; chain.store(blk, block_imported); + struct timespec ts; + ts.tv_sec = 0; + ts.tv_nsec = 1; + while (!finished) - usleep(1000); + nanosleep(&ts, NULL); hash_digest block_hash = hash_block_header(blk.header); // We need orphan blocks so we can do the next getblocks round @@ -222,7 +244,8 @@ buffer_position += block_size + 8; blocks_parsed++; } - + log_info(LOG_BOOTSTRAP) + << "Rewinding file buffer"; // Rewind to the last good magic bytes, which didn't have enough space // left in the buffer for the block fin.seekg(buffer_position - buffer_size, std::ios::cur); diff -Nru libbitcoin0-1.0.10+nmu1/tools/detect-network.cpp libbitcoin0-1.0.10+nmu2/tools/detect-network.cpp --- libbitcoin0-1.0.10+nmu1/tools/detect-network.cpp 1970-01-01 00:00:00.000000000 +0000 +++ libbitcoin0-1.0.10+nmu2/tools/detect-network.cpp 2013-12-13 00:01:55.000000000 +0000 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2011-2013 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * libbitcoin is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License with + * additional permissions to the one published by the Free Software + * Foundation, either version 3 of the License, or (at your option) + * any later version. For more information see LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +/* + Detect which network libbitcoin was compiled for. +*/ +#include + +using namespace bc; +int main(int argc, char** argv) +{ + switch(magic_value()) + { + case 0xd9b4bef9: + std::cout << "Network: mainnet" << std::endl; + break; + + case 0x0709110b: + std::cout << "Network: testnet3" << std::endl; + break; + + default: + std::cout << "Network: unknown" << std::endl; + } + std::cout << "Magic Value: " << magic_value() << std::endl; +} +