Code Monkey home page Code Monkey logo

js-wallet-sdk's Introduction

js-wallet-sdk

This is a typescript/javascript language wallet solution that supports offline transactions. We currently support various mainstream public blockchains, and will gradually release the source codes for each blockchain.

Npm Install

To obtain the latest version, simply require the project using npm:

# needed for all coins
npm install @okxweb3/crypto-lib
npm install @okxweb3/coin-base

# for eth
npm install @okxweb3/coin-ethereum

# for bitcoin
npm install @okxweb3/coin-bitcoin

Build Locally

You can build the sdk locally ,and run test-code.

sh build.sh

Supported chains

Account Generation Transaction Creation Transaction Signing
BTC
Ethereum
Aptos
Cosmos
Eos
Flow
Stacks
Starknet
Sui
Tron
Osmosis
Cardano

*BTC: Supports Supports BRC20-related functions, including inscription creation, BRC20 buying and selling.

Main modules

  • crypto-lib: Handles general security and signature algorithms.
  • coin-base: Provides coin common interface.
  • coin-*: Implements transaction creation and signature in each coin type.

Example

For specific usage examples of each coin type, please refer to the corresponding test files. Remember to replace the placeholder private key with your own private key, which is generally in hex format.

Feedback

You can provide feedback directly in GitHub Issues, and we will respond promptly.

License

Most packages or folders are MIT licensed, see package or folder for the respective license.

js-wallet-sdk's People

Contributors

debuggor avatar hjguang2018 avatar larry-a4 avatar luyishisi avatar lwwl-123 avatar thinpanda avatar yanminmin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

js-wallet-sdk's Issues

Can you please explain how to handle the double spending vulnerability in the doginals protocol for the dog chain?

The contributions of OKX in the field of blockchain are well-known among players and professionals. Therefore, when we learned that OKX is about to support the dog chain with the doginals protocol, which is a legitimate protocol, our team decided to establish a targeted trading market with a background in Dogecoin mining. We have been conducting research in this area for the past month. However, we heard rumors about a double spending vulnerability in the verydogelabs indexing method supported by OKX. During our research, we discovered some evidence supporting these rumors, indicating that some individuals have already taken advantage of this vulnerability in several existing markets, resulting in the loss of millions of Dogecoins. We would like to hear OKX's response and discuss how to address this vulnerability. If this issue is not resolved before the launch of OKX's web3 wallet or if we proceed with establishing a trading market without addressing the vulnerability, it could lead to significant losses for players and even affect OKX's reputation.

We have discovered several dozen addresses on the doggy.market trading platform that are exploiting a double-spending vulnerability by utilizing the verydogelabs index to continuously obtain free DRC20 tokens. These addresses then list these tokens for sale on the market, and each address is making substantial profits. Currently, the trading volume on the doggy market is not significant, but once DRC20 is listed on OKX, we can expect a significant increase in traffic and trading volume. At that point, it will become challenging to control the situation. Moreover, DRC20 has more potential than BRC20, with a larger player base, faster transaction speeds, and lower fees. Once this issue is resolved, we believe OKX will lead this sector comprehensively and be at the forefront of the industry.

Here are some addresses we found from several existing doginals trading markets,The owners of these addresses exploited the double spending vulnerability to acquire a large amount of dog chain doginals and then sell them on the market. These addresses have no minting records or purchase records; they only have records of receiving transfers and selling. Furthermore, these addresses represent only a portion of the issue. We have investigated the communities associated with some doginals and found no evidence of over-the-counter (OTC) trades; they were only traded on the market. Additionally, some players have reported losing a significant amount of their doginals, further confirming the existence of the double spending vulnerability. Currently, our technical team is attempting to verify the vulnerability by testing if our own addresses can be exploited. We hope that OKX will also test and resolve the double spending vulnerability before the launch of the DRC20, as this is crucial.

Issue with DRC-20 Index (doginals) and it's resolution by DPal developer who originally created DRC-20 minting service wallet in early 2023

Please consider the updated DRC-20, Doginals index as well that is provided by the DPal wallet who provided the first inscription wallet services in DRC-20 doginals back in early last year. In the updated DRC-20 index it has handled the issues with security vulnerability, Sybil attack, witch nodes and double spending that were not taken care during initial DRC-20 Doginals index. Public GitHub for the updated DRC-20, Doginals index as below 👇

https://github.com/dogexme/dogim-indexer

Please note that $dogim has killed the witch nodes of $dogi inscription/token from DRC-20, doginals.

Auth issue

I encountered { msg: 'Invalid Request Access uri', code: '50125' }. I have checked everywhere but no documentation for this

Q: stacks-coin Account listing available?

Stacks has the concept of an Account array in their wallet. I see that I can generate new addresses with coin-stacks, but is there a way to see a list of accounts/addresses that have already been created for a specific seed?

For reference: https://github.com/hirosystems/stacks.js/tree/main/packages/wallet-sdk#generate-a-wallet

interface Wallet {
  /** Used when generating app private keys, which encrypt app-specific data */
  salt: string;
  /** The private key associated with the root of a BIP39 keychain */
  rootKey: string;
  /** A private key used to encrypt configuration data */
  configPrivateKey: string;
  /** The encrypted secret key */
  encryptedSecretKey: string;
  /** A list of accounts generated by this wallet */
  accounts: Account[];
}

How can I find this Account[] with coin-stacks?

@okxweb3/crypto-lib using vulnerable packages

Our recent security audit discovered that @okxweb3/crypto-lib which is used by @okxweb3/coin-bitcoin is using an outdated crypto-js version that has a critical vulnerability. Also, jsrsasign has a high severity vulnerability.

Screenshot 2024-04-25 at 2 18 29 PM

when i use coin_bitcoin generateUnSignedBuyingPsbt, i got error

my code:

var buyerUnsignedPsbt = generateUnsignedBuyingPsbt(
        {
            dummyUtxos: [
                {
                    txHash: "9407ee3ca389977c4601932d5c289c4bfb2cbb0ca1347db3975da972f0b7675c",
                    vout: 3,
                    coinAmount: 600,
                    rawTransation: "02000000046c54ac5365e70a1583ca55b70d8b7ebf4f647d8d28319c0b77864b5100eebe42030000006a4730440220111c7c0555efa1884cbbc68cbeaaaf1c4d4b8cc42124705a2c72bf840936fe0702205541c9b15e7dfa7e59ed58f1772d9e278cdb26ea2537ccc36c1ebe2e8eafca30012103b48aee4a6dec95c0e98e5dc31737bdd46b220b79f804a96d93eb06c1b71270efffffffff6c54ac5365e70a1583ca55b70d8b7ebf4f647d8d28319c0b77864b5100eebe42040000006a47304402206a3d77f7a308372e68c96a9af2da2cb7616adb07345bea177a5393aefaf76e55022078dba32b9cd290fdc81222b8f544e2b01870144d11eb01c18e57046161d9ef76012103b48aee4a6dec95c0e98e5dc31737bdd46b220b79f804a96d93eb06c1b71270efffffffff5bc2b84087be9443beba9c8727889975c4b5441cd32ede35f976671c8c1b4e48000000006a47304402205d61563d73fcf92ef5470e4f27a396bc54c76da265cba19b472f9204363f4b620220221f52f99a9e92da5b52e62c18e798fc2c49a2933dcdea6feb8039c5fd00a981832102406cd7e5d61e4c27c7eddcb22af0019bd46c9250bd571bd750075678a84b3378ffffffff6c54ac5365e70a1583ca55b70d8b7ebf4f647d8d28319c0b77864b5100eebe42050000006b483045022100e3c67697aab787de677c7e74b79a03889dd8108ed943f07015d10ff0a52a9a8f022035cba2783f79fd4a06d84d3c74471b27c32cb2e1811df93edcb1ea3452c629da012103b48aee4a6dec95c0e98e5dc31737bdd46b220b79f804a96d93eb06c1b71270efffffffff06b0040000000000001976a914d85290e927b8e20b1e48dbfeac9d8ea4c9a9955088ac22020000000000001976a914d85290e927b8e20b1e48dbfeac9d8ea4c9a9955088ac404b4c00000000001976a9142080c44ce0c1ad69e49b11e364b45848cf3da8cc88ac58020000000000001976a914d85290e927b8e20b1e48dbfeac9d8ea4c9a9955088ac58020000000000001976a914d85290e927b8e20b1e48dbfeac9d8ea4c9a9955088acb053f204000000001976a914d85290e927b8e20b1e48dbfeac9d8ea4c9a9955088ac00000000"
                },
                {
                    txHash: "9407ee3ca389977c4601932d5c289c4bfb2cbb0ca1347db3975da972f0b7675c",
                    vout: 4,
                    coinAmount: 600,
                    rawTransation: "02000000046c54ac5365e70a1583ca55b70d8b7ebf4f647d8d28319c0b77864b5100eebe42030000006a4730440220111c7c0555efa1884cbbc68cbeaaaf1c4d4b8cc42124705a2c72bf840936fe0702205541c9b15e7dfa7e59ed58f1772d9e278cdb26ea2537ccc36c1ebe2e8eafca30012103b48aee4a6dec95c0e98e5dc31737bdd46b220b79f804a96d93eb06c1b71270efffffffff6c54ac5365e70a1583ca55b70d8b7ebf4f647d8d28319c0b77864b5100eebe42040000006a47304402206a3d77f7a308372e68c96a9af2da2cb7616adb07345bea177a5393aefaf76e55022078dba32b9cd290fdc81222b8f544e2b01870144d11eb01c18e57046161d9ef76012103b48aee4a6dec95c0e98e5dc31737bdd46b220b79f804a96d93eb06c1b71270efffffffff5bc2b84087be9443beba9c8727889975c4b5441cd32ede35f976671c8c1b4e48000000006a47304402205d61563d73fcf92ef5470e4f27a396bc54c76da265cba19b472f9204363f4b620220221f52f99a9e92da5b52e62c18e798fc2c49a2933dcdea6feb8039c5fd00a981832102406cd7e5d61e4c27c7eddcb22af0019bd46c9250bd571bd750075678a84b3378ffffffff6c54ac5365e70a1583ca55b70d8b7ebf4f647d8d28319c0b77864b5100eebe42050000006b483045022100e3c67697aab787de677c7e74b79a03889dd8108ed943f07015d10ff0a52a9a8f022035cba2783f79fd4a06d84d3c74471b27c32cb2e1811df93edcb1ea3452c629da012103b48aee4a6dec95c0e98e5dc31737bdd46b220b79f804a96d93eb06c1b71270efffffffff06b0040000000000001976a914d85290e927b8e20b1e48dbfeac9d8ea4c9a9955088ac22020000000000001976a914d85290e927b8e20b1e48dbfeac9d8ea4c9a9955088ac404b4c00000000001976a9142080c44ce0c1ad69e49b11e364b45848cf3da8cc88ac58020000000000001976a914d85290e927b8e20b1e48dbfeac9d8ea4c9a9955088ac58020000000000001976a914d85290e927b8e20b1e48dbfeac9d8ea4c9a9955088acb053f204000000001976a914d85290e927b8e20b1e48dbfeac9d8ea4c9a9955088ac00000000"
                }
            ],
            paymentUtxos: [
                {
                    txHash: "9407ee3ca389977c4601932d5c289c4bfb2cbb0ca1347db3975da972f0b7675c",
                    vout: 5,
                    coinAmount: 82990000,
                    rawTransation: "02000000046c54ac5365e70a1583ca55b70d8b7ebf4f647d8d28319c0b77864b5100eebe42030000006a4730440220111c7c0555efa1884cbbc68cbeaaaf1c4d4b8cc42124705a2c72bf840936fe0702205541c9b15e7dfa7e59ed58f1772d9e278cdb26ea2537ccc36c1ebe2e8eafca30012103b48aee4a6dec95c0e98e5dc31737bdd46b220b79f804a96d93eb06c1b71270efffffffff6c54ac5365e70a1583ca55b70d8b7ebf4f647d8d28319c0b77864b5100eebe42040000006a47304402206a3d77f7a308372e68c96a9af2da2cb7616adb07345bea177a5393aefaf76e55022078dba32b9cd290fdc81222b8f544e2b01870144d11eb01c18e57046161d9ef76012103b48aee4a6dec95c0e98e5dc31737bdd46b220b79f804a96d93eb06c1b71270efffffffff5bc2b84087be9443beba9c8727889975c4b5441cd32ede35f976671c8c1b4e48000000006a47304402205d61563d73fcf92ef5470e4f27a396bc54c76da265cba19b472f9204363f4b620220221f52f99a9e92da5b52e62c18e798fc2c49a2933dcdea6feb8039c5fd00a981832102406cd7e5d61e4c27c7eddcb22af0019bd46c9250bd571bd750075678a84b3378ffffffff6c54ac5365e70a1583ca55b70d8b7ebf4f647d8d28319c0b77864b5100eebe42050000006b483045022100e3c67697aab787de677c7e74b79a03889dd8108ed943f07015d10ff0a52a9a8f022035cba2783f79fd4a06d84d3c74471b27c32cb2e1811df93edcb1ea3452c629da012103b48aee4a6dec95c0e98e5dc31737bdd46b220b79f804a96d93eb06c1b71270efffffffff06b0040000000000001976a914d85290e927b8e20b1e48dbfeac9d8ea4c9a9955088ac22020000000000001976a914d85290e927b8e20b1e48dbfeac9d8ea4c9a9955088ac404b4c00000000001976a9142080c44ce0c1ad69e49b11e364b45848cf3da8cc88ac58020000000000001976a914d85290e927b8e20b1e48dbfeac9d8ea4c9a9955088ac58020000000000001976a914d85290e927b8e20b1e48dbfeac9d8ea4c9a9955088acb053f204000000001976a914d85290e927b8e20b1e48dbfeac9d8ea4c9a9955088ac00000000"
                }
            ],
            receiveNftAddress: "1LiosE627BF9mTr8YmndpAgFPbJVpo4naW",
            paymentAndChangeAddress: "1LiosE627BF9mTr8YmndpAgFPbJVpo4naW",
            feeRate: 2,
            sellerPsbts: [
           "cHNidP8BAP39AAIAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAA/////6t6cZTI1aHqakccl4xqtURPASzcIbDAbm+f50fWKkySAAAAAAD/////AwAAAAAAAAAAIlEgwSVNrUCq6hIeU+DOwJmGNi9s1CInltGUjJR5GzUoHLUAAAAAAAAAACJRIMElTa1AquoSHlPgzsCZhjYvbNQiJ5bRlIyUeRs1KBy1IKEHAAAAAAAZdqkUIIDETODBrWnkmxHjZLRYSM89qMyIrAAAAAAAAQErAAAAAAAAAAAiUSDBJU2tQKrqEh5T4M7AmYY2L2zUIieW0ZSMlHkbNSgctQABASsAAAAAAAAAACJRIMElTa1AquoSHlPgzsCZhjYvbNQiJ5bRlIyUeRs1KBy1AAEA6QIAAAAAAQGQCqFcMCQlzRdf3jAFefpxWz0TJilM/UiH2i/iBjFN9AEAAAAA/////wEiAgAAAAAAABl2qRQggMRM4MGtaeSbEeNktFhIzz2ozIisA0DZ1GeSg6pqVqmaYhUKElrdCYPl+dtSWPHHPQz+OAi+eZqkOE+lnVtj2bSVgorGFugaygCyI30IsV/qhWb7GSGJLQBjA29yZAEBGHRleHQvcGxhaW47Y2hhcnNldD11dGYtOAAJaGVsbG9nYXRlaCHBQGzX5dYeTCfH7dyyKvABm9RsklC9VxvXUAdWeKhLM3gAAAAAAQEiIgIAAAAAAAAZdqkUIIDETODBrWnkmxHjZLRYSM89qMyIrAEDBIMAAAAAAAAA",
            ]
        },
        networks.bitcoin
    )

i got error:

    if (data.startsWith("0x")) {
             ^
TypeError: Cannot read properties of undefined (reading 'startsWith')

maybe i can not decode nonWitnessUtxo from sellerPsbt?
another question, sellerPsbt array need signedPsbt or unSignedPsbt?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.