Skip to content

tapyrusrb使い方ガイド作成#24

Open
oshikawatkm wants to merge 4 commits into
chaintope:masterfrom
oshikawatkm:feature/tapyrusrb_guide
Open

tapyrusrb使い方ガイド作成#24
oshikawatkm wants to merge 4 commits into
chaintope:masterfrom
oshikawatkm:feature/tapyrusrb_guide

Conversation

@oshikawatkm

Copy link
Copy Markdown
Contributor

#23 を作成しました。

Comment thread _pages/guide/tapyrusrb.md Outdated
title: "tapyrusrb ガイド"
---

この記事ではTapyruys rubyライブラリであるtapyrusrbの使用方法を解説します。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
この記事ではTapyruys rubyライブラリであるtapyrusrbの使用方法を解説します
この記事ではTapyruysのプロトコル用のrubyライブラリであるtapyrusrbの使用方法を解説します

Comment thread _pages/guide/tapyrusrb.md Outdated
- SchnorrとECDSAの鍵生成と検証(BIP-32とBIP-39のサポートを含む)
- ECDSA署名(RFC6979 -決定論的ECDSA, LOW-S, LOW-R対応)
- [WIP] SPVノード
- [WIP】0ff-chainプロトコル

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WIPの項目は削除しときましょう。

Comment thread _pages/guide/tapyrusrb.md Outdated

## セットアップ方法 {#setup}

### Level DBのインストール {#setup-leveldb}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Level DBはウォレット用に用意しようとしてたものなので、tapyrusrb自体の改修をしない限りインストールは不要です。

Comment thread _pages/guide/tapyrusrb.md Outdated
```

## RPC呼び出し {#rpc-call}
[TapyrusCoreClientモジュール](https://github.com/chaintope/tapyrusrb/blob/master/lib/tapyrus/rpc/tapyrus_core_client.rb){:target="_blank"}を用いることで、TapyrusCoreに対してRPC呼び出しを行なうことができます。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[TapyrusCoreClientモジュール](https://github.com/chaintope/tapyrusrb/blob/master/lib/tapyrus/rpc/tapyrus_core_client.rb){:target="_blank"}を用いることで、TapyrusCoreに対してRPC呼び出しを行なうことができます
[TapyrusCoreClientモジュール](https://github.com/chaintope/tapyrusrb/blob/master/lib/tapyrus/rpc/tapyrus_core_client.rb){:target="_blank"}を用いることで、Tapyrus Coreに対してRPC呼び出しを行なうことができます

Comment thread _pages/guide/tapyrusrb.md Outdated


## 鍵ペア作成 {#generate-keypair}
鍵ペアの作成には[Keyモジュール](https://github.com/chaintope/tapyrusrb/blob/master/lib/tapyrus/key.rb){:target="_blank"}を使用します。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
鍵ペアの作成には[Keyモジュール](https://github.com/chaintope/tapyrusrb/blob/master/lib/tapyrus/key.rb){:target="_blank"}を使用します
鍵ペアの作成には[Tapyrus::Key](https://github.com/chaintope/tapyrusrb/blob/master/lib/tapyrus/key.rb){:target="_blank"}クラスを使用します

Comment thread _pages/guide/tapyrusrb.md Outdated
```ruby
p2pkh_script = Tapyrus::Script.new << '032ad705d98318241852ba9394a90e85f6afc8f7b5f445675040318a9d9ea29e35' <<
Tapyrus::Script::OP_CHECKSIG
puts p2pkh_script

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これだとP2PKHじゃなくてP2PKですね。

Comment thread _pages/guide/tapyrusrb.md Outdated
032ad705d98318241852ba9394a90e85f6afc8f7b5f445675040318a9d9ea29e35 OP_CHECKSIG
```

### P2PH {#generate-script-p2sh}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### P2PH {#generate-script-p2sh}
### P2SH {#generate-script-p2sh}

Comment thread _pages/guide/tapyrusrb.md Outdated
```

### P2PH {#generate-script-p2sh}
P2PHもBitcoinと同様です。以下は1-of-2マルチシグの例です。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
P2PHもBitcoinと同様です。以下は1-of-2マルチシグの例です。
P2SHもBitcoinと同様です。以下は1-of-2マルチシグの例です。

Comment thread _pages/guide/tapyrusrb.md
key_pair2 = Tapyrus::Key.generate
p2sh_script = Tapyrus::Script.new << 1 << key_pair1.to_p2pkh << key_pair2.to_p2pkh << 2 << Tapyrus::Script::OP_CHECKMULTISIG
puts p2sh_script
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これだと、単にマルチシグのScriptでP2SHにはなってないです。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to_p2sh_multisig_scriptはマルチシグのP2SHのみを作るメソッドなので、普通にマルチシグのScriptをTapyrus::Scriptで構成して、その後to_p2shするのが良いかと思います。

Comment thread _pages/guide/tapyrusrb.md Outdated
サンプルコードは[こちら](https://github.com/chaintope/tapyrus-pages/scripts/tree/master/generate_script.rb){:target="_blank"}です。

## ScriptInterpreterによるスクリプトの評価 {#scriptInterpreter}
[ScriptInterpreterモジュール](https://github.com/chaintope/tapyrusrb/blob/master/lib/tapyrus/script/script_interpreter.rb){:target="_blank"}を使用します。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

最初にScriptInterpreterが何をするものなのか説明を追加してください。

@oshikawatkm oshikawatkm requested a review from azuchi August 19, 2022 06:34

@azuchi azuchi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LevelDBのインストール処理は不要です。

Comment thread _pages/guide/tapyrusrb.md Outdated

実行するとbooleanで検証結果が出力されます。
```
false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trueが返る例の方がいいですね。

Comment thread _pages/guide/tapyrusrb.md
key_pair2 = Tapyrus::Key.generate
p2sh_script = Tapyrus::Script.new << 1 << key_pair1.to_p2pkh << key_pair2.to_p2pkh << 2 << Tapyrus::Script::OP_CHECKMULTISIG
puts p2sh_script
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to_p2sh_multisig_scriptはマルチシグのP2SHのみを作るメソッドなので、普通にマルチシグのScriptをTapyrus::Scriptで構成して、その後to_p2shするのが良いかと思います。

@oshikawatkm oshikawatkm requested a review from azuchi August 19, 2022 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants