-
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.
* update code for testing recovery script * chore: add log * sync header only if not equal current hash * update lib-js * remove cache block * update debug log * chore: update duckdb to v1.1.3 * chore: optimize get pending deposits * remove write block header to duckdb * update initialize of duckdb * update thread of duckdb * feat: split chunk query block height to reduce latency on querying pending deposits * update log * fix fetch simulate app cw bitcoin * chore: remove log * hot_fix: fix skipped scanning mempool txs * make webhook client is an optional * chore: update env.example
- Loading branch information
Showing
19 changed files
with
280 additions
and
331 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
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
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
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
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
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,14 @@ | ||
import { generateDepositAddress } from "."; | ||
|
||
const main = async () => { | ||
const result = await generateDepositAddress({ | ||
dest: { | ||
address: "orai1yzmjgpr08u7d9n9qqhvux9ckfgq32z77c04lkg", | ||
}, | ||
relayers: ["http://127.0.0.1:8000"], | ||
network: "bitcoin", | ||
}); | ||
console.log(result); | ||
}; | ||
|
||
main(); |
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
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
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
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 |
---|---|---|
@@ -1,57 +1,20 @@ | ||
import { AppBitcoinClient } from "@oraichain/bitcoin-bridge-contracts-sdk"; | ||
import { encodeXpub } from "@oraichain/bitcoin-bridge-wasm-sdk"; | ||
import BIP32Factory from "bip32"; | ||
import { OraichainConfig } from "src/configs/networks"; | ||
import { initSignerClient } from "src/utils/cosmos"; | ||
import * as ecc from "tiny-secp256k1"; | ||
import env from "../configs/env"; | ||
import { getCurrentNetwork } from "../utils/bitcoin"; | ||
import { DuckDbNode } from "../services/db"; | ||
import { TableName } from "../utils/db"; | ||
|
||
const main = async () => { | ||
let mnemonic = env.cosmos.mnemonic; | ||
const xpriv = ""; | ||
const bip32 = BIP32Factory(ecc); | ||
const node = bip32.fromBase58(xpriv, getCurrentNetwork("bitcoin")); | ||
let xpub = node.neutered().toBase58(); | ||
console.log("Initilizing DuckDB..."); | ||
await DuckDbNode.create(env.duckdb.name); | ||
console.log("Initilized DuckDB!"); | ||
console.log("Creating tables in DuckDB!"); | ||
await DuckDbNode.instances.createTable(); | ||
console.log("Tables are created in DuckDB!"); | ||
|
||
const { prefix, gasPrice } = OraichainConfig; | ||
const { sender, client } = await initSignerClient( | ||
env.cosmos.rpcUrl, | ||
mnemonic, | ||
prefix, | ||
gasPrice | ||
); | ||
const appBitcoinClient = new AppBitcoinClient( | ||
client, | ||
sender, | ||
env.cosmos.appBitcoin | ||
); | ||
let db = DuckDbNode.instances; | ||
|
||
const realXpub = await appBitcoinClient.signatoryKey({ | ||
addr: sender, | ||
}); | ||
console.log("Actually xpub:", { xpub }, "Expected xpub:", { xpub: realXpub }); | ||
const data = await db.select(TableName.RelayedSet, {}); | ||
|
||
const signTxs = await appBitcoinClient.signingTxsAtCheckpointIndex({ | ||
xpub, | ||
checkpointIndex: 52, | ||
}); | ||
let sigs = []; | ||
for (const signTx of signTxs) { | ||
const [msg, sigsetIndex] = signTx; | ||
|
||
const key = node.derive(sigsetIndex); | ||
const sig = key.sign(Buffer.from(msg)); | ||
sigs = [...sigs, Array.from(sig)]; | ||
} | ||
|
||
const tx = await appBitcoinClient.submitCheckpointSignature({ | ||
btcHeight: 875383, | ||
checkpointIndex: 52, | ||
sigs, | ||
xpub: encodeXpub({ key: xpub }), | ||
}); | ||
console.log(`Signed checkpoint ${52} at ${tx.transactionHash}`); | ||
console.log(data); | ||
}; | ||
|
||
main(); |
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
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
Oops, something went wrong.