forked from Tribler/trustchain-superapp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Tribler#12 from MKuijpers/magical_idea
Magical idea
- Loading branch information
Showing
20 changed files
with
778 additions
and
134 deletions.
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
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
37 changes: 37 additions & 0 deletions
37
demo-android/src/main/java/nl/tudelft/ipv8/android/demo/coin/CoinUtil.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,37 @@ | ||
package nl.tudelft.ipv8.android.demo.coin | ||
|
||
import nl.tudelft.ipv8.attestation.trustchain.TrustChainTransaction | ||
import org.json.JSONArray | ||
import org.json.JSONObject | ||
import java.nio.ByteBuffer | ||
import java.util.* | ||
import kotlin.collections.ArrayList | ||
|
||
|
||
object CoinUtil { | ||
/** | ||
* Generate a random 128 bit string | ||
* From: https://sakthipriyan.com/2017/04/02/creating-base64-uuid-in-java.html | ||
*/ | ||
@JvmStatic | ||
fun randomUUID(): String { | ||
val uuid: UUID = UUID.randomUUID() | ||
val src: ByteArray = ByteBuffer.wrap(ByteArray(16)) | ||
.putLong(uuid.mostSignificantBits) | ||
.putLong(uuid.leastSignificantBits) | ||
.array() | ||
return Base64.getUrlEncoder().encodeToString(src).substring(0, 22) | ||
} | ||
|
||
@JvmStatic | ||
fun parseTransaction(transaction: TrustChainTransaction): JSONObject { | ||
return JSONObject(transaction["message"].toString()) | ||
} | ||
|
||
@JvmStatic | ||
fun parseJSONArray(jsonArray: JSONArray): ArrayList<String> { | ||
return Array(jsonArray.length()) { | ||
jsonArray.getString(it) | ||
}.toCollection(ArrayList()) | ||
} | ||
} |
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
File renamed without changes.
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
3 changes: 3 additions & 0 deletions
3
demo-android/src/main/java/nl/tudelft/ipv8/android/demo/ui/bitcoin/BitcoinViewController.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 |
---|---|---|
@@ -1,5 +1,8 @@ | ||
package nl.tudelft.ipv8.android.demo.ui.bitcoin | ||
|
||
import nl.tudelft.ipv8.attestation.trustchain.TrustChainBlock | ||
|
||
interface BitcoinViewController { | ||
fun showView(bitcoinViewName: String) | ||
fun showSharedWalletTransactionView(sharedWalletBlock: TrustChainBlock) | ||
} |
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
Oops, something went wrong.