├── lib ├── secp256k1 │ ├── .gitignore │ ├── COPYING │ ├── README.md │ └── field_test.go ├── others │ ├── cgo │ │ ├── sipasec │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── sipasec_linux.go │ │ │ └── sipasec_windows.go │ │ ├── openssl │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── openssl.go │ │ │ └── openssl_test.go │ │ ├── README.md │ │ └── ec_bench │ │ │ ├── openssl.go │ │ │ ├── gonative.go │ │ │ └── sipasec.go │ ├── blockdb │ │ └── README.md │ ├── qdb │ │ ├── README.md │ │ ├── os_membinds │ │ │ ├── README.md │ │ │ ├── membind_linux.go │ │ │ └── membind_windows.go │ │ └── stats.go │ ├── sys │ │ ├── ipnet.go │ │ ├── dblock_windows.go │ │ ├── dblock_unix.go │ │ ├── atomic.go │ │ └── hidepass_unix.go │ └── bech32 │ │ └── bech32_test.go ├── test │ ├── README.md │ └── base58_encode_decode.json ├── bch_chain │ ├── bch_const.go │ └── bch_dbg.go ├── bch │ ├── const.go │ ├── multisig_test.go │ ├── opcodes.go │ ├── netaddr.go │ ├── hash.go │ ├── ecdsa.go │ ├── key.go │ ├── target_test.go │ └── unspent.go ├── script │ └── dbg.go └── bch_utxo │ ├── membind.go │ ├── membind_linux.go │ ├── membind_windows.go │ └── unspent_test.go ├── wallet ├── .gitignore └── wallet.cfg ├── website ├── README.md ├── index.html ├── .htaccess ├── menu.html ├── gocoin_index.html ├── gocoin_manual.html ├── style.css ├── gocoin_links.html ├── page.php ├── gocoin_manual_client.html ├── gocoin_issues.html ├── gocoin_tweaks.html ├── gocoin_installation.html └── gocoin_manual_wallet.html ├── .gitignore ├── client ├── www │ ├── resources │ │ ├── del.png │ │ ├── info.png │ │ ├── send.png │ │ ├── close.png │ │ ├── loading.gif │ │ ├── message.png │ │ ├── music.png │ │ ├── qrcode.png │ │ ├── refresh.png │ │ ├── request.png │ │ ├── saving.png │ │ ├── stats.png │ │ ├── warning.png │ │ ├── chainsync.png │ │ ├── incoming.png │ │ ├── new_block.mp3 │ │ ├── outgoing.png │ │ ├── send_once.png │ │ └── back_online.mp3 │ └── templates │ │ ├── page_tail.html │ │ ├── txs_load.html │ │ ├── send_error.html │ │ └── wallet_off.html ├── .gitignore ├── miners.json ├── ssl_cert │ └── README.md ├── speedups │ ├── sipasec.go │ └── sipadll.go └── rpcapi │ └── address.go ├── tools ├── sipa_dll │ ├── secp256k1.dll │ ├── sipadll.go │ └── sipadll_test.go ├── fetchblock.go ├── fetchtx.go ├── utxo.go └── base58.go ├── todo.txt ├── .travis.yml ├── version.go ├── LICENSE └── README.md /lib/secp256k1/.gitignore: -------------------------------------------------------------------------------- 1 | openssl 2 | -------------------------------------------------------------------------------- /lib/others/cgo/sipasec/.gitignore: -------------------------------------------------------------------------------- 1 | secp256k1.h 2 | -------------------------------------------------------------------------------- /lib/others/cgo/openssl/.gitignore: -------------------------------------------------------------------------------- 1 | openssl/*.h 2 | 3 | -------------------------------------------------------------------------------- /wallet/.gitignore: -------------------------------------------------------------------------------- 1 | wallet 2 | *.txt 3 | .others 4 | .secret 5 | balance/ 6 | -------------------------------------------------------------------------------- /website/README.md: -------------------------------------------------------------------------------- 1 | This is the source code of [gocoin.pl](https://gocoin.pl) website 2 | -------------------------------------------------------------------------------- /lib/others/cgo/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/counterpartyxcpc/gocoin-cash/HEAD/lib/others/cgo/README.md -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.exe 2 | *.bin 3 | *.dat 4 | *.a 5 | client/sipadll.go 6 | client/sipasec.go 7 | client/openssl.go 8 | -------------------------------------------------------------------------------- /client/www/resources/del.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/counterpartyxcpc/gocoin-cash/HEAD/client/www/resources/del.png -------------------------------------------------------------------------------- /client/www/resources/info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/counterpartyxcpc/gocoin-cash/HEAD/client/www/resources/info.png -------------------------------------------------------------------------------- /client/www/resources/send.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/counterpartyxcpc/gocoin-cash/HEAD/client/www/resources/send.png -------------------------------------------------------------------------------- /client/www/templates/page_tail.html: -------------------------------------------------------------------------------- 1 | 2 | --> 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /tools/sipa_dll/secp256k1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/counterpartyxcpc/gocoin-cash/HEAD/tools/sipa_dll/secp256k1.dll -------------------------------------------------------------------------------- /client/www/resources/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/counterpartyxcpc/gocoin-cash/HEAD/client/www/resources/close.png -------------------------------------------------------------------------------- /client/www/resources/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/counterpartyxcpc/gocoin-cash/HEAD/client/www/resources/loading.gif -------------------------------------------------------------------------------- /client/www/resources/message.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/counterpartyxcpc/gocoin-cash/HEAD/client/www/resources/message.png -------------------------------------------------------------------------------- /client/www/resources/music.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/counterpartyxcpc/gocoin-cash/HEAD/client/www/resources/music.png -------------------------------------------------------------------------------- /client/www/resources/qrcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/counterpartyxcpc/gocoin-cash/HEAD/client/www/resources/qrcode.png -------------------------------------------------------------------------------- /client/www/resources/refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/counterpartyxcpc/gocoin-cash/HEAD/client/www/resources/refresh.png -------------------------------------------------------------------------------- /client/www/resources/request.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/counterpartyxcpc/gocoin-cash/HEAD/client/www/resources/request.png -------------------------------------------------------------------------------- /client/www/resources/saving.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/counterpartyxcpc/gocoin-cash/HEAD/client/www/resources/saving.png -------------------------------------------------------------------------------- /client/www/resources/stats.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/counterpartyxcpc/gocoin-cash/HEAD/client/www/resources/stats.png -------------------------------------------------------------------------------- /client/www/resources/warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/counterpartyxcpc/gocoin-cash/HEAD/client/www/resources/warning.png -------------------------------------------------------------------------------- /lib/others/blockdb/README.md: -------------------------------------------------------------------------------- 1 | This package can be used for reading blocks from the storage of the reference (satoshi's) client. -------------------------------------------------------------------------------- /client/www/resources/chainsync.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/counterpartyxcpc/gocoin-cash/HEAD/client/www/resources/chainsync.png -------------------------------------------------------------------------------- /client/www/resources/incoming.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/counterpartyxcpc/gocoin-cash/HEAD/client/www/resources/incoming.png -------------------------------------------------------------------------------- /client/www/resources/new_block.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/counterpartyxcpc/gocoin-cash/HEAD/client/www/resources/new_block.mp3 -------------------------------------------------------------------------------- /client/www/resources/outgoing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/counterpartyxcpc/gocoin-cash/HEAD/client/www/resources/outgoing.png -------------------------------------------------------------------------------- /client/www/resources/send_once.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/counterpartyxcpc/gocoin-cash/HEAD/client/www/resources/send_once.png -------------------------------------------------------------------------------- /client/.gitignore: -------------------------------------------------------------------------------- 1 | *.txt 2 | balance/ 3 | client 4 | gocoin*.conf 5 | .stealth 6 | *.bat 7 | ssl_cert/*.crt 8 | ssl_cert/*.key 9 | -------------------------------------------------------------------------------- /client/www/resources/back_online.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/counterpartyxcpc/gocoin-cash/HEAD/client/www/resources/back_online.mp3 -------------------------------------------------------------------------------- /lib/others/qdb/README.md: -------------------------------------------------------------------------------- 1 | From Gocoin version 1.9.0 it is no longer used for UTXO db. 2 | Now it is only used for maintaining peers database. 3 | -------------------------------------------------------------------------------- /lib/test/README.md: -------------------------------------------------------------------------------- 1 | These test vector files come from the original bitcoin project: 2 | 3 | * https://github.com/bitcoin/bitcoin/tree/master/src/test/data 4 | -------------------------------------------------------------------------------- /website/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Gocoin 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /lib/secp256k1/COPYING: -------------------------------------------------------------------------------- 1 | This single package (secp256k1) is distributed with the same license as 2 | the original C implementation by sipa: 3 | 4 | * https://github.com/bitcoin/secp256k1/blob/master/COPYING 5 | -------------------------------------------------------------------------------- /lib/secp256k1/README.md: -------------------------------------------------------------------------------- 1 | Implementation of this package has been based on source code created by Pieter Wuille. 2 | 3 | * https://github.com/bitcoin/secp256k1 4 | 5 | 6 | Use go compiler version 1.7 or higher, for significant performance boost. -------------------------------------------------------------------------------- /client/www/templates/txs_load.html: -------------------------------------------------------------------------------- 1 |
{TX_RAW_DATA}
2 | 7 | -------------------------------------------------------------------------------- /client/www/templates/send_error.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | You will be automatically redirected to the previous page in 5 seconds... 4 | -------------------------------------------------------------------------------- /lib/others/qdb/os_membinds/README.md: -------------------------------------------------------------------------------- 1 | Since currently qdb is only used for peers management, 2 | using the membinds has a little effect and thertefore 3 | this functionality has been disabled. 4 | 5 | If you want to switch OS memory biding on, just copy 6 | all go files from this folder one level up. 7 | -------------------------------------------------------------------------------- /website/.htaccess: -------------------------------------------------------------------------------- 1 | RewriteEngine on 2 | Options +FollowSymLinks 3 | 4 | RewriteRule ^gocoin_([a-z0-9_\-]+).html$ page.php\?id=$1 [L] 5 | 6 | RewriteRule ^$ page.php [L] 7 | RewriteRule ^/$ page.php [L] 8 | RewriteRule ^index.html$ page.php [L] 9 | RewriteRule ^index.php$ page.php [L] 10 | 11 | -------------------------------------------------------------------------------- /lib/others/cgo/sipasec/README.md: -------------------------------------------------------------------------------- 1 | Building 2 | ============== 3 | 4 | 5 | Unix 6 | -------------- 7 | 8 | 1. Execute "sudo apt-get install libgmp3-dev" 9 | 10 | 2. Download secp256k1: 11 | * https://github.com/bitcoin/secp256k1 12 | 13 | 3. Follow "Build steps" section from README.md, iuncluding the install part 14 | 15 | 16 | 17 | Windows 18 | -------------- 19 | 20 | Use MSYS2 - http://www.msys2.org/ 21 | -------------------------------------------------------------------------------- /lib/test/base58_encode_decode.json: -------------------------------------------------------------------------------- 1 | [ 2 | ["", ""], 3 | ["61", "2g"], 4 | ["626262", "a3gV"], 5 | ["636363", "aPEr"], 6 | ["73696d706c792061206c6f6e6720737472696e67", "2cFupjhnEsSn59qHXstmK2ffpLv2"], 7 | ["00eb15231dfceb60925886b67d065299925915aeb172c06647", "1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L"], 8 | ["516b6fcd0f", "ABnLTmg"], 9 | ["bf4f89001e670274dd", "3SEo3LWLoPntC"], 10 | ["572e4794", "3EFU7m"], 11 | ["ecac89cad93923c02321", "EJDM8drfXA6uyA"], 12 | ["10c8511e", "Rt5zm"], 13 | ["00000000000000000000", "1111111111"] 14 | ] 15 | -------------------------------------------------------------------------------- /lib/others/cgo/openssl/README.md: -------------------------------------------------------------------------------- 1 | Building 2 | ============== 3 | 4 | 5 | Unix 6 | -------------- 7 | 8 | The wrapper should build smoothly, as long as you have libssl-dev installed. 9 | 10 | Just run "go build" and if it gives no errors, you can also try "go test". 11 | 12 | 13 | 14 | Windows 15 | -------------- 16 | 17 | Use mingw(64) and msys. 18 | 19 | You will need libcrypto.a build for your architecture and the header files. 20 | 21 | Before doing "go build" edit openssl.go and fix the paths to "libcrypto.a" and openssl include dir. 22 | 23 | If you want to build the lib yourself, leek here: 24 | * http://stackoverflow.com/questions/9379363/how-to-build-openssl-with-mingw-in-windows#9379476 25 | 26 | > perl Configure mingw64 no-shared no-asm --prefix=/C/OpenSSL-x64 -------------------------------------------------------------------------------- /website/menu.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /website/gocoin_index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |

Gocoin

7 | Gocoin is a full Bitcoin solution written in Go language (golang).
8 |
9 | The software's architecture is focused on maximum security and good performance.
10 |
11 | The client (p2p node) is an application independent from the wallet.
12 |
13 | The wallet is deterministic and password seeded. As long as you remember the password, you do not need any backups of your wallet.
14 |
15 | In addition there is also a set of more and less useful tools. They are all inside the tools/ folder. Each source file in that folder is a separate tool.
16 |
17 | See external links to read some additional info about the project. 18 | 19 | -------------------------------------------------------------------------------- /website/gocoin_manual.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |

User Manual

7 |

Client and wallet

8 | The two basic components of the software are: 9 | 12 | 13 |

Wallet without client

14 | It is also possible to use the wallet without the client. 15 | For such purpose there is a tool called balio.
16 | The tool can download the balance data from popular block explorers and save it on disk in a format recognized by the wallet.
17 | 18 |

User interface

19 | The applications are console only (no GUI window), although the client node has a fairly functional and quite convenient web interface 20 | (to be used with a web browser). 21 | 22 | 23 |
24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /website/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | //font-family: Arial, Verdana, sans-serif; 3 | line-height:1.5; 4 | } 5 | 6 | td { 7 | line-height:1.5; 8 | } 9 | 10 | a { 11 | color:blue; 12 | text-decoration:none; 13 | } 14 | 15 | a:visited { 16 | color:blue; 17 | text-decoration:none; 18 | } 19 | 20 | a:hover { 21 | background-color:yellow; 22 | } 23 | 24 | a.selected { 25 | background-color:pink; 26 | } 27 | 28 | code { 29 | color: #006000; 30 | background-color: #eeeeee; 31 | } 32 | 33 | ul { 34 | padding-left:20px; 35 | margin-top:0px; 36 | margin-bottom:0px; 37 | } 38 | 39 | .cfg_name { 40 | font-family: monospace; 41 | font-weight: bold; 42 | } 43 | 44 | .cfg_type { 45 | font-weight: bold; 46 | } 47 | 48 | .cfg_info { 49 | font-style: italic; 50 | } 51 | 52 | pre { 53 | background-color:#d0d0d0; 54 | font-size:80%; 55 | } 56 | 57 | .bigger { 58 | font-size:120%; 59 | } 60 | 61 | tr.even { 62 | background-color:#fcfff8; 63 | } 64 | tr.odd { 65 | background-color:#f8f8ff; 66 | } 67 | -------------------------------------------------------------------------------- /todo.txt: -------------------------------------------------------------------------------- 1 | Global: 2 | * Add suport for multisig segwit 3 | 4 | Lib: 5 | * Check implemetation against this: https://bitslog.wordpress.com/2017/01/08/a-bitcoin-transaction-that-takes-5-hours-to-verify/ 6 | 7 | Client: 8 | * Force to create UTXO.db file once for awhile (when bootstraping) 9 | * Review and update WebUI's Help page 10 | * Monitor: at slow connections it gets stuck (new blocks stop being downloaded). Go to standby and come back. 11 | * Optionally use utils.GetBlockFromWeb() for initial blockchain download 12 | * Figure out a way to purge blocks that we got good headers for, but never managed to download the txs 13 | * Update mining API 14 | 15 | Wallet: 16 | * Implement "server mode", e.g. through TCP or serial connection 17 | * Write more automated tests 18 | 19 | Probably not to do: 20 | * Do not list unmatured coinbase outputs in the balance 21 | * Implement "mempool" network command 22 | * Try to make own (faster) implementation of sha256 and rimp160 23 | 24 | Tools: 25 | * txaddsig - make it to work with multisig and segwit 26 | -------------------------------------------------------------------------------- /website/gocoin_links.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |

Links / Contact

7 |

Github

8 | piotrnar/gocoin 9 | (feel free to report any issues, but note that I do not merge pull requests) 10 |
11 | 12 |

Telegram

13 | See realgocoin channel on Telegram messanger. 14 | For quick questions, send me a direct message @piotrn 15 |
16 | 17 |

Forum

18 | Gocoin - totally different bitcoin client with deterministic cold wallet 19 | (you may ask any questions there) 20 | 21 | 22 |
23 | 24 |

E-mail

25 | piotr@gocoin.pl 26 | (sorry, but I can't answer all the emails) 27 |
28 | 29 |

Wiki

30 | Gocoin 31 | (everybody is invited and welcome to edit the article) 32 | 33 |
34 | 35 |
36 | 37 | 38 | -------------------------------------------------------------------------------- /client/miners.json: -------------------------------------------------------------------------------- 1 | [ 2 | ["AntPool", "AntPool", ""], 3 | ["BTC.TOP", "BTC.TOP/", ""], 4 | ["BTC.COM", "/BTC.COM/", ""], 5 | ["BTC.COM", "", "3EhLZarJUNSfV6TWMZY1Nh5mi3FMsdHa5U"], 6 | ["ViaBTC", "/ViaBTC/", ""], 7 | ["BTCC", "/BTCC/", ""], 8 | ["F2Pool", "", "1KFHE7w8BhaENAswwryaoccDb6qcT6DbYY"], 9 | ["Slush", "/slush/", ""], 10 | ["Bixin", "/Bixin/", ""], 11 | ["Bixin", "", "1KsFhYKLs8qb1GHqrPxHoywNQpet2CtP9t"], 12 | ["Bitfury", "/Bitfury/", ""], 13 | ["BitClub", "/BitClub Network/", ""], 14 | ["BW.COM", "/BW Pool/", ""], 15 | ["1Hash", "Mined by 1hash.com", ""], 16 | ["GBMiners", "/mined by gbminers/", ""], 17 | ["Bitcoin.com", "/pool.bitcoin.com/", ""], 18 | ["BTPOOL", "/BTPOOL/", ""], 19 | ["Bitcoin-Russia", "/Bitcoin-Russia.ru/", ""], 20 | ["KanoPool", "KanoPool", ""], 21 | ["Bitcoin-India", "/Bitcoin-India/", ""], 22 | ["ConnectBTC", "/ConnectBTC - Home for Miners/", ""], 23 | ["BATPOOL", "/BATPOOL/", ""], 24 | ["58coin", "/58coin.com/", ""], 25 | ["DPOOL", "/DPOOL.TOP/", ""], 26 | ["canoepool", "/canoepool/", ""], 27 | ["Helix", "/Helix/", ""], 28 | ["BWPool", "BWPool", ""], 29 | ["SecretSuperstar", "/SecretSuperstar/", ""], 30 | ["Huobi", "/Huobi/", ""], 31 | ["tigerpool.net", "tigerpool.net", ""], 32 | ["P2Pool", "_p2pool_", ""] 33 | ] -------------------------------------------------------------------------------- /wallet/wallet.cfg: -------------------------------------------------------------------------------- 1 | # 2 | # This is an example configuration file for Gocoin wallet. 3 | # 4 | # Uncomment a line, by removing first #, to apply its value. 5 | # 6 | # Command line switches have priority over configuration file. 7 | # 8 | # Normally the wallet looks for wallet.cfg in the current 9 | # folder, but you can overwrite location and name of this 10 | # file with environment variable GOCOIN_WALLET_CONFIG 11 | # 12 | 13 | # Is this a Testnet wallet 14 | #testnet=true 15 | 16 | # Deterministic wallet type. 4 is HD Wallet. Default is 3. 17 | #type=3 18 | 19 | # Hex encoded secret value for Type-2 deterministic wallet. 20 | # When not specified, it gets calculated from seed password. 21 | # The value is ignored for wallets of type different than 2. 22 | #type2sec=217451724657124581247627356472564275427A 23 | 24 | # Number of pre-generated deterministic addresses 25 | #keycnt=250 26 | 27 | # Transaction fee to be used (in BCH) 28 | #fee=0.0001 29 | 30 | # Apply changes to balance/unspent.txt after each send 31 | #apply2bal=false 32 | 33 | # Path to the file with the password seed 34 | #secret=/usr/local/.secret 35 | 36 | # Path to the file with additional private keys (in the base58 format) 37 | #others=C:\Users\Myself\.others 38 | 39 | # If specified, the seed password gets appended to this string (keyboard loggers protection) 40 | #seed=some_secret-seed 41 | -------------------------------------------------------------------------------- /website/page.php: -------------------------------------------------------------------------------- 1 | "); 11 | if ($beg!==FALSE) { 12 | $beg += strlen($tag)+2; 13 | } 14 | $end = strpos($content, ""); 15 | if ($end===FALSE) { 16 | $end = strlen($content); 17 | } 18 | return substr($content, $beg, $end-$beg); 19 | } 20 | 21 | 22 | function get_body($fn) { 23 | $content = file_get_contents($fn); 24 | return get_between_tags($content, "body"); 25 | } 26 | 27 | $menu = get_body("menu.html"); 28 | $fielname = "gocoin_$page.html"; 29 | 30 | // add class="selected" to the main menu 31 | $apos = strpos($menu, 'href="' . $fielname); 32 | if ($apos!==FALSE) { 33 | $menu = substr($menu, 0, $apos) . 'class="selected" ' . substr($menu, $apos); 34 | } 35 | 36 | $content = get_body($fielname); 37 | $title = get_between_tags($content, "h1"); 38 | 39 | 40 | echo ' 41 | 42 | 43 | Gocoin: '.$title.' 44 | 45 | 46 | 47 | 48 | 51 |
'; 49 | echo $menu; 50 | echo ''; 52 | echo $content; 53 | echo 54 | '
55 | 56 | '; 57 | 58 | ?> -------------------------------------------------------------------------------- /website/gocoin_manual_client.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |

Client node

7 | Run client -h to see all available command line switches. Some example ones are: 8 |
9 |
10 | -t - use Testnet (instead of regular bitcoin network)
11 | -ul=NN - set maximum upload speed to NN kilobytes per second
12 | -dl=NN - set maximum download speed to NN kilobytes per second
13 |
14 |
15 | To run the client on a remote Linux server (via ssh connection), you probably want to get adventage of screen command. 16 |
17 |

TextUI

18 | When the client is already running you have an interactive, text command based interface, on the console.
19 | Type help to see the possible commands. 20 |
21 | 22 |

WebUI

23 | There is also a web interface that you can operate with a web browser.
24 |
25 | 26 | Make sure to have the www/ folder in the location where you execute the client from.
27 | The folder contains files that are an essencial part of the WebUI application.
28 |
29 | WebUI application is tested with Google Chrome, but should be compatible with any modern web browser.
30 |
31 | By default (for security reasons) WebUI is available only from a local host, via http://127.0.0.1:8833/
32 |
33 |

Remote server

34 | In order to use WebUI securely on a remote server, set up ssh tunneling to port 8833.
35 |
36 |

Local network

37 | If you run the node on a local network and want to have access to its WebUI from different computers:
38 | 42 |
43 | Read more about the config file at the config file page. 44 | 45 | -------------------------------------------------------------------------------- /website/gocoin_issues.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |

Known issues

7 | 8 |

Volatile UTXO database

9 | 10 | When you start client node for the first time, it will go trough the process of downloading entire bitcoin 11 | block chain and building the UTXO database. 12 | To speed up this process the database is not being flushed to disk as the block processing goes on.
13 |
14 | The node only writes it to disk when either all the blocks are downloaded or when the node's shutdown has 15 | been requested from a user interface (e.g. text command 'quit' was given). 16 | If you kill the process or reboot the machine, you will loose all your hard worked UTXO changes! 17 | Therefore, to save the work as the new blocks are being processed, you should once for awhile quit the node and start it again. 18 | This BTW may also have a positive impact on memory consumption, allowing you to set up the node with less RAM (e.g. 13GB).
19 |
20 | When the node is synchronized, it flushes UTXO database to disk once for awhile. 21 | Killing it then won't have such a bad consequences, as it will start with the most recently written version of the database 22 | and only apply the data from the blocks that came later.
23 |
24 |

Coinbase maturity

25 | According to the block chain protocol, generated coins can be spent only after 100 confirmations.
26 | Users should be aware that fetching a wallet's balance from the client returns also immature coinbase transactions.
27 | Because wallet has no way of knowing if a coinbase output is mature enough, it always considers it mature.
28 | But be aware that the network will not accept your signed transaction until all of the mined coins that it is trying to spend 29 | get at least 100 confirmations.
30 |
31 |

Mining API

32 | The mining RPC API is experimental and had been implemented in March 2016 - long before the segwit support was added.
33 | It was tested on Testnet3 and worked well, but only for one mining setup. 34 | It has not been used ever since then and at this moment shall be considered unusable.
35 | If you are interested in using Gocoin node for mining, please contact me, so I can help you with any issues that may need resolving, 36 | before you start throwing any hash power onto it.
37 |
38 |

Litecoin support in wallet

39 | The wallet only supports Litecoin's P2PKH address types (such that start from L...).
40 | No segwit or multisig suport for Litecoin. It might work, but has not been tested.
41 | 42 | -------------------------------------------------------------------------------- /website/gocoin_tweaks.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |

Tweaks

7 | On this page you can find ways to improve performance or lower resource consumptions of your running node.
8 |

Faster Elliptic Curve verifications

9 | You can use external secp256k1 library (written in C and assembler) 10 | which is up to 4 times faster when it comes to EC_Verify operations.
11 | 12 | In order to use an external library, copy either the file sipadll.go (Windows only) 13 | or sipasec.go (any OS), from the folder gocoin/client/speedups/ to 14 | gocoin/client/
15 | 16 | After copying a speedup file to the client folder, rebuild and restart the client.
17 | 18 |

sipadll.go (Windows only)

19 | To use sipadll.go speedup, you have to place secp256k1.dll 20 | in a folder where Windows looks for executables (e.g. C:\WINDOWS)
21 | 22 | Note: You can find secp256k1.dll in gocoin/tools/sipa_dll/ 23 | or you can download it from sourceforge.net 24 | (it's inside secp256k1.dll-amd64.zip).
25 | 26 |

sipasec.go

27 | In order to use sipasec.go speedup, build and install secp256k1 library in your system.
28 |
29 | On Debian based Linux system, execute the following steps:
30 | 31 |   sudo apt-get install gcc autoconf libtool make
32 |   git clone https://github.com/bitcoin/bitcoin.git
33 |   cd bitcoin/src/secp256k1/
34 |   ./autogen.sh
35 |   ./configure
36 |   make
37 |   sudo make install
38 |
39 | Note: When the library is properly installed, executing go test from 40 | gocoin/lib/others/cgo/sipasec/ says PASS 41 | 42 |
43 |

Disable wallet functionality

44 | 45 | In order to save system memory used by running client and to improve block processing times, you can disable wallet functionality.
46 | In order to do so, use TextUI command wallet off or click the disable wallet button on the bottom of the Wallet page in the WebUI.
47 |
48 | Note that you can switch the wallet functionality back on any time when the node is running.
49 | If you don't want the wallet functionality to automatically enable after the node is started, 50 | set the value of AllBalances.AutoLoad to false in the config file. 51 | 52 | 53 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | ## ====================================================================== 2 | 3 | ## cccccccccc pppppppppp 4 | ## cccccccccccccc pppppppppppppp 5 | ## ccccccccccccccc ppppppppppppppppppp 6 | ## cccccc cc ppppppp pppppp 7 | ## cccccc pppppppp pppppp 8 | ## cccccc ccccpppp pppppp 9 | ## cccccccc cccccccc pppp ppppppp 10 | ## ccccccccccccccccc ppppppppppppppp 11 | ## cccccccccccc pppppppppppppp 12 | ## cccccccc pppppppppppp 13 | ## pppppp 14 | ## pppppp 15 | 16 | ## ====================================================================== 17 | ## Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | ## All Rights Reserved. All work owned by CCA is herby released 19 | ## under Creative Commons Zero (0) License. 20 | 21 | ## Some rights of 3rd party, derivative and included works remain the 22 | ## property of thier respective owners. All marks, brands and logos of 23 | ## member groups remain the exclusive property of their owners and no 24 | ## right or endorsement is conferred by reference to thier organization 25 | ## or brand(s) by CCA. 26 | 27 | ## File: .travis.yml 28 | ## Description: Gocoin-cash Travis CI Config 29 | 30 | ## Credits: 31 | 32 | ## Julian Smith, Direction, Development 33 | ## Arsen Yeremin, Development 34 | ## Sumanth Kumar, Development 35 | ## Clayton Wong, Development 36 | ## Liming Jiang, Development 37 | ## Piotr Narewski, Gocoin Founder 38 | 39 | ## Includes reference work of Shuai Qi "qshuai" (https://github.com/qshuai) 40 | 41 | ## Includes reference work of btsuite: 42 | 43 | ## Copyright (c) 2013-2017 The btcsuite developers 44 | ## Copyright (c) 2018 The bcext developers 45 | ## Use of this source code is governed by an ISC 46 | ## license that can be found in the LICENSE file. 47 | 48 | ## + Other contributors 49 | 50 | ## ===================================================================== 51 | 52 | language: go 53 | 54 | go: "1.11" 55 | 56 | # Skip the install step. Don't `go get` dependencies. Only build with the code 57 | # in vendor/ 58 | install: true 59 | 60 | # Don't email me the results of the test runs. 61 | notifications: 62 | email: false 63 | 64 | before_install: go get -u golang.org/x/lint/golint 65 | 66 | script: 67 | 68 | - golint ./... # run a bunch of code checkers/linters in parallel 69 | - go test -v -race ./... # Run all the tests with the race detector enabled 70 | 71 | # - ./pre-commit 72 | # - go test -cpu=1,2 -v -tags integration ./... 73 | 74 | # - cd $GOPATH/src/github.com/counterpartyxcpc/gocoin-cash/client/ 75 | # - go build 76 | # - cd $GOPATH/src/github.com/counterpartyxcpc/gocoin-cash/wallet/ 77 | # - go build -------------------------------------------------------------------------------- /client/ssl_cert/README.md: -------------------------------------------------------------------------------- 1 | # How to use SSL secured WebUI 2 | 3 | In order to have a SSL secured access to your node's WebUI, place here the following files: 4 | * ca.crt 5 | * server.key 6 | * server.crt 7 | 8 | If all the three files are in place, SSL server will be started at port 4433, in parallell to the regular HTTP server. 9 | 10 | The SSL server will accept connections from any IP address, regardless of the WebUI setting in `gocoin-cash.conf` file. 11 | 12 | In order to access it you will need `client.p12` certificate imported into your browser's Personal certificates. 13 | 14 | Then use URL like **https://your.hostname.or.ip:4433/** 15 | 16 | 17 | # How to generate needed files 18 | 19 | Use `openssl` command to generate all the required files. 20 | 21 | ## Generate ca.key and ca.crt 22 | openssl genrsa -out ca.key 4096 23 | openssl req -new -x509 -days 365 -key ca.key -out ca.crt 24 | 25 | Place `ca.crt` in the current folder. 26 | 27 | If you plan to use self-signed SSL certificate, additionally import `ca.crt` into your browser's Trusted Root CA list. 28 | 29 | ## Generate server.key and server.crt 30 | 31 | You can use one of the CA vendors to acquire SSL certificate for your WebUI hostname. 32 | Both the files are expected to be in the PEM format. 33 | Just rename the your private key file to `server.key` and the certificate (or the chain) to `server.crt`. 34 | 35 | Otherwise, the method below guides you through creating a self-signed SSL certificate. 36 | Using self-signed certificate, make sure to have `ca.crt` imported into your browser's Trusted Root CA list, to avoid security alerts. 37 | 38 | ### Create v3.ext file 39 | Create file named `v3.ext` with the following content: 40 | 41 | authorityKeyIdentifier=keyid,issuer 42 | basicConstraints=CA:FALSE 43 | keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment 44 | subjectAltName = @alt_names 45 | 46 | [alt_names] 47 | DNS.1 = domain.com 48 | 49 | Replace **domain.com** with your node's hostname or IP. 50 | 51 | ### Generate server.key and server.crt 52 | openssl genrsa -out server.key 2048 53 | openssl req -new -key server.key -out server.csr 54 | 55 | When asked for **Common Name** give your node's hostname or IP (same value as **DNS.1** in `v3.ext` file) 56 | 57 | openssl x509 -req -days 365 -in server.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out server.crt -sha256 -extfile v3.ext 58 | 59 | ## Installing server.key and server.crt 60 | 61 | Place `server.key` and `server.crt` in the current folder. 62 | 63 | ## Generate client.p12 64 | openssl genrsa -out client.key 2048 65 | openssl req -new -key client.key -out client.csr 66 | openssl x509 -req -days 365 -in client.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out client.crt 67 | openssl pkcs12 -export -clcerts -in client.crt -inkey client.key -out client.p12 68 | 69 | Import `client.p12` into your browser's Personal certificates. 70 | 71 | 72 | # Security pracautions 73 | 74 | In order to assure the security of the WebUI, make sure to keep the `ca.key` and all the `client.*` files secret. 75 | Whoever gets access to any of these files, will be able to access your node's WebUI. 76 | -------------------------------------------------------------------------------- /website/gocoin_installation.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |

Installation

7 |

System requirements

8 | 9 | If you only want to use the wallet with the corresponding balio tool, 10 | you can run it on anything that your go compiler can build for.
11 | For instance, it will work on even the oldest Raspberry Pi model A with 256MB of RAM. 12 |

13 | 14 | However, in order to run the full node (client), you need a 64-bit OS with at least 15 GB of RAM.
15 | You also need a file system that supports large files (bigger than 4GB) and a decent size of a free space on it.
16 |
17 | Note that you can purge blocks from disk, allowing you to run the node with a limited storage (e.g. 20GB).
18 | See config file values: 19 | Memory.MaxDataFileMB and Memory.DataFilesKeep (set this one to non-zero, e.g. 10)
20 |
21 | The node runs very well on Linux based virtual servers, as long as they have enough RAM.
22 | Find below a list of example providers. Most of them you can rent per-hour (estimated monthly cost in brackets).
23 | Waveride (€20) 24 | • 25 | Scaleway (€25) 26 | • 27 | Vultr (€80) 28 | • 29 | DigitalOcean (€80) 30 | • 31 | Amazon AWS ($100) 32 | • 33 | Gogle Cloud ($100) 34 |
35 | 36 |

Build from source

37 | 38 | You will need git and go commands installed in your system and in most cases 39 | (not for Windows) also gcc (e.g. sudo apt-get install gcc)
40 |
41 | Once you are ready with that, simply execute go get github.com/piotrnar/gocoin to download all the sources and dependencies.
42 |  Note: Sources will be placed within your GOPATH folder, in scr/github.com/piotrnar/gocoin.
43 |  Note: Execute go env GOPATH to see where your GOPATH folder is.

44 |
45 | Then go to gocoin/client/ and execute go build there. 46 | Do the same in gocoin/wallet/, to build the wallet.
47 | In order to build balio or some other tool, go to gocoin/tools/ and do go build balio.go
48 |
49 | 50 | The process is also described in the main README.md file of the github repo 51 | piotrnar/gocoin
52 |
53 | 54 |

Binaries

55 | The binaries (usually not the latest version) for Windows and Linux can be downloaded from 56 | sourceforge.net 57 | 58 | -------------------------------------------------------------------------------- /version.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: version.go 28 | // Description: Bictoin Cash Cash gocoincash Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package gocoincash 75 | 76 | // This file is only to make "go get" working 77 | 78 | import ( 79 | _ "github.com/dchest/siphash" 80 | _ "github.com/golang/snappy" 81 | _ "golang.org/x/crypto/ripemd160" 82 | ) 83 | 84 | // Version is the application version. 85 | const Version = "195.V2(BCH)" 86 | -------------------------------------------------------------------------------- /lib/bch_chain/bch_const.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: bch_const.go 28 | // Description: Bictoin Cash bch_chain Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package bch_chain 75 | 76 | const ( 77 | BlockMapInitLen = 500e3 78 | MovingCheckopintDepth = 2016 // Do not accept forks that wold go deeper in a past 79 | BIP16SwitchTime = 1333238400 // BIP16 didn't become active until Apr 1 2012 80 | COINBASE_MATURITY = 100 81 | MedianTimeSpan = 11 82 | ) 83 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013-2018 Piotr Narewski 2 | ----------------------- 3 | 4 | 5 | NON-COMMERCIAL USE 6 | ----------------------- 7 | Author of this software grants permission to use it in either 8 | original or modified form, free of charge, with no need for an 9 | explicit permission, but only for non-commercial purposes and 10 | only to physical people, not to any kind of legal entities. 11 | 12 | A non-profit community projects can also use this software for 13 | free, without a need for an explicit permission. 14 | 15 | 16 | COMMERCIAL USE 17 | ----------------------- 18 | Commercial companies (businesses) are allowed to use, develop 19 | and distribute this software for research purposes, without an 20 | explicit permission. 21 | 22 | However, selling any software that originates from this code 23 | base or products based on the infrastructure that such a 24 | software would be a part of, is forbidden before acquiring an 25 | explicit written license. 26 | 27 | ----------------------- 28 | piotr@gocoin.pl 29 | 30 | -----BEGIN PGP PUBLIC KEY BLOCK----- 31 | Version: GnuPG v2.0.22 (MingW32) 32 | 33 | mQENBE9sejYBCADOvsyvIo6kAcI/h4g6Sa6wYJmEVGUqRcO0C5SMn1OLvZ9towro 34 | HsbC4m9hLu/Jqz1fOo7FHIBghNmaTc7omi+Dd6IWPDhBcbg2SXzmyUiupS/eEalV 35 | kU1iz2IxeQrUBkcWB4a2tMboqoNhNX/a59+1bUZRlsaSqGzKEhEH54n7a/V8k9qI 36 | UhALMOnpPvAZAr3IXioaNB/H3qSpD5N7xmbe9zIKzMibPvTCUtfgOzf1XlvucdJl 37 | 9V1eoTEzLjiay43t3eUF4L9MzjwoH4cLwywaaWFWZmyQ1aYDDoPH31MUlZOBHt4Q 38 | u0hDHrCVrzm9CkpFPSDqe76fcUGAxnlPoVqdABEBAAG0LVBpb3RyIE5hcmV3c2tp 39 | IChiaXRjb2luKSA8cGlvdHJuYXJAZ21haWwuY29tPokBOwQTAQIAJQIbDwYLCQgH 40 | AwIGFQgCCQoLBBYCAwECHgECF4AFAlNxN+gCGQEACgkQG+e1Rc3z/Q53YQgAuE1n 41 | rGnP9VqXYUIFo70gV5PeCEtWdugV8R4XBFpaLRTUfUNPuFjS6wqqn1i96rtPSkSm 42 | m24Dviim2YaUJpbvJ6BohtT2CDM1cP4oVZLiElYu5aHxrujtIVO58Q7DUt4osW2R 43 | ANJbIiWQT0GOtYWkmTGhR9GAcfBLcs3RIr/sfIJTQIy+VvphGr2LiA8gQuh4iSU8 44 | tEgZNCAdQQkHLkZVowC5BC0D9Mx4mypm3d4KmG3Qbxw7kN4n8DMPP9Ek1VFbBFta 45 | 4q1jFE2qqbPTfRahYeGwvkCr3hx4gEIRU/4l8OLxTFfrtFPCFcQOD8tquSK0bK3d 46 | IiDJY2nM4admGNvL6rQgUGlvdHIgTi4gPHRvbmlrdEBhc3NldHMtb3RjLmNvbT6J 47 | ATkEEwECACMFAlNxOeUCGw8HCwkIBwMCAQYVCAIJCgsEFgIDAQIeAQIXgAAKCRAb 48 | 57VFzfP9DrjXB/48qvOGXCZ/J6N19XZAtlwAyWl+X3tpSQYXuQfV7J5cJ04PFx6Q 49 | lWxF2NwJo65FPSzz2BPbGIMpUjE+BfUZr/m8XWNhWsvC4Qgx89oFwu2yXU89sXH1 50 | VpLo1cyDTQFPid0s2wA+jLZ9mxgx5OOg1Mktq1T80ZEZVxut3/7twjdb4b7Lbhws 51 | /A59+rkuhApxeACXmg1vwKEka9xL4hYnPNVsF7ifuEChzhBHc/pNL5JvZOTja0+Y 52 | irS19G9Qqi7GHGmO/gDWY0xf57+HtcU1pl7i45U60GUBKs4pV8mjYRndUj9SnumK 53 | o6TK3mkAM/X+nSswVl+C2k7hE/O6XJ7VG3vZtHxCVEMgc3RlYWx0aCBhZGRyZXNz 54 | ICh2Sm14QjdlZ2Q3cjYydWJiNDVKM0J6cWtNZW1RdjVIMmRucEtUQzczNWlRdXV4 55 | WVhGTUE3Q3Jlb3VvdTdxWkRwZjc0b3BneGZZaFhTcm03YlA1NDlDaUd6UEZRbmpN 56 | YWFoc3VWdXcpiQE5BBMBAgAjBQJTcToKAhsPBwsJCAcDAgEGFQgCCQoLBBYCAwEC 57 | HgECF4AACgkQG+e1Rc3z/Q5CWQf+Pe5EXTLIUR7nMuFRyjY68+RT86tXSVc83arL 58 | F3WnO3iNoLyZ4hLD3If/6K7RXiyWFO1ezaZ5ZmYuFkZvmfdpOSjO1DDJkIpFKfRj 59 | QcpBbgbSCIFe7lJErGJvNd8+y/TBtZDdGCTXrjyfiHDDvZ3/3NCg+UOHUoXzerFp 60 | oXErVdt/JocVotxGokOLLn5HCd/K8iatkh4F+D8ELVzo/7SfNQWWCq+qvCXw8qYQ 61 | xPRp7bvF/Fvwefhl8k9naBw1FkkN07JnQ8gGAvAYkzoeuw9axGvBi1AFWyGoAMce 62 | vO0TqyrkDDDG0J0UmqcK8TpeUK7HcMbBNycRFsCn9B35KeHmQw== 63 | =JjWK 64 | -----END PGP PUBLIC KEY BLOCK----- 65 | -------------------------------------------------------------------------------- /lib/bch/const.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: const.go 28 | // Description: Bictoin Cash Block Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package bch 75 | 76 | const ( 77 | COIN = 1e8 78 | MAX_MONEY = 21000000 * COIN 79 | MAX_BLOCK_WEIGHT = 4e6 80 | MessageMagic = "Bitcoin Signed Message:\n" 81 | LOCKTIME_THRESHOLD = 500000000 82 | MAX_SCRIPT_ELEMENT_SIZE = 520 83 | MAX_BLOCK_SIGOPS_COST = 80000 84 | MAX_PUBKEYS_PER_MULTISIG = 20 85 | WITNESS_SCALE_FACTOR = 4 86 | 87 | BTC_FORK_ID = 0x40 88 | ) 89 | -------------------------------------------------------------------------------- /lib/others/sys/ipnet.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: ipnet.go 28 | // Description: Bictoin Cash Cash sys Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package sys 75 | 76 | // Discard any IP that may refer to a local network 77 | func ValidIp4(ip []byte) bool { 78 | // local host 79 | if ip[0] == 0 || ip[0] == 127 { 80 | return false 81 | } 82 | 83 | // RFC1918 84 | if ip[0] == 10 || ip[0] == 192 && ip[1] == 168 || ip[0] == 172 && ip[1] >= 16 && ip[1] <= 31 { 85 | return false 86 | } 87 | 88 | //RFC3927 89 | if ip[0] == 169 && ip[1] == 254 { 90 | return false 91 | } 92 | 93 | return true 94 | } 95 | 96 | func IsIPBlocked(ip4 []byte) bool { 97 | return false 98 | } 99 | -------------------------------------------------------------------------------- /tools/sipa_dll/sipadll.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: spiadll.go 28 | // Description: Bictoin Cash Cash spiadll Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package spiadll 75 | 76 | import ( 77 | "syscall" 78 | "unsafe" 79 | ) 80 | 81 | var ( 82 | advapi32 = syscall.NewLazyDLL("secp256k1.dll") 83 | DLL_EC_Verify = advapi32.NewProc("EC_Verify") 84 | ) 85 | 86 | func EC_Verify(pkey, sign, hash []byte) int32 { 87 | r1, _, _ := syscall.Syscall6(DLL_EC_Verify.Addr(), 6, 88 | uintptr(unsafe.Pointer(&hash[0])), uintptr(32), 89 | uintptr(unsafe.Pointer(&sign[0])), uintptr(len(sign)), 90 | uintptr(unsafe.Pointer(&pkey[0])), uintptr(len(pkey))) 91 | return int32(r1) 92 | } 93 | -------------------------------------------------------------------------------- /lib/script/dbg.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: dbg.go 28 | // Description: Bictoin Cash Cash script Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package script 75 | 76 | const ( 77 | DBG_WASTED = 1 << 0 78 | DBG_UNSPENT = 1 << 1 79 | DBG_BLOCKS = 1 << 2 80 | DBG_ORPHAS = 1 << 3 81 | DBG_TX = 1 << 4 82 | DBG_SCRIPT = 1 << 5 83 | DBG_VERIFY = 1 << 6 84 | DBG_SCRERR = 1 << 7 85 | ) 86 | 87 | var dbgmask uint32 = 0 88 | 89 | func don(b uint32) bool { 90 | return (dbgmask & b) != 0 91 | } 92 | 93 | func DbgSwitch(b uint32, on bool) { 94 | if on { 95 | dbgmask |= b 96 | } else { 97 | dbgmask ^= (b & dbgmask) 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /lib/bch_chain/bch_dbg.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: bch_dbg.go 28 | // Description: Bictoin Cash bch_chain Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package bch_chain 75 | 76 | const ( 77 | DBG_WASTED = 1 << 0 78 | DBG_UNSPENT = 1 << 1 79 | DBG_BLOCKS = 1 << 2 80 | DBG_ORPHAS = 1 << 3 81 | DBG_TX = 1 << 4 82 | DBG_SCRIPT = 1 << 5 83 | DBG_VERIFY = 1 << 6 84 | DBG_SCRERR = 1 << 7 85 | ) 86 | 87 | var dbgmask uint32 = 0 88 | 89 | func don(b uint32) bool { 90 | return (dbgmask & b) != 0 91 | } 92 | 93 | func DbgSwitch(b uint32, on bool) { 94 | if on { 95 | dbgmask |= b 96 | } else { 97 | dbgmask ^= (b & dbgmask) 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /lib/others/cgo/sipasec/sipasec_linux.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: sipasec_linux.go 28 | // Description: Bictoin Cash Cash sipasec Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | // +build linux 75 | 76 | package sipasec 77 | 78 | /* 79 | To build and install secp256k1 lib on Debian Linux system, execute the following steps: 80 | 81 | * sudo apt-get install gcc autoconf libtool make 82 | * git clone https://github.com/bitcoin/bitcoin.git 83 | * cd bitcoin/src/secp256k1/ 84 | * ./autogen.sh 85 | * ./configure 86 | * make 87 | * sudo make install 88 | 89 | When the lib is properly installed, executing "go test" in this folder will say "PASS". 90 | Then copy "gocoin/client/speedups/sipasec.go" to "gocoin/client/" to boost your client. 91 | */ 92 | 93 | // #cgo LDFLAGS: /usr/local/lib/libsecp256k1.a 94 | import "C" 95 | -------------------------------------------------------------------------------- /tools/fetchblock.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: fetchblock.go 28 | // Description: Bictoin Cash Cash main Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package main 75 | 76 | import ( 77 | "fmt" 78 | "io/ioutil" 79 | "os" 80 | 81 | "github.com/counterpartyxcpc/gocoin-cash" 82 | bch "github.com/counterpartyxcpc/gocoin-cash/lib/bch" 83 | "github.com/counterpartyxcpc/gocoin-cash/lib/others/utils" 84 | ) 85 | 86 | func main() { 87 | fmt.Println("Gocoin FetchBlock version", gocoincash.Version) 88 | 89 | if len(os.Args) < 2 { 90 | fmt.Println("Specify block hash on the command line (MSB).") 91 | return 92 | } 93 | 94 | hash := bch.NewUint256FromString(os.Args[1]) 95 | bl := utils.GetBlockFromWeb(hash) 96 | if bl == nil { 97 | fmt.Println("Error fetching the block") 98 | } else { 99 | ioutil.WriteFile(bl.Hash.String()+".bin", bl.Raw, 0666) 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /tools/fetchtx.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: fetchx.go 28 | // Description: Bictoin Cash Cash main Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package main 75 | 76 | import ( 77 | "fmt" 78 | "io/ioutil" 79 | "os" 80 | 81 | "github.com/counterpartyxcpc/gocoin-cash" 82 | bch "github.com/counterpartyxcpc/gocoin-cash/lib/bch" 83 | "github.com/counterpartyxcpc/gocoin-cash/lib/others/utils" 84 | ) 85 | 86 | func main() { 87 | fmt.Println("Gocoin FetchTx version", gocoincash.Version) 88 | 89 | if len(os.Args) < 2 { 90 | fmt.Println("Specify transaction id on the command line (MSB).") 91 | return 92 | } 93 | 94 | txid := bch.NewUint256FromString(os.Args[1]) 95 | rawtx := utils.GetTxFromWeb(txid) 96 | if rawtx == nil { 97 | fmt.Println("Error fetching the transaction") 98 | } else { 99 | ioutil.WriteFile(txid.String()+".tx", rawtx, 0666) 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /lib/bch/multisig_test.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: multisig_test.go 28 | // Description: Bictoin Cash Multisig Package Testing 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package bch 75 | 76 | import ( 77 | "bytes" 78 | "encoding/hex" 79 | "testing" 80 | ) 81 | 82 | func TestMultisigFromScript(t *testing.T) { 83 | txt := "004730440220485ef45dd67e7e3ffee699d42cf56ec88b4162d9f373770c30efec075468281702204929343ea97b007c1fc2ed49b306355ebf6bc5fb1613f0ed51ebca44fcc2003a014c69512103af88375d5fc9230446365b7d33540a73397ab3cc1a9f3e306a26833d1bfc260f21030677e0dd58025a5404747fbc64083040083acf3b390515f71a8ede95dc9c4d8a2103af88375d5fc9230446365b7d33540a73397ab3cc1a9f3e306a26833d1bfc260f53ae" 84 | d, _ := hex.DecodeString(txt) 85 | s, e := NewMultiSigFromScript(d) 86 | if e != nil { 87 | t.Error(e.Error()) 88 | } 89 | 90 | b := s.Bytes() 91 | if !bytes.Equal(b, d) { 92 | t.Error("Multisig script does not match the input\n", hex.EncodeToString(b), "\n", hex.EncodeToString(d)) 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /lib/bch/opcodes.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: opcodes.go 28 | // Description: Bictoin Cash Opcodes Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package bch 75 | 76 | const ( 77 | OP_0 = 0x00 78 | OP_FALSE = OP_0 79 | OP_PUSHDATA1 = 0x4c 80 | OP_PUSHDATA2 = 0x4d 81 | OP_PUSHDATA4 = 0x4e 82 | OP_1NEGATE = 0x4f 83 | OP_RESERVED = 0x50 84 | OP_1 = 0x51 85 | OP_TRUE = OP_1 86 | OP_2 = 0x52 87 | OP_3 = 0x53 88 | OP_4 = 0x54 89 | OP_5 = 0x55 90 | OP_6 = 0x56 91 | OP_7 = 0x57 92 | OP_8 = 0x58 93 | OP_9 = 0x59 94 | OP_10 = 0x5a 95 | OP_11 = 0x5b 96 | OP_12 = 0x5c 97 | OP_13 = 0x5d 98 | OP_14 = 0x5e 99 | OP_15 = 0x5f 100 | OP_16 = 0x60 101 | 102 | OP_EQUAL = 0x87 103 | OP_HASH160 = 0xa9 104 | OP_CHECKMULTISIG = 0xae 105 | ) 106 | -------------------------------------------------------------------------------- /client/speedups/sipasec.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: sipasec.go 28 | // Description: Bictoin Cash main Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package main 75 | 76 | /* 77 | This is a EC_Verify speedup that is advised for non Windows systems. 78 | 79 | 1) Build and install sipa's secp256k1 lib for your system 80 | 81 | 2) Copy this file one level up and remove "speedup.go" from there 82 | 83 | 3) Rebuild clinet.exe and enjoy sipa's verify lib. 84 | */ 85 | 86 | import ( 87 | "github.com/counterpartyxcpc/gocoin-cash/client/common" 88 | bch "github.com/counterpartyxcpc/gocoin-cash/lib/bch" 89 | "github.com/counterpartyxcpc/gocoin-cash/lib/others/cgo/sipasec" 90 | ) 91 | 92 | func EC_Verify(k, s, h []byte) bool { 93 | return sipasec.EC_Verify(k, s, h) == 1 94 | } 95 | 96 | func init() { 97 | common.Log.Println("Using libsecp256k1.a by sipa for EC_Verify") 98 | bch.EC_Verify = EC_Verify 99 | } 100 | -------------------------------------------------------------------------------- /lib/bch_utxo/membind.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: membind.go 28 | // Description: Bictoin Cash utxo Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package utxo 75 | 76 | import ( 77 | "sync/atomic" 78 | ) 79 | 80 | var ( 81 | malloc func(le uint32) []byte = func(le uint32) []byte { 82 | return make([]byte, int(le)) 83 | } 84 | 85 | free func([]byte) = func(v []byte) { 86 | } 87 | 88 | malloc_and_copy func(v []byte) []byte = func(v []byte) []byte { 89 | return v 90 | } 91 | 92 | MembindInit func() = func() {} 93 | ) 94 | 95 | var ( 96 | extraMemoryConsumed int64 // if we are using the glibc memory manager 97 | extraMemoryAllocCnt int64 // if we are using the glibc memory manager 98 | ) 99 | 100 | func ExtraMemoryConsumed() int64 { 101 | return atomic.LoadInt64(&extraMemoryConsumed) 102 | } 103 | 104 | func ExtraMemoryAllocCnt() int64 { 105 | return atomic.LoadInt64(&extraMemoryAllocCnt) 106 | } 107 | -------------------------------------------------------------------------------- /lib/others/qdb/stats.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: stats.go 28 | // Description: Bictoin Cash Cash qdb Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package qdb 75 | 76 | import ( 77 | "fmt" 78 | "sort" 79 | "sync" 80 | ) 81 | 82 | var ( 83 | counter map[string]uint64 = make(map[string]uint64) 84 | counter_mutex sync.Mutex 85 | ) 86 | 87 | func cnt(k string) { 88 | cntadd(k, 1) 89 | } 90 | 91 | func cntadd(k string, val uint64) { 92 | counter_mutex.Lock() 93 | counter[k] += val 94 | counter_mutex.Unlock() 95 | } 96 | 97 | func GetStats() (s string) { 98 | counter_mutex.Lock() 99 | ck := make([]string, len(counter)) 100 | idx := 0 101 | for k := range counter { 102 | ck[idx] = k 103 | idx++ 104 | } 105 | sort.Strings(ck) 106 | 107 | for i := range ck { 108 | k := ck[i] 109 | v := counter[k] 110 | s += fmt.Sprintln(k, ": ", v) 111 | } 112 | counter_mutex.Unlock() 113 | return s 114 | } 115 | -------------------------------------------------------------------------------- /tools/utxo.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: utxo.go 28 | // Description: Bictoin Cash Cash main Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package main 75 | 76 | import ( 77 | "encoding/binary" 78 | "fmt" 79 | "os" 80 | 81 | bch "github.com/counterpartyxcpc/gocoin-cash/lib/bch" 82 | ) 83 | 84 | func main() { 85 | var buf [48]byte 86 | if len(os.Args) != 2 { 87 | fmt.Println("Specify the filename containing UTXO database") 88 | return 89 | } 90 | f, er := os.Open(os.Args[1]) 91 | if er != nil { 92 | fmt.Println(er.Error()) 93 | return 94 | } 95 | er = bch.ReadAll(f, buf[:]) 96 | f.Close() 97 | if er != nil { 98 | fmt.Println(er.Error()) 99 | return 100 | } 101 | fmt.Println("Last Block Height:", binary.LittleEndian.Uint64(buf[:8])) 102 | fmt.Println("Last Block Hash:", bch.NewUint256(buf[8:40]).String()) 103 | fmt.Println("Number of UTXO records:", binary.LittleEndian.Uint64(buf[40:48])) 104 | } 105 | -------------------------------------------------------------------------------- /lib/others/sys/dblock_windows.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: dblock_windows.go 28 | // Description: Bictoin Cash Cash sys Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package sys 75 | 76 | import ( 77 | "os" 78 | ) 79 | 80 | var ( 81 | DbLockFileName string 82 | DbLockFileHndl *os.File 83 | ) 84 | 85 | func LockDatabaseDir(GocoinCashHomeDir string) { 86 | var e error 87 | os.MkdirAll(GocoinCashHomeDir, 0770) 88 | DbLockFileName = GocoinCashHomeDir + ".lock" 89 | os.Remove(DbLockFileName) 90 | DbLockFileHndl, e = os.OpenFile(DbLockFileName, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0660) 91 | if e != nil { 92 | println(e.Error()) 93 | println("Could not lock the databse folder for writing. Another instance might be running.") 94 | println("Make sure you can delete and recreate file:", DbLockFileName) 95 | os.Exit(1) 96 | } 97 | } 98 | 99 | func UnlockDatabaseDir() { 100 | DbLockFileHndl.Close() 101 | os.Remove(DbLockFileName) 102 | } 103 | -------------------------------------------------------------------------------- /lib/secp256k1/field_test.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: field_test.go 28 | // Description: Bictoin Cash Cash secp256k1 Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package secp256k1 75 | 76 | import ( 77 | "crypto/rand" 78 | "testing" 79 | ) 80 | 81 | func TestFeInv(t *testing.T) { 82 | var in, out, exp Field 83 | in.SetHex("813925AF112AAB8243F8CCBADE4CC7F63DF387263028DE6E679232A73A7F3C31") 84 | exp.SetHex("7F586430EA30F914965770F6098E492699C62EE1DF6CAFFA77681C179FDF3117") 85 | in.Inv(&out) 86 | if !out.Equals(&exp) { 87 | t.Error("fe.Inv() failed") 88 | } 89 | } 90 | 91 | func BenchmarkFieldSqrt(b *testing.B) { 92 | var dat [32]byte 93 | var f, tmp Field 94 | rand.Read(dat[:]) 95 | f.SetB32(dat[:]) 96 | for i := 0; i < b.N; i++ { 97 | f.Sqrt(&tmp) 98 | } 99 | } 100 | 101 | func BenchmarkFieldInv(b *testing.B) { 102 | var dat [32]byte 103 | var f, tmp Field 104 | rand.Read(dat[:]) 105 | f.SetB32(dat[:]) 106 | for i := 0; i < b.N; i++ { 107 | f.Inv(&tmp) 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /tools/base58.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: base58.go 28 | // Description: Bictoin Cash Cash main Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package main 75 | 76 | import ( 77 | "encoding/hex" 78 | "flag" 79 | "fmt" 80 | "io/ioutil" 81 | "os" 82 | "strings" 83 | 84 | bch "github.com/counterpartyxcpc/gocoin-cash/lib/bch" 85 | ) 86 | 87 | var ( 88 | decode = flag.Bool("d", false, "run base58 decode (instead of encode)") 89 | binary = flag.Bool("b", false, "binary (insted of hex) for decode output") 90 | help = flag.Bool("h", false, "print this help") 91 | ) 92 | 93 | func main() { 94 | flag.Parse() 95 | if *help { 96 | flag.PrintDefaults() 97 | return 98 | } 99 | 100 | msg, _ := ioutil.ReadAll(os.Stdin) 101 | if len(msg) == 0 { 102 | return 103 | } 104 | 105 | if *decode { 106 | res := bch.Decodeb58(strings.Trim(string(msg), " \t\n\r")) 107 | if *binary { 108 | os.Stdout.Write(res) 109 | } else { 110 | fmt.Println(hex.EncodeToString(res)) 111 | } 112 | } else { 113 | fmt.Println(bch.Encodeb58(msg)) 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /lib/bch/netaddr.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: netaddr.go 28 | // Description: Bictoin Cash Address Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package bch 75 | 76 | import ( 77 | "encoding/binary" 78 | "fmt" 79 | ) 80 | 81 | type NetAddr struct { 82 | Services uint64 83 | Ip6 [12]byte 84 | Ip4 [4]byte 85 | Port uint16 86 | } 87 | 88 | func NewNetAddr(b []byte) (na *NetAddr) { 89 | if len(b) != 26 { 90 | println("Incorrect input data length", len(b)) 91 | return 92 | } 93 | na = new(NetAddr) 94 | na.Services = binary.LittleEndian.Uint64(b[0:8]) 95 | copy(na.Ip6[:], b[8:20]) 96 | copy(na.Ip4[:], b[20:24]) 97 | na.Port = binary.BigEndian.Uint16(b[24:26]) 98 | return 99 | } 100 | 101 | func (a *NetAddr) Bytes() (res []byte) { 102 | res = make([]byte, 26) 103 | binary.LittleEndian.PutUint64(res[0:8], a.Services) 104 | copy(res[8:20], a.Ip6[:]) 105 | copy(res[20:24], a.Ip4[:]) 106 | binary.BigEndian.PutUint16(res[24:26], a.Port) 107 | return 108 | } 109 | 110 | func (a *NetAddr) String() string { 111 | return fmt.Sprintf("%d.%d.%d.%d:%d", a.Ip4[0], a.Ip4[1], a.Ip4[2], a.Ip4[3], a.Port) 112 | } 113 | -------------------------------------------------------------------------------- /lib/others/cgo/ec_bench/openssl.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: openssl.go 28 | // Description: Bictoin Cash Cash main Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package main 75 | 76 | import ( 77 | "encoding/hex" 78 | "sync" 79 | "time" 80 | 81 | "github.com/counterpartyxcpc/gocoin-cash/lib/others/cgo/openssl" 82 | ) 83 | 84 | var CNT int = 15 * 250 85 | 86 | func main() { 87 | key, _ := hex.DecodeString("040eaebcd1df2df853d66ce0e1b0fda07f67d1cabefde98514aad795b86a6ea66dbeb26b67d7a00e2447baeccc8a4cef7cd3cad67376ac1c5785aeebb4f6441c16") 88 | sig, _ := hex.DecodeString("3045022100fe00e013c244062847045ae7eb73b03fca583e9aa5dbd030a8fd1c6dfcf11b1002207d0d04fed8fa1e93007468d5a9e134b0a7023b6d31db4e50942d43a250f4d07c") 89 | msg, _ := hex.DecodeString("3382219555ddbb5b00e0090f469e590ba1eae03c7f28ab937de330aa60294ed6") 90 | var wg sync.WaitGroup 91 | sta := time.Now() 92 | for i := 0; i < CNT; i++ { 93 | wg.Add(1) 94 | go func() { 95 | if openssl.EC_Verify(key, sig, msg) != 1 { 96 | println("Verify error") 97 | } 98 | wg.Done() 99 | }() 100 | } 101 | wg.Wait() 102 | sto := time.Now() 103 | println((sto.UnixNano()-sta.UnixNano())/int64(CNT*1000), "us per ECDSA_Verify") 104 | } 105 | -------------------------------------------------------------------------------- /lib/others/sys/dblock_unix.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: dblock_unix.go 28 | // Description: Bictoin Cash Cash sys Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | // +build !windows 75 | 76 | package sys 77 | 78 | import ( 79 | "os" 80 | "syscall" 81 | ) 82 | 83 | var ( 84 | DbLockFileName string 85 | DbLockFileHndl *os.File 86 | ) 87 | 88 | func LockDatabaseDir(GocoinCashHomeDir string) { 89 | os.MkdirAll(GocoinCashHomeDir, 0770) 90 | DbLockFileName = GocoinCashHomeDir + ".lock" 91 | DbLockFileHndl, _ = os.Open(DbLockFileName) 92 | if DbLockFileHndl == nil { 93 | DbLockFileHndl, _ = os.Create(DbLockFileName) 94 | } 95 | if DbLockFileHndl == nil { 96 | goto error 97 | } 98 | 99 | if e := syscall.Flock(int(DbLockFileHndl.Fd()), syscall.LOCK_EX|syscall.LOCK_NB); e != nil { 100 | goto error 101 | } 102 | return 103 | 104 | error: 105 | println("Could not lock the databse folder for writing. Another instance might be running.") 106 | println("If it is not the case, remove this file:", DbLockFileName) 107 | os.Exit(1) 108 | } 109 | 110 | func UnlockDatabaseDir() { 111 | syscall.Flock(int(DbLockFileHndl.Fd()), syscall.LOCK_UN) 112 | DbLockFileHndl.Close() 113 | os.Remove(DbLockFileName) 114 | } 115 | -------------------------------------------------------------------------------- /lib/others/cgo/openssl/openssl.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: openssl.go 28 | // Description: Bictoin Cash Cash openssl Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package openssl 75 | 76 | /* 77 | #cgo !windows LDFLAGS: -lcrypto 78 | #cgo windows LDFLAGS: /DEV/openssl-1.0.2a/libcrypto.a -lgdi32 79 | #cgo windows CFLAGS: -I /DEV/openssl-1.0.2a/include 80 | 81 | #include 82 | #include 83 | #include 84 | #include 85 | 86 | int verify(void *pkey, unsigned int pkl, void *sign, unsigned int sil, void *hasz) { 87 | EC_KEY* ecpkey; 88 | ecpkey = EC_KEY_new_by_curve_name(NID_secp256k1); 89 | if (!ecpkey) { 90 | printf("EC_KEY_new_by_curve_name error!\n"); 91 | return -1; 92 | } 93 | if (!o2i_ECPublicKey(&ecpkey, (const unsigned char **)&pkey, pkl)) { 94 | //printf("o2i_ECPublicKey fail!\n"); 95 | return -2; 96 | } 97 | int res = ECDSA_verify(0, hasz, 32, sign, sil, ecpkey); 98 | EC_KEY_free(ecpkey); 99 | return res; 100 | } 101 | */ 102 | import "C" 103 | import "unsafe" 104 | 105 | // Verify ECDSA signature 106 | func EC_Verify(pkey, sign, hash []byte) int { 107 | return int(C.verify(unsafe.Pointer(&pkey[0]), C.uint(len(pkey)), 108 | unsafe.Pointer(&sign[0]), C.uint(len(sign)), unsafe.Pointer(&hash[0]))) 109 | } 110 | -------------------------------------------------------------------------------- /client/www/templates/wallet_off.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | Minimum output value to be included in wallet's balance: BCH 4 | 15 | 16 | 25 | 26 | 27 |
28 | Import settings: 29 | 30 | 31 | 130 | -------------------------------------------------------------------------------- /lib/bch_utxo/membind_linux.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: membind_linux.go 28 | // Description: Bictoin Cash utxo Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | /* 75 | If this file does not build and you don't know what to do, simply delete it and rebuild. 76 | */ 77 | 78 | package utxo 79 | 80 | /* 81 | #include 82 | */ 83 | import "C" 84 | 85 | import ( 86 | "fmt" 87 | "reflect" 88 | "sync/atomic" 89 | "unsafe" 90 | ) 91 | 92 | func init() { 93 | MembindInit = func() { 94 | fmt.Println("Using malloc() and free() for UTXO records") 95 | 96 | malloc = func(le uint32) []byte { 97 | atomic.AddInt64(&extraMemoryConsumed, int64(le)+24) 98 | atomic.AddInt64(&extraMemoryAllocCnt, 1) 99 | ptr := uintptr(C.malloc(C.size_t(le + 24))) 100 | *(*reflect.SliceHeader)(unsafe.Pointer(ptr)) = reflect.SliceHeader{Data: ptr + 24, Len: int(le), Cap: int(le)} 101 | return *(*[]byte)(unsafe.Pointer(ptr)) 102 | } 103 | 104 | free = func(ptr []byte) { 105 | atomic.AddInt64(&extraMemoryConsumed, -int64(len(ptr)+24)) 106 | atomic.AddInt64(&extraMemoryAllocCnt, -1) 107 | C.free(unsafe.Pointer(uintptr(unsafe.Pointer(&ptr[0])) - 24)) 108 | } 109 | 110 | malloc_and_copy = func(v []byte) []byte { 111 | sl := malloc(uint32(len(v))) 112 | copy(sl, v) 113 | return sl 114 | } 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /lib/others/cgo/openssl/openssl_test.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: openssl_test.go 28 | // Description: Bictoin Cash Cash openssl Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package openssl 75 | 76 | import ( 77 | "encoding/hex" 78 | "testing" 79 | ) 80 | 81 | func TestVerify(t *testing.T) { 82 | pkey, _ := hex.DecodeString("040eaebcd1df2df853d66ce0e1b0fda07f67d1cabefde98514aad795b86a6ea66dbeb26b67d7a00e2447baeccc8a4cef7cd3cad67376ac1c5785aeebb4f6441c16") 83 | hasz, _ := hex.DecodeString("3382219555ddbb5b00e0090f469e590ba1eae03c7f28ab937de330aa60294ed6") 84 | sign, _ := hex.DecodeString("3045022100fe00e013c244062847045ae7eb73b03fca583e9aa5dbd030a8fd1c6dfcf11b1002207d0d04fed8fa1e93007468d5a9e134b0a7023b6d31db4e50942d43a250f4d07c") 85 | res := EC_Verify(pkey, sign, hasz) 86 | if res != 1 { 87 | t.Error("Verify failed") 88 | } 89 | hasz[0]++ 90 | res = EC_Verify(pkey, sign, hasz) 91 | if res != 0 { 92 | t.Error("Verify not failed while it should") 93 | } 94 | res = EC_Verify(pkey[:1], sign, hasz) 95 | if res != -2 { 96 | t.Error("Negative result expected", res) 97 | } 98 | res = EC_Verify(pkey, sign[:1], hasz) 99 | if res != -1 { 100 | t.Error("Yet negative result expected", res) 101 | } 102 | res = EC_Verify(pkey, sign, hasz[:1]) 103 | if res != 0 { 104 | t.Error("Zero expected", res) 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /tools/sipa_dll/sipadll_test.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: spiadll_test.go 28 | // Description: Bictoin Cash Cash spiadll Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package spiadll 75 | 76 | import ( 77 | "encoding/hex" 78 | "testing" 79 | ) 80 | 81 | func TestVerify(t *testing.T) { 82 | pkey, _ := hex.DecodeString("040eaebcd1df2df853d66ce0e1b0fda07f67d1cabefde98514aad795b86a6ea66dbeb26b67d7a00e2447baeccc8a4cef7cd3cad67376ac1c5785aeebb4f6441c16") 83 | hasz, _ := hex.DecodeString("3382219555ddbb5b00e0090f469e590ba1eae03c7f28ab937de330aa60294ed6") 84 | sign, _ := hex.DecodeString("3045022100fe00e013c244062847045ae7eb73b03fca583e9aa5dbd030a8fd1c6dfcf11b1002207d0d04fed8fa1e93007468d5a9e134b0a7023b6d31db4e50942d43a250f4d07c01") 85 | res := EC_Verify(pkey, sign, hasz) 86 | if res != 1 { 87 | t.Error("Verify failed") 88 | } 89 | hasz[0]++ 90 | res = EC_Verify(pkey, sign, hasz) 91 | if res != 0 { 92 | t.Error("Verify not failed while it should") 93 | } 94 | res = EC_Verify(pkey[:1], sign, hasz) 95 | if res >= 0 { 96 | t.Error("Negative result expected", res) 97 | } 98 | res = EC_Verify(pkey, sign[:1], hasz) 99 | if res >= 0 { 100 | t.Error("Yet negative result expected", res) 101 | } 102 | res = EC_Verify(pkey, sign, hasz[:1]) 103 | if res != 0 { 104 | t.Error("Zero expected", res) 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /lib/others/cgo/ec_bench/gonative.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: gonative.go 28 | // Description: Bictoin Cash Cash main Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package main 75 | 76 | import ( 77 | "encoding/hex" 78 | "runtime" 79 | "sync" 80 | "time" 81 | 82 | bch "github.com/counterpartyxcpc/gocoin-cash/lib/bch" 83 | ) 84 | 85 | var CNT int = 100e3 86 | 87 | func main() { 88 | key, _ := hex.DecodeString("040eaebcd1df2df853d66ce0e1b0fda07f67d1cabefde98514aad795b86a6ea66dbeb26b67d7a00e2447baeccc8a4cef7cd3cad67376ac1c5785aeebb4f6441c16") 89 | sig, _ := hex.DecodeString("3045022100fe00e013c244062847045ae7eb73b03fca583e9aa5dbd030a8fd1c6dfcf11b1002207d0d04fed8fa1e93007468d5a9e134b0a7023b6d31db4e50942d43a250f4d07c01") 90 | msg, _ := hex.DecodeString("3382219555ddbb5b00e0090f469e590ba1eae03c7f28ab937de330aa60294ed6") 91 | var wg sync.WaitGroup 92 | max_routines := make(chan bool, 2*runtime.NumCPU()) 93 | println("Number of threads:", cap(max_routines)) 94 | sta := time.Now() 95 | for i := 0; i < CNT; i++ { 96 | wg.Add(1) 97 | max_routines <- true 98 | go func() { 99 | if !bch.EcdsaVerify(key, sig, msg) { 100 | println("Verify error") 101 | } 102 | wg.Done() 103 | <-max_routines 104 | }() 105 | } 106 | wg.Wait() 107 | sto := time.Now() 108 | println((sto.UnixNano()-sta.UnixNano())/int64(CNT*1000), "us per ECDSA_Verify") 109 | } 110 | -------------------------------------------------------------------------------- /lib/others/sys/atomic.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: atomic.go 28 | // Description: Bictoin Cash Cash sys Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package sys 75 | 76 | import ( 77 | "fmt" 78 | "sync/atomic" 79 | ) 80 | 81 | type SyncBool struct { 82 | val int32 83 | } 84 | 85 | func (b *SyncBool) Get() bool { 86 | return atomic.LoadInt32(&b.val) != 0 87 | } 88 | 89 | func (b *SyncBool) Set() { 90 | atomic.StoreInt32(&b.val, 1) 91 | } 92 | 93 | func (b *SyncBool) Clr() { 94 | atomic.StoreInt32(&b.val, 0) 95 | } 96 | 97 | func (b *SyncBool) MarshalText() (text []byte, err error) { 98 | return []byte(fmt.Sprint(b.Get())), nil 99 | } 100 | 101 | func (b *SyncBool) Store(val bool) { 102 | if val { 103 | b.Set() 104 | } else { 105 | b.Clr() 106 | } 107 | } 108 | 109 | type SyncInt struct { 110 | val int64 111 | } 112 | 113 | func (b *SyncInt) Get() int { 114 | return int(atomic.LoadInt64(&b.val)) 115 | } 116 | 117 | func (b *SyncInt) Store(val int) { 118 | atomic.StoreInt64(&b.val, int64(val)) 119 | } 120 | 121 | func (b *SyncInt) Add(val int) { 122 | atomic.AddInt64(&b.val, int64(val)) 123 | } 124 | 125 | func (b *SyncInt) MarshalText() (text []byte, err error) { 126 | return []byte(fmt.Sprint(b.Get())), nil 127 | } 128 | -------------------------------------------------------------------------------- /lib/others/cgo/ec_bench/sipasec.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: sipasec.go 28 | // Description: Bictoin Cash Cash main Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package main 75 | 76 | import ( 77 | "encoding/hex" 78 | "runtime" 79 | "sync" 80 | "time" 81 | 82 | "github.com/counterpartyxcpc/gocoin-cash/lib/others/cgo/sipasec" 83 | ) 84 | 85 | var CNT int = 100e3 86 | 87 | func main() { 88 | key, _ := hex.DecodeString("040eaebcd1df2df853d66ce0e1b0fda07f67d1cabefde98514aad795b86a6ea66dbeb26b67d7a00e2447baeccc8a4cef7cd3cad67376ac1c5785aeebb4f6441c16") 89 | sig, _ := hex.DecodeString("3045022100fe00e013c244062847045ae7eb73b03fca583e9aa5dbd030a8fd1c6dfcf11b1002207d0d04fed8fa1e93007468d5a9e134b0a7023b6d31db4e50942d43a250f4d07c01") 90 | msg, _ := hex.DecodeString("3382219555ddbb5b00e0090f469e590ba1eae03c7f28ab937de330aa60294ed6") 91 | var wg sync.WaitGroup 92 | max_routines := make(chan bool, 2*runtime.NumCPU()) 93 | println("Number of threads:", cap(max_routines)) 94 | sta := time.Now() 95 | for i := 0; i < CNT; i++ { 96 | wg.Add(1) 97 | max_routines <- true 98 | go func() { 99 | if sipasec.EC_Verify(key, sig, msg) != 1 { 100 | println("Verify error") 101 | return 102 | } 103 | wg.Done() 104 | <-max_routines 105 | }() 106 | } 107 | wg.Wait() 108 | sto := time.Now() 109 | println((sto.UnixNano()-sta.UnixNano())/int64(CNT*1000), "us per ECDSA_Verify") 110 | } 111 | -------------------------------------------------------------------------------- /lib/others/qdb/os_membinds/membind_linux.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: membind_linux.go 28 | // Description: Bictoin Cash Cash qdb Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | // +build linux 75 | 76 | /* 77 | If this file does not build and you don't know what to do, simply delete it and rebuild. 78 | */ 79 | 80 | package qdb 81 | 82 | /* 83 | #include 84 | #include 85 | 86 | static void *alloc_ptr(void *c, unsigned long l) { 87 | void *ptr = malloc(l); 88 | memcpy(ptr, c, l); 89 | return ptr; 90 | } 91 | 92 | static void *my_alloc(unsigned long l) { 93 | return malloc(l); 94 | } 95 | 96 | */ 97 | import "C" 98 | 99 | import ( 100 | "unsafe" 101 | ) 102 | 103 | func gcc_HeapAlloc(le uint32) data_ptr_t { 104 | return data_ptr_t(C.my_alloc(C.ulong(le))) 105 | } 106 | 107 | func gcc_HeapFree(ptr data_ptr_t) { 108 | C.free(unsafe.Pointer(ptr)) 109 | } 110 | 111 | func gcc_AllocPtr(v []byte) data_ptr_t { 112 | ptr := unsafe.Pointer(&v[0]) // see https://github.com/golang/go/issues/15172 113 | return data_ptr_t(C.alloc_ptr(ptr, C.ulong(len(v)))) 114 | } 115 | 116 | func init() { 117 | if membind_use_wrapper { 118 | panic("Another wrapper already initialized") 119 | } 120 | println("Using malloc() qdb memory bindings") 121 | _heap_alloc = gcc_HeapAlloc 122 | _heap_free = gcc_HeapFree 123 | _heap_store = gcc_AllocPtr 124 | membind_use_wrapper = true 125 | } 126 | -------------------------------------------------------------------------------- /website/gocoin_manual_wallet.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |

Setup wallet

7 | Run wallet -h to see all available command line switches. 8 |
9 | 10 |

Setup your seed

11 | Wallet is deterministic and the only thing you need to set it up is the seed password.
12 | As long as you remember the password, you do not need to backup the wallet ever.
13 | You can either enter this password each time when running the wallet, or you can store it in a file called .secret and never be asked to enter it again.
14 |
15 | 16 | You do not need to use a memorable password. Instead you can create a random secret seed, e.g. using a command like this:
17 |     cat /dev/urandom | tr -cd a-zA-Z0-9 | head -c 27 > .secret
18 | Note: using a password that you cannot memorize, make sure to have a backup of your .secret file. 19 |
20 |
21 |

Export public addresses

22 | After you setup your wallet in a secured environment, you should export its public addresses.
23 |
24 | In order to do this, just run wallet -l and your wallet's public addresses will be written to wallet.txt.
25 |
26 | 27 | 28 |

Security precautions

29 | Make sure that the disk with .secret file is encrypted.
30 |
31 | 32 | The seed password is the key to your entire wallet and the function used to calculate it is double SHA256, which is pretty easy to compute.
33 | That is why it is very important for you to make sure that the password you're choosing will be resistant to brute force and dictionary attacks.
34 |
35 | If you choose to use a memorable seed-password (aka brain wallet), 36 | make it at least 20 characters long, preferably more than 30. 37 | Use both cases of letters, digits and sepcial characters. 38 | Try to avoid using words that can be found in a dictionary and never use sentences that can be found in Google.
39 |
40 | If you decide to write down the password, because you are affraid of forgetting it, 41 | try to describe it as a puzzle that ony you can understad. Avoid writing down the password as is.
42 |
43 | 44 | Are brain wallets less secure from those based on a random number generator?
45 | It is debatable.
46 | There are people claiming that brain wallets aren't secure because brains cannot possibly be a good source of entropy.
47 | If you have such a brain, make sure to consider this risk (e.g. use a random generator to create the content of the .secret file).
48 | Otherwise coming out with a memorable though uncrackable seed, gives you a more secure and very convenient solution, 49 | because you get rid of backups that are a week point of the wallet's security and you never have to carry the wallet file with you.
50 |
51 | 52 |

Importing other private keys

53 | You can import keys from your existing bitcoin wallet, as well as keys generated by other tools (all kind of key/address generators).
54 |
55 | 56 | The key that you want to import must be in base58 encoded format, which looks somehow like 5KJvsngHeMpm884wtkJNzQGaCErckhHJBGFsvd3VyK5qMZXj3hS. To export a private key from the official bitcoin wallet use dumprivkey RPC command. To import such a key into your Gocoin wallet, just store the base58 encoded value in a text file named .others (each key must be in a separate line). You can also place a key's label in each line, after a space.
57 |
58 | 59 | The imported keys will extend the key pool of the deterministic ones (that come from your password-seed). After Importing each new key, you should redo wallet -l to get an updated wallet.txt for your client. 60 | 61 |
62 | 63 |
64 | 65 |
66 | 67 |

Optional: setup your node with the wallet file

68 | Having wallet.txt file generated at the wallet machine, use Wallet page of WebUI and store the content of 69 | this file as a wallet in your browser. You can choose any name you want and you can change labels for the addresses. 70 | 71 | -------------------------------------------------------------------------------- /lib/others/sys/hidepass_unix.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: hidepass_unix.go 28 | // Description: Bictoin Cash Cash sys Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | // +build !windows 75 | 76 | package sys 77 | 78 | import ( 79 | "fmt" 80 | "os" 81 | "os/signal" 82 | "syscall" 83 | ) 84 | 85 | var wsta syscall.WaitStatus = 0 86 | 87 | func enterpassext(b []byte) (n int) { 88 | si := make(chan os.Signal, 10) 89 | br := make(chan bool) 90 | fd := []uintptr{os.Stdout.Fd()} 91 | 92 | signal.Notify(si, syscall.SIGHUP, syscall.SIGINT, syscall.SIGKILL, syscall.SIGQUIT, syscall.SIGTERM) 93 | go sighndl(fd, si, br) 94 | 95 | pid, er := syscall.ForkExec("/bin/stty", []string{"stty", "-echo"}, &syscall.ProcAttr{Dir: "", Files: fd}) 96 | if er == nil { 97 | syscall.Wait4(pid, &wsta, 0, nil) 98 | n = getline(b) 99 | close(br) 100 | echo(fd) 101 | fmt.Println() 102 | } else { 103 | n = getline(b) 104 | } 105 | 106 | return 107 | } 108 | 109 | func echo(fd []uintptr) { 110 | pid, e := syscall.ForkExec("/bin/stty", []string{"stty", "echo"}, &syscall.ProcAttr{Dir: "", Files: fd}) 111 | if e == nil { 112 | syscall.Wait4(pid, &wsta, 0, nil) 113 | } 114 | } 115 | 116 | func sighndl(fd []uintptr, signal chan os.Signal, br chan bool) { 117 | select { 118 | case <-signal: 119 | echo(fd) 120 | os.Exit(-1) 121 | case <-br: 122 | } 123 | } 124 | 125 | func init() { 126 | secrespass = enterpassext 127 | } 128 | -------------------------------------------------------------------------------- /lib/others/qdb/os_membinds/membind_windows.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: membind_windows.go 28 | // Description: Bictoin Cash Cash qdb Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | // +build windows 75 | 76 | package qdb 77 | 78 | import ( 79 | "reflect" 80 | "syscall" 81 | "unsafe" 82 | ) 83 | 84 | var ( 85 | funcGlobalAlloc *syscall.Proc 86 | funcGlobalFree *syscall.Proc 87 | ) 88 | 89 | func win_HeapAlloc(le uint32) data_ptr_t { 90 | ptr, _, _ := funcGlobalAlloc.Call(0, uintptr(le)) 91 | return data_ptr_t(ptr) 92 | } 93 | 94 | func win_HeapFree(ptr data_ptr_t) { 95 | funcGlobalFree.Call(uintptr(ptr)) 96 | } 97 | 98 | func win_AllocPtr(v []byte) data_ptr_t { 99 | ptr := win_HeapAlloc(uint32(len(v))) 100 | sl := *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{Data: uintptr(ptr), Len: int(len(v)), Cap: int(len(v))})) 101 | copy(sl, v) 102 | return ptr 103 | } 104 | 105 | func init() { 106 | if membind_use_wrapper { 107 | return 108 | } 109 | dll, er := syscall.LoadDLL("kernel32.dll") 110 | if er != nil { 111 | return 112 | } 113 | funcGlobalAlloc, _ = dll.FindProc("GlobalAlloc") 114 | funcGlobalFree, _ = dll.FindProc("GlobalFree") 115 | if funcGlobalAlloc == nil || funcGlobalFree == nil { 116 | return 117 | } 118 | println("Using kernel32.dll for qdb memory bindings") 119 | _heap_alloc = win_HeapAlloc 120 | _heap_free = win_HeapFree 121 | _heap_store = win_AllocPtr 122 | membind_use_wrapper = true 123 | } 124 | -------------------------------------------------------------------------------- /client/rpcapi/address.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: address.go 28 | // Description: Bictoin Cash rpcapi Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package rpcapi 75 | 76 | import ( 77 | "encoding/hex" 78 | 79 | bch "github.com/counterpartyxcpc/gocoin-cash/lib/bch" 80 | //"github.com/counterpartyxcpc/gocoin-cash/client/common" 81 | ) 82 | 83 | /* 84 | 85 | {"result": 86 | {"isvalid":true, 87 | "address":"mqzwxBkSH1UKqEAjGwvkj6aV5Gc6BtBCSs", 88 | "scriptPubKey":"76a91472fc9e6b1bbbd40a66653989a758098bfbf1b54788ac", 89 | "ismine":false, 90 | "iswatchonly":false, 91 | "isscript":false 92 | } 93 | */ 94 | 95 | type ValidAddressResponse struct { 96 | IsValid bool `json:"isvalid"` 97 | Address string `json:"address"` 98 | ScriptPubKey string `json:"scriptPubKey"` 99 | IsMine bool `json:"ismine"` 100 | IsWatchOnly bool `json:"iswatchonly"` 101 | IsScript bool `json:"isscript"` 102 | } 103 | 104 | type InvalidAddressResponse struct { 105 | IsValid bool `json:"isvalid"` 106 | } 107 | 108 | func ValidateAddress(addr string) interface{} { 109 | a, e := bch.NewAddrFromString(addr) 110 | if e != nil { 111 | return new(InvalidAddressResponse) 112 | } 113 | res := new(ValidAddressResponse) 114 | res.IsValid = true 115 | res.Address = addr 116 | res.ScriptPubKey = hex.EncodeToString(a.OutScript()) 117 | return res 118 | //res.IsMine = false 119 | //res.IsWatchOnly = false 120 | //res.IsScript = false 121 | } 122 | -------------------------------------------------------------------------------- /lib/bch/hash.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: hash.go 28 | // Description: Bictoin Cash Hash Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package bch 75 | 76 | import ( 77 | "bytes" 78 | "crypto/sha256" 79 | "golang.org/x/crypto/ripemd160" 80 | ) 81 | 82 | func ShaHash(b []byte, out []byte) { 83 | s := sha256.New() 84 | s.Write(b[:]) 85 | tmp := s.Sum(nil) 86 | s.Reset() 87 | s.Write(tmp) 88 | copy(out[:], s.Sum(nil)) 89 | } 90 | 91 | // Returns hash: SHA256( SHA256( data ) ) 92 | // Where possible, using ShaHash() should be a bit faster 93 | func Sha2Sum(b []byte) (out [32]byte) { 94 | ShaHash(b, out[:]) 95 | return 96 | } 97 | 98 | func RimpHash(in []byte, out []byte) { 99 | sha := sha256.New() 100 | sha.Write(in) 101 | rim := ripemd160.New() 102 | rim.Write(sha.Sum(nil)[:]) 103 | copy(out, rim.Sum(nil)) 104 | } 105 | 106 | // Returns hash: RIMP160( SHA256( data ) ) 107 | // Where possible, using RimpHash() should be a bit faster 108 | func Rimp160AfterSha256(b []byte) (out [20]byte) { 109 | RimpHash(b, out[:]) 110 | return 111 | } 112 | 113 | // This function is used to sign and verify messages using the bitcoin standard. 114 | // The second paramater must point to a 32-bytes buffer, where hash will be stored. 115 | func HashFromMessage(msg []byte, out []byte) { 116 | b := new(bytes.Buffer) 117 | WriteVlen(b, uint64(len(MessageMagic))) 118 | b.Write([]byte(MessageMagic)) 119 | WriteVlen(b, uint64(len(msg))) 120 | b.Write(msg) 121 | ShaHash(b.Bytes(), out) 122 | } 123 | -------------------------------------------------------------------------------- /lib/bch/ecdsa.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: ecdsa.go 28 | // Description: Bictoin Cash ECDSA Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package bch 75 | 76 | import ( 77 | "crypto/rand" 78 | "crypto/sha256" 79 | "errors" 80 | "math/big" 81 | "sync/atomic" 82 | 83 | "github.com/counterpartyxcpc/gocoin-cash/lib/secp256k1" 84 | ) 85 | 86 | var ( 87 | ecdsaVerifyCnt uint64 88 | EC_Verify func(k, s, h []byte) bool 89 | ) 90 | 91 | func EcdsaVerifyCnt() uint64 { 92 | return atomic.LoadUint64(&ecdsaVerifyCnt) 93 | } 94 | 95 | func EcdsaVerify(kd []byte, sd []byte, hash []byte) bool { 96 | atomic.AddUint64(&ecdsaVerifyCnt, 1) 97 | if len(kd) == 0 || len(sd) == 0 { 98 | return false 99 | } 100 | if EC_Verify != nil { 101 | return EC_Verify(kd, sd, hash) 102 | } 103 | return secp256k1.Verify(kd, sd, hash) 104 | } 105 | 106 | func EcdsaSign(priv, hash []byte) (r, s *big.Int, err error) { 107 | var sig secp256k1.Signature 108 | var sec, msg, nonce secp256k1.Number 109 | 110 | sec.SetBytes(priv) 111 | msg.SetBytes(hash) 112 | 113 | sha := sha256.New() 114 | sha.Write(priv) 115 | sha.Write(hash) 116 | for { 117 | var buf [32]byte 118 | rand.Read(buf[:]) 119 | sha.Write(buf[:]) 120 | nonce.SetBytes(sha.Sum(nil)) 121 | if nonce.Sign() > 0 && nonce.Cmp(&secp256k1.TheCurve.Order.Int) < 0 { 122 | break 123 | } 124 | } 125 | 126 | if sig.Sign(&sec, &msg, &nonce, nil) != 1 { 127 | err = errors.New("ESCDS Sign error()") 128 | } 129 | return &sig.R.Int, &sig.S.Int, nil 130 | } 131 | -------------------------------------------------------------------------------- /lib/others/cgo/sipasec/sipasec_windows.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: sipasec_windows.go 28 | // Description: Bictoin Cash Cash sipasec Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | // +build windows 75 | 76 | package sipasec 77 | 78 | /* 79 | 1. MSYS2 + MinGW64 80 | See the following web pages for info on installing MSYS2 and mingw64 for your Windows OS. 81 | Please note that you will need the 64-bit compiler. 82 | * http://www.msys2.org/ 83 | * https://stackoverflow.com/questions/30069830/how-to-install-mingw-w64-and-msys2#30071634 84 | 85 | 86 | 2. Dependencies 87 | After having MSYS2 and Mingw64 installed, you have to install dependency packages. 88 | Just execute the following command from within the "MSYS2 MSYS" shell: 89 | 90 | > pacman -S make autoconf automake libtoolm lzip 91 | 92 | 93 | 3. gmplib + secp256k1 94 | Now use "MSYS2 MinGW 64-bit" shell and execute: 95 | 96 | > cd ~ 97 | > wget https://gmplib.org/download/gmp/gmp-6.1.2.tar.lz 98 | > tar vxf gmp-6.1.2.tar.lz 99 | > cd gmp-6.1.2 100 | > ./configure 101 | > make 102 | > make install 103 | 104 | > cd ~ 105 | > git clone https://github.com/bitcoin/bitcoin.git 106 | > cd bitcoin/src/secp256k1/ 107 | > ./autogen.sh 108 | > ./configure 109 | > make 110 | > make install 111 | 112 | 113 | 114 | If everything went well, you should see "PASS" executing "go test" in this folder. 115 | Then copy "gocoin/client/speedups/sipasec.go" to "gocoin/client/" to boost your client. 116 | */ 117 | 118 | // #cgo LDFLAGS: -lsecp256k1 -lgmp 119 | import "C" 120 | -------------------------------------------------------------------------------- /lib/bch/key.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: key.go 28 | // Description: Bictoin Cash Key Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package bch 75 | 76 | import ( 77 | "encoding/hex" 78 | "errors" 79 | 80 | "github.com/counterpartyxcpc/gocoin-cash/lib/secp256k1" 81 | ) 82 | 83 | type PublicKey struct { 84 | secp256k1.XY 85 | } 86 | 87 | type Signature struct { 88 | secp256k1.Signature 89 | HashType byte 90 | } 91 | 92 | func NewPublicKey(buf []byte) (res *PublicKey, e error) { 93 | res = new(PublicKey) 94 | if !res.XY.ParsePubkey(buf) { 95 | e = errors.New("NewPublicKey: Unknown format: " + hex.EncodeToString(buf[:])) 96 | res = nil 97 | } 98 | return 99 | } 100 | 101 | func NewSignature(buf []byte) (*Signature, error) { 102 | sig := new(Signature) 103 | le := sig.ParseBytes(buf) 104 | if le < 0 { 105 | return nil, errors.New("NewSignature: ParseBytes error") 106 | } 107 | if le < len(buf) { 108 | sig.HashType = buf[len(buf)-1] 109 | } 110 | return sig, nil 111 | } 112 | 113 | // Recoved public key form a signature 114 | func (sig *Signature) RecoverPublicKey(msg []byte, recid int) (key *PublicKey) { 115 | key = new(PublicKey) 116 | if !secp256k1.RecoverPublicKey(sig.R.Bytes(), sig.S.Bytes(), msg, recid, &key.XY) { 117 | key = nil 118 | } 119 | return 120 | } 121 | 122 | func (sig *Signature) IsLowS() bool { 123 | return sig.S.Cmp(&secp256k1.TheCurve.HalfOrder.Int) < 1 124 | } 125 | 126 | // Returns serialized canoncal signature followed by a hash type 127 | func (sig *Signature) Bytes() []byte { 128 | return append(sig.Signature.Bytes(), sig.HashType) 129 | } 130 | -------------------------------------------------------------------------------- /lib/bch/target_test.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: target_test.go 28 | // Description: Bictoin Cash Target Package Testing 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package bch 75 | 76 | import ( 77 | // "fmt" 78 | "math" 79 | "math/big" 80 | "testing" 81 | ) 82 | 83 | type onevec struct { 84 | b uint32 85 | e string 86 | d float64 87 | } 88 | 89 | var testvecs = []onevec{ 90 | {b: 0x1b0404cb, e: "00000000000404CB000000000000000000000000000000000000000000000000"}, 91 | {b: 0x1d00ffff, e: "00000000FFFF0000000000000000000000000000000000000000000000000000"}, 92 | {b: 436330132, d: 8974296.01488785}, 93 | {b: 436543292, d: 3275464.59}, 94 | {b: 436591499, d: 2864140.51}, 95 | {b: 436841986, d: 1733207.51}, 96 | {b: 437155514, d: 1159929.50}, 97 | {b: 436789733, d: 1888786.71}, 98 | {b: 453031340, d: 92347.59}, 99 | {b: 453281356, d: 14484.16}, 100 | {b: 470771548, d: 16.62}, 101 | {b: 486604799, d: 1.00}, 102 | } 103 | 104 | func TestTarget(t *testing.T) { 105 | for i := range testvecs { 106 | x := SetCompact(testvecs[i].b) 107 | d := GetDifficulty(testvecs[i].b) 108 | 109 | c := GetCompact(x) 110 | //fmt.Printf("%d. %d/%d -> %.8f / %.8f\n", i, testvecs[i].b, c, d, testvecs[i].d) 111 | if testvecs[i].b != c { 112 | t.Error("Set/GetCompact mismatch at alement", i) 113 | } 114 | 115 | if testvecs[i].e != "" { 116 | y, _ := new(big.Int).SetString(testvecs[i].e, 16) 117 | if x.Cmp(y) != 0 { 118 | t.Error("Target mismatch at alement", i) 119 | } 120 | } 121 | 122 | if testvecs[i].d != 0 && math.Abs(d-testvecs[i].d) > 0.1 { 123 | t.Error("Difficulty mismatch at alement", i) 124 | } 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /lib/others/bech32/bech32_test.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: bech32_test.go 28 | // Description: Bictoin Cash bech32 Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package bech32 75 | 76 | import ( 77 | "strings" 78 | "testing" 79 | ) 80 | 81 | var ( 82 | valid_checksum = []string{ 83 | "A12UEL5L", 84 | "an83characterlonghumanreadablepartthatcontainsthenumber1andtheexcludedcharactersbio1tt5tgs", 85 | "abcdef1qpzry9x8gf2tvdw0s3jn54khce6mua7lmqqqxw", 86 | "11qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqc8247j", 87 | "split1checkupstagehandshakeupstreamerranterredcaperred2y9e3w"} 88 | 89 | invalid_checksum = []string{ 90 | " 1nwldj5", 91 | "\x7f1axkwrx", 92 | "an84characterslonghumanreadablepartthatcontainsthenumber1andtheexcludedcharactersbio1569pvx", 93 | "pzry9x0s0muk", 94 | "1pzry9x0s0muk", 95 | "x1b4n0q5v", 96 | "li1dgmt3", 97 | "de1lg7wt\xff"} 98 | ) 99 | 100 | func TestValidChecksum(t *testing.T) { 101 | for _, s := range valid_checksum { 102 | hrp, data := Decode(s) 103 | if data == nil || hrp == "" { 104 | t.Error("Decode fails: ", s) 105 | } else { 106 | rebuild := Encode(hrp, data) 107 | if rebuild == "" { 108 | t.Error("Encode fails: ", s) 109 | } else { 110 | if !strings.EqualFold(s, rebuild) { 111 | t.Error("Encode produces incorrect result: ", s) 112 | } 113 | } 114 | } 115 | } 116 | } 117 | 118 | func TestInvalidChecksum(t *testing.T) { 119 | for _, s := range invalid_checksum { 120 | hrp, data := Decode(s) 121 | if data != nil || hrp != "" { 122 | t.Error("Decode succeeds on invalid string: ", s) 123 | } 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # About Gocoin-cash 2 | 3 | **Gocoin-cash** is a full **Bitcoin Cash** (https://www.bitcoincash.org) solution written in Go language ([Golang](http://golang.org)) and is based on 4 | the original work of of Gocoin (https://github.com/piotrnar/gocoin) by Piotr Narewski. 5 | 6 | The software architecture is focused on maximum performance of the node and cold storage security of the wallet. 7 | 8 | **Bitcoin Cash (BCH) Client** 9 | 10 | The BCH client (p2p node) is an application independent from the wallet. 11 | 12 | It keeps the entire BCH UTXO set in RAM, providing the best block processing performance on the market. 13 | 14 | In it's original form, With a decent machine and a fast connection (e.g. 4 vCPUs from Google Cloud or 15 | Amazon AWS), the node would sync the entire bitcoin block chain in less than 4 hours (as of chain 16 | height ~512000) for the Bitcoin core (BTC) chain. 17 | 18 | Benchmarks for the Bitcoin BCH chain are to follow. 19 | 20 | ** Bitcoin Cash Wallet / Merchant and XCPC Trading API ** 21 | 22 | The wallet is designed to be used offline. It is deterministic and password seeded. 23 | As long as you remember the password, you do not need any backups ever. 24 | 25 | # Requirements 26 | 27 | ## Hardware 28 | 29 | **Client**: 30 | 31 | * 64-bit architecture OS and Go compiler. 32 | * File system supporting files larger than 4GB. 33 | * At least 15GB of system memory (RAM). 34 | 35 | **Wallet**: 36 | 37 | * Any platform that you can make your Go (cross)compiler to build for (Raspberry Pi works). 38 | * For security reasons make sure to use encrypted swap file (if there is a swap file). 39 | * If you decide to store your password in a file, have the disk encrypted (in case it gets stolen). 40 | 41 | ## Operating System 42 | Having hardware requirements met, any target OS supported by your Go compiler will do. 43 | Currently that can be at least one of the following: 44 | 45 | * Windows 46 | * Linux 47 | * OS X 48 | * Free BSD 49 | 50 | ## Build environment 51 | In order to build Gocoin-cash yourself, you will need the following tools installed in your system: 52 | 53 | * **Go** (version 1.8 or higher) - http://golang.org/doc/install 54 | * **Git** - http://git-scm.com/downloads 55 | 56 | If the tools mentioned above are all properly installed, you should be able to execute `go` and `git` 57 | from your OS's command prompt without a need to specify full path to the executables. 58 | 59 | ### Linux 60 | 61 | When building for Linux make sure to have `gcc` installed or delete file `lib/utxo/membind_linux.go` 62 | 63 | # Getting sources 64 | 65 | Use `go get` to fetch and install the source code files. 66 | Note that source files get installed within your GOPATH folder. 67 | 68 | go get github.com/counterpartyxcpc/gocoin-cash 69 | 70 | # Building 71 | 72 | ## Client node 73 | Go to the `cd $GOPATH/src/github.com/counterpartyxcpc/gocoin-cash/client/` folder and execute `go build` there. 74 | 75 | ## Wallet 76 | Go to the `cd $GOPATH/src/github.com/counterpartyxcpc/gocoin-cash/wallet/` folder and execute `go build` there. 77 | 78 | ## Tools 79 | Go to the `tools/` folder and execute: 80 | 81 | go build 82 | example: go build btcversig.go 83 | 84 | Repeat the `go build` for each source file of the tool you want to build. 85 | 86 | # Binaries 87 | 88 | Windows or Linux (amd64) binaries can be downloaded from 89 | 90 | (T.B.A) @todo, No binaries yet released (Oct 3, 2018) 91 | 92 | Please note that the binaries are usually not up to date. 93 | We strongly encourage everyone to build the binaries. 94 | 95 | # Development 96 | 97 | Although it is an open source project, we will accept merge and any pull requests, however we need to 98 | have contributors assign copyright to the CCA so we may continue to operate within the bounds of our 99 | limited software license agreement to the original project. The reason is that Piotr Narewsk retains 100 | certain rights as the original author of this software and excersises an interest and control over its 101 | licensing. The CCA accepts these terms without issue and supports the author's rights in this regard. 102 | 103 | # Support 104 | 105 | The official web page of the project is served at Gocoin-cash.com 106 | where you can find extended documentation, including a **User Manual**. 107 | 108 | Please log github issues here when you have questions concerning this software. 109 | -------------------------------------------------------------------------------- /lib/bch_utxo/membind_windows.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: membind_windows.go 28 | // Description: Bictoin Cash utxo Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package utxo 75 | 76 | import ( 77 | "fmt" 78 | "reflect" 79 | "sync/atomic" 80 | "syscall" 81 | "unsafe" 82 | ) 83 | 84 | func init() { 85 | MembindInit = func() { 86 | var ( 87 | hHeap uintptr 88 | funcHeapAllocAddr uintptr 89 | funcHeapFreeAddr uintptr 90 | ) 91 | 92 | dll, er := syscall.LoadDLL("kernel32.dll") 93 | if er != nil { 94 | return 95 | } 96 | fun, _ := dll.FindProc("GetProcessHeap") 97 | hHeap, _, _ = fun.Call() 98 | 99 | fun, _ = dll.FindProc("HeapAlloc") 100 | funcHeapAllocAddr = fun.Addr() 101 | 102 | fun, _ = dll.FindProc("HeapFree") 103 | funcHeapFreeAddr = fun.Addr() 104 | 105 | fmt.Println("Using kernel32.dll heap functions for UTXO records") 106 | malloc = func(le uint32) []byte { 107 | atomic.AddInt64(&extraMemoryConsumed, int64(le)+24) 108 | atomic.AddInt64(&extraMemoryAllocCnt, 1) 109 | ptr, _, _ := syscall.Syscall(funcHeapAllocAddr, 3, hHeap, 0, uintptr(le+24)) 110 | *(*reflect.SliceHeader)(unsafe.Pointer(ptr)) = reflect.SliceHeader{Data: ptr + 24, Len: int(le), Cap: int(le)} 111 | return *(*[]byte)(unsafe.Pointer(ptr)) 112 | } 113 | 114 | free = func(ptr []byte) { 115 | atomic.AddInt64(&extraMemoryConsumed, -int64(len(ptr)+24)) 116 | atomic.AddInt64(&extraMemoryAllocCnt, -1) 117 | syscall.Syscall(funcHeapFreeAddr, 3, hHeap, 0, uintptr(unsafe.Pointer(&ptr[0]))-24) 118 | } 119 | 120 | malloc_and_copy = func(v []byte) []byte { 121 | ptr := malloc(uint32(len(v))) 122 | copy(ptr, v) 123 | return ptr 124 | } 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /client/speedups/sipadll.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: sipadll.go 28 | // Description: Bictoin Cash main Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package main 75 | 76 | /* 77 | This is a EC_Verify speedup that works only with Windows 78 | 79 | Use secp256k1.dll from gocoin/tools/sipa_dll 80 | or build one yourself. 81 | 82 | */ 83 | 84 | import ( 85 | "encoding/hex" 86 | "os" 87 | "syscall" 88 | "unsafe" 89 | 90 | "github.com/counterpartyxcpc/gocoin-cash/client/common" 91 | bch "github.com/counterpartyxcpc/gocoin-cash/lib/bch" 92 | ) 93 | 94 | var ( 95 | dll = syscall.NewLazyDLL("secp256k1.dll") 96 | DLL_EC_Verify = dll.NewProc("EC_Verify") 97 | ) 98 | 99 | func EC_Verify(pkey, sign, hash []byte) bool { 100 | r1, _, _ := syscall.Syscall6(DLL_EC_Verify.Addr(), 6, 101 | uintptr(unsafe.Pointer(&hash[0])), uintptr(32), 102 | uintptr(unsafe.Pointer(&sign[0])), uintptr(len(sign)), 103 | uintptr(unsafe.Pointer(&pkey[0])), uintptr(len(pkey))) 104 | return r1 == 1 105 | } 106 | 107 | func verify() bool { 108 | key, _ := hex.DecodeString("020eaebcd1df2df853d66ce0e1b0fda07f67d1cabefde98514aad795b86a6ea66d") 109 | sig, _ := hex.DecodeString("3045022100fe00e013c244062847045ae7eb73b03fca583e9aa5dbd030a8fd1c6dfcf11b1002207d0d04fed8fa1e93007468d5a9e134b0a7023b6d31db4e50942d43a250f4d07c01") 110 | has, _ := hex.DecodeString("3382219555ddbb5b00e0090f469e590ba1eae03c7f28ab937de330aa60294ed6") 111 | return EC_Verify(key, sig, has) 112 | } 113 | 114 | func init() { 115 | if verify() { 116 | common.Log.Println("Using secp256k1.dll by sipa for EC_Verify") 117 | bch.EC_Verify = EC_Verify 118 | } else { 119 | common.Log.Println("ERROR: Could not initiate secp256k1.dll") 120 | os.Exit(1) 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /lib/bch_utxo/unspent_test.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: unspent_test.go 28 | // Description: Bictoin Cash utxo Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package utxo 75 | 76 | import ( 77 | "encoding/hex" 78 | "testing" 79 | ) 80 | 81 | const ( 82 | UtxoRecord = "B26B877AF9D16E5F634C4997A8393C9496BAA14C34D73829767723D96D4AE368FE19AC0700060100166A146F6D6E69000000000000001F0000008B3B93DC0002FD22021976A914A25DEC4D0011064EF106A983C39C7A540699F22088AC" 83 | //UtxoRecord = "875207AE844E25A60BB57C7E68FDEA8C3BD04FBF678866EF3E7E9FDD408B9E98FEF07A06000401FD60EA17A914379238E99325F2BD2D1F773B8D95CFB9EA92C31887" 84 | ) 85 | 86 | func BenchmarkFullUtxoRec(b *testing.B) { 87 | raw, _ := hex.DecodeString(UtxoRecord) 88 | b.ResetTimer() 89 | for i := 0; i < b.N; i++ { 90 | if FullUtxoRec(raw) == nil { 91 | b.Fatal("Nil pointer returned") 92 | } 93 | } 94 | } 95 | 96 | func BenchmarkNewUtxoRec(b *testing.B) { 97 | raw, _ := hex.DecodeString(UtxoRecord) 98 | var key UtxoKeyType 99 | copy(key[:], raw[:]) 100 | dat := raw[UtxoIdxLen:] 101 | b.ResetTimer() 102 | for i := 0; i < b.N; i++ { 103 | if NewUtxoRec(key, dat) == nil { 104 | b.Fatal("Nil pointer returned") 105 | } 106 | } 107 | } 108 | 109 | func BenchmarkNewUtxoRecStatic(b *testing.B) { 110 | raw, _ := hex.DecodeString(UtxoRecord) 111 | var key UtxoKeyType 112 | copy(key[:], raw[:]) 113 | dat := raw[UtxoIdxLen:] 114 | b.ResetTimer() 115 | for i := 0; i < b.N; i++ { 116 | if NewUtxoRec(key, dat) == nil { 117 | b.Fatal("Nil pointer returned") 118 | } 119 | } 120 | } 121 | 122 | func TestMembinds(t *testing.T) { 123 | MembindInit() 124 | ptr := malloc(0x100000) 125 | for i := range ptr { 126 | ptr[i] = byte(i) 127 | } 128 | free(ptr) 129 | } 130 | -------------------------------------------------------------------------------- /lib/bch/unspent.go: -------------------------------------------------------------------------------- 1 | // ====================================================================== 2 | 3 | // cccccccccc pppppppppp 4 | // cccccccccccccc pppppppppppppp 5 | // ccccccccccccccc ppppppppppppppppppp 6 | // cccccc cc ppppppp pppppp 7 | // cccccc pppppppp pppppp 8 | // cccccc ccccpppp pppppp 9 | // cccccccc cccccccc pppp ppppppp 10 | // ccccccccccccccccc ppppppppppppppp 11 | // cccccccccccc pppppppppppppp 12 | // cccccccc pppppppppppp 13 | // pppppp 14 | // pppppp 15 | 16 | // ====================================================================== 17 | // Copyright © 2018. Counterparty Cash Association (CCA) Zug, CH. 18 | // All Rights Reserved. All work owned by CCA is herby released 19 | // under Creative Commons Zero (0) License. 20 | 21 | // Some rights of 3rd party, derivative and included works remain the 22 | // property of thier respective owners. All marks, brands and logos of 23 | // member groups remain the exclusive property of their owners and no 24 | // right or endorsement is conferred by reference to thier organization 25 | // or brand(s) by CCA. 26 | 27 | // File: unspent.go 28 | // Description: Bictoin Cash Cash Unspent Transaction Package 29 | 30 | // Credits: 31 | 32 | // Piotr Narewski, Gocoin Founder 33 | 34 | // Julian Smith, Direction + Development 35 | // Arsen Yeremin, Development 36 | // Sumanth Kumar, Development 37 | // Clayton Wong, Development 38 | // Liming Jiang, Development 39 | 40 | // Includes reference work of btsuite: 41 | 42 | // Copyright (c) 2013-2017 The btcsuite developers 43 | // Copyright (c) 2018 The bcext developers 44 | // Use of this source code is governed by an ISC 45 | // license that can be found in the LICENSE file. 46 | 47 | // Credits: 48 | 49 | // Piotr Narewski, Gocoin Founder 50 | 51 | // Julian Smith, Direction + Development 52 | // Arsen Yeremin, Development 53 | // Sumanth Kumar, Development 54 | // Clayton Wong, Development 55 | // Liming Jiang, Development 56 | 57 | // Includes reference work of btsuite: 58 | 59 | // Copyright (c) 2013-2017 The btcsuite developers 60 | // Copyright (c) 2018 The bcext developers 61 | // Use of this source code is governed by an ISC 62 | // license that can be found in the LICENSE file. 63 | 64 | // Includes reference work of Bitcoin Core (https://github.com/bitcoin/bitcoin) 65 | // Includes reference work of Bitcoin-ABC (https://github.com/Bitcoin-ABC/bitcoin-abc) 66 | // Includes reference work of Bitcoin Unlimited (https://github.com/BitcoinUnlimited/BitcoinUnlimited/tree/BitcoinCash) 67 | // Includes reference work of gcash by Shuai Qi "qshuai" (https://github.com/bcext/gcash) 68 | // Includes reference work of gcash (https://github.com/gcash/bchd) 69 | 70 | // + Other contributors 71 | 72 | // ===================================================================== 73 | 74 | package bch 75 | 76 | import ( 77 | "encoding/binary" 78 | "fmt" 79 | ) 80 | 81 | type AllUnspentTx []*OneUnspentTx 82 | 83 | // Returned by GetUnspentFromPkScr 84 | type OneUnspentTx struct { 85 | TxPrevOut 86 | Value uint64 87 | MinedAt uint32 88 | *BtcAddr 89 | destAddr string 90 | } 91 | 92 | func (x AllUnspentTx) Len() int { 93 | return len(x) 94 | } 95 | 96 | func (x AllUnspentTx) Less(i, j int) bool { 97 | if x[i].MinedAt == x[j].MinedAt { 98 | if x[i].TxPrevOut.Hash == x[j].TxPrevOut.Hash { 99 | return x[i].TxPrevOut.Vout < x[j].TxPrevOut.Vout 100 | } 101 | return binary.LittleEndian.Uint64(x[i].TxPrevOut.Hash[24:32]) < 102 | binary.LittleEndian.Uint64(x[j].TxPrevOut.Hash[24:32]) 103 | } 104 | return x[i].MinedAt < x[j].MinedAt 105 | } 106 | 107 | func (x AllUnspentTx) Swap(i, j int) { 108 | x[i], x[j] = x[j], x[i] 109 | } 110 | 111 | func (ou *OneUnspentTx) String() (s string) { 112 | s = fmt.Sprintf("%15.8f ", float64(ou.Value)/1e8) + ou.TxPrevOut.String() 113 | if ou.BtcAddr != nil { 114 | s += " " + ou.DestAddr() + ou.BtcAddr.Label() 115 | } 116 | if ou.MinedAt != 0 { 117 | s += fmt.Sprint(" ", ou.MinedAt) 118 | } 119 | return 120 | } 121 | 122 | func (ou *OneUnspentTx) UnspentTextLine() (s string) { 123 | s = fmt.Sprintf("%s # %.8f BCH @ %s%s, block %d", ou.TxPrevOut.String(), 124 | float64(ou.Value)/1e8, ou.DestAddr(), ou.BtcAddr.Label(), ou.MinedAt) 125 | return 126 | } 127 | 128 | func (ou *OneUnspentTx) DestAddr() string { 129 | if ou.destAddr == "" { 130 | return ou.BtcAddr.String() 131 | } 132 | return ou.destAddr 133 | } 134 | --------------------------------------------------------------------------------