Bitcoin full node and query server

December 2018

Archive of the libbitcoin Slack #general channel.

Saturday, December 1, 2018

skaht00:21
% echo 486170707920373774682042697274686461792053696c76657220466f780a | bx base16-decode
Happy 77th Birthday Silver Fox
skaht00:34
% bx fetch-balance mztCURLXppqDsUnk4XtebZAkq8sr93etgs
balance
{
    address mztCURLXppqDsUnk4XtebZAkq8sr93etgs
    received 18446744073709551615
    spent 18446744073709551615
}
Using bx v3 connected to testnet1.libbitcoin.net, here is a TX that has an OP_RETURN output. Note the associated value at the bottom of the associated fetch history for mztCURLXppqDsUnk4XtebZAkq8sr93etgs. % bx fetch-tx a041f7d7139debf75ade2d8ea7f7d22e88acfa9f6a4b08b8b5625dc0779af198
transaction
{
    hash a041f7d7139debf75ade2d8ea7f7d22e88acfa9f6a4b08b8b5625dc0779af198
    inputs
    {
        input
        {
            address_hash d46ef5fd67873ccbe43cd71ac55c4c3b335213e5
            previous_output
            {
                hash 354b1eda7d1929a5105d0f16bbce76ec76c48097f79a6d6ae7e6ee67aff0c4cf
                index 1
            }
            script "[3044022001d50b67bf020de1a22f808098ef467bc643217a5fee430e63c2f8d5a85894a0022047df7c0d15ddd2fa45e4068ca94ce8087bb260ac2bf33e6264a4d4f12251ce0b01] [033297c7e4f78310e53d9c732374267b4deeeb30b532bda0947e5269bffc3ceb4e]"
            sequence 4294967295
        }
    }
    lock_time 0
    outputs
    {
        output
        {
            address_hash d46ef5fd67873ccbe43cd71ac55c4c3b335213e5
            script "dup hash160 [d46ef5fd67873ccbe43cd71ac55c4c3b335213e5] equalverify checksig"
            value 4399900000
        }
        output
        {
            script "return [486170707920373774682042697274686461792053696c76657220466f780a]"
            value 0
        }
    }
    version 1
}
% bx fetch-history mztCURLXppqDsUnk4XtebZAkq8sr93etgs
transfers
{
    transfer
    {
        received
        {
            hash a041f7d7139debf75ade2d8ea7f7d22e88acfa9f6a4b08b8b5625dc0779af198
            height 529179
            index 0
        }
        value 4399900000
    }
    transfer
    {
        received
        {
            hash 354b1eda7d1929a5105d0f16bbce76ec76c48097f79a6d6ae7e6ee67aff0c4cf
            height 509580
            index 1
        }
        spent
        {
            hash a041f7d7139debf75ade2d8ea7f7d22e88acfa9f6a4b08b8b5625dc0779af198
            height 529179
            index 0
        }
        value 4400000000
    }
    transfer
    {
        received
        {
            hash 8c294512c98c463f0d4fb2476e8e517549ce1219c71b0eb0c79f632ed446fb5b
            height 505549
            index 0
        }
        spent
        {
            hash 354b1eda7d1929a5105d0f16bbce76ec76c48097f79a6d6ae7e6ee67aff0c4cf
            height 509580
            index 0
        }
        value 4900100000
    }
    transfer
    {
        spent
        {
            hash a041f7d7139debf75ade2d8ea7f7d22e88acfa9f6a4b08b8b5625dc0779af198
            height 529179
            index 0
        }
        value 18446744073709551615
    }
    transfer
    {
        spent
        {
            hash 354b1eda7d1929a5105d0f16bbce76ec76c48097f79a6d6ae7e6ee67aff0c4cf
            height 509580
            index 0
        }
        value 18446744073709551615
    }
}
neillm02:03
The Web Log of Aaron Jaramillo
OP_RETURN OP_RETURN is the formal way of embedding data into the blockchain. By using a special script operation, we can create an output with a value of 0 and a script that includes up to 80 bytes…
skaht02:04
I hand jammed the OP_RETURN above with some ugly guesswork over 3 years ago.
neillm02:05
Nice. I know it's not as convenient as a bx command, but it's the same idea
skaht02:17
I stubbed the base TX using tx-encode with one input and two outputs. Then signed the first input with input-sign followed by a tx-set on index 0. The second task was to over ride the second default locking script for: % bx tx-decode 0100000001cfc4f0af67eee6e76a6d9af79780c476ec76cebb160f5d10a529197dda1e4b35010000006a47304402202c3a685e40e98df65fc45a3f504e4e4c4c00b4be56e2bba6ca9ae1e009a1180602205659957b593ff724fa69fab99729aa5981f5d86029b4198c61351735bad805f60121033297c7e4f78310e53d9c732374267b4deeeb30b532bda0947e5269bffc3ceb4effffffff0260254106010000001976a914d46ef5fd67873ccbe43cd71ac55c4c3b335213e588ac000000000000000017a914abdc6bdb3646d67f6117047bbea7a419f1bf35788700000000
transaction
{
    hash 80eecb43742ab119a30121c8bf733fbb9bd4de95bcd50d35d1e33d6a328d6a90
    inputs
    {
        input
        {
            address_hash d46ef5fd67873ccbe43cd71ac55c4c3b335213e5
            previous_output
            {
                hash 354b1eda7d1929a5105d0f16bbce76ec76c48097f79a6d6ae7e6ee67aff0c4cf
                index 1
            }
            script "[304402202c3a685e40e98df65fc45a3f504e4e4c4c00b4be56e2bba6ca9ae1e009a1180602205659957b593ff724fa69fab99729aa5981f5d86029b4198c61351735bad805f601] [033297c7e4f78310e53d9c732374267b4deeeb30b532bda0947e5269bffc3ceb4e]"
            sequence 4294967295
        }
    }
    lock_time 0
    outputs
    {
        output
        {
            address_hash d46ef5fd67873ccbe43cd71ac55c4c3b335213e5
            script "dup hash160 [d46ef5fd67873ccbe43cd71ac55c4c3b335213e5] equalverify checksig"
            value 4399900000
        }
        output
        {
            address_hash abdc6bdb3646d67f6117047bbea7a419f1bf3578
            script "hash160 [abdc6bdb3646d67f6117047bbea7a419f1bf3578] equal"
            value 0
        }
    }
    version 1
}
% echo ‘Happy 77th Birthday Silver Fox’ | bx base16-encode
486170707920373774682042697274686461792053696c76657220466f780a
(edited)
skaht02:28
% echo 6a1F486170707920373774682042697274686461792053696c76657220466f780a | bx script-decode
return [486170707920373774682042697274686461792053696c76657220466f780a]
OP_RETURN (0x6a) came from https://en.bitcoin.it/wiki/Script % echo -n 486170707920373774682042697274686461792053696c76657220466f780a | wc
       0       1      62
(62/2 = 31 = 0x1f)
(edited)
From careful editing the last portion of the skeleton TX above the following was what resulted: % bx tx-decode 0100000001cfc4f0af67eee6e76a6d9af79780c476ec76cebb160f5d10a529197dda1e4b35010000006a47304402202c3a685e40e98df65fc45a3f504e4e4c4c00b4be56e2bba6ca9ae1e009a1180602205659957b593ff724fa69fab99729aa5981f5d86029b4198c61351735bad805f60121033297c7e4f78310e53d9c732374267b4deeeb30b532bda0947e5269bffc3ceb4effffffff0260254106010000001976a914d46ef5fd67873ccbe43cd71ac55c4c3b335213e588ac0000000000000000216a1F486170707920373774682042697274686461792053696c76657220466f780a00000000
transaction
{
    hash 9b4ff8d9045456d50d542599f801020a5e7c19e012bd77b2d3136184491b5e6f
    inputs
    {
        input
        {
            address_hash d46ef5fd67873ccbe43cd71ac55c4c3b335213e5
            previous_output
            {
                hash 354b1eda7d1929a5105d0f16bbce76ec76c48097f79a6d6ae7e6ee67aff0c4cf
                index 1
            }
            script "[304402202c3a685e40e98df65fc45a3f504e4e4c4c00b4be56e2bba6ca9ae1e009a1180602205659957b593ff724fa69fab99729aa5981f5d86029b4198c61351735bad805f601] [033297c7e4f78310e53d9c732374267b4deeeb30b532bda0947e5269bffc3ceb4e]"
            sequence 4294967295
        }
    }
    lock_time 0
    outputs
    {
        output
        {
            address_hash d46ef5fd67873ccbe43cd71ac55c4c3b335213e5
            script "dup hash160 [d46ef5fd67873ccbe43cd71ac55c4c3b335213e5] equalverify checksig"
            value 4399900000
        }
        output
        {
            script "return [486170707920373774682042697274686461792053696c76657220466f780a]"
            value 0
        }
    }
    version 1
}
A slightly ugly process but it worked 3 years ago.
👍 1
This message was deleted.16:28
1 reply · neillm · last Dec 03, 2018
neillm02:09
Try testnet3 for now. I'm going to take mainnet1/testnet1 offline at some point this week for a hardware upgrade and will be restoring the libbitcoin stores from known good sources, which should also correct this. I'll update testnet2 after that is complete. Heads up will be coming at some point here (in this channel) before the upgrade. I don't expect downtime of more than a few hours.
jungly19:10
Interesting article by Jameson Lopp sharing his observations on synch performance of various implementations with full validation turned on. Curious to hear what others here make of it. “Bitcoin Full Validation Sync Performance” by Jameson Lopp https://link.medium.com/ChljI0YFiS
link.medium.com
A place where words matter
👍 1
29 replies · neillm, James C., jungly, evoskuil · last Dec 04, 2018
neillm21:59
Thanks for posting @jungly!
neillm22:02
I expect we'll be doing some more comparison tests of our own as version4 is closer to launch. ~5 hours for a core sync sounds way faster than anything I've experienced, although I hadn't tried a full sync on 0.17 ni particular yet
James C.11:53
Hm, why did he comment out all the checkpoints? I remember they are identical to core?
neillm13:17
For the full validation
neillm13:21
It sounds like he wants a "full_validation = true" option that ignores all checkpoints post genesis (?)
(edited)
neillm13:25
While that hypothetical option could be confusing (messing with checkpoints and they're not working because that option is set), it seemed it was difficult to remove the pre-populated checkpoints: "the hardest part was removing the hardcoded block checkpoints". Not sure, I don't find that so difficult, and perhaps now that he knows, it may not be as difficult (?)
(edited)
neillm13:29
The "recompiling for full validation" part confuses me. Anyone know what he means by that?
neillm13:30
Oh, unless he means switching between core consensus vs native(?). Actually, I'm curious if he used native consensus (I don't think it says, but maybe I missed that)
jungly13:31
Maybe he means rebuilding the stack from his fork with the his changes to take out checkpoints?
neillm13:38
Hrm, maybe, but there's no need for that since he can just edit the config, which he already did.
👍 1
jungly13:52
True. I misread what he was saying. Weird he had to rebuild. Maybe we should mention that on the tweet thread Check out @lopp’s Tweet: https://twitter.com/lopp/status/1068900532788563968?s=09
neillm13:54
Go for it, I don't tweet myself 😉
James C.16:26
Btw - does libbitcoin have a lax DER parser for pre bip66 signatures in earlier blocks? I guess it used to be openssl, but that isn’t a dependency obviously...
James C.18:10
Perfect thank you @neillm !
👍 1
evoskuil08:52
He apparently failed to recognize that providing a genesis only checkpoint eliminates all checkpoints. However this is non-consensus behavior, so not why it’s useful.
evoskuil08:54
Switching between use of libconsensus and native does not require a recompile.
evoskuil08:57
The way core gets “faster” is by not validating most of the chain by using “known good” blocks (our v4 milestones). If he didn’t disable this it’s not a reasonable comparison.
James C.09:10
What’s the difference between known-blocks and checkpoints?
evoskuil09:19
The later treat a hash mismatch at the height as invalid.
James C.09:23
Ah, so core just has a white-list of known subsequent header hashes it specifically fetches for the first n blocks?
evoskuil09:32
No, like checkpoints except that if they are not found they are ignored but if found allow skipping validation of ancestry.
👍 1
James C.09:38
Theoretically: If “known blocks” are not bound to a specific height, and no known blocks are found, does core begin to validate at genesis at some hard-coded height?
evoskuil09:38
It just validates after the last standard checkpoint.
evoskuil10:04
And they don’t have to be height bound but could be. The hash is identified via header sync and then all blocks prior can skip validation.
James C.10:11
Cool, think I get it: so it foregoes validation until it reaches the last “known” block, and otherwise resorts to most recent “known-block” or even checkpoint as a starting point for validation (Assuming these “known blocks” are all higher than checkpoints).
(edited)
James C.10:14
Just wondering when it “gives up” on finding all known-blocks if they aren’t bound to height…
evoskuil11:28
Logically you just check every strong chain header against milestones and when matched, treat the branch up to that point as prevalidated. In our implementation these are concurrent activities, but that just represents an implementation detail.
👍 1
James C.15:22
I like implementation details!
👍 1

Monday, December 3, 2018

James C.13:16
Hi @evoskuil: A general question about the transaction_database. When an unconfirmed tx is stored, the height field is set to validation_forks. Is this for the case of a reorg, where the new branch no longer satisfies certain fork activation criteria, so that the two branches don’t follow same fork_rules? (I couldn’t think of another scenario…). Thanks!
James C.13:25
Or @neillm?
evoskuil13:32
Yes
Since the tx is unconfirmed it could just be a new block that changes rules, not necessarily a reorg
James C.13:41
Ah yes, needn’t be reorg, thanks👍🏻, quite a few non-trivial scenarios which require consideration 🙂
K
kalifed14:41
A question about the protocol: I am trying to interact with my full node in order to receive new blocks and transactions. I managed to do the handshake (sending version and verrack). I receive all the new transactions from the node (inv message, to which I reply with a "getdata", and the node reply me back with the transaction) However I don't receive new blocks. The inv messages only contain transaction hash, no block hash. Any idea why?
Oh @James C. you replied to me on stackexchange 🙂
👍 1
James C.14:45
Sorry, I can’t think of any reason a peer would not share new headers/block inv messages if it is already propagating tx inv’s.
K
kalifed14:46
Maybe I should try connecting to another node then?
I only tried my own full node
6 replies · kalifed, James C. · last Dec 04, 2018
K
kalifed20:08
I can properly handshake (>version, <version, >verack, <verack). However after that I don't receive anything from the node. Is it normal?
James C.09:06
Did you receive ping messages?
James C.09:09
Those represent a bare minimum protocol to keep the channel alive. What version are you announcing to the peer? The version implies whether a pong response is expected.
K
kalifed10:39
I did not receive any ping message (I indeed reply to ping with pong). I did not receive anything from the node except version and verack.
K
kalifed10:40
I announce version 70015
K
kalifed10:41
Maybe that is the problem, because mainnet1.libbitcoin.net is 70013?

Tuesday, December 4, 2018

evoskuil08:52
replied to a thread: view
He apparently failed to recognize that providing a genesis only checkpoint eliminates all checkpoints. However this is non-consensus behavior, so not why it’s useful.
evoskuil08:57
replied to a thread: view
The way core gets “faster” is by not validating most of the chain by using “known good” blocks (our v4 milestones). If he didn’t disable this it’s not a reasonable comparison.
evoskuil09:19
replied to a thread: view
The later treat a hash mismatch at the height as invalid.
evoskuil09:32
replied to a thread: view
No, like checkpoints except that if they are not found they are ignored but if found allow skipping validation of ancestry.
👍 1
James C.09:38
replied to a thread: view
Theoretically: If “known blocks” are not bound to a specific height, and no known blocks are found, does core begin to validate at genesis at some hard-coded height?
evoskuil11:28
replied to a thread: view
Logically you just check every strong chain header against milestones and when matched, treat the branch up to that point as prevalidated. In our implementation these are concurrent activities, but that just represents an implementation detail.
👍 1

Wednesday, December 5, 2018

N
narodnik09:03
Also syncing the wallets is a strange thing to test
fetch times are the most important
evoskuil09:07
Yeah, query performance is clearly an order of magnitude more important if you are running a server or miner node. And we aren’t really good for full node consumer wallets, given hard shutdown corruption.
skaht21:45
Are their plans for v4 bx to have an output-set command to override default locking scripts with specified custom locking scripts? It is cool how v3 tx-encode examines output address formats and makes good guesses as to what the output script is most likely to be. However, v3 requires error prone manual editing TX to add more complex behaviors associated with OP_RETURN, OP_CHECKLOCKTIMEVERIFY, OP_CHECKSEQUENCEVERIFY or to take advantage of flow control.
evoskuil22:13
What’s a locking script? You meant the output script? ;) this is already possible.
Outputs can be set as arbitrary scripts.
Inputs are set via a distinct cmd only because of signing.
skaht22:16
I use locking script and output script interchangeably. Thanks for pointing out the easy way,
or a Base16 script
I overlooked that alternative means to set the script with the -o flag.
(edited)
skaht22:25
One more question concerning bx. With v3, how does one explicitly set the script version associated segwit?
evoskuil22:26
There is no witness support in bx.
skaht22:27
Aware of that. Was wondering if there is an interim hack.
evoskuil22:30
You can do what you want with scripts, but not set winesses.
skaht22:33
Like the witnesses pun. For example, a P2SH(P2WPKH) address can be computed using this % echo “0 [d5858d1e5e0f7f750d32cca66619f3385dc6c15b]” | bx script-to-address -v 5
382Db9auK4UrFCzWc15Tu8GGCv2RLfVkmc
Was hoping to see if I could synthesize associated witness scripts.
(edited)
Unclear how segwit influences script synthesis when contrasted to the way v3 encodes scripts.
evoskuil22:38
Witnesses aren’t scripts.
Otherwise scripts are just scripts.
skaht22:45
As Andreas says, there are block version, transaction versions, and versioning of scripts that was introduced during segwit architectural changes.
Is this versioning Andreas talks about really the new BIP 68 nSequence semantics?
(edited)
evoskuil22:56
It’s just data in scripts.
But must be a witness tx.
skaht23:11
Look at https://github.com/bitcoin/bips/blob/master/bip-0049.mediawiki#address-derivation. The scriptSig 0x16 prefix in BIP 49 confuses me. % echo “0 [aefc3905c26f851f8c319b0050d493fbc3e83a18]” | bx script-encode
0014aefc3905c26f851f8c319b0050d493fbc3e83a18
Was wondering if this is segwit version related?
evoskuil23:23
Looks like it.
skaht23:45
If the 0x16 is not a typo, I’m guessing a legacy spending wallet would not know to add that prefix while a segwit spending wallet will add the the prefix. Not sure how this will ultimately impact script-encode or tx-encode behaviors.

Thursday, December 6, 2018

N
narodnik13:20
Where are the conversion functions for satoshi -> string representation and vice versa?
Slackbot13:20
👻
N
narodnik13:20
slackbot just sent me a ghost icon
jungly13:21
It was probably sent to everyone
N
narodnik13:21
ok thanks, so... any idea where the functions are for conversion between decimal string and satoshi? ("2.141" -> 214100000)
Slackbot13:21
👻
jungly13:23
Probably in the bx repo. There's a btc-to-satoshi command.
Slackbot13:23
👻
N
narodnik13:31
oh right thanks
jungly13:33
Could this be it? https://github.com/libbitcoin/libbitcoin/blob/master/src/formats/base_10.cpp#L90 Seems like format_amount got replaced by encode_base10. But I am new here, so I might be wrong.
N
narodnik13:34
yes
it's the encode_base10 functions
thanks @jungly
jungly13:34
👍🏾
vdeurzen13:52
Does the bot trigger on the word satoshi ?
👍 1
Slackbot13:52
👻
vdeurzen13:52
yup 😜
neillm16:01
That's funny, I never knew that 😉
👍 1

Saturday, December 8, 2018

N
narodnik13:51
I just made a pull request
👍 2
N
narodnik20:29
@evoskuil I accidentally pushed by mistake
I thought I was pushing to my own branch
2 replies · evoskuil, narodnik · last Dec 09, 2018
evoskuil00:30
No worries, but I have comments on the non-test changes. I'll revert these portions and we can discuss on my PR.
N
narodnik22:29
ok
N
narodnik20:38
sorry about that... new pull request:

Sunday, December 9, 2018

skaht00:07
bitcoin.kn
To help you better understand Bitcoin the top people in the Bitcoin industry are interviewed by Trace Mayer for the Bitcoin Knowledge Podcast.
N
narodnik22:32
what do you think needs to change about bitcoin?
the direction or focus of the community
2 replies · jungly · last Dec 12, 2018
jungly09:04
That is a fascinating question @narodnik and very difficult for me to answer. But I'll try. I would, in my naive understanding, love to see more individual/home miners (probably a fantasy) and more use of btc for trading (again, probably a fantasy, given all the speculation around)
jungly06:47
I guess I am still only thinking of the technology. But privacy and fungibility are probably needed as badly as they ever were. I haven't looked into the dark wallet work this community is doing, but I was curious what people think of the wasabi wallet and the chaum mixers approach they have taken.

Monday, December 10, 2018

M
Mlmikael02:07
Guys, BIP 143 has a funny detail, what do you think of it? https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki When you make an endorsement for a segwit input witness to spend a P2WPKH output, the signtext part for the pubkey script of the output to be consumed is this: "The item 5: For P2WPKH witness program, the scriptCode is 0x1976a914{20-byte-pubkey-hash}88ac." I.e. the P2*PKH* pubkeyscript template (DUP HASH160 hash EQUALVERIFY CHECKSIG). What sense do you make of this choice? At least on first sight it looks a bit assymetrical to me. Gmaxwell provided the following clarifications which I feel didn't clarify at all also: "it is the implied pubkey. Because that is the actual public key in use. in the sense that that is the script that the network is actually validating. In general, it's advistable that signatures actually commit to their conditions, so they can't be rebound. Otherwise, I could potentially trick an application into signing for X when it's really signing for Y. (like if a user reused a key in different applications, foolishly) you can just think of it as the stored spk being compressed. the txout effectively is storing a compressed representation of the actual script. The actual script is OP_DUP OP_HASH160 x OP_EQUALVERIFY OP_CHECKSIG. but it wastes some blockchain space to encode all that, so instead only a version and x gets stored. The P2WPKH is just a compact encoding for the witness script I pasted above. You sign the actual script, rather than the compact encoding." Thoughts?
i don't see how this makes sense or makes anything more symmetrical, normally I'd have thought should be used here would be OP_0 OP_PUSHDATA 20byte-hash.
M
Mlmikael02:41
Ah, Maxwell clarified additionally eventually. What I understand him to mean is that, conceptually P2WPKH is P2PKH just with the signature in the witness instead. P2WPKH's nature is such that, when you endorse spending a P2WPKH output, then the pubkey script regarded is, conceptually, DUP HASH160 hash EQUALVERIFY CHECKSIG, and for this reason that's what an endorsement in a witness should sign. (He then goes on to make a separate point that the native P2WPKH pubkey script can be seen as "compressed" in the sense that OP_0 PUSHDATA [20B] is 22 bytes while DUP HASH160 hash EQUALVERIFY CHECKSIG is 25 bytes.) I guess that brought final clarification to it.

Wednesday, December 12, 2018

J
Julian08:03
Hello Libbitcoin! Is there a way to translate error codes to some broader categories. When using transaction_pool_broadcast function I'd like to detect if it failed because of a network error (e.g. I could not reach the libbitcoin-server) or if the transaction failed validation.
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?
neillm14:01
@here mainnet1/testnet1 and mainnet2/testnet2 will experience some downtime today for maintenance. This will not affect anyone using the mainnet.libbitcoin.net or testnet.libbitcoin.net DNS mappings, which currently point to mainnet3/testnet3, respectively. If you happen to be using mainnet1/mainnet2 directly, you will be affected until the servers are back online. I expect them to be down within the hour, and back up within a couple hours after that. Will update when they're back online and fully operational. testnet1/testnet2 v3 will be re-syncing from scratch and mainnet1/mainnet2 will be restored from a known good snapshot. Both will be updated with the latest version3 software.
2 replies · neillm · last Dec 13, 2018
neillm20:37
Quick update, this is taking much longer than originally expected, but everything should be back up in the next couple of hours 😉
neillm03:27
Servers are finally back up!
N
narodnik15:13
blogs.msdn.microsoft.com
C++ tutorials, C and C++ news, and information about the C++ IDE Visual Studio from the Microsoft C++ team.

Thursday, December 13, 2018

vdeurzen16:19
If I want to filter outputs based on whether they are p2pkh or p2wpkh, I can use the utilities: script::is_pay_key_hash_pattern(...) and script::is_witness_program_pattern(...) right?
neillm16:24
The first part is correct, but the second is not. It could return true for p2wsh also. Not sure if that matters for your use case.
N
narodnik16:25
made a pull request adding non const accessor to ec_point
1 reply · evoskuil · last Dec 13, 2018
evoskuil23:31
I’ve twice previously commented on this method. Can you address the comments in the last PR?
vdeurzen16:26
Well, I'm going to be receiving btc from unknown sources and I want to ensure that whatever comes does not have a script that prevents me from spending it some how (e.g. by requiring multiple signatures or by having another kind of custom script)
So, for further processing I want to initially just categorize the outputs into 'pay 2 pub key hash' and its segwit variant
neillm16:27
@vdeurzen You are providing the addresses for receiving, right?
vdeurzen16:27
yes
processing is currently split between 2 separate services, the first effectively just takes raw bitcoin blocks and transactions and pushes them to the next service through kafka. Currently the second service is responsible for filtering, so for that to be effective I have to provide the data tagged somehow. Though architecturally I'm not a 100% happy with this yet tbh
evoskuil23:31
replied to a thread: view
I’ve twice previously commented on this method. Can you address the comments in the last PR?

Sunday, December 16, 2018

Mr Hash11:57
@neillm hey i’ve added a couple of wiki pages to libbitcoin-server with JS client examples. I can’t pull request the wiki though so shall i send a git stash patch or something?
9 replies · neillm, Mr Hash · last Dec 17, 2018
neillm18:00
Cool, send me what you've got, I'd like to see it!
Mr Hash12:45
ok here’s a patch
js-wiki.patch Diff · 4.4 KB
diff --git a/Javascript-Query-Example.md b/Javascript-Query-Example.md
new file mode 100644
index 0000000..e333142
--- /dev/null
+++ b/Javascript-Query-Example.md
@@ -0,0 +1,75 @@
+### Fetch transaction:
+```js
+const zmq = require('zeromq');
+const pystruct = require('python-struct');
+const requester = zmq.socket('req');
+
+const endpoint = 'tcp://mainnet.libbitcoin.net:9091';
+
+requester.on('message', function(command, identifier, buffer) {
+  console.log(buffer.toString('hex').substr(8));
+  requester.close();
+});
+
+requester.setsockopt(zmq.ZMQ_RCVTIMEO, 5000);
+requester.setsockopt(zmq.ZMQ_SNDTIMEO, 5000);
+requester.connect(endpoint);
+
+const txhash = '60e030aba2f593caf913a7d96880ff227143bfc370d03dbaee37d582801ebd83';
+requester.send('blockchain.fetch_transaction2', zmq.ZMQ_SNDMORE);
+requester.send(pystruct.pack('I', 42), zmq.ZMQ_SNDMORE);
+requester.send(Buffer.from(txhash.match(/.{1,2}/g).reverse().join(''), 'hex'));
+
+```
+Output:
+```
+010000000181d06e4403b989d1e003def4944080e9537ef38e219f58a3856333050d72fe4a080000008b483045022100943e28772ef850587034b447a76c1eb918d63c82a4619a01a34cf32dee13807a02204cbe75c49f8ced0ebc373a6d8e7cb7ecab31369861d8997873b94bac13c379b3014104dbfb10dd8a498b3431f4c7041bbba82aa33146d40b7def4315e9e6df7424d527e762042f9fcc5450cbfc5f849bd3dace5cc9d9b3be8fadc3de92f96e303cf599ffffffff02a8101300000000001976a914b4dc57e35f93de9ec155872c1ad0136134fb08b188acbbe633000000000017a91461ec8bf07c6a3a04a08d1251d70178c1b3d273cc8700000000
+```
+
+### Fetch block header
+```js
+const zmq = require('zeromq');
+const pystruct = require('python-struct');
+const requester = zmq.socket('req');
+
full file
neillm19:17
Rather than a wiki page, maybe adding them to libbitcoin-server/data is appropriate, as that's where the python examples currently reside. Thoughts?
Mr Hash20:36
well there are a couple of examples in the wiki for python so i just copied that
Mr Hash20:36
but i don’t mind
Mr Hash20:36
i can add them as just js files
Mr Hash20:36
and submit a pull request
neillm20:37
Ah, you're right, I guess either way. It might be harder to keep the wiki documentation up to date than the files, although I expect they won't change that much
Mr Hash20:38
up to you, i’m easy either way, just let me know which you prefer
N
narodnik13:33
hello everyone MW impl written with libbitcoin in 2 weeks (excuse the bad code): https://github.com/narodnik/dtek/
👍 3
CoinDesk
Nym Technologies, a stealth startup sporting a roster of privacy activists and cryptography experts, plans "to anonymize the world."
👍 4
@evoskuil when is the next libbitcoin release? Is there a chance to rename
struct ring_signature { ... proof_list proofs; }
to
struct ring_signature { ... response_list responses; }
- calling that value the response is more standard that proof.
Otherwise we can make an alias and deprecate the old name using a union or something
evoskuil13:38
The change is not a compat problem prior to v4 release.
N
narodnik14:24
ok great I'll submit a pull request

Monday, December 17, 2018

phitsc20:07
Hello Everyone I posted to this Slack channel a while ago about the research I am currently conducting related to the usability of Bitcoin APIs. As I had mentioned, I am specifically looking into libbitcoin. This mainly for two reasons: on the one hand, C++ is the programming language I am most familiar with. On the other hand, the other noteworthy C++ implementation, i.e. Bitcoin Core, does not offer a C++ API per se (but an RPC JSON API, as I am sure all of you know). Although I am also planning to evaluate Bitcoin Core's C++ implementation if time allows, my research is primarily focusing on libbitcoin. I am studying for a Master in Computer and Information Security at the University of Liverpool and this is my final research project. This is an online programme; I am actually living in Switzerland. My project requires me to have an expert review my findings. I am, therefore, asking if one of the libbitcoin contributors among you would be willing to spend one to two hours of your time to review the relevant chapters of my dissertation and provide written feedback for me to cite in the dissertation report. My dissertation is due 6th of March 2019. I am planning to finish the chapters related to the libbitcoin API evaluation sometime in January 2019 but should be able to provide a draft by the end of the year. Your review would be required to reach me towards the end of January 2019. While I cannot offer any compensation for your help, I can offer to send pull requests related to any of my findings for you to merge or ignore at your discretion. Please let me know if you have further questions about my research. Thanks! Philipp
👍 2
8 replies · neillm, jungly, phitsc, evoskuil +1 · last Dec 18, 2018
neillm20:14
I could probably help out. Keep me posted.
😌 1
jungly20:17
Count me in too @phitsc. If you want to share any ideas on the methodology, I'll be happy to give some feedback on it too.
😌 1
phitsc20:40
This is just great guys! I really appreciate it!
phitsc20:40
As for the methodology, I am evaluating libbitcoin's API in relation to a subset of the API usability heuristics and guidelines defined by Mosqueira-Rey et al. (see reference further down). To help with this, I have implemented some of the guidelines in a static code analysis tool built using Clang Libtooling. As my hypothesis was (or is) that supporting usable security in Bitcoin APIs would help to protect against potential vulnerabilities in SW that uses such APIs, I had initially planned to analyse client SW that uses libbitcoin. However, I have not found many open source applications suitable for analysis, so I am focusing on the API and its usability now. I still have to analyse its use, as this is what my proposal says I will do, but I'll have to do with what's available, which is basically what comes with libbitcoin, i.e. libbitcoin-explorer, libbitcoin-node and libbitcoin-server. I think I found one or two others. Mosqueira-Rey, Eduardo, David Alonso-Ríos, Vicente Moret-Bonillo, Isaac Fernández-Varela, and Diego Álvarez-Estévez. “A Systematic Approach to API Usability: Taxonomy-Derived Criteria and a Case Study.” Information and Software Technology 97 (May 2018): 46–63. https://doi.org/10.1016/j.infsof.2017.12.010.
evoskuil21:18
Happy to help!
phitsc21:34
Thanks evoskuil! Very much appreciated!
vdeurzen10:45
also happy to contribute, although I'm primarily a user of libbitcoin, not a developer (yet) 🙂
phitsc20:22
Thanks vdeurzen. Your help is just as appreciated! 🙂

Wednesday, December 19, 2018

evoskuil04:22
The libbitcoin repo has been renamed to libbitcoin-system for v4 (in master). Github redirects all URLs from the old repo, so the wiki links and old builds are still good. I've noticed that I had to delete my own fork and recreate it in github in order for it to show properly as a fork. I haven't noticed any other problems.
👍 4
Revive16:36
Nice

Friday, December 21, 2018

skaht06:13
Is v4 going to enable tx-decode to expose witness info?
skaht21:50
Ah, I see in v3 it is the fetch-tx -w flag that gets the associated witness info from libbitcoin-server v3.4 or later.

Sunday, December 23, 2018

evoskuil00:43
Websockets code has been merged to mainnet/v4. great work @neillm!
👍🏾 2👍 2
1 reply · neillm · last Dec 23, 2018
neillm02:39
Thanks for the many rounds of review!
👍 3
jungly01:15
👏🏾 @neillm
👍 1
evoskuil03:04
There are no open pull requests and I've reviewed all recent issues.
👍 2
jungly08:34
Thanks @evoskuil
I have a general question about styles. I have gone through the styles wiki page, but I was wondering if any of you is using a config/settings file or a tool to conform to the style?
evoskuil11:32
No, just eyeball.
jungly11:35
Even no VS formatting! 🙇🏾
evoskuil12:00
Right. I’ve considered automation, but haven’t found anything that makes sense.
It’s clearly not as uniform as automation would be, and many of the inconsistencies bug me. But I try not to obsess about it :).
jungly12:11
You are totally right on watching out for the style. Consistency is important. It's just hard for a newcomer like me who is used to let the machine watch out for my inconsistencies. I am curious to find something that works on my setup (Emacs) and visual studio without too many external dependencies. I like the promise of clang-format, but as you said, it's hard to find something that makes sense for every setup. I'll keep you posted on what I find useful.
4 replies · neillm, jungly · last Dec 24, 2018
neillm21:53
I also use emacs and had chatted about clang-format at one point with @evoskuil. Workflow-wise, it would be nice for me, but we'd have to codify the style for it. Not sure about VS support. Good luck and keep us posted! :-)
jungly14:40
Messed around with clang-format a bit. It won’t conform 100% with the style in libbitcoin. Some rules that we just configure it for are 1. can’t force breaks before inheritance lists, unless they hit 80 col limit 2. it will put a break before the first parameter if call or function declaration exceeds 80 col limit 3. can’t config it to put a new line before lambda expressions Am sure there are some other rules it breaks too. As pros, it has excellent support for VS and emacs. For VS you can format a file explicitly or automatically on save. There is a ClangFormat extension for VS Code since last year.
(edited)
jungly14:45
In short, I don’t think we can use it to “enforce” a standard. But I might use it to sanity check my commits before creating PRs. To take some load of reviewers. I’ll ask it to format things for me and then massage away its non-conformant changes. The file I am going to use (and not add to a repo) is coming next
jungly14:52
I used the LLVM initial config and formatted it to - order include files as per the styles page - make brace wrapping as true to style as possible. (It still breaks for lambda expressions) - used bin packaging for args and params, but it creates another issue with putting all args/params on a new line - expression/statement alignment - breaks at binary operator - small misc other changes Would love any recommended changes/improvements to meet the style. Just hoping it’ll ease load on reviews, aka Eric! 😉
.clang-format Plain Text · 3.3 KB
---
Language:        Cpp
# BasedOnStyle:  WebKit
AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands:   false
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
BinPackArguments: true
BinPackParameters: true
BraceWrapping:   
  AfterClass:      true
  AfterControlStatement: true
  AfterEnum:       true
  AfterFunction:   true
  AfterNamespace:  false
  AfterObjCDeclaration: false
  AfterStruct:     true
  AfterUnion:      true
  AfterExternBlock: false
  BeforeCatch:     false
  BeforeElse:      true
  IndentBraces:    false
  SplitEmptyFunction: true
  SplitEmptyRecord: true
  SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
full file
evoskuil12:20
👍

Monday, December 24, 2018

vdeurzen11:16
Unless there is a very hard requirement for the exact style I think clang-format is a very nice solution. I use it in all projects, even though I don't always like the formatting, the fact I don't have to think about it at all is quite valuable 🙂
2 replies · neillm, vdeurzen · last Dec 24, 2018
neillm13:34
Well, we do have a project coding style, and you can codify custom styles using clang-format. It's just that someone would have to do that. And then be sure it works across platforms ;-). I may get to this eventually if no one else does, but other things tend to take priority.
👍 1
vdeurzen14:00
I can try to help with the style definition. Though I would recommend letting go of the existing style and simply restyling as close as possible to what you want 🙂 incrementally: -> touch a file for a change -> first reformat and commit it 🙂
Revive13:58
Wow what! Not one but two other emacs users? I thought I was the last living soul
1 reply · jungly · last Dec 24, 2018
jungly14:53
“Home is where .emacs is”
vdeurzen14:00
I too use emacs, but only for orgmode 🙂
Revive14:09
(((EmacsOS)))
(edited)
1 reply · neillm · last Dec 24, 2018
neillm14:26
Emacs, not EmacsOS please ;-)

Monday, December 31, 2018

evoskuil19:39
Happy New Year Libbitcoin!
🎉 5
jungly20:15
Happy new year! Coming soon to Italy too! Have a feeling it'll be an exciting year for libbitcoin!
👍 1🎉 1