Post
Topic
Board Service Discussion
Re: How to correctly push transaction?
by
DrSeuss
on 23/01/2017, 15:48:50 UTC
Code:
var transactionHex = tx.build().toHex()

                        // Request current BTC Price for $ & €
                        var decodedHex;

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

Decoded Hex: " + JSON.stringify(response);

                                $.ajax({
                                    url: "https://testnet-api.smartbit.com.au/v1/blockchain/pushtx",
                                    type: "post",
                                    data2: {
                                    hex: transactionHex
                                    },
                                    success: function(response) {
                                        console.log("Transaction pushed. " + response);
                                    },
                                    error: function(xhr) {
                                        console.log("Failed to Push: " + xhr.responseText);
                                        console.log("Transaction Hash: " + transactionHex);
                                        console.log("This is pushed: " + JSON.stringify(this.data2));
                                    }
                                });
                            },
                            error: function(xhr) {
                                console.log("Failed to decode Hex. -> " + xhr);
                            }
                        });

I don't really understand what you mean but as you see I'm using the transactionHash as a parameter. Shocked
Code:
{"hex":"010000000194bacfdc39a29fb55269ff2e1bf91140bf3d08efa943b6c8c131a059c15ec23f01000000694630430220691210387a5a5897afedf546e42a482265b2be96ba36f5e2624168f4d94df8d7021f587c9b670089d81f0aee897364aa6e3320f0a9235e5f70924bbaee287f0f6d01210250a251bd8365ee73a91fe09cb3477b400841c158a59874a8b041e7dff48412e5ffffffff0280969800000000001976a9142ca0f264fcffd0ceb34b109e1403a11ecacd73b288ac00b7ef08000000001976a914251fafe412cdd9d4f32aabb8ea8858a97203016588ac00000000"}
is what's beeing pushed, with hex beeing the key and the transactionHash as parameter, what is my mistake?
I feel so stupid right now  Roll Eyes