Post
Topic
Board Service Discussion
Topic OP
How to correctly push transaction?
by
DrSeuss
on 23/01/2017, 12:19:32 UTC
What's up! Wink

I'm currently coding a Bitcoin-Transaction-System on my Website. (via bitcoinjs-lib)
Now I'm kinda stuck with pushing the transaction.
Can anyone tell me what exactly I have to push?
It's weird because I generate a Hex which works fine if I push it manually via http://tbtc.blockr.io/documentation/api
But as soon as I try to push via code the whole thing just dies.

Code:
Failed to push transaction. -> {"status":"error","data":"TX is missing","code":400,"message":"Please see API documentation on how to POST tx hex as json."}

Code:
$.ajax({
                            url: "http://btc.blockr.io/api/v1/tx/decode",
                            type: "post",
                            data: {
                            hex: transactionHex
                            },
                            success: function(response) {
                                decodedHex = response;
                                console.log(decodedHex);
                                document.getElementById('baseDiv').innerHTML += "

Decoded Hex: " + transactionHex;
                            },
                            error: function(xhr) {
                                console.log("Failed to decode Hex. -> " + xhr);
                            }
                        });

                        $.ajax({
                            url: "http://btc.blockr.io/api/v1/tx/push",
                            type: "post",
                            data: {
                            hex: decodedHex
                            },
                            success: function(response) {
                                console.log("Transaction pushed. " + response);
                            },
                            error: function(xhr) {
                                console.log("Failed to push transaction. -> " + xhr.responseText);
                            }
                        });

Can anyone give me a few pointers what could be the problem? Smiley
Thanks so much! <3
Cheerz~