Bitcoin full node and query server

Dec 12, 2018

View in context in the libbitcoin Slack #general mirror.

neillm13:55
@Julian The broadcast call can only tell you if it failed (or succeeded) to broadcast the tx. There's no way to determine which nodes think it's valid from that call. You could verify the tx before broadcast, which can tell you if your node think it's valid.
8 replies · Julian, neillm · last Dec 19, 2018
J
Julian00:47
Hey Neil! Sorry for the late response. I think I might not have been very clear. I have written a client that uses libbitcoin-client to talk to a libbitcoin-server instance. When I send a transaction using transaction_pool_broadcast to that instance, wouldn't that bs server do an initial validation on my transaction and return any of the numerous error codes if it found a problem? If so, how can I distinguish any such error from an error caused by connectivity problems? (the connection between my application and my bs instance)
(edited)
J
Julian23:42
ping @neillm 🙂
neillm14:28
Hey, sorry I'm not sure I'm following what you're seeing. Are you trying to do a broadcast and not getting error codes for invalid transactions? You should be (and you distinguish based on the value of the error code). But if the tx is otherwise fine and it's broadcasted, there's no way to determine acceptance to the network from that call.
J
Julian23:55
(and you distinguish based on the value of the error code).
I think this is what I'm having trouble with. Can I assume that any of these error codes are related to verifying the transaction? Also, what if there's a network error when sending the transaction to the libbitcoin-server? Is there something similar to:
...
auto on_error = [](const bc::code& ec) {
    if (bc::is_network_error(ec)) {
        // network error handling
    }
    if (bc::is_validation_error(ec)) {
        // validation error handling
    }
    // do on_error
};

auto on_done = [](const bc::code& ec) {
    if (bc::is_network_error(ec)) {
        // network error handling
    }
    if (bc::is_validation_error(ec)) {
        // validation error handling
    }
    // do on_done
};

client.transaction_pool_broadcast(on_error, on_done, transaction);
...
(edited)
J
Julian23:56
Actually, I'm also a bit confused about the two callbacks and why both of them receive error codes 😕
neillm00:13
No, they are just error codes that you should handle appropriately. The two handlers is confusing, sure. Its gone in master/v4 btw
J
Julian00:20
Hmm so I need to switch on the codes myself and identify the network related codes and verification related codes?
J
Julian00:22
And how do I deal with the op eval codes? Presumably any of those can happen if there's something wrong with my script?