Skip to content

Commit

Permalink
Bip47 lelantus (#1013)
Browse files Browse the repository at this point in the history
* Add bip47

* Update walletdb.cpp

* Update wallet.h

* Fix Permissions Issue

* Add Space to Trigger Jenkins

* Remove Comments #1

* Remove Extraneous Comments from Recent Payments

* Remove Comments from BIP47 Util

* Remove Extraneous Comments

* Remove Extraneous Comments from the Channel File

* Remove Extraneous Comments from Payment Code Page

* Remove Extraneous Comments in Walletmodel

* Remove Extra Comments

* Remove Extra Comments Related to Old PK Material

* Update addressbookpage.cpp

* Remove Commented Code and Add Comment

* Comment Intentionally Empty if Statement

* Suppress False Flags and Remove Commented Code

* Remove Comments

* Remove Comments and Surpress False Alarms in Wallet and QT Folder

* Remove Comments and LGTM Alerts

* Porting Bip47 to Core14

* remove unused codes

* A little polishing

* remove unused code

* fix error in extracting designated public key in P2PK script

* remove unused function importBip47PaymentChannelData

* fix bugs in address book

* disable delete/edit/new on payment code book

* Fixing linking issues

* Fixing build

* Start BIP47 code refactor
- fix circular dependency issues
- bring tests into one file & remove separate test binary
- correct naming of files, removal of no longer used files

* Class renaming; removing bad code

* refactorings

* merge

* modify rpc commands

* qt bip47 receive screen

* Merge QT

* Merged with master

* Making tests work

* Making tests working

* Minor refactoring, fixing test crashes

* Added the namespace

* Classes were renamed to compy with the convention

* Minor optimization

* Minor refactoring

* First test done

* Minor cleanup

* Ecdh params tests are done

* Done the shared secret test

* CPaymentAddress, CPaymentChannel refactoring

* Address generation based on shared secret is done

* Masked payload has been done

* Minor merge error

* Merge cleanup and minor improvements

* Redesing of bip47 wallet and account has been started

* Account functionality has been split

* Change in comments

* Sending account has been done

* Implemented payment code unmasking

* Preparation for address similarity tests

* Addresses made the same using DH on both sides

* Cleaning up the previous implementation

* Secret addresses in the wallet. Preparatory steps

* Secret addresses added to the wallet.

* Minor improvement for pcode validation

* Minor improvement for address generation

* Preparation for a notification TX sending

* Preparing of a notification tx has been done

* Receiving of notification txs is done

Revert "Receiving of notification txs is done"

This reverts commit 6821b82bab3d10c3852d66bf4feb028c2e6aafd2.

Minor improvements

Minor change

* Minor improvements

* A basic RPC test has been done

* Minor redesign in account numbering

* WIP making notification TX use Lelantus

* Notification tx use Lelantus was done

* Dealing with prelim code review

* Test for Lelantus use

* Serialization work was commenced

* Payment channel serialization tests

* Serialization tests for accounts were done

* Serialization and unit tests added

* Secret privkeys were revised

* Secret privkeys were revised.Minor addition

* Serialization is almost done and tested

* Lelantus fixes

* Reverted the initial code

* Added the RAP form

* Minor improvements

* Fixing Range proof challenge generation

* GUI: Creation of pcodes is done

* Add new challenge generator with CHash256 and use it for new version

* Linking transcripts betweed sigma and balance proofs, using unique_ptr in place of classic pointer

* GUI: Started implementing Sending to pcode

* GUI: Sending to pcode dialog was designed

* GUI: Sending funds to pcode GUI has almost been done.

* GUI: Sending funds to pcode GUI has been done.

* Not using std::any

* Use jsplit version instead of comparing height, add version into domain separators, add pubkeys into transcript

* Opted out from use size_t in address numbering

* Minor fixes

* Adding some comments

* Minor refactoring and bugfixes, Some advanced features are implemented

* Minor fix for test memory leaks

* Removing unneeded functions from SigmaExtendedProver/Verifier

* Review comments applied

* Adding schnorr proof for Qk

* Added check to verify that n-th power is not returning 1

* Use template and merge 2 challenge generator classes

* Review comment applied

* Minor display improvements

* Showing advanced address information

* Allowing bip47 to be null

* Version bump, testnet HF block, testnet blacklist

* Minor improvements, autotests

* QT warnings have been fixed

* Handling Sigma selection for bip47

* Fixing a minor bug

* Version 0.14.6.0

* Gui improvements, bugfixes

* Index loading fixed

* Saving set hash only if there are mints in the block

* Failing test fixed

* Fixing db reading error

* Changing HF block for mainnnet

* Fixing the rescan issues

* Setting mainnet HF block

* Check unique-properties of ProUpRegTx when building new list

* Unlock dialog was added

* Tests have been fixed

* Fixing the lelantus discrepancies

* Code style fix

* Starting the encrypted wallet fix

* The encrypted wallet fix

* Fix for Unlock close crash, cannot send when unconfirmed

* Merge with master

* Version v0.14.7.0

* Improving tests stability

* Adding the Reconsider bip47 transaction menu item

* Transaction description was improved

* Dealing with lgtm comments

* Making the filenames unique

* Making the filenames unique

* Adding Pcodes to the address book

* Fixing the code review comments

* BIP47 pcodes addressbook

* BIP47 pcodes addressbook. Minor improvements

* Improving the OP_RETURN data display

* Improving the tx long descriptiong

* Setting used address number was done

* Resolving Macos build issues

* Minor GUI: balance display, first time message

* GUI improvements: not showing secret address dialog after a notification tx

* GUI: unlock message was done

* GUI: Added hints to send pcode dialog

* GUI: wording change

* GUI: wording change

* Fixing macos build

* GUI: Transaction page now supports pcodes

* Fixing typo and uninitialized value

* GUI: minor fixes and improvements

* GUI: typo fixes

* GUI: minor size fixes

* Locking the notification tx output

* Dealing with code review comments

* Dealing with code review comments

Co-authored-by: Rasikh Morani <rasikh@moranilabs.com>
Co-authored-by: top1st <riguang102@gmail.com>
Co-authored-by: Rasikh Morani <Rasikh@arcadia.agency>
Co-authored-by: Rasikh Morani <rasikh@arcadiamgroup.com>
Co-authored-by: Levon Petrosyan <petrosyan.levon93@gmail.com>
Co-authored-by: Cam <damvananh91@gmail.com>
Co-authored-by: levonpetrosyan93 <45027856+levonpetrosyan93@users.noreply.github.com>
Co-authored-by: riordant <riordant@tcd.ie>
Co-authored-by: Andrey <andrey@zcoin.io>
  • Loading branch information
10 people authored Jun 9, 2021
1 parent 677b54c commit e2c8db6
Show file tree
Hide file tree
Showing 80 changed files with 5,671 additions and 173 deletions.
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 0)
define(_CLIENT_VERSION_MINOR, 14)
define(_CLIENT_VERSION_REVISION, 6)
define(_CLIENT_VERSION_BUILD, 1)
define(_CLIENT_VERSION_REVISION, 7)
define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2021)
define(_COPYRIGHT_HOLDERS,[The %s developers])
Expand Down
1 change: 1 addition & 0 deletions contrib/bitcoin-qt.pro
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ FORMS += \
../src/qt/forms/openuridialog.ui \
../src/qt/forms/optionsdialog.ui \
../src/qt/forms/overviewpage.ui \
../src/qt/forms/paymentcodepage.ui \
../src/qt/forms/receivecoinsdialog.ui \
../src/qt/forms/receiverequestdialog.ui \
../src/qt/forms/debugwindow.ui \
Expand Down
4 changes: 4 additions & 0 deletions qa/pull-tester/rpc-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@

# Unstable tests
#, 'dip4-coinbasemerkleroots.py'

# bip47
'bip47-sendreceive.py',
'bip47-walletrestore.py'
]
# if ENABLE_ZMQ:
# testScripts.append('zmq_test.py')
Expand Down
60 changes: 60 additions & 0 deletions qa/rpc-tests/bip47-sendreceive.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env python3
# Copyright (c) 2017-2021 The Firo Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""dip47 sending receiving RPCs QA test.
"""

from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *

class Bip47SendReceive(BitcoinTestFramework):

def __init__(self):
super().__init__()
self.setup_clean_chain = True
self.num_nodes = 3

def setup_network(self, split=False):
self.nodes = start_nodes(self.num_nodes, self.options.tmpdir)
connect_nodes_bi(self.nodes,0,1)
connect_nodes_bi(self.nodes,1,2)
connect_nodes_bi(self.nodes,0,2)
self.is_network_split=False
self.sync_all()

def run_test(self):

self.nodes[1].generate(1010)
node0_pcode = self.nodes[0].createpcode("node0-pcode0")

try:
self.nodes[1].setupchannel(node0_pcode)
raise AssertionError('Lelantus balance should be zero')
except JSONRPCException as e:
assert(e.error['code']==-6)

self.nodes[1].mintlelantus(1)
self.nodes[1].mintlelantus(1)
self.nodes[1].generate(10)
self.nodes[1].setupchannel(node0_pcode)
self.nodes[1].generate(1)
sync_blocks(self.nodes)
self.nodes[1].sendtopcode(node0_pcode, 10)

self.nodes[1].generate(1)
self.sync_all()

assert_equal(self.nodes[0].getbalance(), Decimal("10.0001"))

self.nodes[0].sendtoaddress(self.nodes[2].getaccountaddress(""), 9.99)

self.sync_all()
self.nodes[1].generate(1)
sync_blocks(self.nodes)

assert_equal(self.nodes[2].getbalance(), Decimal("9.99"))


if __name__ == '__main__':
Bip47SendReceive().main()
40 changes: 40 additions & 0 deletions qa/rpc-tests/bip47-walletrestore.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env python3
# Copyright (c) 2017-2021 The Firo Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""dip47 sending receiving RPCs QA test.
"""

from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *

class Bip47WalletRestore(BitcoinTestFramework):

def __init__(self):
super().__init__()
self.setup_clean_chain = True
self.num_nodes = 1

def setup_network(self, split=False):
self.nodes = start_nodes(self.num_nodes, self.options.tmpdir)

def run_test(self):
backup_file = os.path.join(self.options.tmpdir, "cleanwallet.bak")
wallet_file = os.path.join(self.options.tmpdir, "node0/regtest/wallet.dat")
self.nodes[0].backupwallet(backup_file)
initial_pcodes = [self.nodes[0].createpcode("pcode" + str(num)) for num in range(0,200)]
assert(len(initial_pcodes) == 200)

stop_node(self.nodes[0], 0)
os.remove(wallet_file)
shutil.copy(backup_file, wallet_file)

self.nodes[0] = start_node(0, self.options.tmpdir)
assert(len(self.nodes[0].listpcodes()) == 0)

for i in range(0, 200):
assert(initial_pcodes[i] == self.nodes[0].createpcode("pcode" + str(i)))


if __name__ == '__main__':
Bip47WalletRestore().main()
2 changes: 1 addition & 1 deletion qa/rpc-tests/llmq-cl-evospork.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def wait_for_chainlock_tip(self, node):

def wait_for_chainlock(self, node, block_hash):
t = time()
while time() - t < 15:
while time() - t < 30:
try:
block = node.getblock(block_hash)
if block["confirmations"] > 0 and block["chainlock"]:
Expand Down
11 changes: 11 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,12 @@ BITCOIN_CORE_H = \
hdmint/mintpool.h \
hdmint/tracker.h \
hdmint/wallet.h \
bip47/defs.h \
bip47/account.h \
bip47/paymentchannel.h \
bip47/bip47utils.h \
bip47/paymentcode.h \
bip47/secretpoint.h \
sigma.h \
lelantus.h \
blacklists.h \
Expand Down Expand Up @@ -495,6 +501,11 @@ libbitcoin_wallet_a_SOURCES = \
wallet/authhelper.cpp \
hdmint/tracker.cpp \
policy/rbf.cpp \
bip47/account.cpp \
bip47/paymentchannel.cpp \
bip47/bip47utils.cpp \
bip47/paymentcode.cpp \
bip47/secretpoint.cpp \
primitives/mint_spend.cpp \
$(BITCOIN_CORE_H)

Expand Down
18 changes: 15 additions & 3 deletions src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ QT_FORMS_UI = \
qt/forms/debugwindow.ui \
qt/forms/sendcoinsdialog.ui \
qt/forms/sendcoinsentry.ui \
qt/forms/sendtopcodedialog.ui \
qt/forms/signverifymessagedialog.ui \
qt/forms/transactiondescdialog.ui \
qt/forms/sendmpdialog.ui \
Expand All @@ -130,7 +131,8 @@ QT_FORMS_UI = \
qt/forms/metadexdialog.ui \
qt/forms/tradehistorydialog.ui \
qt/forms/elyassetsdialog.ui \
qt/forms/lelantusdialog.ui
qt/forms/lelantusdialog.ui \
qt/forms/createpcodedialog.ui

QT_MOC_CPP = \
qt/moc_addressbookpage.cpp \
Expand All @@ -150,6 +152,7 @@ QT_MOC_CPP = \
qt/moc_manualmintdialog.cpp \
qt/moc_coincontroltreewidget.cpp \
qt/moc_csvmodelwriter.cpp \
qt/moc_createpcodedialog.cpp \
qt/moc_editaddressdialog.cpp \
qt/moc_guiutil.cpp \
qt/moc_intro.cpp \
Expand All @@ -174,6 +177,7 @@ QT_MOC_CPP = \
qt/moc_rpcconsole.cpp \
qt/moc_sendcoinsdialog.cpp \
qt/moc_sendcoinsentry.cpp \
qt/moc_sendtopcodedialog.cpp \
qt/moc_signverifymessagedialog.cpp \
qt/moc_splashscreen.cpp \
qt/moc_trafficgraphwidget.cpp \
Expand All @@ -199,7 +203,8 @@ QT_MOC_CPP = \
qt/moc_lelantusdialog.cpp \
qt/moc_lelantuscoincontroldialog.cpp \
qt/moc_automintmodel.cpp \
qt/moc_automintnotification.cpp
qt/moc_automintnotification.cpp \
qt/moc_pcodemodel.cpp

BITCOIN_MM = \
qt/macdockiconhandler.mm \
Expand Down Expand Up @@ -236,6 +241,7 @@ BITCOIN_QT_H = \
qt/bitcoinunits.h \
qt/clientmodel.h \
qt/coincontroldialog.h \
qt/createpcodedialog.h \
qt/manualmintdialog.h \
qt/coincontroltreewidget.h \
qt/csvmodelwriter.h \
Expand All @@ -257,6 +263,7 @@ BITCOIN_QT_H = \
qt/overviewpage.h \
qt/paymentrequestplus.h \
qt/paymentserver.h \
qt/pcodemodel.h \
qt/peertablemodel.h \
qt/platformstyle.h \
qt/qvalidatedlineedit.h \
Expand All @@ -267,6 +274,7 @@ BITCOIN_QT_H = \
qt/rpcconsole.h \
qt/sendcoinsdialog.h \
qt/sendcoinsentry.h \
qt/sendtopcodedialog.h \
qt/signverifymessagedialog.h \
qt/splashscreen.h \
qt/trafficgraphwidget.h \
Expand Down Expand Up @@ -309,6 +317,7 @@ RES_ICONS = \
qt/res/icons/firo.png \
qt/res/icons/zerocoin.png \
qt/res/icons/sigma.png \
qt/res/icons/paymentcode.png \
qt/res/icons/masternodes.png \
qt/res/icons/qrcode.png \
qt/res/icons/chevron.png \
Expand Down Expand Up @@ -417,18 +426,21 @@ BITCOIN_QT_WALLET_CPP = \
qt/addresstablemodel.cpp \
qt/askpassphrasedialog.cpp \
qt/coincontroldialog.cpp \
qt/manualmintdialog.cpp \
qt/coincontroltreewidget.cpp \
qt/createpcodedialog.cpp \
qt/editaddressdialog.cpp \
qt/manualmintdialog.cpp \
qt/openuridialog.cpp \
qt/overviewpage.cpp \
qt/pcodemodel.cpp \
qt/paymentrequestplus.cpp \
qt/paymentserver.cpp \
qt/receivecoinsdialog.cpp \
qt/receiverequestdialog.cpp \
qt/recentrequeststablemodel.cpp \
qt/sendcoinsdialog.cpp \
qt/sendcoinsentry.cpp \
qt/sendtopcodedialog.cpp \
qt/signverifymessagedialog.cpp \
qt/transactiondesc.cpp \
qt/transactiondescdialog.cpp \
Expand Down
3 changes: 3 additions & 0 deletions src/Makefile.test.include
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ BITCOIN_TESTS = \
test/base58_tests.cpp \
test/base64_tests.cpp \
test/bip32_tests.cpp \
test/bip47_test_data.h \
test/bip47_tests.cpp \
test/bip47_serialization_tests.cpp \
test/blockencodings_tests.cpp \
test/bloom_tests.cpp \
test/bswap_tests.cpp \
Expand Down
4 changes: 2 additions & 2 deletions src/base58.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ std::string EncodeBase58Check(const std::vector<unsigned char>& vchIn);
* Decode a base58-encoded string (psz) that includes a checksum into a byte
* vector (vchRet), return true if decoding is successful
*/
inline bool DecodeBase58Check(const char* psz, std::vector<unsigned char>& vchRet);
bool DecodeBase58Check(const char* psz, std::vector<unsigned char>& vchRet);

/**
* Decode a base58-encoded string (str) that includes a checksum into a byte
* vector (vchRet), return true if decoding is successful
*/
inline bool DecodeBase58Check(const std::string& str, std::vector<unsigned char>& vchRet);
bool DecodeBase58Check(const std::string& str, std::vector<unsigned char>& vchRet);

/**
* Base class for all base58-encoded data
Expand Down
Loading

0 comments on commit e2c8db6

Please sign in to comment.