Updated on 2026-08-14
This commit is contained in:
parent
8013392219
commit
92d3780a82
7 changed files with 150 additions and 55 deletions
|
|
@ -14,7 +14,7 @@ import retrofit2.http.Query;
|
|||
|
||||
public interface BlockchainInfoApi {
|
||||
@GET(Server.ApiBlockchainInfo.Method.ADDRESS)
|
||||
Single<BlockchainInfoAddress> blockchainInfoAddress(@Path("address") String address);
|
||||
Single<BlockchainInfoAddress> blockchainInfoAddress(@Path("address") String address, @Query("offset") Integer offset);
|
||||
|
||||
@GET(Server.ApiBlockchainInfo.Method.UTXO)
|
||||
Single<BlockchainInfoUnspents> blockchainInfoUnspents(@Query("active") String address);
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ public class Server {
|
|||
|
||||
public static class Method {
|
||||
static final String MAIN = URL_BLOCKCYPHER + V1_MAIN;
|
||||
static final String ADDRESS = MAIN + "/addrs/{address}?unspentOnly=true&includeScript=true";
|
||||
static final String ADDRESS = MAIN + "/addrs/{address}?includeScript=true&limit=2000";
|
||||
static final String TXS = MAIN + "/txs/{txHash}?includeHex=true";
|
||||
static final String PUSH = MAIN + "/txs/push";
|
||||
}
|
||||
|
|
@ -123,7 +123,7 @@ public class Server {
|
|||
public static final String URL_BLOCKCHAININFO = ServerURL.API_BLOCKCHAIN_INFO;
|
||||
|
||||
public static class Method {
|
||||
static final String ADDRESS = URL_BLOCKCHAININFO + "rawaddr/{address}?limit=5";
|
||||
static final String ADDRESS = URL_BLOCKCHAININFO + "rawaddr/{address}";
|
||||
static final String UTXO = URL_BLOCKCHAININFO + "unspent";
|
||||
// static final String TX = URL_BLOCKCHAININFO + "rawtx/{txHash}";
|
||||
static final String PUSH = URL_BLOCKCHAININFO + "pushtx";
|
||||
|
|
|
|||
|
|
@ -5,9 +5,11 @@ import android.util.Log;
|
|||
import com.tangem.App;
|
||||
import com.tangem.data.network.model.BlockchainInfoAddress;
|
||||
import com.tangem.data.network.model.BlockchainInfoAddressAndUnspents;
|
||||
import com.tangem.data.network.model.BlockchainInfoTransaction;
|
||||
import com.tangem.data.network.model.BlockchainInfoUnspents;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.SingleObserver;
|
||||
|
|
@ -17,12 +19,13 @@ import okhttp3.ResponseBody;
|
|||
|
||||
public class ServerApiBlockchainInfo {
|
||||
private static String TAG = ServerApiBlockchainInfo.class.getSimpleName();
|
||||
private int page = 1;
|
||||
|
||||
public void getAddressAndUnspents(String wallet, SingleObserver<BlockchainInfoAddressAndUnspents> addressAndUnspentsObserver) {
|
||||
Log.i(TAG, "new getAddressAndUnspents request");
|
||||
BlockchainInfoApi api = App.Companion.getNetworkComponent().getRetrofitBlockchainInfo().create(BlockchainInfoApi.class);
|
||||
|
||||
Single<BlockchainInfoAddress> addressObservable = api.blockchainInfoAddress(wallet);
|
||||
Single<BlockchainInfoAddress> addressObservable = api.blockchainInfoAddress(wallet, null);
|
||||
|
||||
Single<BlockchainInfoUnspents> unspentsObservable = api.blockchainInfoUnspents(wallet)
|
||||
.onErrorReturnItem(new BlockchainInfoUnspents(new ArrayList<>()));
|
||||
|
|
@ -43,4 +46,17 @@ public class ServerApiBlockchainInfo {
|
|||
|
||||
sendObservable.subscribe(sendObserver);
|
||||
}
|
||||
|
||||
public Single<List<BlockchainInfoTransaction>> getMoreAddressTxs(String wallet) {
|
||||
Log.i(TAG, "new getAddress request");
|
||||
BlockchainInfoApi api = App.Companion.getNetworkComponent().getRetrofitBlockchainInfo().create(BlockchainInfoApi.class);
|
||||
|
||||
Single<List<BlockchainInfoTransaction>> addressObservable = api.blockchainInfoAddress(wallet, page * 50)
|
||||
.map(BlockchainInfoAddress::getTxs)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
|
||||
page++;
|
||||
return addressObservable;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,10 @@ data class BlockchainInfoTransaction(
|
|||
var hash: String? = null,
|
||||
|
||||
@SerializedName("block_height")
|
||||
var block_height: Long? = null
|
||||
var block_height: Long? = null,
|
||||
|
||||
@SerializedName("inputs")
|
||||
var inputs: List<BlockchainInfoInput>
|
||||
)
|
||||
|
||||
data class BlockchainInfoUnspents(
|
||||
|
|
@ -37,6 +40,16 @@ data class BlockchainInfoUtxo(
|
|||
var script: String? = null
|
||||
)
|
||||
|
||||
data class BlockchainInfoInput(
|
||||
@SerializedName("prev_out")
|
||||
var prev_out: BlockchainInfoOutput
|
||||
)
|
||||
|
||||
data class BlockchainInfoOutput(
|
||||
@SerializedName("addr")
|
||||
var addr: String? = null
|
||||
)
|
||||
|
||||
data class BlockchainInfoAddressAndUnspents(
|
||||
var address: BlockchainInfoAddress,
|
||||
var unspents: BlockchainInfoUnspents
|
||||
|
|
|
|||
|
|
@ -13,13 +13,22 @@ data class BlockcypherResponse(
|
|||
var unconfirmed_balance: Long? = null,
|
||||
|
||||
@SerializedName("txrefs")
|
||||
var txrefs: List<BlockcypherTxref>? = null
|
||||
var txrefs: List<BlockcypherTxref>? = null,
|
||||
|
||||
@SerializedName("unconfirmed_txrefs")
|
||||
var unconfirmed_txrefs: List<BlockcypherTxref>? = null,
|
||||
|
||||
@SerializedName("hasMore")
|
||||
var hasMore: Boolean? = null
|
||||
)
|
||||
|
||||
data class BlockcypherTxref(
|
||||
@SerializedName("tx_hash")
|
||||
var tx_hash: String? = null,
|
||||
|
||||
@SerializedName("tx_input_n")
|
||||
var tx_input_n: Int? = null,
|
||||
|
||||
@SerializedName("tx_output_n")
|
||||
var tx_output_n: Int? = null,
|
||||
|
||||
|
|
@ -30,7 +39,10 @@ data class BlockcypherTxref(
|
|||
var confirmations: Long? = null,
|
||||
|
||||
@SerializedName("script")
|
||||
var script: String? = null
|
||||
var script: String? = null,
|
||||
|
||||
@SerializedName("spent")
|
||||
var spent: Boolean? = null
|
||||
)
|
||||
|
||||
data class BlockcypherTx(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue