-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[Sync]: Apply changes from DeFi wallet-core #3225
Merged
Merged
Changes from 4 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
8accc66
Apply changes from DeFi wallet-core
satoshiotomakan 5b922f6
Clean code #1
satoshiotomakan 8f6218b
Clean code 2 (minor changes)
satoshiotomakan 048c39e
Clean code 3
satoshiotomakan 35e83b4
Clean code 4
satoshiotomakan e25883a
[Cardano]: Add `asset_name_hex` property to `TokenAmount`
satoshiotomakan 2ef41c9
Clean code 5
satoshiotomakan 4d02e0d
Fix compile errors
satoshiotomakan afa060d
Clean code 6
satoshiotomakan 2e09219
Clean code 7
satoshiotomakan 64120a7
Clean code 8
satoshiotomakan c9ae4b9
Fix unit tests
satoshiotomakan 30e74f1
Clean code 9
satoshiotomakan e1b4b0a
Clean code 10
satoshiotomakan 61ee61a
Update kmp wc to 3.1.39
satoshiotomakan b794af0
Merge branch 'master' into s/sync-defi-repo
satoshiotomakan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains 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
31 changes: 31 additions & 0 deletions
31
...est/java/com/trustwallet/core/app/blockchains/bitcoindiamond/TestBitcoinDiamondAddress.kt
This file contains 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,31 @@ | ||
// Copyright © 2017-2022 Trust Wallet. | ||
// | ||
// This file is part of Trust. The full Trust copyright notice, including | ||
// terms governing use, modification, and redistribution, is contained in the | ||
// file LICENSE at the root of the source code distribution tree. | ||
|
||
package com.trustwallet.core.app.blockchains.bitcoindiamond | ||
|
||
import com.trustwallet.core.app.utils.toHex | ||
import com.trustwallet.core.app.utils.toHexByteArray | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
import wallet.core.jni.* | ||
|
||
class TestBitcoinDiamondAddress { | ||
|
||
init { | ||
System.loadLibrary("TrustWalletCore") | ||
} | ||
|
||
@Test | ||
fun testAddress() { | ||
val key = PrivateKey("d2b9f2846d3adcead910ee0124a3ba7ae29e8a4729787d27f9bea1f532928eee".toHexByteArray()) | ||
val pubkey = key.getPublicKeySecp256k1(true); | ||
val address = AnyAddress(pubkey, CoinType.BITCOINDIAMOND) | ||
val expected = AnyAddress("1G15VvshDxwFTnahZZECJfFwEkq9fP79o8", CoinType.BITCOINDIAMOND) | ||
|
||
assertEquals(pubkey.data().toHex(), "0x02485a209514cc896f8ed736e205bc4c35bd5299ef3f9e84054475336b964c02a3") | ||
assertEquals(address.description(), expected.description()) | ||
} | ||
} |
88 changes: 88 additions & 0 deletions
88
...Test/java/com/trustwallet/core/app/blockchains/bitcoindiamond/TestBitcoinDiamondSigner.kt
This file contains 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,88 @@ | ||
// Copyright © 2017-2022 Trust Wallet. | ||
// | ||
// This file is part of Trust. The full Trust copyright notice, including | ||
// terms governing use, modification, and redistribution, is contained in the | ||
// file LICENSE at the root of the source code distribution tree. | ||
|
||
package com.trustwallet.core.app.blockchains.bitcoindiamond | ||
|
||
import com.google.protobuf.ByteString | ||
import com.trustwallet.core.app.utils.Numeric | ||
import com.trustwallet.core.app.utils.toHexByteArray | ||
import com.trustwallet.core.app.utils.toHexBytes | ||
import com.trustwallet.core.app.utils.toHexBytesInByteString | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
|
||
import wallet.core.java.AnySigner | ||
import wallet.core.jni.BitcoinScript | ||
import wallet.core.jni.BitcoinSigHashType | ||
import wallet.core.jni.CoinType | ||
import wallet.core.jni.proto.Bitcoin | ||
import wallet.core.jni.proto.Common.SigningError | ||
|
||
class TestBitcoinDiamondSigner { | ||
|
||
init { | ||
System.loadLibrary("TrustWalletCore") | ||
} | ||
|
||
@Test | ||
fun BitcoinDiamondTransactionSigning() { | ||
val toScript = BitcoinScript.lockScriptForAddress("1HevQVTSEc8cEpDm65UpfCdj5erd4xxBhx", CoinType.BITCOINDIAMOND); | ||
assertEquals(Numeric.toHexString(toScript.data()), "0x76a914b6adfbbf15c8f6fa53f1edb37054dce5c7c145c688ac"); | ||
|
||
// prepare SigningInput | ||
val input = Bitcoin.SigningInput.newBuilder() | ||
.setHashType(BitcoinScript.hashTypeForCoin(CoinType.BITCOINDIAMOND)) | ||
.setAmount(17615) | ||
.setByteFee(1) | ||
.setToAddress("1HevQVTSEc8cEpDm65UpfCdj5erd4xxBhx") | ||
.setChangeAddress("1G15VvshDxwFTnahZZECJfFwEkq9fP79o8") | ||
.setCoinType(CoinType.BITCOINDIAMOND.value()) | ||
|
||
val utxoKey0 = | ||
(Numeric.hexStringToByteArray("d2b9f2846d3adcead910ee0124a3ba7ae29e8a4729787d27f9bea1f532928eee")) | ||
input.addPrivateKey(ByteString.copyFrom(utxoKey0)) | ||
|
||
// build utxo | ||
val txHash0 = (Numeric.hexStringToByteArray("034f4667301711e8a69236a93476ed798f9c11aaae472da5b315191a0453461d")) | ||
val outpoint0 = Bitcoin.OutPoint.newBuilder() | ||
.setHash(ByteString.copyFrom(txHash0)) | ||
.setIndex(0) | ||
.setSequence(Long.MAX_VALUE.toInt()) | ||
.build() | ||
|
||
val utxo0 = Bitcoin.UnspentTransaction.newBuilder() | ||
.setAmount(27615) | ||
.setOutPoint(outpoint0) | ||
.setScript(ByteString.copyFrom("76a914a48da46386ce52cccad178de900c71f06130c31088ac".toHexBytes())) | ||
.build() | ||
|
||
input.addUtxo(utxo0) | ||
|
||
val plan = AnySigner.plan(input.build(), CoinType.BITCOINDIAMOND, Bitcoin.TransactionPlan.parser()) | ||
|
||
input.plan = Bitcoin.TransactionPlan.newBuilder() | ||
.mergeFrom(plan) | ||
.setAmount(17615) | ||
.setFee(10000) | ||
.setChange(0) | ||
.setPreblockhash(ByteString.copyFrom("99668daf7c77c6462f3ba8fab61b4f62abaabd62911e7e59729ee9e1929dfa4b".toHexBytes())) | ||
.build() | ||
|
||
|
||
val output = AnySigner.sign(input.build(), CoinType.BITCOINDIAMOND, Bitcoin.SigningOutput.parser()) | ||
|
||
assertEquals(output.error, SigningError.OK) | ||
val signedTransaction = output.transaction | ||
assert(signedTransaction.isInitialized) | ||
assertEquals(12, signedTransaction.version) | ||
assertEquals(1, signedTransaction.inputsCount) | ||
assertEquals(1, signedTransaction.outputsCount) | ||
|
||
val encoded = output.encoded | ||
assertEquals("0x0c00000099668daf7c77c6462f3ba8fab61b4f62abaabd62911e7e59729ee9e1929dfa4b01034f4667301711e8a69236a93476ed798f9c11aaae472da5b315191a0453461d000000006a473044022078e0d3a9e1eb270ab02c15f8fcf1d3bfc95a324839690b7de4f011a4266132ff02204679e8103c4d3f0bb5192a5f53cc273732fd0e8392ab3b00dc708fd24d0160b3012102485a209514cc896f8ed736e205bc4c35bd5299ef3f9e84054475336b964c02a3ffffffff01cf440000000000001976a914b6adfbbf15c8f6fa53f1edb37054dce5c7c145c688ac00000000", | ||
Numeric.toHexString(encoded.toByteArray())); | ||
} | ||
} |
This file contains 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 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 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 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 |
---|---|---|
|
@@ -82,7 +82,7 @@ class TestEOSSigning { | |
val signatureValue: String = signatures.get(0) as String; | ||
assertNotNull("Error parsing JSON result", signatureValue) | ||
assertEquals( | ||
"SIG_K1_KfCdjsrTnx5cBpbA5cUdHZAsRYsnC9uKzuS1shFeqfMCfdZwX4PBm9pfHwGRT6ffz3eavhtkyNci5GoFozQAx8P8PBnDmj", | ||
"SIG_K1_K9RdLC7DEDWjTfR64GU8BtDHcAjzR1ntcT651JMcfHNTpdsvDrUwfyzF1FkvL9fxEi2UCtGJZ9zYoNbJoMF1fbU64cRiJ7", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to test EOS signature There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
We changed the |
||
signatureValue | ||
) | ||
|
||
|
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.
any chance we change it to binance testnet?