Pages:
Author

Topic: Command Line and JSON-RPC (Read 34123 times)

member
Activity: 92
Merit: 10
July 01, 2011, 02:53:33 AM
#46
Unknown key type: bestblock
This error is not related to your problem. It's just that the wallet contain a new type of data that the bitcointools is not aware of. (namely, the most recent block that this wallet was synchronized with)

Do you have a thread where you describe the scenario that led to hung transactions ?
edit: I assume this is the one. My advice would be to wait a bit for the import/export private keys feature to be formally released in an official version. Then you can dump your keys to a text file and import back the relevant ones to a fresh wallet.

Yup, that's the one, and yes, those are the features I need.  I found the github branch with a download of stuff that supposedly patches those RPC commands into bitcoin, but, after extracting it nothing was installed or patched, and I don't know what to do.  I want to dump my wallet, and only have the stuff I want, not the hung or damaged stuff, and then import the good stuff into a new wallet, a fresh start.  Please please please, someone put it into the main branch so it gets included in the next official release!
newbie
Activity: 56
Merit: 0
June 30, 2011, 06:21:26 PM
#45
Unknown key type: bestblock
This error is not related to your problem. It's just that the wallet contain a new type of data that the bitcointools is not aware of. (namely, the most recent block that this wallet was synchronized with)

Do you have a thread where you describe the scenario that led to hung transactions ?
edit: I assume this is the one. My advice would be to wait a bit for the import/export private keys feature to be formally released in an official version. Then you can dump your keys to a text file and import back the relevant ones to a fresh wallet.
member
Activity: 92
Merit: 10
June 30, 2011, 02:29:31 PM
#44
bitcointools has a fixwallet.py that can often fix broken wallet.dat files.
  https://github.com/gavinandresen/bitcointools/


If that works, I'll be very very happy, OMG!!  You're the best Gavin. Smiley

I finally managed to figure out how to run it, and then it spouted an error I don't understand.  Here is the text:

Code:
C:\Program Files\Bitcoin\bitcointools>fixwallet.py --datadir=m:\bitcoin --out=walletFixed.dat
Unknown key type: bestblock

Well, it didn't fix the wallet the way I wanted it to, it still had the hung transactions on it.  I want to Remove those hung transactions, and fix whatever caused them, Or fix whatever is causing it so that they will stop being hung. 
legendary
Activity: 1652
Merit: 1186
Chief Scientist
June 29, 2011, 07:12:38 PM
#43
bitcointools has a fixwallet.py that can often fix broken wallet.dat files.
  https://github.com/gavinandresen/bitcointools/
member
Activity: 92
Merit: 10
June 29, 2011, 03:53:48 PM
#42

Yay, thanks. Smiley  Now I just need to figure out how to dump my broken wallet, and import only the good stuff into a new wallet.  Grrr!
full member
Activity: 147
Merit: 100
June 27, 2011, 08:16:26 AM
#41
Look at rpc.cpp for the list of commands.

Seriously?  So, everyone knows C++ but me?  I don't understand where this list of commands is in this file.  *sigh* I have tried to understand C++ for years, things just are not clicking in my head for some reason.  Do you mean this stuff?
Code:
        //
        // Special case non-string parameter types
        //
        if (strMethod == "setgenerate"            && n > 0) ConvertTo(params[0]);
        if (strMethod == "setgenerate"            && n > 1) ConvertTo(params[1]);
        if (strMethod == "sendtoaddress"          && n > 1) ConvertTo(params[1]);
        if (strMethod == "settxfee"               && n > 0) ConvertTo(params[0]);
        if (strMethod == "getamountreceived"      && n > 1) ConvertTo(params[1]); // deprecated
        if (strMethod == "getreceivedbyaddress"   && n > 1) ConvertTo(params[1]);
        if (strMethod == "getreceivedbyaccount"   && n > 1) ConvertTo(params[1]);
        if (strMethod == "getreceivedbylabel"     && n > 1) ConvertTo(params[1]); // deprecated
        if (strMethod == "getallreceived"         && n > 0) ConvertTo(params[0]); // deprecated
        if (strMethod == "getallreceived"         && n > 1) ConvertTo(params[1]);
        if (strMethod == "listreceivedbyaddress"  && n > 0) ConvertTo(params[0]);
        if (strMethod == "listreceivedbyaddress"  && n > 1) ConvertTo(params[1]);
        if (strMethod == "listreceivedbyaccount"  && n > 0) ConvertTo(params[0]);
        if (strMethod == "listreceivedbyaccount"  && n > 1) ConvertTo(params[1]);
        if (strMethod == "listreceivedbylabel"    && n > 0) ConvertTo(params[0]); // deprecated
        if (strMethod == "listreceivedbylabel"    && n > 1) ConvertTo(params[1]); // deprecated
        if (strMethod == "getbalance"             && n > 1) ConvertTo(params[1]);
        if (strMethod == "move"                   && n > 2) ConvertTo(params[2]);
        if (strMethod == "move"                   && n > 3) ConvertTo(params[3]);
        if (strMethod == "sendfrom"               && n > 2) ConvertTo(params[2]);
        if (strMethod == "sendfrom"               && n > 3) ConvertTo(params[3]);
        if (strMethod == "listtransactions"       && n > 1) ConvertTo(params[1]);
        if (strMethod == "listtransactions"       && n > 2) ConvertTo(params[2]);
        if (strMethod == "listaccounts"           && n > 0) ConvertTo(params[0]);
        if (strMethod == "sendmany"               && n > 1)
        {
            string s = params[1].get_str();
            Value v;
            if (!read_string(s, v) || v.type() != obj_type)
                throw runtime_error("type mismatch");
            params[1] = v.get_obj();
        }
        if (strMethod == "sendmany"                && n > 2) ConvertTo(params[2]);

Well, there are comments throughout, so that's good, I really get annoyed by spaghetti code.

Are you looking for this list? https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_Calls_list
member
Activity: 92
Merit: 10
June 26, 2011, 10:47:21 AM
#40
Look at rpc.cpp for the list of commands.

Seriously?  So, everyone knows C++ but me?  I don't understand where this list of commands is in this file.  *sigh* I have tried to understand C++ for years, things just are not clicking in my head for some reason.  Do you mean this stuff?
Code:
        //
        // Special case non-string parameter types
        //
        if (strMethod == "setgenerate"            && n > 0) ConvertTo(params[0]);
        if (strMethod == "setgenerate"            && n > 1) ConvertTo(params[1]);
        if (strMethod == "sendtoaddress"          && n > 1) ConvertTo(params[1]);
        if (strMethod == "settxfee"               && n > 0) ConvertTo(params[0]);
        if (strMethod == "getamountreceived"      && n > 1) ConvertTo(params[1]); // deprecated
        if (strMethod == "getreceivedbyaddress"   && n > 1) ConvertTo(params[1]);
        if (strMethod == "getreceivedbyaccount"   && n > 1) ConvertTo(params[1]);
        if (strMethod == "getreceivedbylabel"     && n > 1) ConvertTo(params[1]); // deprecated
        if (strMethod == "getallreceived"         && n > 0) ConvertTo(params[0]); // deprecated
        if (strMethod == "getallreceived"         && n > 1) ConvertTo(params[1]);
        if (strMethod == "listreceivedbyaddress"  && n > 0) ConvertTo(params[0]);
        if (strMethod == "listreceivedbyaddress"  && n > 1) ConvertTo(params[1]);
        if (strMethod == "listreceivedbyaccount"  && n > 0) ConvertTo(params[0]);
        if (strMethod == "listreceivedbyaccount"  && n > 1) ConvertTo(params[1]);
        if (strMethod == "listreceivedbylabel"    && n > 0) ConvertTo(params[0]); // deprecated
        if (strMethod == "listreceivedbylabel"    && n > 1) ConvertTo(params[1]); // deprecated
        if (strMethod == "getbalance"             && n > 1) ConvertTo(params[1]);
        if (strMethod == "move"                   && n > 2) ConvertTo(params[2]);
        if (strMethod == "move"                   && n > 3) ConvertTo(params[3]);
        if (strMethod == "sendfrom"               && n > 2) ConvertTo(params[2]);
        if (strMethod == "sendfrom"               && n > 3) ConvertTo(params[3]);
        if (strMethod == "listtransactions"       && n > 1) ConvertTo(params[1]);
        if (strMethod == "listtransactions"       && n > 2) ConvertTo(params[2]);
        if (strMethod == "listaccounts"           && n > 0) ConvertTo(params[0]);
        if (strMethod == "sendmany"               && n > 1)
        {
            string s = params[1].get_str();
            Value v;
            if (!read_string(s, v) || v.type() != obj_type)
                throw runtime_error("type mismatch");
            params[1] = v.get_obj();
        }
        if (strMethod == "sendmany"                && n > 2) ConvertTo(params[2]);

Well, there are comments throughout, so that's good, I really get annoyed by spaghetti code.
full member
Activity: 202
Merit: 108
GCC - Global cryptocurrency
June 14, 2010, 10:25:58 PM
#39
Here's an article about cross domain scripting: http://www.ibm.com/developerworks/library/wa-aj-jsonp1/

It seems that direct remote calling from javascript might not be possible after all. I wonder if calling localhost:8332 is possible from pages stored on your hard disk.

I didn't try that, but I did try two servers on the same machine.  One on 127.0.0.1:8332 and the other on 127.0.0.1:8080.  Neither browser script could make a request to the opposite server.  I was using Firefox 3.6
sr. member
Activity: 429
Merit: 272
June 14, 2010, 06:26:45 PM
#38
Here's an article about cross domain scripting: http://www.ibm.com/developerworks/library/wa-aj-jsonp1/

It seems that direct remote calling from javascript might not be possible after all. I wonder if calling localhost:8332 is possible from pages stored on your hard disk.
full member
Activity: 199
Merit: 696
June 14, 2010, 04:14:29 PM
#37
Is this really true for modern web browsers, or would the web page have to be loaded from localhost as well?  Can you make an HTTP call from javascript to the localhost if the page was loaded from an internet host?
sr. member
Activity: 429
Merit: 272
June 14, 2010, 03:16:28 PM
#36
Note: Running the server/daemon on a computer that you use for Internet browsing is unsafe. A malicious page could host javascript that calls your local API and sends your coins out.
administrator
Activity: 4228
Merit: 8647
June 11, 2010, 03:55:33 PM
#35
You need to recompile your kernel with support for "owner match support" for netfilter. I was always running into this problem (wanting exotic iptables filters), so I have all of the netfilter modules enabled, even though most of them seem useless to me right now.

I agree that proper authentication would be good, but it's not very important right now. Very few people are running BitCoin on actual multi-user machines, I think.

Quote
if I were root, couldn't I just...

Of course. But packets that originate from the "root" account will still be blocked unless you remove the iptables rule.
full member
Activity: 210
Merit: 100
June 11, 2010, 03:22:14 PM
#34
Code:
FATAL: Module xt_owner not found.
It's not a big problem at the moment. I'd still like to see authentication and wallet encryption in bitcoin in the future. Also, if I were root, couldn't I just
sudo su -
and evade the owner check in iptables?
administrator
Activity: 4228
Merit: 8647
June 11, 2010, 02:56:41 PM
#33
Try loading the "xt_owner" kernel module.

Quote
Setting the UID to my username will block the packet for everyone but me (and root, obviously), right?

Yes. Root will also be blocked unless you add that user as well.
full member
Activity: 210
Merit: 100
June 11, 2010, 02:15:40 PM
#32
iptables -A OUTPUT -o lo -p tcp --dport 8332 -m owner --uid-owner root -j ACCEPT
iptables -A OUTPUT -o lo -p tcp --dport 8332 -j REJECT
Oh sweet. I didn't know you could do that. Setting the UID to my username will block the packet for everyone but me (and root, obviously), right?
Not working for me. It gives the error:
Code:
iptables: No chain/target/match by that name.
administrator
Activity: 4228
Merit: 8647
June 11, 2010, 01:06:59 PM
#31
iptables -A OUTPUT -o lo -p tcp --dport 8332 -m owner --uid-owner root -j ACCEPT
iptables -A OUTPUT -o lo -p tcp --dport 8332 -j REJECT
full member
Activity: 199
Merit: 696
June 11, 2010, 12:49:36 PM
#30
I don't think you can do that with iptables.. is there some module that lets you match a locally generated packet against the UID of a process?
administrator
Activity: 4228
Merit: 8647
June 11, 2010, 12:46:09 PM
#29
You can block it for everyone but your intended users with iptables.
full member
Activity: 210
Merit: 100
June 11, 2010, 10:54:57 AM
#28
Is there some way this might be recast as a file socket (I suppose Windows would be an issue) or with some sort of security?

At the moment, the lowliest user on any of my machines can happily make a completely unauthenticated SendToAddress call and empty my wallet.
full member
Activity: 185
Merit: 111
April 29, 2010, 06:04:36 AM
#27
This sounds very promising. Is there anyway to carve it out as a stand alone binary? My very rudimentary programming skills might not cut the cheese, but I would like to try to make a Firefox bitcoin wallet plugin. If anybody wants to hack at that and leave me in the dust then I gladly eat dust, otherwise I will plod along and see what I can't do (I refuse to do the impossible, but merely resist the inevitable Cheesy). If there were a way to just get the extra files for the JSON and such like (for web only), working with the bitcoin 0.2.0 version and save having to compile, then the target user would not have to install anything other than the plugin itself, that what I'm fishing for really. Is that a tall order?

I would aim to have bitcoin built into Firefox as a standard. Since no third party is being given preference here, can't it be standard browser code, or even built into the HTML or JavaScript, to parse dedicated scripting code and streamline development of online banking and financial utilities? Perhaps even deposits and withdrawals from banks could then finally be done online without their greedy charges. The plugin would demonstrate the idea for now though and save some user hassle as installing is easy, standard and the plugin repository has wide exposure. Then people may want to email and invite their friends to get the new electronic cash standard. The Paypal tactic of being able to email cash to somebody without an account, and have them login to make an account (to get their money), will translate to, having them load Firefox and/or open the plugin window from the email and install. Guaranteed - satisfaction or your money back, (to the sender of course). Go viral bitcoin. Wink


EDIT: "can't it be standard browser code, or even built into the HTML or JavaScript"  -- And now with a little research, I realize that is just what the JSON stuff does. Yikes! you can't fall asleep for 5 minutes without finding yourself out of the loop.
Pages:
Jump to: