Gutyn
9 years ago
43 changed files with 1296 additions and 85 deletions
@ -1 +0,0 @@ |
|||||
Subproject commit b1626c728004a962152e37fe17d4ea934f66cab3 |
|
@ -1,4 +1,4 @@ |
|||||
package com.breadwallet.tools.others; |
package com.breadwallet.tools; |
||||
|
|
||||
/** |
/** |
||||
* DO WHAT YOU WANT TO PUBLIC LICENSE |
* DO WHAT YOU WANT TO PUBLIC LICENSE |
@ -1,4 +1,4 @@ |
|||||
package com.breadwallet.tools.others; |
package com.breadwallet.tools; |
||||
|
|
||||
import android.content.Context; |
import android.content.Context; |
||||
import android.content.SharedPreferences; |
import android.content.SharedPreferences; |
@ -1,4 +1,4 @@ |
|||||
package com.breadwallet.tools.others; |
package com.breadwallet.tools; |
||||
|
|
||||
import org.json.JSONArray; |
import org.json.JSONArray; |
||||
import org.json.JSONException; |
import org.json.JSONException; |
@ -1,4 +1,4 @@ |
|||||
package com.breadwallet.tools.others; |
package com.breadwallet.tools; |
||||
|
|
||||
import android.content.BroadcastReceiver; |
import android.content.BroadcastReceiver; |
||||
import android.content.Context; |
import android.content.Context; |
@ -1,4 +1,4 @@ |
|||||
package com.breadwallet.tools.others; |
package com.breadwallet.tools; |
||||
|
|
||||
/** |
/** |
||||
* BreadWallet |
* BreadWallet |
@ -0,0 +1,102 @@ |
|||||
|
package com.breadwallet.tools; |
||||
|
|
||||
|
import java.io.ByteArrayInputStream; |
||||
|
import java.io.ByteArrayOutputStream; |
||||
|
import java.io.IOException; |
||||
|
import java.io.ObjectInput; |
||||
|
import java.io.ObjectInputStream; |
||||
|
import java.io.ObjectOutput; |
||||
|
import java.io.ObjectOutputStream; |
||||
|
import java.io.StreamCorruptedException; |
||||
|
|
||||
|
/** |
||||
|
* BreadWallet |
||||
|
* <p/> |
||||
|
* Created by Mihail on 9/28/15. |
||||
|
* Copyright (c) 2015 Mihail Gutan <mihail@breadwallet.com> |
||||
|
* <p/> |
||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
* of this software and associated documentation files (the "Software"), to deal |
||||
|
* in the Software without restriction, including without limitation the rights |
||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
|
* copies of the Software, and to permit persons to whom the Software is |
||||
|
* furnished to do so, subject to the following conditions: |
||||
|
* <p/> |
||||
|
* The above copyright notice and this permission notice shall be included in |
||||
|
* all copies or substantial portions of the Software. |
||||
|
* <p/> |
||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
|
* THE SOFTWARE. |
||||
|
*/ |
||||
|
public class ReadWriteBytes { |
||||
|
|
||||
|
public static Object readBytes(byte[] bytes) { |
||||
|
ByteArrayInputStream bis = new ByteArrayInputStream(bytes); |
||||
|
ObjectInput in = null; |
||||
|
Object o = null; |
||||
|
try { |
||||
|
in = new ObjectInputStream(bis); |
||||
|
o = in.readObject(); |
||||
|
} catch (ClassNotFoundException e) { |
||||
|
e.printStackTrace(); |
||||
|
} catch (StreamCorruptedException e) { |
||||
|
e.printStackTrace(); |
||||
|
} catch (IOException e) { |
||||
|
e.printStackTrace(); |
||||
|
} finally { |
||||
|
try { |
||||
|
bis.close(); |
||||
|
} catch (IOException ex) { |
||||
|
// ignore close exception
|
||||
|
} |
||||
|
try { |
||||
|
if (in != null) { |
||||
|
in.close(); |
||||
|
} |
||||
|
} catch (IOException ex) { |
||||
|
// ignore close exception
|
||||
|
} |
||||
|
} |
||||
|
if (o != null) { |
||||
|
return o; |
||||
|
} else { |
||||
|
throw new NullPointerException("bytes should not be null"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public static byte[] writeBytes(Object obj) { |
||||
|
ByteArrayOutputStream bos = new ByteArrayOutputStream(); |
||||
|
ObjectOutput out = null; |
||||
|
byte[] yourBytes = null; |
||||
|
try { |
||||
|
out = new ObjectOutputStream(bos); |
||||
|
out.writeObject(obj); |
||||
|
yourBytes = bos.toByteArray(); |
||||
|
} catch (IOException e) { |
||||
|
e.printStackTrace(); |
||||
|
} finally { |
||||
|
try { |
||||
|
if (out != null) { |
||||
|
out.close(); |
||||
|
} |
||||
|
} catch (IOException ex) { |
||||
|
// ignore close exception
|
||||
|
} |
||||
|
try { |
||||
|
bos.close(); |
||||
|
} catch (IOException ex) { |
||||
|
// ignore close exception
|
||||
|
} |
||||
|
} |
||||
|
if (yourBytes != null) { |
||||
|
return yourBytes; |
||||
|
} else { |
||||
|
throw new NullPointerException("bytes should not be null"); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -1,4 +1,4 @@ |
|||||
package com.breadwallet.tools.others; |
package com.breadwallet.tools; |
||||
|
|
||||
import android.content.Context; |
import android.content.Context; |
||||
import android.graphics.Typeface; |
import android.graphics.Typeface; |
@ -1,4 +1,4 @@ |
|||||
package com.breadwallet.tools.others; |
package com.breadwallet.tools; |
||||
|
|
||||
import android.content.Context; |
import android.content.Context; |
||||
import android.content.res.AssetManager; |
import android.content.res.AssetManager; |
@ -0,0 +1,171 @@ |
|||||
|
package com.breadwallet.tools.sqlite; |
||||
|
|
||||
|
import android.content.Context; |
||||
|
import android.database.sqlite.SQLiteDatabase; |
||||
|
import android.database.sqlite.SQLiteOpenHelper; |
||||
|
import android.util.Log; |
||||
|
|
||||
|
/** |
||||
|
* BreadWallet |
||||
|
* <p/> |
||||
|
* Created by Mihail on 9/25/15. |
||||
|
* Copyright (c) 2015 Mihail Gutan <mihail@breadwallet.com> |
||||
|
* <p/> |
||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
* of this software and associated documentation files (the "Software"), to deal |
||||
|
* in the Software without restriction, including without limitation the rights |
||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
|
* copies of the Software, and to permit persons to whom the Software is |
||||
|
* furnished to do so, subject to the following conditions: |
||||
|
* <p/> |
||||
|
* The above copyright notice and this permission notice shall be included in |
||||
|
* all copies or substantial portions of the Software. |
||||
|
* <p/> |
||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
|
* THE SOFTWARE. |
||||
|
*/ |
||||
|
public class BRSQLiteHelper extends SQLiteOpenHelper { |
||||
|
public static final String TAG = BRSQLiteHelper.class.getName(); |
||||
|
|
||||
|
private static final String DATABASE_NAME = "breadwallet.db"; |
||||
|
private static final int DATABASE_VERSION = 3; |
||||
|
|
||||
|
/** |
||||
|
* MerkleBlock table |
||||
|
*/ |
||||
|
public static final String MB_TABLE_NAME = "merkleBlockTable"; |
||||
|
public static final String MB_COLUMN_ID = "_id"; |
||||
|
public static final String MB_COLUMN_BLOCK_HASH = "blockHash"; |
||||
|
public static final String MB_COLUMN_FLAGS = "flags"; |
||||
|
public static final String MB_COLUMN_HASHES = "hashes"; |
||||
|
public static final String MB_COLUMN_HEIGHT = "height"; |
||||
|
public static final String MB_COLUMN_MERKLE_ROOT = "merkleRoot"; |
||||
|
public static final String MB_COLUMN_NONCE = "nonce"; |
||||
|
public static final String MB_COLUMN_PREV_BLOCK = "prevBlock"; |
||||
|
public static final String MB_COLUMN_TARGET = "target"; |
||||
|
public static final String MB_COLUMN_TIME_STAMP = "timeStamp"; |
||||
|
public static final String MB_COLUMN_TOTAL_TRANSACTIONS = "totalTransactions"; |
||||
|
public static final String MB_COLUMN_VERSION = "version"; |
||||
|
|
||||
|
private static final String MB_DATABASE_CREATE = "create table " + MB_TABLE_NAME + "(" + |
||||
|
MB_COLUMN_ID + " integer primary key autoincrement, " + |
||||
|
MB_COLUMN_BLOCK_HASH + " blob, " + |
||||
|
MB_COLUMN_FLAGS + " blob, " + |
||||
|
MB_COLUMN_HASHES + " blob, " + |
||||
|
MB_COLUMN_HEIGHT + " integer, " + |
||||
|
MB_COLUMN_MERKLE_ROOT + " blob, " + |
||||
|
MB_COLUMN_NONCE + " integer, " + |
||||
|
MB_COLUMN_PREV_BLOCK + " blob, " + |
||||
|
MB_COLUMN_TARGET + " integer, " + |
||||
|
MB_COLUMN_TIME_STAMP + " integer, " + |
||||
|
MB_COLUMN_TOTAL_TRANSACTIONS + " integer, " + |
||||
|
MB_COLUMN_VERSION + " integer );"; |
||||
|
|
||||
|
/** |
||||
|
* Transaction table |
||||
|
*/ |
||||
|
|
||||
|
public static final String TX_TABLE_NAME = "transactionTable"; |
||||
|
public static final String TX_COLUMN_ID = "_id"; |
||||
|
public static final String TX_BLOCK_HEIGHT = "blockHeight"; |
||||
|
public static final String TX_LOCK_TIME = "lockTime"; |
||||
|
public static final String TX_TIME_STAMP = "timeStamp"; |
||||
|
public static final String TX_HASH = "txHash"; |
||||
|
|
||||
|
private static final String TX_DATABASE_CREATE = "create table " + TX_TABLE_NAME + "(" + |
||||
|
TX_COLUMN_ID + " integer primary key autoincrement, " + |
||||
|
TX_BLOCK_HEIGHT + " integer, " + |
||||
|
TX_LOCK_TIME + " integer, " + |
||||
|
TX_TIME_STAMP + " integer, " + |
||||
|
TX_HASH + " blob );"; |
||||
|
|
||||
|
/** |
||||
|
* Peer table |
||||
|
*/ |
||||
|
|
||||
|
public static final String PEER_TABLE_NAME = "peerTable"; |
||||
|
public static final String PEER_COLUMN_ID = "_id"; |
||||
|
public static final String PEER_ADDRESS = "address"; |
||||
|
public static final String PEER_MISBEHAVIN = "misbehavin"; |
||||
|
public static final String PEER_PORT = "port"; |
||||
|
public static final String PEER_SERVICES = "services"; |
||||
|
public static final String PEER_TIME_STAMP = "timeStamp"; |
||||
|
|
||||
|
private static final String PEER_DATABASE_CREATE = "create table " + PEER_TABLE_NAME + "(" + |
||||
|
PEER_COLUMN_ID + " integer primary key autoincrement, " + |
||||
|
PEER_ADDRESS + " integer, " + |
||||
|
PEER_MISBEHAVIN + " integer, " + |
||||
|
PEER_PORT + " integer, " + |
||||
|
PEER_SERVICES + " integer " + |
||||
|
PEER_TIME_STAMP + " integer );"; |
||||
|
|
||||
|
/** |
||||
|
* Inputs table |
||||
|
*/ |
||||
|
|
||||
|
public static final String IN_TABLE_NAME = "inputTable"; |
||||
|
public static final String IN_COLUMN_ID = "_id"; |
||||
|
public static final String IN_TX_HASH = "txHash"; |
||||
|
public static final String IN_INDEX = "index"; |
||||
|
public static final String IN_PREV_OUT_TX_HASH = "prevOutTxHash"; |
||||
|
public static final String IN_PREV_OUT_INDEX = "prevOutIndex"; |
||||
|
public static final String IN_SEQUENCE = "sequence"; |
||||
|
public static final String IN_SIGNATURE = "signature"; |
||||
|
|
||||
|
private static final String INPUTS_DATABASE_CREATE = "create table " + IN_TABLE_NAME + "(" + |
||||
|
IN_COLUMN_ID + " integer primary key autoincrement, " + |
||||
|
IN_TX_HASH + " blob, " + |
||||
|
IN_INDEX + " integer, " + |
||||
|
IN_PREV_OUT_TX_HASH + " blob, " + |
||||
|
IN_PREV_OUT_INDEX + " integer " + |
||||
|
IN_SEQUENCE + " integer ," + |
||||
|
IN_SIGNATURE + " blob );"; |
||||
|
|
||||
|
/** |
||||
|
* Outputs table |
||||
|
*/ |
||||
|
|
||||
|
public static final String OUT_TABLE_NAME = "outputTable"; |
||||
|
public static final String OUT_COLUMN_ID = "_id"; |
||||
|
public static final String OUT_TX_HASH = "txHash"; |
||||
|
public static final String OUT_INDEX = "index"; |
||||
|
public static final String OUT_VALUE = "value"; |
||||
|
|
||||
|
private static final String OUTPUTS_DATABASE_CREATE = "create table " + OUT_TABLE_NAME + "(" + |
||||
|
OUT_COLUMN_ID + " integer primary key autoincrement, " + |
||||
|
OUT_TX_HASH + " blob, " + |
||||
|
OUT_INDEX + " integer, " + |
||||
|
OUT_VALUE + " integer );"; |
||||
|
|
||||
|
|
||||
|
public BRSQLiteHelper(Context context) { |
||||
|
super(context, DATABASE_NAME, null, DATABASE_VERSION); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void onCreate(SQLiteDatabase database) { |
||||
|
database.execSQL(MB_DATABASE_CREATE); |
||||
|
database.execSQL(TX_DATABASE_CREATE); |
||||
|
database.execSQL(PEER_DATABASE_CREATE); |
||||
|
database.execSQL(INPUTS_DATABASE_CREATE); |
||||
|
database.execSQL(OUTPUTS_DATABASE_CREATE); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { |
||||
|
Log.e(TAG, "Upgrading database from version " + oldVersion + " to " |
||||
|
+ newVersion + ", which will destroy all old data"); |
||||
|
db.execSQL("DROP TABLE IF EXISTS " + MB_TABLE_NAME); |
||||
|
db.execSQL("DROP TABLE IF EXISTS " + TX_TABLE_NAME); |
||||
|
db.execSQL("DROP TABLE IF EXISTS " + PEER_TABLE_NAME); |
||||
|
db.execSQL("DROP TABLE IF EXISTS " + IN_TABLE_NAME); |
||||
|
db.execSQL("DROP TABLE IF EXISTS " + OUT_TABLE_NAME); |
||||
|
//recreate the dbs
|
||||
|
onCreate(db); |
||||
|
} |
||||
|
} |
@ -0,0 +1,131 @@ |
|||||
|
package com.breadwallet.tools.sqlite; |
||||
|
|
||||
|
/** |
||||
|
* BreadWallet |
||||
|
* <p/> |
||||
|
* Created by Mihail on 9/25/15. |
||||
|
* Copyright (c) 2015 Mihail Gutan <mihail@breadwallet.com> |
||||
|
* <p/> |
||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
* of this software and associated documentation files (the "Software"), to deal |
||||
|
* in the Software without restriction, including without limitation the rights |
||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
|
* copies of the Software, and to permit persons to whom the Software is |
||||
|
* furnished to do so, subject to the following conditions: |
||||
|
* <p/> |
||||
|
* The above copyright notice and this permission notice shall be included in |
||||
|
* all copies or substantial portions of the Software. |
||||
|
* <p/> |
||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
|
* THE SOFTWARE. |
||||
|
*/ |
||||
|
|
||||
|
import android.content.ContentValues; |
||||
|
import android.content.Context; |
||||
|
import android.database.Cursor; |
||||
|
import android.database.SQLException; |
||||
|
import android.database.sqlite.SQLiteDatabase; |
||||
|
import android.util.Log; |
||||
|
|
||||
|
import com.breadwallet.tools.sqlite.entities.BRMerkleBlockEntity; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
|
||||
|
public class MerkleBlockDataSource { |
||||
|
public static final String TAG = MerkleBlockDataSource.class.getName(); |
||||
|
|
||||
|
// Database fields
|
||||
|
private SQLiteDatabase database; |
||||
|
private BRSQLiteHelper dbHelper; |
||||
|
private String[] allColumns = {BRSQLiteHelper.MB_COLUMN_ID, |
||||
|
BRSQLiteHelper.MB_COLUMN_BLOCK_HASH, BRSQLiteHelper.MB_COLUMN_FLAGS, |
||||
|
BRSQLiteHelper.MB_COLUMN_HASHES, BRSQLiteHelper.MB_COLUMN_HEIGHT, |
||||
|
BRSQLiteHelper.MB_COLUMN_MERKLE_ROOT, BRSQLiteHelper.MB_COLUMN_NONCE, |
||||
|
BRSQLiteHelper.MB_COLUMN_PREV_BLOCK, BRSQLiteHelper.MB_COLUMN_TARGET, |
||||
|
BRSQLiteHelper.MB_COLUMN_TIME_STAMP, BRSQLiteHelper.MB_COLUMN_TOTAL_TRANSACTIONS, |
||||
|
BRSQLiteHelper.MB_COLUMN_VERSION}; |
||||
|
|
||||
|
public MerkleBlockDataSource(Context context) { |
||||
|
dbHelper = new BRSQLiteHelper(context); |
||||
|
} |
||||
|
|
||||
|
public void open() throws SQLException { |
||||
|
database = dbHelper.getWritableDatabase(); |
||||
|
} |
||||
|
|
||||
|
public void close() { |
||||
|
dbHelper.close(); |
||||
|
} |
||||
|
|
||||
|
public BRMerkleBlockEntity createMerkleBlock(BRMerkleBlockEntity merkleBlock) { |
||||
|
ContentValues values = new ContentValues(); |
||||
|
// values.put(BRSQLiteHelper.MB_COLUMN_ID, merkleBlock.getId());
|
||||
|
values.put(BRSQLiteHelper.MB_COLUMN_BLOCK_HASH, merkleBlock.getBlockHash()); |
||||
|
values.put(BRSQLiteHelper.MB_COLUMN_FLAGS, merkleBlock.getFlags()); |
||||
|
values.put(BRSQLiteHelper.MB_COLUMN_HASHES, merkleBlock.getHashes()); |
||||
|
values.put(BRSQLiteHelper.MB_COLUMN_HEIGHT, merkleBlock.getHeight()); |
||||
|
values.put(BRSQLiteHelper.MB_COLUMN_MERKLE_ROOT, merkleBlock.getMerkleRoot()); |
||||
|
values.put(BRSQLiteHelper.MB_COLUMN_NONCE, merkleBlock.getNonce()); |
||||
|
values.put(BRSQLiteHelper.MB_COLUMN_PREV_BLOCK, merkleBlock.getPrevBlock()); |
||||
|
values.put(BRSQLiteHelper.MB_COLUMN_TARGET, merkleBlock.getTarget()); |
||||
|
values.put(BRSQLiteHelper.MB_COLUMN_TIME_STAMP, merkleBlock.getTimeStamp()); |
||||
|
values.put(BRSQLiteHelper.MB_COLUMN_TOTAL_TRANSACTIONS, merkleBlock.getTotalTransactions()); |
||||
|
values.put(BRSQLiteHelper.MB_COLUMN_VERSION, merkleBlock.getVersion()); |
||||
|
|
||||
|
long insertId = database.insert(BRSQLiteHelper.MB_TABLE_NAME, null, values); |
||||
|
Cursor cursor = database.query(BRSQLiteHelper.MB_TABLE_NAME, |
||||
|
allColumns, BRSQLiteHelper.MB_COLUMN_ID + " = " + insertId, null, |
||||
|
null, null, null); |
||||
|
cursor.moveToFirst(); |
||||
|
BRMerkleBlockEntity newMerkleBlock = cursorToMerkleBlock(cursor); |
||||
|
cursor.close(); |
||||
|
return newMerkleBlock; |
||||
|
} |
||||
|
|
||||
|
public void deleteMerkleBlock(BRMerkleBlockEntity merkleBlock) { |
||||
|
long id = merkleBlock.getId(); |
||||
|
Log.e(TAG, "MerkleBlock deleted with id: " + id); |
||||
|
database.delete(BRSQLiteHelper.MB_TABLE_NAME, BRSQLiteHelper.MB_COLUMN_ID |
||||
|
+ " = " + id, null); |
||||
|
} |
||||
|
|
||||
|
public List<BRMerkleBlockEntity> getAllMerkleBlocks() { |
||||
|
List<BRMerkleBlockEntity> merkleBlocks = new ArrayList<>(); |
||||
|
|
||||
|
Cursor cursor = database.query(BRSQLiteHelper.MB_TABLE_NAME, |
||||
|
allColumns, null, null, null, null, null); |
||||
|
|
||||
|
cursor.moveToFirst(); |
||||
|
while (!cursor.isAfterLast()) { |
||||
|
BRMerkleBlockEntity merkleBlockEntity = cursorToMerkleBlock(cursor); |
||||
|
merkleBlocks.add(merkleBlockEntity); |
||||
|
cursor.moveToNext(); |
||||
|
} |
||||
|
// make sure to close the cursor
|
||||
|
cursor.close(); |
||||
|
return merkleBlocks; |
||||
|
} |
||||
|
|
||||
|
private BRMerkleBlockEntity cursorToMerkleBlock(Cursor cursor) { |
||||
|
BRMerkleBlockEntity merkleBlockEntity = new BRMerkleBlockEntity(); |
||||
|
merkleBlockEntity.setId(cursor.getInt(0)); |
||||
|
merkleBlockEntity.setBlockHash(cursor.getBlob(1)); |
||||
|
merkleBlockEntity.setFlags(cursor.getBlob(2)); |
||||
|
merkleBlockEntity.setHashes(cursor.getBlob(3)); |
||||
|
merkleBlockEntity.setHeight(cursor.getInt(4)); |
||||
|
merkleBlockEntity.setMerkleRoot(cursor.getBlob(5)); |
||||
|
merkleBlockEntity.setNonce(cursor.getInt(6)); |
||||
|
merkleBlockEntity.setPrevBlock(cursor.getBlob(7)); |
||||
|
merkleBlockEntity.setTarget(cursor.getInt(8)); |
||||
|
merkleBlockEntity.setTimeStamp(cursor.getLong(9)); |
||||
|
merkleBlockEntity.setTotalTransactions(cursor.getInt(10)); |
||||
|
merkleBlockEntity.setVersion(cursor.getInt(11)); |
||||
|
return merkleBlockEntity; |
||||
|
} |
||||
|
} |
@ -0,0 +1,117 @@ |
|||||
|
package com.breadwallet.tools.sqlite; |
||||
|
|
||||
|
/** |
||||
|
* BreadWallet |
||||
|
* <p/> |
||||
|
* Created by Mihail on 9/25/15. |
||||
|
* Copyright (c) 2015 Mihail Gutan <mihail@breadwallet.com> |
||||
|
* <p/> |
||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
* of this software and associated documentation files (the "Software"), to deal |
||||
|
* in the Software without restriction, including without limitation the rights |
||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
|
* copies of the Software, and to permit persons to whom the Software is |
||||
|
* furnished to do so, subject to the following conditions: |
||||
|
* <p/> |
||||
|
* The above copyright notice and this permission notice shall be included in |
||||
|
* all copies or substantial portions of the Software. |
||||
|
* <p/> |
||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
|
* THE SOFTWARE. |
||||
|
*/ |
||||
|
|
||||
|
import android.content.ContentValues; |
||||
|
import android.content.Context; |
||||
|
import android.database.Cursor; |
||||
|
import android.database.SQLException; |
||||
|
import android.database.sqlite.SQLiteDatabase; |
||||
|
import android.util.Log; |
||||
|
|
||||
|
import com.breadwallet.tools.sqlite.entities.BRPeerEntity; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
|
||||
|
public class PeerDataSource { |
||||
|
public static final String TAG = PeerDataSource.class.getName(); |
||||
|
|
||||
|
// Database fields
|
||||
|
private SQLiteDatabase database; |
||||
|
private BRSQLiteHelper dbHelper; |
||||
|
private String[] allColumns = { |
||||
|
BRSQLiteHelper.PEER_COLUMN_ID, BRSQLiteHelper.PEER_ADDRESS, |
||||
|
BRSQLiteHelper.PEER_MISBEHAVIN, BRSQLiteHelper.PEER_PORT, |
||||
|
BRSQLiteHelper.PEER_SERVICES, BRSQLiteHelper.PEER_TIME_STAMP |
||||
|
}; |
||||
|
|
||||
|
public PeerDataSource(Context context) { |
||||
|
dbHelper = new BRSQLiteHelper(context); |
||||
|
} |
||||
|
|
||||
|
public void open() throws SQLException { |
||||
|
database = dbHelper.getWritableDatabase(); |
||||
|
} |
||||
|
|
||||
|
public void close() { |
||||
|
dbHelper.close(); |
||||
|
} |
||||
|
|
||||
|
public BRPeerEntity createPeer(BRPeerEntity peer) { |
||||
|
ContentValues values = new ContentValues(); |
||||
|
// values.put(BRSQLiteHelper.PEER_COLUMN_ID, peer.getId());
|
||||
|
values.put(BRSQLiteHelper.PEER_ADDRESS, peer.getAddress()); |
||||
|
values.put(BRSQLiteHelper.PEER_MISBEHAVIN, peer.getMisbehavin()); |
||||
|
values.put(BRSQLiteHelper.PEER_PORT, peer.getPort()); |
||||
|
values.put(BRSQLiteHelper.PEER_SERVICES, peer.getServices()); |
||||
|
values.put(BRSQLiteHelper.PEER_TIME_STAMP, peer.getTimeStamp()); |
||||
|
|
||||
|
long insertId = database.insert(BRSQLiteHelper.PEER_TABLE_NAME, null, values); |
||||
|
Cursor cursor = database.query(BRSQLiteHelper.PEER_TABLE_NAME, |
||||
|
allColumns, BRSQLiteHelper.PEER_COLUMN_ID + " = " + insertId, null, |
||||
|
null, null, null); |
||||
|
cursor.moveToFirst(); |
||||
|
BRPeerEntity peerEntity = cursorToPeer(cursor); |
||||
|
cursor.close(); |
||||
|
return peerEntity; |
||||
|
} |
||||
|
|
||||
|
public void deletePeer(BRPeerEntity peerEntity) { |
||||
|
long id = peerEntity.getId(); |
||||
|
Log.e(TAG, "Peer deleted with id: " + id); |
||||
|
database.delete(BRSQLiteHelper.PEER_TABLE_NAME, BRSQLiteHelper.PEER_COLUMN_ID |
||||
|
+ " = " + id, null); |
||||
|
} |
||||
|
|
||||
|
public List<BRPeerEntity> getAllPeers() { |
||||
|
List<BRPeerEntity> peers = new ArrayList<>(); |
||||
|
|
||||
|
Cursor cursor = database.query(BRSQLiteHelper.PEER_TABLE_NAME, |
||||
|
allColumns, null, null, null, null, null); |
||||
|
|
||||
|
cursor.moveToFirst(); |
||||
|
while (!cursor.isAfterLast()) { |
||||
|
BRPeerEntity peerEntity = cursorToPeer(cursor); |
||||
|
peers.add(peerEntity); |
||||
|
cursor.moveToNext(); |
||||
|
} |
||||
|
// make sure to close the cursor
|
||||
|
cursor.close(); |
||||
|
return peers; |
||||
|
} |
||||
|
|
||||
|
private BRPeerEntity cursorToPeer(Cursor cursor) { |
||||
|
BRPeerEntity peerEntity = new BRPeerEntity(); |
||||
|
peerEntity.setId(cursor.getInt(0)); |
||||
|
peerEntity.setAddress(cursor.getInt(1)); |
||||
|
peerEntity.setMisbehavin(cursor.getShort(2)); |
||||
|
peerEntity.setPort(cursor.getShort(3)); |
||||
|
peerEntity.setServices(cursor.getShort(4)); |
||||
|
peerEntity.setTimeStamp(cursor.getLong(5)); |
||||
|
return peerEntity; |
||||
|
} |
||||
|
} |
@ -0,0 +1,137 @@ |
|||||
|
package com.breadwallet.tools.sqlite; |
||||
|
|
||||
|
/** |
||||
|
* BreadWallet |
||||
|
* <p/> |
||||
|
* Created by Mihail on 9/25/15. |
||||
|
* Copyright (c) 2015 Mihail Gutan <mihail@breadwallet.com> |
||||
|
* <p/> |
||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
* of this software and associated documentation files (the "Software"), to deal |
||||
|
* in the Software without restriction, including without limitation the rights |
||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
|
* copies of the Software, and to permit persons to whom the Software is |
||||
|
* furnished to do so, subject to the following conditions: |
||||
|
* <p/> |
||||
|
* The above copyright notice and this permission notice shall be included in |
||||
|
* all copies or substantial portions of the Software. |
||||
|
* <p/> |
||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
|
* THE SOFTWARE. |
||||
|
*/ |
||||
|
|
||||
|
import android.content.ContentValues; |
||||
|
import android.content.Context; |
||||
|
import android.database.Cursor; |
||||
|
import android.database.SQLException; |
||||
|
import android.database.sqlite.SQLiteDatabase; |
||||
|
import android.util.Log; |
||||
|
|
||||
|
import com.breadwallet.tools.sqlite.entities.BRTransactionEntity; |
||||
|
import com.breadwallet.tools.sqlite.entities.BRTxInputEntity; |
||||
|
import com.breadwallet.tools.sqlite.entities.BRTxOutputEntity; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
|
||||
|
public class TransactionDataSource { |
||||
|
public static final String TAG = TransactionDataSource.class.getName(); |
||||
|
|
||||
|
// Database fields
|
||||
|
private SQLiteDatabase database; |
||||
|
private BRSQLiteHelper dbHelper; |
||||
|
private String[] allColumns = { |
||||
|
BRSQLiteHelper.TX_COLUMN_ID, BRSQLiteHelper.TX_BLOCK_HEIGHT, BRSQLiteHelper.TX_LOCK_TIME, |
||||
|
BRSQLiteHelper.TX_TIME_STAMP, BRSQLiteHelper.TX_HASH |
||||
|
}; |
||||
|
|
||||
|
public TransactionDataSource(Context context) { |
||||
|
dbHelper = new BRSQLiteHelper(context); |
||||
|
} |
||||
|
|
||||
|
public void open() throws SQLException { |
||||
|
database = dbHelper.getWritableDatabase(); |
||||
|
} |
||||
|
|
||||
|
public void close() { |
||||
|
dbHelper.close(); |
||||
|
} |
||||
|
|
||||
|
public BRTransactionEntity createTransaction(BRTransactionEntity transactionEntity) { |
||||
|
ContentValues values = new ContentValues(); |
||||
|
// values.put(BRSQLiteHelper.TX_COLUMN_ID, transactionEntity.getId());
|
||||
|
values.put(BRSQLiteHelper.TX_BLOCK_HEIGHT, transactionEntity.getBlockHeight()); |
||||
|
values.put(BRSQLiteHelper.TX_LOCK_TIME, transactionEntity.getLockTime()); |
||||
|
values.put(BRSQLiteHelper.TX_TIME_STAMP, transactionEntity.getTimeStamp()); |
||||
|
values.put(BRSQLiteHelper.TX_HASH, transactionEntity.getTxHash()); |
||||
|
|
||||
|
for(BRTxInputEntity input : transactionEntity.getInputs()){ |
||||
|
ContentValues inputValues = new ContentValues(); |
||||
|
inputValues.put(BRSQLiteHelper.IN_INDEX,input.getIndex()); |
||||
|
inputValues.put(BRSQLiteHelper.IN_PREV_OUT_INDEX, input.getPrevOutIndex()); |
||||
|
inputValues.put(BRSQLiteHelper.IN_PREV_OUT_TX_HASH, input.getPrevOutTxHash()); |
||||
|
inputValues.put(BRSQLiteHelper.IN_SEQUENCE, input.getSequence()); |
||||
|
inputValues.put(BRSQLiteHelper.IN_SIGNATURE, input.getSignatures()); |
||||
|
|
||||
|
database.insert(BRSQLiteHelper.IN_TABLE_NAME, null, values); |
||||
|
} |
||||
|
|
||||
|
for(BRTxOutputEntity output : transactionEntity.getOutputs()){ |
||||
|
ContentValues outputValues = new ContentValues(); |
||||
|
outputValues.put(BRSQLiteHelper.OUT_INDEX,output.getIndex()); |
||||
|
outputValues.put(BRSQLiteHelper.OUT_TX_HASH, output.getTxHash()); |
||||
|
outputValues.put(BRSQLiteHelper.OUT_VALUE, output.getValue()); |
||||
|
|
||||
|
database.insert(BRSQLiteHelper.OUT_TABLE_NAME, null, values); |
||||
|
} |
||||
|
|
||||
|
long insertId = database.insert(BRSQLiteHelper.TX_TABLE_NAME, null, values); |
||||
|
Cursor cursor = database.query(BRSQLiteHelper.TX_TABLE_NAME, |
||||
|
allColumns, BRSQLiteHelper.TX_COLUMN_ID + " = " + insertId, null, |
||||
|
null, null, null); |
||||
|
cursor.moveToFirst(); |
||||
|
BRTransactionEntity transactionEntity1 = cursorToTransaction(cursor); |
||||
|
cursor.close(); |
||||
|
return transactionEntity1; |
||||
|
} |
||||
|
|
||||
|
public void deleteTransaction(BRTransactionEntity transaction) { |
||||
|
long id = transaction.getId(); |
||||
|
Log.e(TAG, "transaction deleted with id: " + id); |
||||
|
database.delete(BRSQLiteHelper.TX_TABLE_NAME, BRSQLiteHelper.TX_COLUMN_ID |
||||
|
+ " = " + id, null); |
||||
|
} |
||||
|
|
||||
|
public List<BRTransactionEntity> getAllTransactions() { |
||||
|
List<BRTransactionEntity> transactions = new ArrayList<>(); |
||||
|
|
||||
|
Cursor cursor = database.query(BRSQLiteHelper.TX_TABLE_NAME, |
||||
|
allColumns, null, null, null, null, null); |
||||
|
|
||||
|
cursor.moveToFirst(); |
||||
|
while (!cursor.isAfterLast()) { |
||||
|
BRTransactionEntity transactionEntity = cursorToTransaction(cursor); |
||||
|
transactions.add(transactionEntity); |
||||
|
cursor.moveToNext(); |
||||
|
} |
||||
|
// make sure to close the cursor
|
||||
|
cursor.close(); |
||||
|
return transactions; |
||||
|
} |
||||
|
|
||||
|
private BRTransactionEntity cursorToTransaction(Cursor cursor) { |
||||
|
BRTransactionEntity transactionEntity = new BRTransactionEntity(); |
||||
|
transactionEntity.setId(cursor.getInt(0)); |
||||
|
transactionEntity.setBlockHeight(cursor.getInt(1)); |
||||
|
transactionEntity.setLockTime(cursor.getInt(2)); |
||||
|
transactionEntity.setTimeStamp(cursor.getInt(3)); |
||||
|
transactionEntity.setTxHash(cursor.getBlob(4)); |
||||
|
return transactionEntity; |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,138 @@ |
|||||
|
package com.breadwallet.tools.sqlite.entities; |
||||
|
|
||||
|
/** |
||||
|
* BreadWallet |
||||
|
* <p/> |
||||
|
* Created by Mihail on 9/25/15. |
||||
|
* Copyright (c) 2015 Mihail Gutan <mihail@breadwallet.com> |
||||
|
* <p/> |
||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
* of this software and associated documentation files (the "Software"), to deal |
||||
|
* in the Software without restriction, including without limitation the rights |
||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
|
* copies of the Software, and to permit persons to whom the Software is |
||||
|
* furnished to do so, subject to the following conditions: |
||||
|
* <p/> |
||||
|
* The above copyright notice and this permission notice shall be included in |
||||
|
* all copies or substantial portions of the Software. |
||||
|
* <p/> |
||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
|
* THE SOFTWARE. |
||||
|
*/ |
||||
|
public class BRMerkleBlockEntity { |
||||
|
|
||||
|
private long id; |
||||
|
private byte[] blockHash = new byte[32]; |
||||
|
private byte[] flags = new byte[32]; |
||||
|
private byte[] hashes = new byte[32]; |
||||
|
private int height; |
||||
|
private byte[] merkleRoot = new byte[32]; |
||||
|
private int nonce; |
||||
|
private byte[] prevBlock = new byte[32]; |
||||
|
private int target; |
||||
|
private long timeStamp; |
||||
|
private int totalTransactions; |
||||
|
private int version; |
||||
|
|
||||
|
|
||||
|
public byte[] getBlockHash() { |
||||
|
return blockHash; |
||||
|
} |
||||
|
|
||||
|
public void setBlockHash(byte[] blockHash) { |
||||
|
this.blockHash = blockHash; |
||||
|
} |
||||
|
|
||||
|
public byte[] getFlags() { |
||||
|
return flags; |
||||
|
} |
||||
|
|
||||
|
public void setFlags(byte[] flags) { |
||||
|
this.flags = flags; |
||||
|
} |
||||
|
|
||||
|
public byte[] getHashes() { |
||||
|
return hashes; |
||||
|
} |
||||
|
|
||||
|
public void setHashes(byte[] hashes) { |
||||
|
this.hashes = hashes; |
||||
|
} |
||||
|
|
||||
|
public int getHeight() { |
||||
|
return height; |
||||
|
} |
||||
|
|
||||
|
public void setHeight(int height) { |
||||
|
this.height = height; |
||||
|
} |
||||
|
|
||||
|
public long getId() { |
||||
|
return id; |
||||
|
} |
||||
|
|
||||
|
public void setId(long id) { |
||||
|
this.id = id; |
||||
|
} |
||||
|
|
||||
|
public byte[] getMerkleRoot() { |
||||
|
return merkleRoot; |
||||
|
} |
||||
|
|
||||
|
public void setMerkleRoot(byte[] merkleRoot) { |
||||
|
this.merkleRoot = merkleRoot; |
||||
|
} |
||||
|
|
||||
|
public int getNonce() { |
||||
|
return nonce; |
||||
|
} |
||||
|
|
||||
|
public void setNonce(int nonce) { |
||||
|
this.nonce = nonce; |
||||
|
} |
||||
|
|
||||
|
public byte[] getPrevBlock() { |
||||
|
return prevBlock; |
||||
|
} |
||||
|
|
||||
|
public void setPrevBlock(byte[] prevBlock) { |
||||
|
this.prevBlock = prevBlock; |
||||
|
} |
||||
|
|
||||
|
public int getTarget() { |
||||
|
return target; |
||||
|
} |
||||
|
|
||||
|
public void setTarget(int target) { |
||||
|
this.target = target; |
||||
|
} |
||||
|
|
||||
|
public long getTimeStamp() { |
||||
|
return timeStamp; |
||||
|
} |
||||
|
|
||||
|
public void setTimeStamp(long timeStamp) { |
||||
|
this.timeStamp = timeStamp; |
||||
|
} |
||||
|
|
||||
|
public int getTotalTransactions() { |
||||
|
return totalTransactions; |
||||
|
} |
||||
|
|
||||
|
public void setTotalTransactions(int totalTransactions) { |
||||
|
this.totalTransactions = totalTransactions; |
||||
|
} |
||||
|
|
||||
|
public int getVersion() { |
||||
|
return version; |
||||
|
} |
||||
|
|
||||
|
public void setVersion(int version) { |
||||
|
this.version = version; |
||||
|
} |
||||
|
} |
@ -0,0 +1,93 @@ |
|||||
|
package com.breadwallet.tools.sqlite.entities; |
||||
|
|
||||
|
import java.util.HashSet; |
||||
|
|
||||
|
/** |
||||
|
* BreadWallet |
||||
|
* <p/> |
||||
|
* Created by Mihail on 9/23/15. |
||||
|
* Copyright (c) 2015 Mihail Gutan <mihail@breadwallet.com> |
||||
|
* <p/> |
||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
* of this software and associated documentation files (the "Software"), to deal |
||||
|
* in the Software without restriction, including without limitation the rights |
||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
|
* copies of the Software, and to permit persons to whom the Software is |
||||
|
* furnished to do so, subject to the following conditions: |
||||
|
* <p/> |
||||
|
* The above copyright notice and this permission notice shall be included in |
||||
|
* all copies or substantial portions of the Software. |
||||
|
* <p/> |
||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
|
* THE SOFTWARE. |
||||
|
*/ |
||||
|
public class BRTransactionEntity { |
||||
|
private int id; |
||||
|
private int blockHeight; |
||||
|
private int lockTime; |
||||
|
private long timeStamp; |
||||
|
private byte[] txHash = new byte[32]; |
||||
|
private HashSet<BRTxInputEntity> inputs; |
||||
|
private HashSet<BRTxOutputEntity> outputs; |
||||
|
|
||||
|
public int getBlockHeight() { |
||||
|
return blockHeight; |
||||
|
} |
||||
|
|
||||
|
public void setBlockHeight(int blockHeight) { |
||||
|
this.blockHeight = blockHeight; |
||||
|
} |
||||
|
|
||||
|
public int getId() { |
||||
|
return id; |
||||
|
} |
||||
|
|
||||
|
public void setId(int id) { |
||||
|
this.id = id; |
||||
|
} |
||||
|
|
||||
|
public HashSet<BRTxInputEntity> getInputs() { |
||||
|
return inputs; |
||||
|
} |
||||
|
|
||||
|
public void setInputs(HashSet<BRTxInputEntity> inputs) { |
||||
|
this.inputs = inputs; |
||||
|
} |
||||
|
|
||||
|
public int getLockTime() { |
||||
|
return lockTime; |
||||
|
} |
||||
|
|
||||
|
public void setLockTime(int lockTime) { |
||||
|
this.lockTime = lockTime; |
||||
|
} |
||||
|
|
||||
|
public HashSet<BRTxOutputEntity> getOutputs() { |
||||
|
return outputs; |
||||
|
} |
||||
|
|
||||
|
public void setOutputs(HashSet<BRTxOutputEntity> outputs) { |
||||
|
this.outputs = outputs; |
||||
|
} |
||||
|
|
||||
|
public long getTimeStamp() { |
||||
|
return timeStamp; |
||||
|
} |
||||
|
|
||||
|
public void setTimeStamp(long timeStamp) { |
||||
|
this.timeStamp = timeStamp; |
||||
|
} |
||||
|
|
||||
|
public byte[] getTxHash() { |
||||
|
return txHash; |
||||
|
} |
||||
|
|
||||
|
public void setTxHash(byte[] txHash) { |
||||
|
this.txHash = txHash; |
||||
|
} |
||||
|
} |
@ -0,0 +1,94 @@ |
|||||
|
package com.breadwallet.tools.sqlite.entities; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* BreadWallet |
||||
|
* <p/> |
||||
|
* Created by Mihail on 9/25/15. |
||||
|
* Copyright (c) 2015 Mihail Gutan <mihail@breadwallet.com> |
||||
|
* <p/> |
||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
|
* of this software and associated documentation files (the "Software"), to deal |
||||
|
* in the Software without restriction, including without limitation the rights |
||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
|
* copies of the Software, and to permit persons to whom the Software is |
||||
|
* furnished to do so, subject to the following conditions: |
||||
|
* <p/> |
||||
|
* The above copyright notice and this permission notice shall be included in |
||||
|
* all copies or substantial portions of the Software. |
||||
|
* <p/> |
||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
|
* THE SOFTWARE. |
||||
|
*/ |
||||
|
public class BRTxInputEntity implements Serializable { |
||||
|
|
||||
|
private int id; |
||||
|
private int index; |
||||
|
private byte[] prevOutTxHash; |
||||
|
private int prevOutIndex; |
||||
|
private int sequence; |
||||
|
private byte[] signatures = new byte[32]; |
||||
|
private byte[] txHash = new byte[32]; |
||||
|
|
||||
|
public int getIndex() { |
||||
|
return index; |
||||
|
} |
||||
|
|
||||
|
public void setIndex(int index) { |
||||
|
this.index = index; |
||||
|
} |
||||
|
|
||||
|
public int getPrevOutIndex() { |
||||
|
return prevOutIndex; |
||||
|
} |
||||
|
|
||||
|
public void setPrevOutIndex(int prevOutIndex) { |
||||
|
this.prevOutIndex = prevOutIndex; |
||||
|
} |
||||
|
|
||||
|
public byte[] getPrevOutTxHash() { |
||||
|
return prevOutTxHash; |
||||
|
} |
||||
|
|
||||
|
public void setPrevOutTxHash(byte[] prevOutTxHash) { |
||||
|
this.prevOutTxHash = prevOutTxHash; |
||||
|
} |
||||
|
|
||||
|
public int getId() { |
||||
|
return id; |
||||
|
} |
||||
|
|
||||
|
public void setId(int id) { |
||||
|
this.id = id; |
||||
|
} |
||||
|
|
||||
|
public int getSequence() { |
||||
|
return sequence; |
||||
|
} |
||||
|
|
||||
|
public void setSequence(int sequence) { |
||||
|
this.sequence = sequence; |
||||
|
} |
||||
|
|
||||
|
public byte[] getSignatures() { |
||||
|
return signatures; |
||||
|
} |
||||
|
|
||||
|
public void setSignatures(byte[] signatures) { |
||||
|
this.signatures = signatures; |
||||
|
} |
||||
|
|
||||
|
public byte[] getTxHash() { |
||||
|
return txHash; |
||||
|
} |
||||
|
|
||||
|
public void setTxHash(byte[] txHash) { |
||||
|
this.txHash = txHash; |
||||
|
} |
||||
|
} |
@ -1,28 +0,0 @@ |
|||||
package com.breadwallet.wallet; |
|
||||
|
|
||||
/** |
|
||||
* BreadWallet |
|
||||
* <p/> |
|
||||
* Created by Mihail on 9/23/15. |
|
||||
* Copyright (c) 2015 Mihail Gutan <mihail@breadwallet.com> |
|
||||
* <p/> |
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy |
|
||||
* of this software and associated documentation files (the "Software"), to deal |
|
||||
* in the Software without restriction, including without limitation the rights |
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
||||
* copies of the Software, and to permit persons to whom the Software is |
|
||||
* furnished to do so, subject to the following conditions: |
|
||||
* <p/> |
|
||||
* The above copyright notice and this permission notice shall be included in |
|
||||
* all copies or substantial portions of the Software. |
|
||||
* <p/> |
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|
||||
* THE SOFTWARE. |
|
||||
*/ |
|
||||
public class BRTransaction { |
|
||||
} |
|
@ -0,0 +1 @@ |
|||||
|
Subproject commit 11e35d689ae7655a15df20668536028d9b68f411 |
@ -0,0 +1,18 @@ |
|||||
|
//
|
||||
|
// Created by Mihail Gutan on 9/24/15.
|
||||
|
//
|
||||
|
#include "stdio.h" |
||||
|
#include "core.h" |
||||
|
JNIEXPORT void Java_com_breadwallet_presenter_activities_MainActivity_sendMethodCallBack |
||||
|
(JNIEnv *env, jobject obj){ |
||||
|
jclass cls = (*env)->GetObjectClass(env, obj); |
||||
|
jmethodID mid = (*env)->GetMethodID(env, cls, "callback", "()V"); |
||||
|
if (mid == 0) |
||||
|
return; |
||||
|
(*env)->CallVoidMethod(env, obj, mid); |
||||
|
}; |
||||
|
|
||||
|
JNIEXPORT jbyteArray Java_com_breadwallet_wallet_BRWalletManager_encodePhrase |
||||
|
(JNIEnv *env, jobject obj, jbyteArray seed){ |
||||
|
|
||||
|
} |
@ -0,0 +1,11 @@ |
|||||
|
//
|
||||
|
// Created by Mihail Gutan on 9/24/15.
|
||||
|
//
|
||||
|
#include <jni.h> |
||||
|
#ifndef BREADWALLET_CORE_H |
||||
|
#define BREADWALLET_CORE_H |
||||
|
|
||||
|
#endif //BREADWALLET_CORE_H
|
||||
|
|
||||
|
JNIEXPORT void Java_com_breadwallet_presenter_activities_MainActivity_sendMethodCallBack |
||||
|
(JNIEnv *env, jobject thiz); |
@ -0,0 +1,8 @@ |
|||||
|
#include <jni.h> |
||||
|
|
||||
|
//#define DEBUG_TAG "NDK_AndroidNDK1SampleActivity"
|
||||
|
JNIEXPORT jstring Java_com_breadwallet_presenter_activities_MainActivity_messageFromNativeCode |
||||
|
(JNIEnv *env, jobject this, jstring logThis) { |
||||
|
const char *nativeString = (*env)->GetStringUTFChars(env, logThis, 0); |
||||
|
return (*env)->NewStringUTF(env, nativeString); |
||||
|
} |
Loading…
Reference in new issue