Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encode&decode #11

Open
hychang23 opened this issue Aug 9, 2016 · 58 comments
Open

encode&decode #11

hychang23 opened this issue Aug 9, 2016 · 58 comments

Comments

@hychang23
Copy link

現在要處理的是在交易中能encode&decode所加上去的東西

@iblis17 :
誰可以跟我解釋 tx 裡的 Script 是啥?
我猜這個 function ScriptPubKeyToJSON 是 encode

@iblislin
Copy link
Member

iblislin commented Aug 9, 2016

@iblislin
Copy link
Member

iblislin commented Aug 9, 2016

https://en.bitcoin.it/wiki/Script 找個人看完,沒人要看再跟我說

@hychang23
Copy link
Author

我先看 https://en.bitcoin.it/wiki/Script

@iblislin
Copy link
Member

iblislin commented Aug 9, 2016

https://en.bitcoin.it/wiki/Contract 看起來這就是說明怎麼應用?

@hychang23
Copy link
Author

我覺得Contract這篇比較像在講概念說可以用腳本寫一些應用

@iblislin
Copy link
Member

iblislin commented Aug 9, 2016

聽起來就是我們要的?

@hychang23
Copy link
Author

看起來是應用3較相關
另外Scrip那篇有看沒有懂耶 第2部分的範例看不太懂

@iblislin
Copy link
Member

iblislin commented Aug 9, 2016

@HuaYang-Chang 這禮拜找個時間當面聽你解釋?

@hychang23
Copy link
Author

可以阿 看你哪時方便再跟我說一下

@iblislin
Copy link
Member

iblislin commented Aug 9, 2016

@HuaYang-Chang 三下午之後都可

@hychang23
Copy link
Author

好阿 我在207 下午會跟老師meeting

@iblislin
Copy link
Member

/me 2 點後到

@mchliu
Copy link

mchliu commented Aug 17, 2016

@iblis17
華洋找到了null data transaction的寫法

https://bitcointalk.org/index.php?topic=453086.0
裡面的#19處

目前好像是可以把data放入交易了
BUT
不知道怎麼把放進去的Data取出來
需要你神來一筆

@iblislin
Copy link
Member

不是有個 decode transaction 的 api?

@iblislin
Copy link
Member

明天找個時間用 skype 來看看好了

@iblislin
Copy link
Member

decoderawtransaction 的話會看到啥

@hychang23
Copy link
Author

ok了 有成功 我們是用getrawtransaction

@hychang23
Copy link
Author

hychang23 commented Aug 19, 2016

./bitcoin-cli listunspent
找一個txid和相對應的vout

bitcoin-cli createrawtransaction '[{"txid":"from listunspent","vout":0}]' '{"data":"將要傳的data轉成hex","要給的address":$$}'
return hex-encoded transaction in a string (are not signed)

./bitcoin-cli signrawtransaction hex-encoded transaction in a string
return 'Returns json object with keys'

./bitcoin-cli sendrawtransaction raw transaction with signature(s) (hex-encoded string)
return txid

./bitcoin-cli getrawtransaction txid 1
returns a JSON Object containing information about the transaction
data會在OP_RETURN裡面

@iblislin
Copy link
Member

(Y) 現在的資料量 可以放多少字?

@hychang23
Copy link
Author

目前是80bytes

@iblislin
Copy link
Member

那麼 超過 80 bytes 怎麼辦?

@hychang23
Copy link
Author

sendrawtransaction那邊會出錯
error code: -26
error message:
64: scriptpubkey

@iblislin
Copy link
Member

想個方法存超過 80 bytes 吧?

不過那筆交易是怎麼存到 block 裡面的?給手續費?

@mchliu
Copy link

mchliu commented Aug 24, 2016

@iblis17
yep
交易一定要有錢
EX: 拿一個50元
放DATA
給自己49.999
差價就是手續費給掉

老師現在要我們想辦法可以爬data下來分析
是不是要寫爬蟲還什麼東西
給個方向吧俊頤大大

@iblislin
Copy link
Member

iblislin commented Aug 24, 2016

老師現在要我們想辦法可以爬data下來分析

有更多細節嘛?分析啥

@mchliu
Copy link

mchliu commented Aug 24, 2016

@iblis17
細節是?

就是可能在DATA裡面存評價訊息
例如:
劉銘騏 麥當勞 3分 太油太膩

然後要把資料從BLOCK CHAIN裡面撈出來

@iblislin
Copy link
Member

這不是之前就做完了?

@mchliu
Copy link

mchliu commented Aug 24, 2016

@iblis17
撈出來放到資料庫之類的地方
要做統計或是查詢用的

我們只是可以看到裡面的東西
不知道怎麼把它通通抓出來

@iblislin
Copy link
Member

大概的想法:

  1. 找出 api: 怎麼 iter 過所有的 blocks
  2. block 裡應該有 transaction id

@mchliu
Copy link

mchliu commented Aug 25, 2016

@iblis17
意思是先想辦法掃過所有block嗎

那請問一下要怎麼紀錄下那些txid?

@iblislin
Copy link
Member

先看看 api 了, 記在哪裡啥的都還好,先抓到記在 memory

@mchliu
Copy link

mchliu commented Aug 25, 2016

@iblis17
不知道要用什麼記阿 :/

@iblislin
Copy link
Member

@mchliu 用個 arrray 存,就是存在 memory 中,總之先拿到資料,後續再考慮存在哪裡。

@iblislin
Copy link
Member

你要用啥語言都沒關係,總之用該語言的 premitive type 就會在 memory 中了

@mchliu
Copy link

mchliu commented Aug 25, 2016

@iblis17
有笨方法
就x=getblockhash 1
然後getblock x
然後一路掃下去
好像沒有直接掃全部的API

@iblislin
Copy link
Member

iblislin commented Aug 25, 2016

@mchliu
很好啊,下個問題想:有沒有 programmable 的 api?

我是在想 bitcoin-cli 是實作了 json rpc 的 client ,他底下也是去問 bitcoind 的 rpc api。 我們需要的是 知道 bitcoind 的 rcp api 怎麼 call,然後實作隻 client 程式 拿到 json response。

https://en.bitcoin.it/wiki/API_reference_(JSON-RPC)

這裡有 sample @mchliu 去吧 就是你了

@iblislin
Copy link
Member

想寫 python 嗎

@mchliu
Copy link

mchliu commented Aug 25, 2016

@iblis17
找到了
listsinceblock
會把某block之後的tx通通列出

可以啊我都沒寫過

@iblislin
Copy link
Member

(Y) try it out

@mchliu
Copy link

mchliu commented Aug 25, 2016

@iblis17
然後實作隻 client 程式 拿到 json response。
HOW?

@iblislin
Copy link
Member

@mchliu
Copy link

mchliu commented Aug 30, 2016

@iblis17
所以是要先弄
http://json-rpc.org/wiki/python-json-rpc
這東西嗎

可以請你解釋一下這東西在幹嘛嗎
毫無頭緒阿阿啊阿啊阿啊

@iblislin
Copy link
Member

python-jsonrpc is the official JSON-RPC implementation for Python. It automatically generates Python methods for RPC calls. However, due to its design for supporting old versions of Python, it is also rather inefficient. jgarzik has forked it as Python-BitcoinRPC and optimized it for current versions. Generally, this version is recommended.

那麼就用 Bitcoin-RPC 吧

@mchliu
Copy link

mchliu commented Aug 30, 2016

@iblis17
Bitcoin-RPC是指?
Python-BitcoinRPC?

@iblislin
Copy link
Member

哦對

@mchliu
Copy link

mchliu commented Aug 30, 2016

@iblis17
他抓不到我扔在bitcoin.conf的username跟password阿阿阿阿阿阿
完全卡住

@mchliu
Copy link

mchliu commented Aug 30, 2016

@iblis17
經過一波折是可以用python叫bitcoin的API了俊頤大大
你什麼時候會回LAB?

@iblislin
Copy link
Member

@mchliu 我在 313

@mchliu
Copy link

mchliu commented Aug 30, 2016

@iblis17
原來噢....
以後要找你就上去找你是嗎哈

@iblislin
Copy link
Member

ok

@hychang23
Copy link
Author

@mchliu
Copy link

mchliu commented Sep 8, 2016

@iblis17
我們到時候會需要一些功能
想問你一下那些是我要寫出來還是你通通都會搞定
例如
要知道所有票的分布
Ex: sort by ticket amount
20 01user765
16 01user58
16 01user631
.
.
.
.

然後還要可以抓下個別演唱會的私下交易以及金額
例如01user334 用 6000 元 買下了 01user456 的 A區票 2張
(票的類別會紀錄在data裡面)

然後還有一開始的拍賣完畢後 發出票根給所有得票者的部分

這些有哪些是我可以做的還是你通通要搞定阿
我很願意幫忙阿阿俊頤大大

@iblislin
Copy link
Member

iblislin commented Sep 8, 2016

要知道所有票的分布

誰有票的資訊 不是記錄在 block chain 上?那麼就給我 blockchain 的 api call

然後還要可以抓下個別演唱會的私下交易以及金額

私下交易, blockchain 有記錄嗎?

然後還有一開始的拍賣完畢後 發出票根給所有得票者的部分

我需要 transaction 的 api

@mchliu
Copy link

mchliu commented Sep 9, 2016

txid會在block內
access.getblockhash(blocknum)可得第N個block的hash
access.getblock(blockhash)裡面有各個txid
用access.getrawtransaction('txid')就可以看

私下交易會有紀錄
簡單來說A賣票給B就是
把A的UTXO寄給B (一樣要用createrawtransaction,因為要選擇UTXO而且要把放在裡面的data(票的資訊)跟token(票)一起傳送過去)

傳送transaction的包含create sign send
查詢的是get 還有listsinceblock
網址裡面應該都有了
是另外需要什麼呢?

@mchliu
Copy link

mchliu commented Sep 9, 2016

@iblis17
忘了TAG你哈

@iblislin
Copy link
Member

iblislin commented Sep 9, 2016

私下交易會有紀錄
簡單來說A賣票給B就是
把A的UTXO寄給B (一樣要用createrawtransaction,因為要選擇UTXO而且要把放在裡面的data(票的資訊)跟token(票)一起傳送過去)

私下交易也必須在手機上完成?

然後這個 project 的 dead line 是何時?

@mchliu
Copy link

mchliu commented Sep 11, 2016

@iblis17

我們是想說買方掃賣方QR CODE(包含自己要賣的價錢資訊)
然後用信用卡或比特幣付款
然後票就到買方手上了

不太確定deadline哈
我跟學妹確認過再跟你講
阿如果有哪裡幫得上忙儘管說
又麻煩你了不好意思哈

@mchliu
Copy link

mchliu commented Sep 11, 2016

@iblis17
最慢最慢應該是十月底吧我猜
11月要比賽要demo
可是應該先有東西比較穩一點

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

No branches or pull requests

3 participants