Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Konstantinos Nitsopoulos authored Oct 9, 2021
1 parent f530fd1 commit 2704be1
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 24 deletions.
Binary file modified VanityTXID-Plugin.zip
Binary file not shown.
42 changes: 25 additions & 17 deletions VanityTXID/qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from PyQt5.QtWidgets import QDialog, QVBoxLayout, QHBoxLayout, QLineEdit, QLabel, QPlainTextEdit, QPushButton
from electroncash.i18n import _
from electroncash.plugins import BasePlugin, hook
import electroncash, subprocess, multiprocessing, threading, zipfile, shutil
import electroncash, subprocess, multiprocessing, threading, zipfile, shutil, os
from electroncash import bitcoin

class Plugin(BasePlugin):
Expand All @@ -15,18 +15,19 @@ def __init__(self, parent, config, name):
def on_close(self):
"""BasePlugin callback called when the wallet is disabled among other things."""
for window in list(self.wallet_windows.values()): self.close_wallet(window.wallet)
shutil.rmtree(self.parent.get_external_plugin_dir()+'\\VanityTXID')
shutil.rmtree(self.parent.get_external_plugin_dir()+'/VanityTXID')
@hook
def init_qt(self, qt_gui):
"""Hook called when a plugin is loaded (or enabled)."""
# We get this multiple times. Only handle it once, if unhandled.
if len(self.wallet_windows):
return
Dir=self.parent.get_external_plugin_dir()
Zip=zipfile.ZipFile(Dir+'\\VanityTXID-Plugin.zip')
Zip=zipfile.ZipFile(Dir+'/VanityTXID-Plugin.zip')
for Item in Zip.namelist():
if 'bin' in Item: Zip.extract(Item,Dir+'\\VanityTXID')
if 'bin' in Item: Zip.extract(Item,Dir+'/VanityTXID')
Zip.close()
if os.name is not 'nt': subprocess.Popen(['chmod','+x',Dir+'/VanityTXID/bin/VanityTXID-Plugin'])
# These are per-wallet windows.
for window in qt_gui.windows:
self.load_wallet(window.wallet, window)
Expand All @@ -39,10 +40,11 @@ def load_wallet(self, wallet, window):
tab = window.create_list_tab(l)
self.wallet_payment_tabs[wallet_name] = tab
self.wallet_payment_lists[wallet_name] = l
window.tabs.addTab(tab, QIcon(self.parent.get_external_plugin_dir()+"\\VanityTXID\\bin\\Icon.ico"), 'VanityTXID')
window.tabs.addTab(tab, QIcon(self.parent.get_external_plugin_dir()+"/VanityTXID/bin/Icon.ico"), 'VanityTXID')
@hook
def close_wallet(self, wallet):
subprocess.Popen('TaskKill /IM VanityTXID-Plugin.exe /F',creationflags=subprocess.CREATE_NO_WINDOW)
if os.name is 'nt': subprocess.Popen('TaskKill /IM VanityTXID-Plugin.exe /F',creationflags=subprocess.CREATE_NO_WINDOW)
else: subprocess.Popen(['pkill','VanityTXID'])
wallet_name = wallet.basename()
window = self.wallet_windows[wallet_name]
del self.wallet_windows[wallet_name]
Expand All @@ -61,12 +63,12 @@ def __init__(self, window, plugin):
VBox = QVBoxLayout()
self.setLayout(VBox)

Title=QLabel('VanityTXID v1.0.3');
Title=QLabel('VanityTXID v1.1.0');
Title.setAlignment(Qt.AlignCenter)
VBox.addWidget(Title)

AddressesLabel=QLabel(_('VanityTXID Addresses: '))
ConverterLabel=QLabel(_('Address converter: '))
ConverterLabel=QLabel(_('Address Converter: '))
AddressesLabel.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
ConverterLabel.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
VBoxAddressesLabels=QVBoxLayout()
Expand Down Expand Up @@ -192,8 +194,8 @@ def IsHex(String):
if Input['signatures']==[None]:
window.show_transaction(TX) # More sigs needed, return.
return
Pattern=' '+self.Pattern.text()
if Pattern==' ':
Pattern=self.Pattern.text()
if len(Pattern) is 0:
window.show_transaction(TX) #Empty Pattern, return
return

Expand All @@ -207,15 +209,19 @@ def IsHex(String):
Input['scriptSig']=bitcoin.int_to_hex(MessageSize)+Message+'080000000000000000'+SigScript
break
TX=electroncash.Transaction(TX.serialize())
NoncePos=' '+bitcoin.rev_hex(bitcoin.int_to_hex(int(TX.raw.find(SigScript)/2)-8,2))
NoncePos=bitcoin.rev_hex(bitcoin.int_to_hex(int(TX.raw.find(SigScript)/2)-8,2))

Threads=' '+bitcoin.int_to_hex(int(self.Threads.text())-1) #I figure ' 00' means 1 since highest index is specified to C++ binary.
Threads=bitcoin.int_to_hex(int(self.Threads.text())-1) #I figure ' 00' means 1 since highest index is specified to C++ binary.
Dir=self.plugin.parent.get_external_plugin_dir()
Command='"'+Dir+'\\VanityTXID\\bin\\VanityTXID-Plugin.exe"'+Threads+NoncePos+Pattern+' '+TX.raw
Process=subprocess.Popen(Command,stdout=subprocess.PIPE,stderr=subprocess.STDOUT,stdin=subprocess.DEVNULL,creationflags=subprocess.CREATE_NO_WINDOW | subprocess.BELOW_NORMAL_PRIORITY_CLASS)
if os.name is 'nt':
Command='"'+Dir+'/VanityTXID/bin/VanityTXID-Plugin.exe"'+' '+Threads+' '+NoncePos+' '+Pattern+' '+TX.raw
Process=subprocess.Popen(Command,stdout=subprocess.PIPE,stderr=subprocess.STDOUT,stdin=subprocess.DEVNULL,creationflags=subprocess.CREATE_NO_WINDOW | subprocess.BELOW_NORMAL_PRIORITY_CLASS)
else:
Command=[Dir+'/VanityTXID/bin/VanityTXID-Plugin',''+Threads,''+NoncePos,Pattern,TX.raw]
Process=subprocess.Popen(Command,stdout=subprocess.PIPE,stderr=subprocess.STDOUT,stdin=subprocess.DEVNULL)
threading.Thread(target=self.Bin,args=(Process,len(TX.raw))).start()

self.Button.setText('TaskKill')
self.Button.setText('Cancel')
self.Button.clicked.disconnect()
self.Button.clicked.connect(self.Cancel)
def Bin(self,Process,lenTX):
Expand All @@ -226,7 +232,9 @@ def Bin(self,Process,lenTX):
def ShowTX(self):
try: self.window.show_transaction(electroncash.Transaction(self.HiddenBox.toPlainText()))
except: return
def Cancel(self): subprocess.Popen('TaskKill /IM VanityTXID-Plugin.exe /F',creationflags=subprocess.CREATE_NO_WINDOW)
def Cancel(self):
if os.name is 'nt': subprocess.Popen('TaskKill /IM VanityTXID-Plugin.exe /F',creationflags=subprocess.CREATE_NO_WINDOW)
else: subprocess.Popen(['pkill','VanityTXID'])
def AddressGen(self):
wallet=self.window.wallet
for Word in self.Converter.text().split(): #Generate many addresses simultaneously.
Expand Down Expand Up @@ -256,4 +264,4 @@ def FindAddresses(self):
if pAddress.to_cashaddr()==label or pAddress.to_string(pAddress.FMT_LEGACY)==label:
self.AddressLine.insert(label+' ') #List all P2SH addresses.
except: continue


Binary file added bin/VanityTXID-Plugin
Binary file not shown.
Binary file modified bin/VanityTXID-Plugin.exe
Binary file not shown.
Binary file added bin/libgcc_s_dw2-1.dll
Binary file not shown.
Binary file modified bin/libstdc++-6.dll
Binary file not shown.
Binary file modified bin/libwinpthread-1.dll
Binary file not shown.
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"display_name": "VanityTXID",
"version": "1.0.3",
"description": "Generate TX which has ID starting with any choice of hex digits. Currently Windows only. First generate P2SH address which gets imported into a watching-only wallet, from which raw TX hex is copied to the original wallet, to be signed & mined.",
"version": "1.1.0",
"description": "Generate TX which has ID starting with any choice of hex digits. First generate P2SH address which gets imported into a watching-only wallet, from which raw TX hex is copied to the original wallet, to be signed & mined. Linux is faster than Windows, for now. ",
"project_url": "https://github.com/TinosNitso/VanityTXID-Plugin",
"minimum_ec_version": "3.2",
"package_name": "VanityTXID",
Expand Down
2 changes: 1 addition & 1 deletion src/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
The following applies only to the sha256.cpp & sha256.h code used in compiling VanityTXID-Plugin.exe
The following applies only to the sha256.cpp & sha256.h code used in compiling VanityTXID-Plugin executables.
The three .dll libraries are copy-pasted from Code::Blocks and aren't related to this.

/*
Expand Down
9 changes: 5 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <iostream>
#include <sstream>
#include <thread>
#include <unistd.h>
#include "sha256.cpp"

std::string FromHex(std::string Hex){
Expand Down Expand Up @@ -70,13 +71,13 @@ void Hasher(int ThreadN,char **argv) {
char Return[2*String.length()];
for (int i = 0; i < String.length(); i++)
sprintf(Return+2*i, "%02x", (uint8_t) String[i]);
std::cout<<Return<<std::flush;
system("taskkill /IM VanityTXID-Plugin.exe /F >nul 2>&1");
std::cout<<Return;
exit(0);
}
int main(int argc , char **argv){
int Threads=(uint8_t)FromHex(argv[1])[0]+1;
std::thread Thread[Threads];
for (uint8_t ThreadN=0;ThreadN<Threads;ThreadN++){
for (uint8_t ThreadN=0;ThreadN<Threads;ThreadN++)
Thread[ThreadN]=std::thread(Hasher,ThreadN,argv);
} Thread[0].join();
Thread[0].join();
}

0 comments on commit 2704be1

Please sign in to comment.