Created
August 24, 2019 09:49
-
-
Save kannapoix/45d3440c887c6b5d8c12e32bbe5040fb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# bip47 Pyament Code @ https://github.com/bitcoin/bips/blob/master/bip-0047.mediawiki#version-1 | |
# bitcoionrb @ https://github.com/chaintope/bitcoinrb | |
require 'bitcoin' | |
include Bitcoin | |
bip32_master = Bitcoin::ExtKey.generate_master('64dca76abc9c6f0cf3d212d248c380c4622c8f93b2c425ec6a5567fd5db57e10d3e6f94a2f6af4ac2edb8998072aad92098db73558c323777abf5bd1082d970a') | |
depth3 = bip32_master.derive(47, harden=true).derive(0, harden=true).derive(0, harden=true) | |
chain_code = depth3.chain_code | |
prefix = '47' | |
byte0 = '01' | |
byte1 = '00' | |
byte2 = '02' | |
byte3_34 = depth3.pub.slice(2...depth3.pub.length) | |
byte35_66 = chain_code.unpack('H*').first | |
byte67_79 = '0' * 26 | |
row_payment_code = prefix + byte0 + byte1 + byte2 + byte3_34 + byte35_66 + byte67_79 | |
base58_payment_code = Bitcoin::Base58.encode(row_payment_code + Bitcoin.calc_checksum(row_payment_code)) | |
p base58_payment_code |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment