-
Notifications
You must be signed in to change notification settings - Fork 0
feat: don't process sanctioned BTC and SUI address #336
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
Merged
rmeena840
merged 4 commits into
master
from
323-workers-dont-process-sanctioned-addresses
Feb 12, 2026
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
2,486 changes: 2,122 additions & 364 deletions
2,486
packages/block-ingestor/worker-configuration.d.ts
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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,46 @@ | ||
| import { Transaction, payments, script } from "bitcoinjs-lib"; | ||
| import { logError } from "@gonative-cc/lib/logger"; | ||
| import { BtcNet } from "@gonative-cc/lib/nbtc"; | ||
| import { btcNetworkCfg } from "./models"; | ||
| import type { Input } from "bitcoinjs-lib/src/transaction"; | ||
|
|
||
| function extractAddressFromInput(input: Input, btcNetwork: BtcNet): string | null { | ||
| try { | ||
| const network = btcNetworkCfg[btcNetwork]; | ||
|
|
||
| if (input.witness && input.witness.length >= 2) { | ||
| const pubKey = input.witness[1]; | ||
| const { address } = payments.p2wpkh({ pubkey: pubKey, network }); | ||
| return address || null; | ||
| } | ||
|
|
||
| const scriptSig = input?.script; | ||
| if (scriptSig && scriptSig.length >= 65) { | ||
| const chunks = script.decompile(scriptSig); | ||
| if (!chunks) return null; | ||
|
|
||
| const pubKey = chunks[chunks.length - 1] as Buffer; | ||
| const { address } = payments.p2pkh({ pubkey: pubKey, network }); | ||
| return address || null; | ||
| } | ||
|
|
||
| return null; | ||
| } catch (e) { | ||
| logError({ method: "extractAddressFromInput", msg: "Failed to extract address" }, e); | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| export async function extractSenderAddresses( | ||
rmeena840 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| tx: Transaction, | ||
| btcNetwork: BtcNet, | ||
| ): Promise<string[]> { | ||
rmeena840 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (tx.ins.length === 0) return []; | ||
|
|
||
| const addresses: string[] = []; | ||
| for (const input of tx.ins) { | ||
| const addr = extractAddressFromInput(input, btcNetwork); | ||
| if (addr) addresses.push(addr); | ||
| } | ||
| return addresses; | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,5 @@ | ||
| CREATE TABLE IF NOT EXISTS sanctioned_addresses ( | ||
| address TEXT NOT NULL, | ||
| chain INTEGER NOT NULL, -- 0 - bitcoin, 1 - sui | ||
| PRIMARY KEY (address, chain) | ||
| ) STRICT; |
This file contains hidden or 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 hidden or 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,11 +1,17 @@ | ||
| import { D1Storage } from "./storage"; | ||
| import { logger, logError } from "@gonative-cc/lib/logger"; | ||
| import { updateSanctionedAddress } from "./sanction"; | ||
|
|
||
| // Export RPC entrypoints for service bindings | ||
| export { RPC } from "./rpc"; | ||
|
|
||
| export default { | ||
| async scheduled(_event: ScheduledController, env: Env, _ctx: ExecutionContext): Promise<void> { | ||
| // TODO: run DB updates | ||
| const storage = new D1Storage(env.DB); | ||
| logger.debug({ msg: "Cron job starting" }); | ||
rmeena840 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| try { | ||
| await updateSanctionedAddress(env.DB); | ||
| logger.info({ msg: "Cron job finished successfully" }); | ||
rmeena840 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } catch (e) { | ||
| logError({ msg: "Cron job failed", method: "scheduled" }, e); | ||
| } | ||
| }, | ||
| } satisfies ExportedHandler<Env>; | ||
This file contains hidden or 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,22 +1,15 @@ | ||
| import { WorkerEntrypoint } from "cloudflare:workers"; | ||
|
|
||
| import { D1Storage } from "./storage"; | ||
| import type { | ||
| ConfirmingRedeemReq, | ||
| RedeemRequestEventRaw, | ||
| RedeemRequestResp, | ||
| FinalizeRedeemTx, | ||
| } from "@gonative-cc/lib/rpc-types"; | ||
| import type { ComplianceRpc } from "@gonative-cc/lib/rpc-types"; | ||
|
|
||
| /** | ||
| * RPC entrypoint for the worker. | ||
| * | ||
| * @see https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/rpc/ | ||
| */ | ||
| export class RPC extends WorkerEntrypoint<Env> { | ||
| // TODO: check if we can use a proper type for address instead of string | ||
| async isBtcBlocked(btcAddrs: string[]): Promise<boolean> { | ||
| export class RPC extends WorkerEntrypoint<Env> implements ComplianceRpc { | ||
| async isBtcBlocked(btcAddresses: string[]): Promise<Record<string, boolean>> { | ||
| const storage = new D1Storage(this.env.DB); | ||
| return storage.isBtcBlocked(btcAddrs); | ||
| return storage.isBtcBlocked(btcAddresses); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.