-
Notifications
You must be signed in to change notification settings - Fork 241
Feature/add firo network #584
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
Open
narekpetrosyan
wants to merge
113
commits into
enkryptcom:develop
Choose a base branch
from
firoorg:feature/add-firo-network
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
113 commits
Select commit
Hold shift + click to select a range
f3dde22
devop: merge
kvhnuke 0d16daa
feature: add firo network spark address generation and vew functional…
narekpetrosyan e36e2d3
feature: add transparent -> spark address fund sending functionality
narekpetrosyan 643b114
feature: add send from spark to spark address functionality
narekpetrosyan ce6ed47
[WIP]: add wasm handler
narekpetrosyan e9ad83c
fix balance preview for Firo chain, add anonymize funds functionality
narekpetrosyan 51d3fef
add socket electrumx client interactions
narekpetrosyan 1820efd
added TODO for loading wasm in worker
narekpetrosyan e64272b
PK remaining
narekpetrosyan 12d8523
PK fix errors
narekpetrosyan ad52556
add DB sync for metas, fix wasm script loading 2 times
narekpetrosyan 20037b4
change wasm to modularized
narekpetrosyan e3199ce
fix coin processing
narekpetrosyan ad77bac
save processed coin value sum in DB
narekpetrosyan 37f89c8
spark balance calculation
narekpetrosyan 6fa0e37
refactor: fix append data
narekpetrosyan 140167e
crate hardcoded txData
VahanSargsyan 1f54a66
add spark tx
VahanSargsyan b1376b0
add get coins tags methods
VahanSargsyan 47dd4ff
Fix spark send and public send actions: FIRO
narekpetrosyan 1e23aaf
Merge remote-tracking branch 'firo/feature/add-firo-network' into fea…
VahanSargsyan f6970bf
Add TX activity history after sending from Spark address
narekpetrosyan b78b5cf
Merge pull request #1 from firoorg/feature/from-spark-tx-activity
narekpetrosyan 9853950
Disable activity when spark to spark transaction is failed or dropped
narekpetrosyan 62217a9
add coin tags handling
VahanSargsyan 92a5520
Merge remote-tracking branch 'firo/feature/add-firo-network' into fea…
VahanSargsyan ad138ff
Merge pull request #2 from firoorg/feature/disable-activity-when-fail…
narekpetrosyan 9569d29
Merge remote-tracking branch 'firo/feature/add-firo-network' into fea…
VahanSargsyan 166e5af
add coins set sync handler
VahanSargsyan c8b7129
Minor changes
narekpetrosyan b1de5db
move tags update to sync
VahanSargsyan 5f01994
move tags update to sync
VahanSargsyan 1489fa3
Add synchronization logic for sets and tags
narekpetrosyan a4956f7
Merge pull request #3 from firoorg/feature/sync-tags-and-sets
narekpetrosyan ddebcf0
Add synchronization logic for sets and tags
narekpetrosyan 47be2db
Fix tags append issue, fix coin calculation issue
narekpetrosyan 716490d
Merge pull request #4 from firoorg/feature/spark-balance-calculation
narekpetrosyan da156e6
Add spark address generation
narekpetrosyan 6ee1c2e
Move all axios calls to electrum
narekpetrosyan 03a9e7f
fix spark tx
VahanSargsyan 45ced19
Merge pull request #5 from firoorg/feature/spark-address-generation
narekpetrosyan f12af42
Minor fix
narekpetrosyan 8e9a2cd
Fix transparent to transparent transaction
narekpetrosyan 642e421
fix merge conflicts
narekpetrosyan 178e17a
Merge remote-tracking branch 'firo/feature/add-firo-network' into fea…
VahanSargsyan 0b598b0
Minor fix
narekpetrosyan 9f1d697
fix UI new tab button
VahanSargsyan db4b702
Merge remote-tracking branch 'firo/feature/add-firo-network' into fea…
VahanSargsyan c95f159
Merge remote-tracking branch 'firo/feature/add-firo-network' into fea…
VahanSargsyan c867060
Merge remote-tracking branch 'firo/feature/add-firo-network' into fea…
VahanSargsyan 3d278fb
fix tests
VahanSargsyan 26d3189
Fix Vue warnings
narekpetrosyan 66af092
Merge remote-tracking branch 'origin/feature/add-firo-network' into f…
narekpetrosyan 4cda38c
Fix activity view and confirm send to spark transaction view
narekpetrosyan ae7a1d9
Fix activity view and confirm send to spark transaction view
narekpetrosyan 0206ae7
Merge remote-tracking branch 'firo/feature/add-firo-network' into fea…
VahanSargsyan ca09ac0
hide spark send tabs
VahanSargsyan 33bc01c
Merge branch 'develop' into feature/add-firo-network
VahanSargsyan cdca95c
hide Full Screen button
VahanSargsyan 4e667a5
coderabbit suggestions
narekpetrosyan 6941111
Add _free memory executions for generateSparkWallet
narekpetrosyan 35d8e3d
Clean up allocated memory in generateSparkWallet
narekpetrosyan 49e5b62
Fix
narekpetrosyan 42e1c8c
Fix free memory
narekpetrosyan 60368ac
fix: error that occurred when executing two Spark transactions in a row.
VahanSargsyan 83e0a62
feat: get mint and spend activities from tags and hashes.
VahanSargsyan 117e432
Fix processing modal appearance, refactor sendAction in send from spa…
narekpetrosyan 835763c
Merge pull request #7 from firoorg/fix/modal-appearance
VahanSargsyan 3a20136
Fix activities appearance and saving in activity state
narekpetrosyan aa4848f
fix: bulk coins status write in db
VahanSargsyan 06eb5de
Merge pull request #8 from firoorg/fix/show-activity
narekpetrosyan 86fa8c5
Merge remote-tracking branch 'firo/feature/add-firo-network' into fea…
VahanSargsyan 4743d5d
fix: coin check functionality
VahanSargsyan dc23193
fix: anonymitySet sector getting bug
VahanSargsyan 1ef2261
Save last found coin set id in DB
narekpetrosyan f7c344e
Remove coin info worker manipulations
narekpetrosyan be3abd6
Add coin synchronizing
narekpetrosyan 7a4204a
Add coin synchronizing with modal and separate states
narekpetrosyan 72bfcbd
Merge pull request #9 from firoorg/lastcoinsetid-into-db
narekpetrosyan 2a703d2
fix: anonymity set update order
VahanSargsyan 71862d1
Merge remote-tracking branch 'firo/feature/add-firo-network' into fea…
VahanSargsyan ff912c9
Fix get balance
narekpetrosyan 002012d
Add anonymize functionality
narekpetrosyan bfcda3a
fix: anonymity set update order
VahanSargsyan f042e1d
Merge pull request #10 from firoorg/fix/fix-prod-bugs
VahanSargsyan b6bb483
Merge remote-tracking branch 'firo/feature/add-firo-network' into fea…
VahanSargsyan 39f9494
Revert "Fix get balance"
narekpetrosyan 237a55f
add: value to received spark transaction activity
VahanSargsyan d8c955b
Minor changes
narekpetrosyan 65ba42f
Merge branch 'feature/add-firo-network' into revert-10-fix/fix-prod-bugs
narekpetrosyan 0e923d6
Merge pull request #11 from firoorg/revert-10-fix/fix-prod-bugs
narekpetrosyan 2a128df
Fix activity state and add reset DB on reset
narekpetrosyan d6b4e08
Merge pull request #12 from firoorg/feature/fix-activity-state
VahanSargsyan 208cd42
fix: private balance check on new wallets
VahanSargsyan db6d501
Merge remote-tracking branch 'firo/feature/add-firo-network' into fea…
VahanSargsyan 913dba8
feat: filter firo accounts
VahanSargsyan 0c5cac2
Show compatible accounts on Firo, show only spark addresses
narekpetrosyan ab10fd5
fix: firo accounts filtering
VahanSargsyan 188dfd2
1. Accounts list show spark addresses
narekpetrosyan 418048f
Remove redundant code, show inactive accounts addresses
narekpetrosyan 138662e
Merge pull request #13 from firoorg/bugfix/test-bugs
narekpetrosyan 5396d08
Fix sending from spark spend utxo
narekpetrosyan 339884d
fix: spark to transparent transaction
VahanSargsyan 4bc47c8
Minor fix
narekpetrosyan 6828efa
Merge remote-tracking branch 'firo/feature/add-firo-network' into fea…
VahanSargsyan 0e58ba0
Fix activity state value representation
narekpetrosyan 270c141
Optimize coin updates and balance calculation logics
VahanSargsyan 1362fcf
Merge pull request #794 from enkryptcom/develop
kvhnuke fc944d4
Fix data inconsistency issue
narekpetrosyan 258de8e
Fix merge conflicts with main
narekpetrosyan f641bb5
Fix test cases
narekpetrosyan c06b438
Free WASM pointers in getMintTxData and getSparkCoinInfo
narekpetrosyan 954bb4b
fix(spark): allocate WASM buffer for serialContext using its own length
cursoragent 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
There are no files selected for viewing
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 |
|---|---|---|
|
|
@@ -119,3 +119,4 @@ dist | |
|
|
||
| # IDE | ||
| .history | ||
| .idea | ||
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,2 @@ | ||
| **/*.js | ||
| **/*.d.ts |
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,3 @@ | ||
| export const SPARK_TX_TYPE = 9; | ||
|
|
||
| export const LOCK_TIME = 999999; |
53 changes: 53 additions & 0 deletions
53
packages/extension/src/libs/spark-handler/createTempFromSparkTx.ts
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,53 @@ | ||
| import * as bitcoin from 'bitcoinjs-lib'; | ||
| import { LOCK_TIME, SPARK_TX_TYPE } from '@/libs/spark-handler/constants'; | ||
| import { isSparkAddress } from '@/providers/bitcoin/libs/utils'; | ||
| import BigNumber from 'bignumber.js'; | ||
|
|
||
| interface CreateTempFromSparkTxArgs { | ||
| network: bitcoin.networks.Network; | ||
| to: string; | ||
| amount: string; | ||
| } | ||
|
|
||
| interface CreateTempFromSparkTxResult { | ||
| txHashSig: string; | ||
| additionalTxSize: number; | ||
| } | ||
|
|
||
| export const createTempFromSparkTx = async ({ | ||
| network, | ||
| amount, | ||
| to, | ||
| }: CreateTempFromSparkTxArgs): Promise<CreateTempFromSparkTxResult> => { | ||
| const isSparkTransaction = await isSparkAddress(to); | ||
| const tempTx = new bitcoin.Transaction(); | ||
| tempTx.version = 3 | (SPARK_TX_TYPE << 16); | ||
| tempTx.locktime = LOCK_TIME; | ||
| tempTx.addInput( | ||
| Buffer.alloc(32, 0), | ||
| 4294967295, | ||
| 4294967295, | ||
| Buffer.from('d3', 'hex'), | ||
| ); | ||
|
|
||
| const baseTempTxBuffer = tempTx.toBuffer(); | ||
|
|
||
| if (!isSparkTransaction) { | ||
| tempTx.addOutput( | ||
| bitcoin.address.toOutputScript(to, network), | ||
| new BigNumber(amount).multipliedBy(10 ** 8).toNumber(), | ||
| ); | ||
| } | ||
|
|
||
| const fullTempTxBuffer = tempTx.toBuffer(); | ||
| const extendedTempTxBuffer = Buffer.concat([ | ||
| fullTempTxBuffer, | ||
| Buffer.from([0x00]), | ||
| ]); | ||
|
|
||
| const txHash = bitcoin.crypto.hash256(extendedTempTxBuffer); | ||
| return { | ||
| txHashSig: txHash.reverse().toString('hex'), | ||
| additionalTxSize: fullTempTxBuffer.length - baseTempTxBuffer.length, | ||
| }; | ||
| }; |
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,79 @@ | ||
| import { validator } from '@/providers/bitcoin/libs/firo-wallet/base-firo-wallet'; | ||
| import BigNumber from 'bignumber.js'; | ||
| import * as bitcoin from 'bitcoinjs-lib'; | ||
| import { ECPairInterface } from 'ecpair'; | ||
|
|
||
| interface CreateTempTxArgs { | ||
| network: bitcoin.networks.Network; | ||
| changeAmount?: BigNumber; | ||
| mintValueOutput: { | ||
| script: Buffer<ArrayBuffer>; | ||
| value: number; | ||
| }[]; | ||
| inputs: { | ||
| hash: string; | ||
| index: number; | ||
| nonWitnessUtxo: Buffer<ArrayBuffer>; | ||
| }[]; | ||
| spendableUtxos: { | ||
| keyPair: ECPairInterface; | ||
| address: string; | ||
| txid: string; | ||
| vout: number; | ||
| scriptPubKey: string; | ||
| amount: number; | ||
| satoshis: number; | ||
| confirmations: number; | ||
| }[]; | ||
| addressKeyPairs: Record<string, any>; | ||
| } | ||
|
|
||
| export const createTempTx = ({ | ||
| network, | ||
| inputs, | ||
| spendableUtxos, | ||
| addressKeyPairs, | ||
| mintValueOutput, | ||
| changeAmount, | ||
| }: CreateTempTxArgs) => { | ||
| const tx = new bitcoin.Psbt({ network }); | ||
| tx.setVersion(2); | ||
|
|
||
| inputs.forEach(input => { | ||
| tx.addInput(input); | ||
| }); | ||
|
|
||
| mintValueOutput.forEach(mint => { | ||
| tx.addOutput({ | ||
| script: mint.script, | ||
| value: mint.value, | ||
| }); | ||
| }); | ||
|
|
||
| if (changeAmount && changeAmount.gt(0)) { | ||
| const firstUtxoAddress = spendableUtxos[0].address; | ||
|
|
||
| tx.addOutput({ | ||
| address: firstUtxoAddress!, | ||
| value: changeAmount.toNumber(), | ||
| }); | ||
| } | ||
|
|
||
| for (let index = 0; index < spendableUtxos.length; index++) { | ||
| const utxo = spendableUtxos[index]; | ||
| const keyPair = addressKeyPairs[utxo.address]; | ||
|
|
||
| const Signer = { | ||
| sign: (hash: Uint8Array) => { | ||
| return Buffer.from(keyPair.sign(hash)); | ||
| }, | ||
| publicKey: Buffer.from(keyPair.publicKey), | ||
| } as unknown as bitcoin.Signer; | ||
|
|
||
| tx.signInput(index, Signer); | ||
| } | ||
| tx.validateSignaturesOfAllInputs(validator); | ||
| tx.finalizeAllInputs(); | ||
|
|
||
| return tx.extractTransaction(); | ||
| }; | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signing loop assumes
inputsandspendableUtxosare 1:1 aligned — no guard.The loop iterates over
spendableUtxosindices and callstx.signInput(index, ...), but inputs are added from the separateinputsarray. Ifinputs.length !== spendableUtxos.length, this will sign wrong indices or throw at runtime. Additionally,addressKeyPairs[utxo.address]can beundefined, causing an NPE onkeyPair.sign.Proposed fix — add guards
for (let index = 0; index < spendableUtxos.length; index++) { const utxo = spendableUtxos[index]; const keyPair = addressKeyPairs[utxo.address]; + if (!keyPair) { + throw new Error(`Missing key pair for address: ${utxo.address}`); + } const Signer = {📝 Committable suggestion
🤖 Prompt for AI Agents