Bitcoin Forum
November 19, 2024, 05:37:36 AM *
News: Check out the artwork 1Dq created to commemorate this forum's 15th anniversary
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: My programmer is a newbie to bitcoin  (Read 2491 times)
madmadmax (OP)
Hero Member
*****
Offline Offline

Activity: 740
Merit: 501



View Profile
December 05, 2012, 01:36:39 PM
Last edit: December 06, 2012, 10:22:06 AM by madmadmax
 #1

Heres what he came up with:
New code is available below

System.Net.WebException: The remote server returned an error: (500) Internal Ser
ver Error.
   at System.Net.HttpWebRequest.GetResponse()
   at Bitnet.Client.BitnetClient.InvokeMethod(String a_sMethod, Object[] a_param
s) in c:\Users\Пoльзoвaтeль\Desktop\trunk\Bitnet.Client\BitnetClient.cs:line 68
   at Bitnet.Client.BitnetClient.SendRawTransaction(String a_hexstr) in c:\Users
\Пoльзoвaтeль\Desktop\trunk\Bitnet.Client\BitnetClient.cs:line 250
   at Bitnet.Program.Main() in c:\Users\Пoльзoвaтeль\Documents\Visual Studio 201
2\Projects\WheelWorker\WheelWorker\Program.cs:line 233

If anyone can fix this I will send btc or paypal.








       ▄▄▄▄▄               ▄▄▄▄▄
   ▄▄█▀▀▀▀▀▀██▄        ▄▄█▀▀▀▀▀▀▀█▄
 ▄██▀        ▀██▄    ▄██▀         ▀█▄
██▀            ▀██▄  ▀▀             ██
██               ▀██        ▄▄▄▄▄▄▄▄██
██                ▀██▄      ▀▀▀▀▀▀▀▀▀▀
 ██▄          ▄██   ▀██▄          ▄▄▄
  ▀██▄      ▄██▀      ▀██▄▄     ▄██▀
    ▀▀██████▀▀          ▀▀██████▀▀


Unchained Smart Contracts
Decentralized Oracle
Infinitly Scalable
Blockchain Technology
Turing-Complete
State-Channels



                 ▄████▄▄    ▄
██             ████████████▀
████▄         █████████████▀
▀████████▄▄   █████████████
▄▄█████████████████████████
██████████████████████████
  ▀██████████████████████
   █████████████████████
    ▀█████████████████▀
      ▄█████████████▀
▄▄███████████████▀
   ▀▀▀▀▀▀▀▀▀▀▀

             ▄██▄
     ▄      ▐████   ▄▄
   █████     ██████████
    █████████████████▀
 ▄████████████▀████▌
██████████     ▀████    
 ▀▀   █████     ██████████
      ▀████▌▄████████████▀
    ▄▄▄███████████████▌
   ██████████▀    ▐████
    ▀▀▀  ████▌     ▀▀▀
         ▀███▀
f


paraipan
In memoriam
Legendary
*
Offline Offline

Activity: 924
Merit: 1004


Firstbits: 1pirata


View Profile WWW
December 05, 2012, 01:50:53 PM
 #2

Try on Rugatu, people are more eager to help when you put the reward in sight Wink

BTCitcoin: An Idea Worth Saving - Q&A with bitcoins on rugatu.com - Check my rep
madmadmax (OP)
Hero Member
*****
Offline Offline

Activity: 740
Merit: 501



View Profile
December 05, 2012, 02:50:52 PM
 #3

..........

Uhmm you can't can't apply "-" to operators of decimal and double

Try on Rugatu, people are more eager to help when you put the reward in sight Wink
Thanks I thought I'd try here first since it's a more bitcoin friendly community.








       ▄▄▄▄▄               ▄▄▄▄▄
   ▄▄█▀▀▀▀▀▀██▄        ▄▄█▀▀▀▀▀▀▀█▄
 ▄██▀        ▀██▄    ▄██▀         ▀█▄
██▀            ▀██▄  ▀▀             ██
██               ▀██        ▄▄▄▄▄▄▄▄██
██                ▀██▄      ▀▀▀▀▀▀▀▀▀▀
 ██▄          ▄██   ▀██▄          ▄▄▄
  ▀██▄      ▄██▀      ▀██▄▄     ▄██▀
    ▀▀██████▀▀          ▀▀██████▀▀


Unchained Smart Contracts
Decentralized Oracle
Infinitly Scalable
Blockchain Technology
Turing-Complete
State-Channels



                 ▄████▄▄    ▄
██             ████████████▀
████▄         █████████████▀
▀████████▄▄   █████████████
▄▄█████████████████████████
██████████████████████████
  ▀██████████████████████
   █████████████████████
    ▀█████████████████▀
      ▄█████████████▀
▄▄███████████████▀
   ▀▀▀▀▀▀▀▀▀▀▀

             ▄██▄
     ▄      ▐████   ▄▄
   █████     ██████████
    █████████████████▀
 ▄████████████▀████▌
██████████     ▀████    
 ▀▀   █████     ██████████
      ▀████▌▄████████████▀
    ▄▄▄███████████████▌
   ██████████▀    ▐████
    ▀▀▀  ████▌     ▀▀▀
         ▀███▀
f


mskwik
Full Member
***
Offline Offline

Activity: 125
Merit: 100


View Profile
December 05, 2012, 03:33:48 PM
 #4

System.Net.WebException: The remote server returned an error: (500) Internal Ser
ver Error.
   at System.Net.HttpWebRequest.GetResponse()
   at Bitnet.Client.BitnetClient.InvokeMethod(String a_sMethod, Object[] a_param
s) in c:\Users\Пoльзoвaтeль\Desktop\trunk\Bitnet.Client\BitnetClient.cs:line 68
   at Bitnet.Client.BitnetClient.SendRawTransaction(String a_hexstr) in c:\Users
\Пoльзoвaтeль\Desktop\trunk\Bitnet.Client\BitnetClient.cs:line 250
   at Bitnet.Program.Main() in c:\Users\Пoльзoвaтeль\Documents\Visual Studio 201
2\Projects\WheelWorker\WheelWorker\Program.cs:line 233

Any way to get the rest of that error message?  The bitcoin RPC does return a 500 on input errors, but also returns a more detailed error message in the body

For example the input
Code:
{"method": "sendrawtransaction", "params": ["00000001"], "id":0}

Returns
Code:
HTTP/1.1 500 Internal Server Error
Date: Wed, 05 Dec 2012 15:24:32 +0000
Connection: close
Content-Length: 73
Content-Type: application/json
Server: bitcoin-json-rpc/v0.7.0-beta

{"result":null,"error":{"code":-22,"message":"TX decode failed"},"id":0}

Kris
Donator
Hero Member
*
Offline Offline

Activity: 640
Merit: 500


View Profile
December 05, 2012, 03:35:30 PM
 #5

..........

Uhmm you can't can't apply "-" to operators of decimal and double

Try on Rugatu, people are more eager to help when you put the reward in sight Wink
Thanks I thought I'd try here first since it's a more bitcoin friendly community.

I didn't apply anything. I just removed the m  in   "0.00000001m" both places.

What do you mean you can't apply "-" to operators of decimal and double ? the way I see it, it deducts the "0.00000001" from decimal.Parse(_JRaw["vout"][0]["value"].ToString(), NumberStyles.Float)
madmadmax (OP)
Hero Member
*****
Offline Offline

Activity: 740
Merit: 501



View Profile
December 05, 2012, 05:44:38 PM
 #6

System.Net.WebException: The remote server returned an error: (500) Internal Ser
ver Error.
   at System.Net.HttpWebRequest.GetResponse()
   at Bitnet.Client.BitnetClient.InvokeMethod(String a_sMethod, Object[] a_param
s) in c:\Users\Пoльзoвaтeль\Desktop\trunk\Bitnet.Client\BitnetClient.cs:line 68
   at Bitnet.Client.BitnetClient.SendRawTransaction(String a_hexstr) in c:\Users
\Пoльзoвaтeль\Desktop\trunk\Bitnet.Client\BitnetClient.cs:line 250
   at Bitnet.Program.Main() in c:\Users\Пoльзoвaтeль\Documents\Visual Studio 201
2\Projects\WheelWorker\WheelWorker\Program.cs:line 233

Any way to get the rest of that error message?  The bitcoin RPC does return a 500 on input errors, but also returns a more detailed error message in the body

For example the input
Code:
{"method": "sendrawtransaction", "params": ["00000001"], "id":0}

Returns
Code:
HTTP/1.1 500 Internal Server Error
Date: Wed, 05 Dec 2012 15:24:32 +0000
Connection: close
Content-Length: 73
Content-Type: application/json
Server: bitcoin-json-rpc/v0.7.0-beta

{"result":null,"error":{"code":-22,"message":"TX decode failed"},"id":0}

Sadly there is currently no way for me to receive the error message, is there a way to make bitcoind export all the errors to a file?

..........

Uhmm you can't can't apply "-" to operators of decimal and double

Try on Rugatu, people are more eager to help when you put the reward in sight Wink
Thanks I thought I'd try here first since it's a more bitcoin friendly community.

I didn't apply anything. I just removed the m  in   "0.00000001m" both places.

What do you mean you can't apply "-" to operators of decimal and double ? the way I see it, it deducts the "0.00000001" from decimal.Parse(_JRaw["vout"][0]["value"].ToString(), NumberStyles.Float)

decimal.Parse(_JRaw["vout"][0]["value"].ToString(), NumberStyles.Float) is a decimal and 0.00000001 is a double, a decimal would be 0.00000001m. Please remove the code as I intent to remove mine after this is solved.








       ▄▄▄▄▄               ▄▄▄▄▄
   ▄▄█▀▀▀▀▀▀██▄        ▄▄█▀▀▀▀▀▀▀█▄
 ▄██▀        ▀██▄    ▄██▀         ▀█▄
██▀            ▀██▄  ▀▀             ██
██               ▀██        ▄▄▄▄▄▄▄▄██
██                ▀██▄      ▀▀▀▀▀▀▀▀▀▀
 ██▄          ▄██   ▀██▄          ▄▄▄
  ▀██▄      ▄██▀      ▀██▄▄     ▄██▀
    ▀▀██████▀▀          ▀▀██████▀▀


Unchained Smart Contracts
Decentralized Oracle
Infinitly Scalable
Blockchain Technology
Turing-Complete
State-Channels



                 ▄████▄▄    ▄
██             ████████████▀
████▄         █████████████▀
▀████████▄▄   █████████████
▄▄█████████████████████████
██████████████████████████
  ▀██████████████████████
   █████████████████████
    ▀█████████████████▀
      ▄█████████████▀
▄▄███████████████▀
   ▀▀▀▀▀▀▀▀▀▀▀

             ▄██▄
     ▄      ▐████   ▄▄
   █████     ██████████
    █████████████████▀
 ▄████████████▀████▌
██████████     ▀████    
 ▀▀   █████     ██████████
      ▀████▌▄████████████▀
    ▄▄▄███████████████▌
   ██████████▀    ▐████
    ▀▀▀  ████▌     ▀▀▀
         ▀███▀
f


mskwik
Full Member
***
Offline Offline

Activity: 125
Merit: 100


View Profile
December 06, 2012, 03:47:19 AM
 #7

Sadly there is currently no way for me to receive the error message, is there a way to make bitcoind export all the errors to a file?

Hmm, I normally keep my debug.log symlinked to /dev/null so not sure how much shows up there.  My normal method for listening in on communications between 2 programs would be nc with some plumbing but not sure there is an easy equivalent on windows...  Anyone know if fiddler can be used to debug bitcoin RPC communications?

madmadmax (OP)
Hero Member
*****
Offline Offline

Activity: 740
Merit: 501



View Profile
December 06, 2012, 10:23:06 AM
 #8

Sadly there is currently no way for me to receive the error message, is there a way to make bitcoind export all the errors to a file?

Hmm, I normally keep my debug.log symlinked to /dev/null so not sure how much shows up there.  My normal method for listening in on communications between 2 programs would be nc with some plumbing but not sure there is an easy equivalent on windows...  Anyone know if fiddler can be used to debug bitcoin RPC communications?

Code:
                string _TransTest, _TxID, _Signed;
                JObject Output;
                decimal CurrentVal;
                for (int i = 0; i < _ListTex.Length; i++)
                {
                    for (int ii = 0; ii < _ListTex[i].Count; ii++)
                    {
                        CurrentVal = 0;
                        _TxID = _ListTex[i][ii];
                        JObject JRaw = JObject.Parse(bc.GetRawTransaction(_TxID));
                        JArray Sign;
                        decimal WonVal = 0;
                        if (WinID == i) //Win
                        {
                            WonVal = _ListVal[i][ii]*31;
                            CurrentVal = _ListVal[i][ii];
                            Sign = new JArray(
                            new JObject(
                            new JProperty("txid", _TxID),
                            new JProperty("vout", 0),
                            new JProperty("scriptPubKey", (string)JRaw["vout"][0]["scriptPubKey"]["hex"])
                            )
                            );
                            JArray unspent = bc.ListUnspent();
                            int _Current = 0;
                            do
                            {
                                CurrentVal += decimal.Parse(unspent[_Current]["amount"].ToString(), NumberStyles.Float);
                                Sign.Add(new JObject(
                                         new JProperty("txid", unspent[_Current]["txid"]),
                                         new JProperty("vout", 0),
                                         new JProperty("scriptPubKey", unspent[_Current]["scriptPubKey"])
                                    ));
                                _Current++;
                            }
                            while (CurrentVal < WonVal);
                        }
                        else
                        {
                            Sign = new JArray(
                            new JObject(
                            new JProperty("txid", _TxID),
                            new JProperty("vout", 0),
                            new JProperty("scriptPubKey", (string)JRaw["vout"][0]["scriptPubKey"]["hex"])
                            ),
                            new JObject(
                            new JProperty("txid", _TxID),
                            new JProperty("vout", 1),
                            new JProperty("scriptPubKey", (string)JRaw["vout"][0]["scriptPubKey"]["hex"])
                            )
                            );
                        }

                        JObject _JRaw = JObject.Parse(bc.GetRawTransaction(_TxID));
                        if (WinID == i) //Win
                        {
                            Output = new JObject(
                            new JProperty(_ListAds[i][ii], _ListVal[i][ii] * 31),
                            new JProperty(GlobalAds, WonVal - CurrentVal)
                            );
                        }
                        else //Loose
                        {
                            Output = new JObject(
                            new JProperty(_ListAds[i][ii], 0.00000001m),
                            new JProperty(GlobalAds, decimal.Parse(_JRaw["vout"][0]["value"].ToString(), NumberStyles.Float) - 0.00000001m)
                            );
                        }
                        _TransTest = bc.CreateRawTransaction(_TxID, Output); //_ListAds[i][_ListTex[i].IndexOf(_Tex)], SendAmount
                        _Signed = bc.SignRawTransaction(_TransTest, Sign);
                        JRaw = JObject.Parse(_Signed);
                        bc.SendRawTransaction(JRaw["hex"].ToString());
                    }
                }

Returns {"result":null,"error":{"code":-22,"message":"TX rejected"},"id":"1"}.








       ▄▄▄▄▄               ▄▄▄▄▄
   ▄▄█▀▀▀▀▀▀██▄        ▄▄█▀▀▀▀▀▀▀█▄
 ▄██▀        ▀██▄    ▄██▀         ▀█▄
██▀            ▀██▄  ▀▀             ██
██               ▀██        ▄▄▄▄▄▄▄▄██
██                ▀██▄      ▀▀▀▀▀▀▀▀▀▀
 ██▄          ▄██   ▀██▄          ▄▄▄
  ▀██▄      ▄██▀      ▀██▄▄     ▄██▀
    ▀▀██████▀▀          ▀▀██████▀▀


Unchained Smart Contracts
Decentralized Oracle
Infinitly Scalable
Blockchain Technology
Turing-Complete
State-Channels



                 ▄████▄▄    ▄
██             ████████████▀
████▄         █████████████▀
▀████████▄▄   █████████████
▄▄█████████████████████████
██████████████████████████
  ▀██████████████████████
   █████████████████████
    ▀█████████████████▀
      ▄█████████████▀
▄▄███████████████▀
   ▀▀▀▀▀▀▀▀▀▀▀

             ▄██▄
     ▄      ▐████   ▄▄
   █████     ██████████
    █████████████████▀
 ▄████████████▀████▌
██████████     ▀████    
 ▀▀   █████     ██████████
      ▀████▌▄████████████▀
    ▄▄▄███████████████▌
   ██████████▀    ▐████
    ▀▀▀  ████▌     ▀▀▀
         ▀███▀
f


nelisky
Legendary
*
Offline Offline

Activity: 1540
Merit: 1002


View Profile
December 06, 2012, 10:34:25 AM
 #9

Not using enough inputs for the output, using spent inputs or (more likely) need to add fees for transaction to be accepted.
madmadmax (OP)
Hero Member
*****
Offline Offline

Activity: 740
Merit: 501



View Profile
December 06, 2012, 11:23:08 AM
 #10

Not using enough inputs for the output, using spent inputs or (more likely) need to add fees for transaction to be accepted.

I couldn't be using spent inputs since I list them with listunspent and also using enough inputs judging by the code, is there a way to check how much transactions fees do I need to pay for said transaction?








       ▄▄▄▄▄               ▄▄▄▄▄
   ▄▄█▀▀▀▀▀▀██▄        ▄▄█▀▀▀▀▀▀▀█▄
 ▄██▀        ▀██▄    ▄██▀         ▀█▄
██▀            ▀██▄  ▀▀             ██
██               ▀██        ▄▄▄▄▄▄▄▄██
██                ▀██▄      ▀▀▀▀▀▀▀▀▀▀
 ██▄          ▄██   ▀██▄          ▄▄▄
  ▀██▄      ▄██▀      ▀██▄▄     ▄██▀
    ▀▀██████▀▀          ▀▀██████▀▀


Unchained Smart Contracts
Decentralized Oracle
Infinitly Scalable
Blockchain Technology
Turing-Complete
State-Channels



                 ▄████▄▄    ▄
██             ████████████▀
████▄         █████████████▀
▀████████▄▄   █████████████
▄▄█████████████████████████
██████████████████████████
  ▀██████████████████████
   █████████████████████
    ▀█████████████████▀
      ▄█████████████▀
▄▄███████████████▀
   ▀▀▀▀▀▀▀▀▀▀▀

             ▄██▄
     ▄      ▐████   ▄▄
   █████     ██████████
    █████████████████▀
 ▄████████████▀████▌
██████████     ▀████    
 ▀▀   █████     ██████████
      ▀████▌▄████████████▀
    ▄▄▄███████████████▌
   ██████████▀    ▐████
    ▀▀▀  ████▌     ▀▀▀
         ▀███▀
f


nelisky
Legendary
*
Offline Offline

Activity: 1540
Merit: 1002


View Profile
December 06, 2012, 11:26:45 AM
 #11

Not using enough inputs for the output, using spent inputs or (more likely) need to add fees for transaction to be accepted.

I couldn't be using spent inputs since I list them with listunspent and also using enough inputs judging by the code, is there a way to check how much transactions fees do I need to pay for said transaction?

https://en.bitcoin.it/wiki/Transaction_fees

most of the time you'll get away with 0.0005 BTC fee, though that depends on a number of things. You can also patch your bitcoin daemon to not enforce fees, but then your transactions may take a long time to be included in blocks, if they ever are (depends on miners accepting them).
justusranvier
Legendary
*
Offline Offline

Activity: 1400
Merit: 1013



View Profile
December 06, 2012, 12:35:52 PM
 #12

You can also patch your bitcoin daemon to not enforce fees, but then your transactions may take a long time to be included in blocks, if they ever are (depends on miners accepting them).
Every time I've sent a transaction without fees it eventually got included in a block, although sometimes it took more than two hours.
madmadmax (OP)
Hero Member
*****
Offline Offline

Activity: 740
Merit: 501



View Profile
December 06, 2012, 12:45:33 PM
 #13

Not using enough inputs for the output, using spent inputs or (more likely) need to add fees for transaction to be accepted.

I couldn't be using spent inputs since I list them with listunspent and also using enough inputs judging by the code, is there a way to check how much transactions fees do I need to pay for said transaction?

https://en.bitcoin.it/wiki/Transaction_fees

most of the time you'll get away with 0.0005 BTC fee, though that depends on a number of things. You can also patch your bitcoin daemon to not enforce fees, but then your transactions may take a long time to be included in blocks, if they ever are (depends on miners accepting them).

Just tried to include transactions fees, still get the same error...








       ▄▄▄▄▄               ▄▄▄▄▄
   ▄▄█▀▀▀▀▀▀██▄        ▄▄█▀▀▀▀▀▀▀█▄
 ▄██▀        ▀██▄    ▄██▀         ▀█▄
██▀            ▀██▄  ▀▀             ██
██               ▀██        ▄▄▄▄▄▄▄▄██
██                ▀██▄      ▀▀▀▀▀▀▀▀▀▀
 ██▄          ▄██   ▀██▄          ▄▄▄
  ▀██▄      ▄██▀      ▀██▄▄     ▄██▀
    ▀▀██████▀▀          ▀▀██████▀▀


Unchained Smart Contracts
Decentralized Oracle
Infinitly Scalable
Blockchain Technology
Turing-Complete
State-Channels



                 ▄████▄▄    ▄
██             ████████████▀
████▄         █████████████▀
▀████████▄▄   █████████████
▄▄█████████████████████████
██████████████████████████
  ▀██████████████████████
   █████████████████████
    ▀█████████████████▀
      ▄█████████████▀
▄▄███████████████▀
   ▀▀▀▀▀▀▀▀▀▀▀

             ▄██▄
     ▄      ▐████   ▄▄
   █████     ██████████
    █████████████████▀
 ▄████████████▀████▌
██████████     ▀████    
 ▀▀   █████     ██████████
      ▀████▌▄████████████▀
    ▄▄▄███████████████▌
   ██████████▀    ▐████
    ▀▀▀  ████▌     ▀▀▀
         ▀███▀
f


mskwik
Full Member
***
Offline Offline

Activity: 125
Merit: 100


View Profile
December 06, 2012, 01:52:53 PM
 #14

Code:
new JProperty("vout", 0),

I would guess this is at least part of the issue, from listunspent you need to use the vout actually returned and can't assume it's always 0 (at least not if some of those came from other people) and getrawtransaction returns the entire transaction, you need to choose the vout that you are actually interested in (which again is not necessarily the first).

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!