Bitcoin: stratum mining protocol

f2pool

telnet stratum.f2pool.com 3333

---> send
{"id": 1, "method": "mining.subscribe", "params": []}
---> receive
{"id":1,"result":[[["mining.notify","mining.notify"],["mining.set_difficulty","mining.set_difficulty"]],"00",8],"error":null}

---> send
{"id": 2, "method": "mining.authorize", "params": ["user", "password"]}

---> receive
{"id":null, "method":"mining.set_difficulty","params":[8192]}

---> receive
{
    "id":null,
    "method":"mining.notify",
    "params":[
        "B9OwZ1S45VrRdA68xCxngG",
        "e39dc0f699f5bf79b23a35801a0a1671679730f00013003b0000000000000000",
        "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff640308c8082cfabe6d6d59958fc389ffe84f8de80adef133f4877c91c42d1b756e1010b2f736273afdbe10000000f09f909f000d4d696e6564206279207573657200000000000000000000000000000000000000000000000000000000000005",
        "032b48d04f000000001976a914c825a1ecf2a6830c4401620c3a16f1995057c2ab88ac00000000000000002f6a24aa21a9ed993f69ddd8c50685546580c8113d40b7a21ccc17e732526509e4bd27c4c2d9d608000000000000000000000000000000002c6a4c2952534b424c4f434b3a99a95af280c7ba1ef071f96a8223a55ac1f4620a7fb6a705f02dd39580e8817e85800238",    [ "1cb14b15ad78009fea8ef638ac2e81236bf0c973c485541284385c4e5f3e7b67",          "7a6252c0ce8fec6d7703de7226aa0448e4377e9a3fe3c8cc0889ea12bb48143a",     "7c6dfe82ce417f79d20c45ed00c83220058da34888b4896f2a685e2ed89dbc85",            "21bc8c3b360cd73d2e2c00b47a2f3298c3233c7e8f515633d78551dbdf69f2b1",            "64ec37e39297c602d9ebf8d52f5bcaba337619e90d672f5642daba0f372ede8f",          "1d7655bd14c4a4cda74553fab127e2bf191409f7a9278d58a0653d3256c92046",            "c0f44808ea765496520f2475afb33c7930c9c64a10aff1ebb4a80f80a3fae634",            "921a9fb324d88f1f2e4a70a197158e7db71cc4de136826da92d5caee01d8cfd1",            "bbf71595776349a4934c43dde29b2e4a2913266b79a2bad62d23b1df6e518998",
"d3bbf2b07b6cd269d0ac21fd606d824b120a655e6e6fe9621cf91a4470cc8a45",            "ffb56fff2e4020e6b018a6f2db5520724920227afb4d8fdfe143cbbae5bab840",
"4a7825dcc1cbdc35d42dd26e981a616b224ccbd77007c5b66c387f9e13064513"
        ],
        "20000000",
        "1729ff38",
        "5cd64e36",
        false
    ]
}

poolin

telnet btc.ss.poolin.com 443

{"id": 1, "method": "mining.subscribe", "params": []}

{"id": 2, "method": "mining.authorize", "params": ["user", "password"]}

---> receive
{
    "id":null,
    "method":"mining.notify",
    "params":[
        "0rDDRrGgEqI-NR[.PO([7{p&2Hb(j=DTEx71Da-co5b)o",
        "99796469c24811de787cdd924d8cef33c38b59d5001097650000000000000000",
        "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff5f0309c808048d55d65c2f706f6f6c696e2e636f6d2ffabe6d6d9c5496e662f7ce02877e9d34dda9fffc5562f5055fbfa765ab5c1312f5f78d9e0100000000000000a38ec2cba86b18aec5758639a92e7b600fc6048b29",
        "ffffffff02b6740b51000000001976a9142b0c6a29dbf71c6dab00639c17c5010b707c9df588ac0000000000000000266a24aa21a9edcf880eadcdf18acdfbdb8a03a66816610183cedc6559329744aa53bc7952926dfd4adc9b",
        [
            "6eec11d83bc7212adaedfe3f705b0b96e4546889d02e125cd53b7b36e1a2d282",
            "cd6e5b0ec9e9c7cbef1e25e18815adfed80b3c3b4b153cb61c224c914688cb37",
            "b8133eed5cd409f3f2dd29559b717f86c25e03479bc5af14dba9af19919ebc9d",
            "2e093a6e029724e8402851949216234d38dba971267a1064fd462eb7405be8a5",
            "af66a3a25996904ee91187f28b02ddfb9a2db3bc3c8a8ce03db5257234ed8ff8",
            "0f2c1f3aae955a283f2416e894d1c44b20234ba343861f383891b1bef685f65e",
            "e34f3663b0a4cf60d4decb4477b61b25d6ecec39d3d1775d6701a94f5ad606cd",
            "e0086bab0f4197dd94ed101ef3a0970dad189db590a2da9871e6f66ba7a2b00b",
            "5bfecd86dcc9cd03c92e81b0ed6656ba5fdefa67d5db0f70a88f7154fa8369d8",
            "bc81e6330426ecda7ba9ea5e5bdfa3affa716b32f33c0662afaa9d1355a619fb",
            "7f8f63f202120482a7e0aab623506728b2332d323852d004cecafec1119a2943",
            "e9c40ef8d6395ecac1d0d9e7892cc558973becf4a18670470dab8d061c047848"
        ],
        "20000000",
        "1729ff38",
        "5cd6558c",
        false
    ]
}

flypool

telnet cn1-zcash.flypool.org 3333
---> send
{"id": 0, "method": "mining.subscribe", "params": ["zec.f2pool.com", 3357, "zcash/1.0", "1"]}

{"id": 0, "method": "mining.subscribe", "params": ["cn1-zcash.flypool.org", 3333, "zcash/1.0", "1"]}

---> result
{"id":0,"result":["3476b2b74c", "3476b2b74c"], "error": null}

---> send
{"id": 1, "method": "mining.authorize", "params": ["t1WSHqAC7Zi5XmCeS4RJozUSVxvzFZ3Gruc", "shooter01"]}

---> result

{"id":null,"method":"mining.notify","params":["65ce77a81d2156427a61","04000000","0adb71f7df928dda4a0c3cf433cf4e237f504204a8effd60cbec755900000000","59be4ec49e49cd416bb0d0b980748847aa2f4aa8e41cc3b7384da8413b140118","0000000000000000000000000000000000000000000000000000000000000000","4a3f0c59","f24a6f1c",true]}

{"id": null, "method": "mining.notify","params": ["JOB_ID", "VERSION", "PREVHASH", "MERKLEROOT", "RESERVED", "TIME", "BITS", CLEAN_JOBS]}

slushpool

telnet stratum.slushpool.com 3333

python code

def each_slice(arr, n):
  return [arr[i:i + n] for i in range(0, len(arr), n)]

def getprevhash(prev):
  items = each_slice(prev, 8)
  items.reverse() # 直接修改items,没有返回值
  prevhash = "".join(items)
  print("prevhash: " + prevhash)

raw_prev = "e39dc0f699f5bf79b23a35801a0a1671679730f00013003b0000000000000000"
getprevhash(raw_prev) # 00000000000000000013003b679730f01a0a1671b23a358099f5bf79e39dc0f6


参考:

https://en.bitcoin.it/wiki/Stratum_mining_protocol
https://bitcoin.stackexchange.com/a/23112
https://www.f2pool.com/help
https://github.com/slush0/stratum-mining
https://github.com/sumory/BTC
https://github.com/btccom/btcpool
https://gist.github.com/YihaoPeng/254d9daf3a5a80131507f32be6ed92df
https://www.jianshu.com/p/797401d8a80e

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 204,732评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 87,496评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 151,264评论 0 338
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,807评论 1 277
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,806评论 5 368
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,675评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,029评论 3 399
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,683评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 41,704评论 1 299
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,666评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,773评论 1 332
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,413评论 4 321
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,016评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,978评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,204评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,083评论 2 350
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,503评论 2 343

推荐阅读更多精彩内容