Git Product home page Git Product logo

hdwallet's People

Contributors

betuha avatar dmytrostriletskyi avatar euwars avatar impul avatar ivan-artemov-studiomobile avatar kozlov-oleksandr avatar samouraidev avatar yuzushioh 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

hdwallet's Issues

Use of unresolved identifier 'Scrypt'

Tried to update to the latest version - 0.2.8 , on building it gives error in the KeystoreV3 class's encryptData function
Am i missing something?
pod 'HDWalletKit'
This is what i have in my podfile.

support for usdt

USDT is a BTC token base on omni layer. As HDWallet is support BTC well, so support USDT is easy to implement.
To transfer USDT, we need to construct a transaction base on BTC, so we have two outputs.

  1. transfer 546 Satoshi to destination
  2. change to change address
  3. a OP_RETURN output script to construct the USDT transaction.

Please check the code below:

public struct USDTTransactionBuilder: UtxoTransactionBuilderInterface {
    public init(usdtLockingScript: Data) {
        self.usdtLockingScript = usdtLockingScript
    }
    
    private let usdtLockingScript: Data
    
    public func build(destinations: [(address: Address, amount: UInt64)], utxos: [UnspentTransaction]) throws -> UnsignedTransaction {
        var outputs = try destinations.map { (address: Address, amount: UInt64) -> TransactionOutput in
            guard let lockingScript = Script(address: address)?.data else {
                throw TransactionBuildError.error("Invalid address type")
            }
            return TransactionOutput(value: amount, lockingScript: lockingScript)
        }
        let usdtTxOutput = TransactionOutput(value: 0, lockingScript: usdtLockingScript)
        outputs.append(usdtTxOutput) //add a new script output
        
        let unsignedInputs = utxos.map { TransactionInput(previousOutput: $0.outpoint, signatureScript: $0.output.lockingScript, sequence: UInt32.max) }
        let tx = Transaction(version: 1, inputs: unsignedInputs, outputs: outputs, lockTime: 0)
        return UnsignedTransaction(tx: tx, utxos: utxos)
    }
}
    static func generateUSDTLockingScript(amountInUSDT: Double) -> Data {
       //
        let converter = BitcoinConverter(bitcoinString: "\(amountInUSDT)")
        let amountInSatoshi = converter.inSatoshi
        
        var usdtData = Data()
        usdtData += [0x6a,0x14] //OP_RETURN
        usdtData += [0x6f,0x6d,0x6e,0x69] //OMNI
        usdtData += [0x00,0x00] //Transaction version
        usdtData += [0x00,0x00] // Transaction type
        usdtData += [0x00,0x00,0x00,0x1f] //Currency identifier
        ewLogger.debug("[USDT] amount data=\(amountInSatoshi.littleEndianData.toHexString())")
        usdtData += amountInSatoshi.littleEndianData
        
        return usdtData
    }

some references links:

Private key generation does not work on iPhones having processor make Apple A6

Getting Fatal error: Operation is not supported ios error while generating private key:

Calling:
privateKey = privateKey.derived(at: .hardened(index))

Crashing at:
(mulHi, mulLo) = l.multipliedFullWidth(by: multiplicand)

I tried to look for the issue and found that the issue is related to the architecture of the processor. The library currently supports 64-bit processors and not 32-bit (A6).

Get exact sign hash.

Hi I need to get exact hex for a string...what I have tried
   let mnemonic = "xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx"
    let seed = Mnemonic.createSeed(mnemonic: mnemonic)
    let purpose1 = PrivateKey.init(seed: seed, coin: .bitcoin)
    let purpose = purpose1.derived(at: .hardened(44))
    //Bitcoin
    let coinType = purpose.derived(at: .hardened(0))
    // m/44'/0'/0'
    let account = coinType.derived(at: .hardened(0))
    // m/44'/0'/0'/0
    let change = account.derived(at: .notHardened(0))
    // m/44'/0'/0'/0/0
    let firstPrivateKey = change.derived(at: .notHardened(0))
    
    let sign = "1dca0a148623f3f5ce5f49b2abc34384403e545620dca69ceb59da246951b4c3"
    let data = Data.init(hex: sign)
     let signatureData = try! firstPrivateKey.sign(hash: data)
    print(signatureData.hex)

    It gives me wrong hex and Error reading signaturesalid signature, wrong length.

KeystoreV3.swift An error occurred .error missage: 'Type of expression is ambiguous without more context'

private func encryptData(password: String, salt: Data, length: Int, N: Int, R: Int, P: Int) -> Data? { guard let passwordData = password.data(using: .utf8)?.sha3(.keccak256) else {return nil} guard let deriver = try? Scrypt(password: [UInt8](passwordData), salt: [UInt8](salt), dkLen: length, N: N, r: R, p: P) else {return nil} guard let result = try? deriver.calculate() else {return nil} return Data(result) }
This method prompts an error: Type of expression is ambiguous without more context

Unable to send Litecoin Testnet Transaction?

Json:
{
hash = 733c8d399ab699ff00dd90380cefde5df28b72133f5a34cc6cc3b669b538b8b7;
in = ( {
"prev_out" = {
hash = 9862388f00461efbc895cedade0fcf11a1d8b4e0618e7748992ccf08c2e59f83;
n = 0;
};
scriptSig =
"3045022100e4866462ba92ba393052442224e4298d364f824a8d8c763e2120d4c9b9f5e0b902207be56d53c728ff1f5129803c2375ddc96a9b765d8beb901751480421bdb1c72101 03ccb5d8fbb1faaba8d45a77b9f3b6f078f15f51a589c1f5c4c901ebc78f00ded9";
},
{
"prev_out" = {
hash = 78d05820ce909233d6e2eb826b2348f053c053d7883f260abc24a44776ef07ae;
n = 0;
};
scriptSig =
"304402204f403404ce9d8a51c7c6052dc130aa8bb55ab72a67efb5fcf12d80a5efe1dd96022052ab59f23bee0286ca0d43a010544fe4e01ff8408fff9ef503d14966bd5fd23401 03ccb5d8fbb1faaba8d45a77b9f3b6f078f15f51a589c1f5c4c901ebc78f00ded9";
},
{
"prev_out" = {
hash = fbb583d131a190ddd0c5a9670c927fdb05b4f96927c8d90ea7b8987cecafa8d8;
n = 1;
};
scriptSig =
"304402205a677d5f52d60b08cf3d050bf0c74c5f2ab3a54b5da2b76fc244f2d7c278cd0502205e90f1f3ae1f2b06030448927749e3fcbb5fcb9d33ca2c96da4a0137108200dd01 03ccb5d8fbb1faaba8d45a77b9f3b6f078f15f51a589c1f5c4c901ebc78f00ded9";
}
);
"lock_time" = 0;
out = (
{
scriptPubKey = "OP_DUP OP_HASH160 55a91d96b23b3093b3673c04e22ea25670fc76f5
OP_EQUALVERIFY OP_CHECKSIG";
value = "0.10000000";
},
{
scriptPubKey = "OP_DUP OP_HASH160 95ef26ce20cc64134484501fcfb0f4a264b969df
OP_EQUALVERIFY OP_CHECKSIG";
value = "0.69994810";
}
);
size = 520;
ver = 1;
"vin_sz" = 3;
"vout_sz" = 2;
}

Transaction Raw with Sign:
0100000003839fe5c208cf2c9948778e61e0b4d8a111cf0fdedace95c8fb1e46008f386298000000006b483045022100e4866462ba92ba393052442224e4298d364f824a8d8c763e2120d4c9b9f5e0b902207be56d53c728ff1f5129803c2375ddc96a9b765d8beb901751480421bdb1c721012103ccb5d8fbb1faaba8d45a77b9f3b6f078f15f51a589c1f5c4c901ebc78f00ded9ffffffffae07ef7647a424bc0a263f88d753c053f048236b82ebe2d6339290ce2058d078000000006a47304402204f403404ce9d8a51c7c6052dc130aa8bb55ab72a67efb5fcf12d80a5efe1dd96022052ab59f23bee0286ca0d43a010544fe4e01ff8408fff9ef503d14966bd5fd234012103ccb5d8fbb1faaba8d45a77b9f3b6f078f15f51a589c1f5c4c901ebc78f00ded9ffffffffd8a8afec7c98b8a70ed9c82769f9b405db7f920c67a9c5d0dd90a131d183b5fb010000006a47304402205a677d5f52d60b08cf3d050bf0c74c5f2ab3a54b5da2b76fc244f2d7c278cd0502205e90f1f3ae1f2b06030448927749e3fcbb5fcb9d33ca2c96da4a0137108200dd012103ccb5d8fbb1faaba8d45a77b9f3b6f078f15f51a589c1f5c4c901ebc78f00ded9ffffffff0280969800000000001976a91455a91d96b23b3093b3673c04e22ea25670fc76f588ac3a092c04000000001976a91495ef26ce20cc64134484501fcfb0f4a264b969df88ac00000000

API:
https://chain.so/api/v2/send_tx/LTCTEST
in body: {"tx_hex": rawstring}

Issue:
{
data = {
network = "Network is required (DOGE, DOGETEST, ...)";
"tx_hex" = "A valid signed transaction hexadecimal string is required. Please check if all inputs in the given transactions are still available to spend. See the " Is Tx Output Spent?" API call for a reference.";
};
status = fail;
}

Build error

how to fix "unable to open file (in target "HDWalletKit" in project "HDWalletKit")"?

Check mnemonic for correctness

Is there a way to check the particular mnemonic phrase for correctness using your lib?

let mnemonic = Mnemonic.createSeed(mnemonic: "sdfsafsadfasfd")
seems generates a seed anyways without any indication of an error

Transactions are not sending

I tried to sign transaction exactly as in documentation:

func signTransaction() {
        guard let amountString = amountTextField.text else { return }
        guard let address = addressTextField.text else { return }
        let amount = Int((Double(amountString) ?? 0.0) * ethDivident)
        
        let signer = EIP155Signer(chainId: 1)
        let rawTransaction1 = EthereumRawTransaction(
            value: Wei("\(amount)") ?? 0,
            to: "\(address)",
            gasPrice: Int(gasPrice),
            gasLimit: 21000,
            nonce: 2
        )
        guard let signed = try? signer.hash(rawTransaction: rawTransaction1).toHexString() else { return }
        print(signed)
        
        
    }

It's printing transaction hash, but is not substracting any ethereum from the wallet. Also when I check the transaction on Etherium Scan is not showin at all.

Generated Ethereum address differs from Coleman

let seed = Mnemonic.createSeed(mnemonic: "hazard unable hover gossip impact music country miss end armor addict tissue")
let privateKey = PrivateKey(seed: seed, network: .main(.ethereum))
let purpose = privateKey.derived(at: .hardened(44))
let coinType = purpose.derived(at: .hardened(60))
let account = coinType.derived(at: .hardened(0))
let change = account.derived(at: .notHardened(0))
let firstPrivateKey = change.derived(at: .notHardened(0))
print(firstPrivateKey.publicKey.address) // 0xF8De36ff4fC73528c1C083eC1265e6d6eEF9D82e

image

Both private and public keys are the same as Coleman, but the address isn't.

My build fails because of HDWalletKit

After installing HDWalletKit via cocoaPods, my build fails with following error:


HDWalletKit/HDWalletKit/Core/BitcoinScript/Script.swift:455:107: error: 
the compiler is unable to type-check this expression in reasonable time; 
try breaking up the expression into distinct sub-expressions

In development I have fixed this by breaking up mentioned line of code into 2
But now that I want to perform pod lint lib or publish it, it fails
both on my machine and on travis

Carthage build error

Hello, there. I tried to build HDWallet via Carthage on xCode 10.1 (10B61) and i get this error ->
I tried also carthage update --platform iOS && carthage update --platform iOS --no-use-binaries but result was the same.

Skipped building scrypt-cryptoswift due to the error:
Dependency "scrypt-cryptoswift" has no shared framework schemes for any of the platforms: iOS

If you believe this to be an error, please file an issue with the maintainers at https://github.com/shamatar/scrypt-cryptoswift/issues/new
*** Building scheme "secp256k1.swift" in secp256k1.xcworkspace
*** Skipped building HDWallet due to the error:
Dependency "HDWallet" has no shared framework schemes for any of the platforms: iOS

If you believe this to be an error, please file an issue with the maintainers at https://github.com/essentiaone/HDWallet/issues/new

Any suggestion what i'm doing wrong?

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.