
var btc = require('bitcore-lib') var oldAddress = btc.Address.fromString("1Ek9S3QNnutPV7GhtzR8Lr8yKPhxnUP8iw") // here's the old address var oldHash = oldAddress.hashBuffer var segwitP2PKH = Buffer.concat([new Buffer("0014","hex"), oldHash]) // 0x00 + 0x14 (pushdata 20 bytes) + old pubkeyhash var p2shHash = btc.crypto.Hash.sha256ripemd160(segwitP2PKH) var p2shAddress = btc.Address.fromScriptHash(p2shHash) var newAddress = p2shAddress.toString() // 36ghjA1KSAB1jDYD2RdiexEcY7r6XjmDQk Using bitcore-lib.This p2sh address is the hash of the redeem script:00 14 96 c2 8f 5d 2d 22 00 a8 2b f3 f2 8d 3f 4f 5f 8c a3 8f 89 46Which is the segwit scriptPubkey to send a normal single sig transaction to a pubkey hash.All single sig software at the beginning will use this p2sh "3" address format until we can figure out a way to encode the segwit output into an address.To anyone who thinks "why not just change the way we make outputs and just keep the addresses the same?" the answer is "what happens if a person with a non-segwit old address gives you their address and your segwit software makes an output their software doesn't know how to spend?" or the opposite as well. Segwit wallets will need to check every utxo to see if it was sent using old output style or segwit output style. via /r/Bitcoin http://bit.ly/2giQ7e4
No comments :
Post a Comment