trustwallet / trust-core Goto Github PK
View Code? Open in Web Editor NEWDEPRECATED. Please use wallet-core
Home Page: https://github.com/TrustWallet/wallet-core
License: MIT License
DEPRECATED. Please use wallet-core
Home Page: https://github.com/TrustWallet/wallet-core
License: MIT License
Recovers the account that signed the data. Example
web3.eth.personal.ecRecover("Hello world", "0x30755ed65396facf86c53e6217c52b4daebe72aa4941d89635409de4c9c7f9466d4e9aaec7977f05e923889b33c0d0dd27d7226b6e6f56ce737465c5cfd04be400")
.then(console.log);
"0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe"
reference: https://web3js.readthedocs.io/en/1.0/web3-eth-personal.html#ecrecover
pid: 0, tid: 0 >>> com.wallet.crypto.trustapp <<<
backtrace:
#00 pc 0000000000021afc /system/lib64/libc.so (abort+124)
#1 pc 000000000046ad40 /system/lib64/libart.so (art::Runtime::Abort(char const*)+1208)
#2 pc 0000000000008d2c /system/lib64/libbase.so (android::base::LogMessage::~LogMessage()+724)
#3 pc 000000000049b070 /system/lib64/libart.so (art::Thread::AssertNoPendingException() const+1144)
#4 pc 000000000011c658 /system/lib64/libart.so (art::ClassLinker::FindClass(art::Thread*, char const*, art::Handleart::mirror::ClassLoader)+64)
#5 pc 0000000000136d84 /system/lib64/libart.so (art::ClassLinker::DoResolveType(art::dex::TypeIndex, art::Handleart::mirror::DexCache, art::Handleart::mirror::ClassLoader)+188)
#6 pc 00000000004c59f8 /system/lib64/libart.so (art::verifier::MethodVerifier::ScanTryCatchBlocks()+496)
#7 pc 00000000004c2bcc /system/lib64/libart.so (art::verifier::MethodVerifier::Verify()+684)
#8 pc 00000000004c54bc /system/lib64/libart.so (art::verifier::MethodVerifier::FindLocksAtDexPc()+140)
#9 pc 00000000004c53a4 /system/lib64/libart.so (art::verifier::MethodVerifier::FindLocksAtDexPc(art::ArtMethod*, unsigned int, std::__1::vector<art::verifier::MethodVerifier::DexLockInfo, std::__1::allocatorart::verifier::MethodVerifier::DexLockInfo>)+524)
#10 pc 00000000003c4bf4 /system/lib64/libart.so (art::Monitor::VisitLocks(art::StackVisitor, void ()(art::mirror::Object, void*), void*, bool)+812)
#11 pc 00000000004a4714 /system/lib64/libart.so (art::MonitorObjectsStackVisitor::VisitFrame()+164)
#12 pc 0000000000484418 /system/lib64/libart.so (_ZN3art12StackVisitor9WalkStackILNS0_16CountTransitionsE0EEEvb+1096)
#13 pc 0000000000499e38 /system/lib64/libart.so (art::Thread::DumpJavaStack(std::__1::basic_ostream<char, std::__1::char_traits>&, bool, bool) const+320)
#14 pc 0000000000495e18 /system/lib64/libart.so (art::Thread::DumpStack(std::__1::basic_ostream<char, std::__1::char_traits>&, bool, BacktraceMap*, bool) const+376)
#15 pc 00000000004afd9c /system/lib64/libart.so (art::DumpCheckpoint::Run(art::Thread*)+844)
#16 pc 00000000004a8ea4 /system/lib64/libart.so (art::ThreadList::RunCheckpoint(art::Closure*, art::Closure*)+1444)
#17 pc 00000000004a7f2c /system/lib64/libart.so (art::ThreadList::Dump(std::__1::basic_ostream<char, std::__1::char_traits>&, bool)+1036)
#18 pc 000000000046aa10 /system/lib64/libart.so (art::Runtime::Abort(char const*)+392)
#19 pc 0000000000008d2c /system/lib64/libbase.so (android::base::LogMessage::~LogMessage()+724)
#20 pc 00000000002e8898 /system/lib64/libart.so (art::JavaVMExt::JniAbort(char const*, char const*)+1656)
#21 pc 0000000000359db8 /system/lib64/libart.so (art::JNI::CallStaticObjectMethod(_JNIEnv*, _jclass*, _jmethodID*, ...)+1664)
#22 pc 00000000001656ac /data/app/com.wallet.crypto.trustapp-YhV4TkGoGgFOtXHSaLt82w==/lib/arm64/libTrustWalletCore.so (Java_com_wallet_crypto_trustapp_jni_BitcoinTransactionSigner_sign+204)
#23 pc 000000000016597c /data/app/com.wallet.crypto.trustapp-YhV4TkGoGgFOtXHSaLt82w==/oat/arm64/base.odex (com.kenai.jffi.Foreign.getArch [DEDUPED]+124)
#24 pc 000000000055cb88 /system/lib64/libart.so (art_quick_invoke_stub+584)
#25 pc 00000000000cf740 /system/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+200)
#26 pc 00000000002823f0 /system/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+344)
#27 pc 000000000027c3ac /system/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+948)
#28 pc 000000000052f4a8 /system/lib64/libart.so (MterpInvokeVirtualQuick+584)
#29 pc 0000000000552e94 /system/lib64/libart.so (ExecuteMterpImpl+29972)
#30 pc 00000000004d1f50 /data/app/com.wallet.crypto.trustapp-YhV4TkGoGgFOtXHSaLt82w==/oat/arm64/base.vdex (trust.blockchain.bitcoin.BitcoinTransactionSigner.sign+734)
#31 pc 0000000000255ea8 /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.1271626068+496)
#32 pc 000000000025ba28 /system/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+216)
#33 pc 000000000027c390 /system/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+920)
#34 pc 000000000052d3d0 /system/lib64/libart.so (MterpInvokeInterface+1392)
#35 pc 000000000054f314 /system/lib64/libart.so (ExecuteMterpImpl+14740)
#36 pc 00000000004d5216 /data/app/com.wallet.crypto.trustapp-YhV4TkGoGgFOtXHSaLt82w==/oat/arm64/base.vdex (trust.blockchain.mnemonic.MnemonicAdapter.lambda$signTransaction$6+42)
#37 pc 0000000000255ea8 /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.1271626068+496)
#38 pc 000000000025ba28 /system/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+216)
#39 pc 000000000027c390 /system/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+920)
#40 pc 000000000052d95c /system/lib64/libart.so (MterpInvokeStatic+204)
#41 pc 000000000054f294 /system/lib64/libart.so (ExecuteMterpImpl+14612)
#42 pc 00000000004d4e9c /data/app/com.wallet.crypto.trustapp-YhV4TkGoGgFOtXHSaLt82w==/oat/arm64/base.vdex (trust.blockchain.mnemonic.-$$Lambda$MnemonicAdapter$X-HQO0giO_Lo9ZJGYES4cZHd4Wo.apply+12)
#43 pc 0000000000255ea8 /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.1271626068+496)
#44 pc 000000000051cb98 /system/lib64/libart.so (artQuickToInterpreterBridge+1032)
#45 pc 0000000000565cfc /system/lib64/libart.so (art_quick_to_interpreter_bridge+92)
#46 pc 0000000000481ecc /data/app/com.wallet.crypto.trustapp-YhV4TkGoGgFOtXHSaLt82w==/oat/arm64/base.odex (io.reactivex.internal.operators.single.SingleMap$MapSingleObserver.onSuccess+76)
#47 pc 0000000000482044 /data/app/com.wallet.crypto.trustapp-YhV4TkGoGgFOtXHSaLt82w==/oat/arm64/base.odex (io.reactivex.internal.operators.single.SingleMap$MapSingleObserver.onSuccess+452)
#48 pc 00000000004f4d70 /data/app/com.wallet.crypto.trustapp-YhV4TkGoGgFOtXHSaLt82w==/oat/arm64/base.odex (io.reactivex.internal.operators.single.SingleFromCallable.subscribeActual+800)
#49 pc 0000000000475d78 /data/app/com.wallet.crypto.trustapp-YhV4TkGoGgFOtXHSaLt82w==/oat/arm64/base.odex (io.reactivex.Single.subscribe+312)
#50 pc 00000000004f5118 /data/app/com.wallet.crypto.trustapp-YhV4TkGoGgFOtXHSaLt82w==/oat/arm64/base.odex (io.reactivex.internal.operators.single.SingleMap.subscribeActual+168)
#51 pc 0000000000475d78 /data/app/com.wallet.crypto.trustapp-YhV4TkGoGgFOtXHSaLt82w==/oat/arm64/base.odex (io.reactivex.Single.subscribe+312)
#52 pc 00000000004f5118 /data/app/com.wallet.crypto.trustapp-YhV4TkGoGgFOtXHSaLt82w==/oat/arm64/base.odex (io.reactivex.internal.operators.single.SingleMap.subscribeActual+168)
#53 pc 0000000000475d78 /data/app/com.wallet.crypto.trustapp-YhV4TkGoGgFOtXHSaLt82w==/oat/arm64/base.odex (io.reactivex.Single.subscribe+312)
#54 pc 0000000000481794 /data/app/com.wallet.crypto.trustapp-YhV4TkGoGgFOtXHSaLt82w==/oat/arm64/base.odex (io.reactivex.internal.operators.single.SingleFlatMap$SingleFlatMapCallback.onSuccess+724)
#55 pc 00000000004f4d70 /data/app/com.wallet.crypto.trustapp-YhV4TkGoGgFOtXHSaLt82w==/oat/arm64/base.odex (io.reactivex.internal.operators.single.SingleFromCallable.subscribeActual+800)
#56 pc 0000000000475d78 /data/app/com.wallet.crypto.trustapp-YhV4TkGoGgFOtXHSaLt82w==/oat/arm64/base.odex (io.reactivex.Single.subscribe+312)
#57 pc 00000000004f48d8 /data/app/com.wallet.crypto.trustapp-YhV4TkGoGgFOtXHSaLt82w==/oat/arm64/base.odex (io.reactivex.internal.operators.single.SingleFlatMap.subscribeActual+168)
#58 pc 0000000000475d78 /data/app/com.wallet.crypto.trustapp-YhV4TkGoGgFOtXHSaLt82w==/oat/arm64/base.odex (io.reactivex.Single.subscribe+312)
#59 pc 0000000000482858 /data/app/com.wallet.crypto.trustapp-YhV4TkGoGgFOtXHSaLt82w==/oat/arm64/base.odex (io.reactivex.internal.operators.single.SingleSubscribeOn$SubscribeOnObserver.run+72)
#60 pc 0000000000471b98 /data/app/com.wallet.crypto.trustapp-YhV4TkGoGgFOtXHSaLt82w==/oat/arm64/base.odex (io.reactivex.Scheduler$DisposeTask.run+104)
#61 pc 000000000048498c /data/app/com.wallet.crypto.trustapp-YhV4TkGoGgFOtXHSaLt82w==/oat/arm64/base.odex (io.reactivex.internal.schedulers.ScheduledRunnable.run+108)
#62 pc 0000000000484618 /data/app/com.wallet.crypto.trustapp-YhV4TkGoGgFOtXHSaLt82w==/oat/arm64/base.odex (io.reactivex.internal.schedulers.ScheduledRunnable.call+40)
#63 pc 000000000036f8f8 /system/framework/arm64/boot.oat
Hello!
I try to create HDWallet with private and public keys
Code I use:
// blockchainCoin is .bitcoin
wallet = TrustCore.HDWallet(mnemonic: mnemonic)
privateKey = wallet.getKey(at: coin.blockchainCoin.derivationPath(at: 0))
publicKey = privateKey.publicKey(for: coin.blockchainCoin.blockchain.type)
But publicKey.address.description
return incorrect address, I researched with other services for validating that and came to the conclusion that publicKey is incorrect.
Check please publicKey data generation. I think the problem is somewhere at data compression (33 bytes or 65 bytes length)
If change method at file Crypto.m
all works as expected for BTC, but incorrect for ETH:
(Use 33 bytes length instead 65 and ecdsa_get_public_key33
instead ecdsa_get_public_key65
)
+ (nonnull NSData *)getPublicKeyFrom:(nonnull NSData *)privateKey {
NSMutableData *publicKey = [[NSMutableData alloc] initWithLength:33];
ecdsa_get_public_key33(&secp256k1, privateKey.bytes, publicKey.mutableBytes);
return publicKey;
}
Please fix this or add examples of correct library work(ex. wallet creation and etc.). Maybe I make something incorrect.
Thank!
There are some sign funcs in the ‘BitcoinSignerTests.swift’ file:
SignTransaction、SignP2WPKH、SignP2WSH、SignP2SH_P2WPKH、SignP2SH_P2WSH
I got UTXOs from my API, now I want to build a transaction, but I'm not clear which sign func should I use, Thx!
My UTXO data(Testnet):
{
"tx_hash": "6991154e998d0c6fa16427d9d214f311bde1236d8a1040d759359475bf074689",
"tx_output_n": 0,
"tx_version": 1,
"tx_locktime": 0,
"value": 1,
"script": "a91430e0467762621877fae8d66122346adc81b9565e87",
"addr": "2Mwhf6QjWi8MTNGGi2wqripb982fiRLwP58",
"confirmations": 21423,
}
In taking a look at your excellent project today, I noticed that pod install
fails because trezor-crypto-ios is no longer available on github. It appears that the podspec here is pointing to a location that no longer exists.
Steps to reproduce the issue are:
git clone [email protected]:TrustWallet/trust-core.git
cd /your/path/to/trust-core
pod install
Output from pod install
:
Analyzing dependencies
Downloading dependencies
Installing BigInt (3.1.0)
Installing SipHash (1.2.2)
Installing SwiftLint (0.26.0)
Installing TrezorCrypto (0.0.6)
Username for 'https://github.com': [email protected]
Password for 'https://[email protected]@github.com':
Error installing TrezorCrypto
/usr/local/bin/git clone https://github.com/TrustWallet/trezor-crypto-ios.git /var/folders/pt/s4w3g06s69d16vbdx32vvc_w0000gn/T/d20180810-7011-qslgbz --template= --single-branch --depth 1 --branch 0.0.6
Cloning into '/var/folders/pt/s4w3g06s69d16vbdx32vvc_w0000gn/T/d20180810-7011-qslgbz'...
remote: Repository not found.
fatal: repository 'https://github.com/TrustWallet/trezor-crypto-ios.git/' not found```
Any ideas?
Hello. Is this support android ?
A CLI should be enough
public func matchMultisig() -> ([PublicKey], required: Int)? {
if bytes.count < 1 || bytes.last != OpCode.OP_CHECKMULTISIG {
return nil
}
var keys = [PublicKey]()
var it = bytes.startIndex
guard let (opcode, _) = getScriptOp(index: &it), OpCode.isSmallInteger(opcode) else {
return nil
}
let required = BitcoinScript.decodeNumber(opcode: opcode)
while case .some(_, let data?) = getScriptOp(index: &it), let key = PublicKey(data: data) {
keys.append(key)
}
if !OpCode.isSmallInteger(opcode) {
return nil
}
let expectedCount = BitcoinScript.decodeNumber(opcode: opcode)
if keys.count != expectedCount || expectedCount < required {
return nil
}
if it + 1 != bytes.endIndex {
return nil
}
return (keys, required)
}
'expectedCount' is equal to 'required', so below code must be entered, and return nil:
if keys.count != expectedCount || expectedCount < required {
return nil
}
CardanoAddress
address generation.CardanoTransaction
- for signingIn BitcoinScript Extention,function "func getScriptOp(index: inout Int) -> (opcode: UInt8, operand: Data?)? " below:
func getScriptOp(index: inout Int) -> (opcode: UInt8, operand: Data?)? {
// Read instruction
if index >= bytes.endIndex {
return nil
}
let opcode = bytes[index]
index += 1
if opcode > OpCode.OP_PUSHDATA4 {
return (opcode: opcode, operand: nil)
}
// Immediate operand
var size = 0
if opcode < OpCode.OP_PUSHDATA1 {
size = Int(opcode)
} else if opcode == OpCode.OP_PUSHDATA1 {
if bytes.endIndex - index < 1 {
return nil
}
size = index
index += 1
} else if opcode == OpCode.OP_PUSHDATA2 {
if bytes.endIndex - index < 2 {
return nil
}
size = Int(readLE16(at: index))
index += 2
} else if opcode == OpCode.OP_PUSHDATA4 {
if bytes.endIndex - index < 4 {
return nil
}
size = Int(readLE32(at: index))
index += 4
}
if bytes.endIndex - index < size {
return nil
}
let operand = data[index ..< index + size]
index += size
return (opcode: opcode, operand: operand)
}
when opcode == OpCode.OP_PUSHDATA1, that 'size = index' should be replaced by 'size = Int(bytes[index])'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.