Transcript for #bitcoin-dev 2018/04/19

07:17 nightcat hello.. I was going through recreating the process of address creation for learning and understanding sake.. I was looking at this https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses trying to follow steps in How to create bitcoin address.. I started by generating a private key with `openssl ecparam -genkey -name secp256r1..`
07:18 nightcat then created a corresponding public key in the form of an x509 cert
07:18 nightcat step 1 says Take the corresponding public key generated with it (65 bytes, 1 byte 0x04, 32 bytes corresponding to X coordinate, 32 bytes corresponding to Y coordinate)
07:19 nightcat but my public key coords don't seem to match these bitlenght constraint
07:19 nightcat am i on right tracks or not?
07:26 luke-jr nightcat: pretty sure secp256k1 is not secp256r1
07:28 nightcat oh it was secp256k1
07:28 nightcat thanks luke-jr
07:57 nightcat I generated another keypair with secp256k1.. luke-jr you know how to get x and y coords from this?
07:57 nightcat -----BEGIN PUBLIC KEY-----
07:57 nightcat MIH1MIGuBgcqhkjOPQIBMIGiAgEBMCwGByqGSM49AQECIQD/////////////////
07:57 nightcat //////////////////+///8LzAGBAEABAEHBEEEeb5mfvncu6xVoGKVzocLBwKb
07:57 nightcat AP////////////////////66rtzmr0igO7/SXozQNkFBAgEBA0IABMLCg6ktbJd6
07:57 nightcat 4fBsnZNPV+opaKvah0apa8yjsi7WbOfqDGOGk+rxnOioKse3S2zG2ILktFfwMt25
07:57 nightcat pWUDg9QLhpc=
07:57 nightcat -----END PUBLIC KEY-----
07:57 luke-jr nope
07:58 luke-jr btw, the instructions on that page are semi-wrong
07:58 nightcat I see.. you can suggest something better?
07:58 luke-jr Bitcoin Core source code maybe?
08:01 bedotech hi all! i want to build a online service that generate address from extended public key, is better to use backward compatibility P2SH-P2WPKH or i can use direct P2WPKH?
08:04 luke-jr nightcat: semi-updated it
08:05 luke-jr bedotech: don't ask users to put information like that into webpages..
08:06 nightcat I see.. so it's just the X coord now
08:06 nightcat anyway i think I got it
08:06 luke-jr bedotech: if you mean your own.. order of preference should probably be p2pkh, p2wpkh, p2sh-p2wpkh
08:06 luke-jr nightcat: the prefix byte is 03 instead of 04 also
08:07 luke-jr bedotech: but inevitably, what you do needs to conform to what your wallet expects
08:08 nightcat parsing the pubkey with openssl x509 -in device.pem -noout -pubkey openssl asn1parse i get this http://sprunge.us/EJab
08:08 bedotech luke-jr: yep the key are stored in my backed server, i generate address to make payment to my service, so i think is better p2sh-p2wpkh so the fee are limited and the old wallet can send payments to me
08:08 luke-jr bedotech: find out what your wallet supports; you can't just use whatever ;)
08:09 nightcat if it was still 65 byte I guess it would be the 75 field
08:09 luke-jr bedotech: old wallets can send payments to p2pkh too, btw. and they're better for the network.
08:10 luke-jr nightcat: probably. so just change the 04 to 03, and cut off the last 32 bytes
08:10 luke-jr nightcat: before using, test with testnet ;)
08:11 nightcat yea sure
08:11 nightcat thanks a lot
08:12 bedotech luke-jr: you have some reference wallet for this use? because i think for generate address in secure manner is better to use library that load only extended pubkeys, i see pycoin and bitcoinjs-lib
08:13 bedotech because i need to generate really a lot of address
08:14 luke-jr bedotech: no, I don't
08:14 luke-jr personally, I would just upload addresses into a database, not derive them
08:15 bedotech luke-jr: yeah you are right, but if you do so you always need to ask a 'remote' wallet and backup the wallet and you database.
08:16 bedotech for mantain user-address couple
08:19 luke-jr bedotech: you always need to backup that anyway, or you don't have customer info
08:19 luke-jr and don't ask the remote wallet; have the remote wallet push it
09:36 nightcat luke-jr, concerning step 0.. that is the X coord of the privkey?
12:56 plorark Hey guys
12:56 plorark wasup
12:57 plorark I'm looking for a js library to build a full wallet in nodejs (electron and stuff) for a bitcoin fork, but I can't find something good
12:57 plorark I've tried bitcore, but it so hard to change the network
12:57 plorark it just keep conecting to thhe default one
15:58 fluffypony unfortunately there's no shitcoin support here
15:58 fluffypony oh they left already
18:33 robzon I'm trying to figure out how bitcoin core handles chain reorgs with regards to the chain state database... if we're at height X (and the db reflects the state at that height) and I need to reorg at height X-Y, how does core roll back the db to the state at height X-Y? are there snapshots every now and then? is there a limit on how big Y can be?
18:56 jonasschnelli robzon: bitcoin core keeps those "undo" files
18:58 jonasschnelli robzon: check CChainState::DisconnectBlock() in Cores source code
19:06 robzon jonasschnelli: exactly what I was looking for, thanks!