bitcoin-rubyでsegwitアドレスのエンコードとデコード/ bech32
環境
bitcoin-ruby v0.0.18
ruby v2.5
こんな感じ
bech32.rb
require 'bitcoin'
include Bitcoin
include Util
Bitcoin.network = :regtest
p Util.encode_segwit_address(0, '67c6df70223a3cfbf241e7551057001707d72af9')
# => "bcrt1qvlrd7upz8g70hujpua23q4cqzuraw2he97gtyc"
# encode_segwit_address('segwitのversion', 'pubkey-hash-20byte')
# pubkey-hash-20byte => ripemd160(sha256(pubkey))
p Util.decode_segwit_address('bcrt1qvlrd7upz8g70hujpua23q4cqzuraw2he97gtyc')
# =>[0, "67c6df70223a3cfbf241e7551057001707d72af9"]
もっとくわしく!
bech32.rb
require 'bitcoin'
include Bitcoin
include Util
Bitcoin.network = :regtest
p Util.encode_segwit_address(0, '67c6df70223a3cfbf241e7551057001707d72af9')
# => "bcrt1qvlrd7upz8g70hujpua23q4cqzuraw2he97gtyc"
# encode_segwit_address('segwitのversion', 'pubkey-hash-20byte')
# pubkey-hash-20byte => ripemd160(sha256(pubkey))
p Util.decode_segwit_address('bcrt1qvlrd7upz8g70hujpua23q4cqzuraw2he97gtyc')
# =>[0, "67c6df70223a3cfbf241e7551057001707d72af9"]
Author And Source
この問題について(bitcoin-rubyでsegwitアドレスのエンコードとデコード/ bech32), 我々は、より多くの情報をここで見つけました https://qiita.com/kanna/items/07598e426037ad4b0b8d著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .