Author

Topic: My programmer is a newbie to bitcoin (Read 2491 times)

full member
Activity: 125
Merit: 100
December 06, 2012, 08:52:53 AM
#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).
hero member
Activity: 740
Merit: 501
December 06, 2012, 07:45:33 AM
#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...
legendary
Activity: 1400
Merit: 1013
December 06, 2012, 07:35:52 AM
#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.
legendary
Activity: 1540
Merit: 1002
December 06, 2012, 06: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).
hero member
Activity: 740
Merit: 501
December 06, 2012, 06: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?
legendary
Activity: 1540
Merit: 1002
December 06, 2012, 05: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.
hero member
Activity: 740
Merit: 501
December 06, 2012, 05: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"}.
full member
Activity: 125
Merit: 100
December 05, 2012, 10:47:19 PM
#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?
hero member
Activity: 740
Merit: 501
December 05, 2012, 12: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.
donator
Activity: 640
Merit: 500
December 05, 2012, 10:35:30 AM
#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)
full member
Activity: 125
Merit: 100
December 05, 2012, 10:33:48 AM
#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}
hero member
Activity: 740
Merit: 501
December 05, 2012, 09:50:52 AM
#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.
legendary
Activity: 924
Merit: 1004
Firstbits: 1pirata
December 05, 2012, 08:50:53 AM
#2
Try on Rugatu, people are more eager to help when you put the reward in sight Wink
hero member
Activity: 740
Merit: 501
December 05, 2012, 08:36:39 AM
#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.
Jump to: