-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add solana feat: add hardhat feat: add ord feat: add ganache feat: add defichain feat: add bitcoin chore: bump dependencies
- Loading branch information
Showing
58 changed files
with
4,768 additions
and
188 deletions.
There are no files selected for viewing
This file contains 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
{ | ||
"$schema": "https://chainfile.org/schema.json", | ||
"caip2": "bip122:000000000019d6689c085ae165831e93", | ||
"name": "Bitcoin Mainnet", | ||
"params": { | ||
"rpc_user": { | ||
"description": "Username for Basic HTTP authentication to the RPC server.", | ||
"secret": true, | ||
"default": { | ||
"random": { | ||
"bytes": 16, | ||
"encoding": "hex" | ||
} | ||
} | ||
}, | ||
"rpc_password": { | ||
"description": "Password for Basic HTTP authentication to the RPC server.", | ||
"secret": true, | ||
"default": { | ||
"random": { | ||
"bytes": 16, | ||
"encoding": "hex" | ||
} | ||
} | ||
} | ||
}, | ||
"volumes": { | ||
"data": { | ||
"type": "persistent", | ||
"size": "600Gi", | ||
"expansion": { | ||
"startFrom": "2024-01-01", | ||
"monthlyRate": "20Gi" | ||
} | ||
} | ||
}, | ||
"containers": { | ||
"bitcoind": { | ||
"image": "docker.io/kylemanna/bitcoind", | ||
"tag": "latest", | ||
"source": "https://github.com/kylemanna/docker-bitcoind", | ||
"endpoints": { | ||
"p2p": { | ||
"port": 8333 | ||
}, | ||
"rpc": { | ||
"port": 8332, | ||
"protocol": "HTTP JSON-RPC 2.0", | ||
"authorization": { | ||
"type": "HttpBasic", | ||
"username": { | ||
"$param": "rpc_user" | ||
}, | ||
"password": { | ||
"$param": "rpc_password" | ||
} | ||
}, | ||
"probes": { | ||
"readiness": { | ||
"method": "getblockchaininfo", | ||
"params": [], | ||
"match": { | ||
"result": { | ||
"type": "object", | ||
"properties": { | ||
"blocks": { | ||
"type": "number" | ||
} | ||
}, | ||
"required": ["blocks"] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"resources": { | ||
"cpu": 1, | ||
"memory": 2048 | ||
}, | ||
"environment": { | ||
"DISABLEWALLET": "1", | ||
"RPCUSER": { | ||
"$param": "rpc_user" | ||
}, | ||
"RPCPASSWORD": { | ||
"$param": "rpc_password" | ||
} | ||
}, | ||
"mounts": [ | ||
{ | ||
"volume": "data", | ||
"mountPath": "/bitcoin/.bitcoin" | ||
} | ||
] | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
import { CFContainer, CFTestcontainers } from '@chainfile/testcontainers'; | ||
import { afterAll, beforeAll, describe, expect, it } from '@workspace/jest/globals'; | ||
import waitFor from '@workspace/jest/wait-for'; | ||
|
||
import mainnet from './mainnet.json'; | ||
|
||
const testcontainers = new CFTestcontainers(mainnet); | ||
|
||
beforeAll(async () => { | ||
await testcontainers.start(); | ||
}); | ||
|
||
afterAll(async () => { | ||
await testcontainers.stop(); | ||
}); | ||
|
||
describe('bitcoind', () => { | ||
let bitcoind: CFContainer; | ||
|
||
beforeAll(() => { | ||
bitcoind = testcontainers.get('bitcoind'); | ||
}); | ||
|
||
it('should rpc(getblockchaininfo)', async () => { | ||
const response = await bitcoind.rpc({ | ||
method: 'getblockchaininfo', | ||
}); | ||
|
||
expect(response.status).toStrictEqual(200); | ||
|
||
expect(await response.json()).toMatchObject({ | ||
result: { | ||
bestblockhash: '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f', | ||
chain: 'main', | ||
}, | ||
}); | ||
}); | ||
|
||
it('should rpc(getblockcount)', async () => { | ||
const response = await bitcoind.rpc({ | ||
method: 'getblockcount', | ||
}); | ||
|
||
expect(response.status).toStrictEqual(200); | ||
|
||
expect(await response.json()).toMatchObject({ | ||
result: 0, | ||
}); | ||
}); | ||
|
||
it('should rpc(getblock)', async () => { | ||
const response = await bitcoind.rpc({ | ||
method: 'getblock', | ||
params: ['000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f', 2], | ||
}); | ||
|
||
expect(response.status).toStrictEqual(200); | ||
|
||
expect(await response.json()).toEqual({ | ||
error: null, | ||
id: expect.any(Number), | ||
result: { | ||
bits: '1d00ffff', | ||
chainwork: '0000000000000000000000000000000000000000000000000000000100010001', | ||
confirmations: 1, | ||
difficulty: 1, | ||
hash: '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f', | ||
height: 0, | ||
mediantime: 1231006505, | ||
merkleroot: '4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b', | ||
nTx: 1, | ||
nonce: 2083236893, | ||
size: 285, | ||
strippedsize: 285, | ||
time: 1231006505, | ||
tx: [ | ||
{ | ||
hash: '4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b', | ||
hex: '01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000', | ||
locktime: 0, | ||
size: 204, | ||
txid: '4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b', | ||
version: 1, | ||
vin: [ | ||
{ | ||
coinbase: | ||
'04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73', | ||
sequence: 4294967295, | ||
}, | ||
], | ||
vout: [ | ||
{ | ||
n: 0, | ||
scriptPubKey: { | ||
asm: '04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f OP_CHECKSIG', | ||
desc: 'pk(04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f)#vlz6ztea', | ||
hex: '4104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac', | ||
type: 'pubkey', | ||
}, | ||
value: 50, | ||
}, | ||
], | ||
vsize: 204, | ||
weight: 816, | ||
}, | ||
], | ||
version: 1, | ||
versionHex: '00000001', | ||
weight: 1140, | ||
}, | ||
}); | ||
}); | ||
|
||
describe.skip('synchronization', () => { | ||
// Takes too long to run and is not deterministic | ||
beforeAll(async () => { | ||
await waitFor(async () => { | ||
const response = await bitcoind.rpc({ | ||
method: 'getblockcount', | ||
params: [], | ||
}); | ||
|
||
const result = ((await response.json()) as any).result; | ||
expect(result).toBeGreaterThan(1); | ||
}, 30000); | ||
}); | ||
|
||
it('should bitcoind.rpc getblock(1)', async () => { | ||
const response = await bitcoind.rpc({ | ||
method: 'getblock', | ||
params: ['00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048'], | ||
}); | ||
|
||
expect(response.status).toStrictEqual(200); | ||
expect(await response.json()).toEqual({}); | ||
}); | ||
}); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "chainfile-bitcoin", | ||
"version": "0.0.0", | ||
"private": false, | ||
"repository": { | ||
"url": "git+https://github.com/fuxingloh/chainfile" | ||
}, | ||
"license": "MPL-2.0", | ||
"files": [ | ||
"*.json" | ||
], | ||
"scripts": { | ||
"lint": "eslint .", | ||
"test": "jest" | ||
}, | ||
"jest": { | ||
"preset": "@workspace/jest" | ||
}, | ||
"devDependencies": { | ||
"@chainfile/testcontainers": "workspace:*" | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
{ | ||
"$schema": "https://chainfile.org/schema.json", | ||
"caip2": "bip122:0f9188f13cb7b2c71f2a335e3a4fc328", | ||
"name": "Bitcoin Regtest", | ||
"params": { | ||
"rpc_user": { | ||
"description": "Username for Basic HTTP authentication to the RPC server.", | ||
"default": "user" | ||
}, | ||
"rpc_password": { | ||
"description": "Password for Basic HTTP authentication to the RPC server.", | ||
"default": "pass" | ||
} | ||
}, | ||
"volumes": { | ||
"data": { | ||
"type": "persistent", | ||
"size": "250Mi" | ||
} | ||
}, | ||
"containers": { | ||
"bitcoind": { | ||
"image": "docker.io/kylemanna/bitcoind", | ||
"tag": "latest", | ||
"source": "https://github.com/kylemanna/docker-bitcoind", | ||
"command": ["btc_oneshot", "-fallbackfee=0.00000200", "-rpcbind=:8332", "-rpcallowip=0.0.0.0/0"], | ||
"endpoints": { | ||
"p2p": { | ||
"port": 18445 | ||
}, | ||
"rpc": { | ||
"port": 8332, | ||
"protocol": "HTTP JSON-RPC 2.0", | ||
"authorization": { | ||
"type": "HttpBasic", | ||
"username": { | ||
"$param": "rpc_user" | ||
}, | ||
"password": { | ||
"$param": "rpc_password" | ||
} | ||
}, | ||
"probes": { | ||
"readiness": { | ||
"method": "getblockchaininfo", | ||
"params": [], | ||
"match": { | ||
"result": { | ||
"type": "object", | ||
"properties": { | ||
"blocks": { | ||
"type": "number" | ||
} | ||
}, | ||
"required": ["blocks"] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"resources": { | ||
"cpu": 0.25, | ||
"memory": 256 | ||
}, | ||
"environment": { | ||
"REGTEST": "1", | ||
"DISABLEWALLET": "0", | ||
"RPCUSER": { | ||
"$param": "rpc_user" | ||
}, | ||
"RPCPASSWORD": { | ||
"$param": "rpc_password" | ||
} | ||
}, | ||
"mounts": [ | ||
{ | ||
"volume": "data", | ||
"mountPath": "/bitcoin/.bitcoin" | ||
} | ||
] | ||
} | ||
} | ||
} |
Oops, something went wrong.