Patched to allow "./cjdroute --import {privkey} > cjdroute.conf" to gene... #18

Closed
wants to merge 3 commits into
from

Projects

None yet

2 participants

XertroV commented Feb 3, 2012

...rate valid config based on given privkey.

XertroV added some commits Feb 3, 2012
Owner

19:23 @cjd XertroV: re your pull request, it looks ok to me but it doesn't add anything which is important to the
average user.
19:24 @cjd so as it stands, it is adding complexity without a benefit (except to people who want vanity addresses)
19:25 @cjd if you were to include some testing, perhaps a test that "genconf --import" outputs something which can
be parsed in properly
19:27 @cjd if you make the genconf tool write to an arbitrary file (replacing printf with fprintf) and add a test
which uses tmpfile() to get a temporary file, write the config to it, then parse it in with a
FileReader/BencJsonSerializer, then it will provide something for everyone, testing is always good.

@cjdelisle cjdelisle commented on the diff Feb 17, 2012
cjdroute.c
@@ -101,7 +101,48 @@ static int genAddress(uint8_t addressOut[40],
}
}
-static int genconf()
+static int genAddressFromPrivKey(uint8_t addressOut[40],
+ uint8_t privateKeyHexOut[65],
+ uint8_t publicKeyBase32Out[53],
+ char* privateKeyChar)
+{
+ struct Address address;
+ uint8_t privateKey[32];
+ uint8_t chosenPrivateKeyHex[65];
+ for(int i = 0; i < 64; i++){
cjdelisle
cjdelisle Feb 17, 2012 Owner

check Hex_decode() defined in util/Hex.h

@cjdelisle cjdelisle commented on the diff Feb 17, 2012
cjdroute.c
@@ -101,7 +101,48 @@ static int genAddress(uint8_t addressOut[40],
}
}
-static int genconf()
+static int genAddressFromPrivKey(uint8_t addressOut[40],
+ uint8_t privateKeyHexOut[65],
+ uint8_t publicKeyBase32Out[53],
+ char* privateKeyChar)
+{
+ struct Address address;
+ uint8_t privateKey[32];
+ uint8_t chosenPrivateKeyHex[65];
+ for(int i = 0; i < 64; i++){
+ char c = privateKeyChar[i];
+ if (c >= '0' && c <= '9')
cjdelisle
cjdelisle Feb 17, 2012 Owner

all if statements are bracketed

@cjdelisle cjdelisle commented on the diff Feb 17, 2012
cjdroute.c
@@ -113,7 +154,10 @@ static int genconf()
uint8_t publicKeyBase32[53];
uint8_t address[40];
uint8_t privateKeyHex[65];
- genAddress(address, privateKeyHex, publicKeyBase32);
+ if(havePrivKey)
cjdelisle
cjdelisle Feb 17, 2012 Owner

brackets after if statements

@cjdelisle cjdelisle commented on the diff Feb 17, 2012
cjdroute.c
+ uint8_t privateKey[32];
+ uint8_t chosenPrivateKeyHex[65];
+ for(int i = 0; i < 64; i++){
+ char c = privateKeyChar[i];
+ if (c >= '0' && c <= '9'){
+ chosenPrivateKeyHex[i] = atoi(&c);
+ }
+ else{
+ chosenPrivateKeyHex[i] = (int)c-(int)'a'+10;
+ }
+ }
+ printf("\n");
+ //Hex_decode(privateKey, 32, chosenPrivateKeyHex, 64);
+ int high;
+ int low;
+ for (int i = 0; i < 64; i+=2){
cjdelisle
cjdelisle Feb 17, 2012 Owner

4 spaces not 8

Owner

closing as incomplete, feel free to reopen later with patches to the code.

@cjdelisle cjdelisle closed this Mar 2, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment