Skip to content

Commit

Permalink
add connect_peer rpc, bump version number
Browse files Browse the repository at this point in the history
  • Loading branch information
Ash-L2L committed Mar 18, 2024
1 parent 3e40eb0 commit 8fa4d0e
Show file tree
Hide file tree
Showing 6 changed files with 240 additions and 226 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ members = [
[workspace.package]
authors = [ "Ash Manning <[email protected]>" ]
edition = "2021"
version = "0.6.1"
version = "0.6.2"

[workspace.dependencies.bip300301]
git = "https://github.com/Ash-L2L/bip300301.git"
Expand Down
114 changes: 60 additions & 54 deletions app/rpc_api.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! RPC API
use std::net::SocketAddr;

use bip300301::bitcoin;
use fraction::Fraction;
use jsonrpsee::{core::RpcResult, proc_macros::rpc};
Expand All @@ -14,35 +16,13 @@ use plain_bitassets::{

#[rpc(client, server)]
pub trait Rpc {
#[method(name = "stop")]
async fn stop(&self);

/// Balance in sats
#[method(name = "bitcoin_balance")]
async fn bitcoin_balance(&self) -> RpcResult<u64>;

#[method(name = "format_deposit_address")]
async fn format_deposit_address(
&self,
address: Address,
) -> RpcResult<String>;

#[method(name = "getblockcount")]
async fn getblockcount(&self) -> RpcResult<u32>;

#[method(name = "get_amm_price")]
async fn get_amm_price(
&self,
base: AssetId,
quote: AssetId,
) -> RpcResult<Option<Fraction>>;

#[method(name = "get_amm_pool_state")]
async fn get_amm_pool_state(
#[method(name = "amm_burn")]
async fn amm_burn(
&self,
asset0: AssetId,
asset1: AssetId,
) -> RpcResult<AmmPoolState>;
lp_token_amount: u64,
) -> RpcResult<()>;

#[method(name = "amm_mint")]
async fn amm_mint(
Expand All @@ -53,14 +33,6 @@ pub trait Rpc {
amount1: u64,
) -> RpcResult<()>;

#[method(name = "amm_burn")]
async fn amm_burn(
&self,
asset0: AssetId,
asset1: AssetId,
lp_token_amount: u64,
) -> RpcResult<()>;

/// Returns the amount of `asset_receive` to receive
#[method(name = "amm_swap")]
async fn amm_swap(
Expand All @@ -76,17 +48,13 @@ pub trait Rpc {
&self,
) -> RpcResult<Vec<(BitAssetSeqId, BitAssetId, BitAssetData)>>;

/// List all Dutch auctions
#[method(name = "dutch_auctions")]
async fn dutch_auctions(
&self,
) -> RpcResult<Vec<(DutchAuctionId, DutchAuctionState)>>;
/// Balance in sats
#[method(name = "bitcoin_balance")]
async fn bitcoin_balance(&self) -> RpcResult<u64>;

#[method(name = "dutch_auction_create")]
async fn dutch_auction_create(
&self,
dutch_auction_params: DutchAuctionParams,
) -> RpcResult<()>;
/// Connect to a peer
#[method(name = "connect_peer")]
async fn connect_peer(&self, addr: SocketAddr) -> RpcResult<()>;

/// Returns the amount of the base asset to receive
#[method(name = "dutch_auction_bid")]
Expand All @@ -96,19 +64,60 @@ pub trait Rpc {
bid_size: u64,
) -> RpcResult<u64>;

#[method(name = "dutch_auction_create")]
async fn dutch_auction_create(
&self,
dutch_auction_params: DutchAuctionParams,
) -> RpcResult<()>;

/// Returns the amount of the base asset and quote asset to receive
#[method(name = "dutch_auction_collect")]
async fn dutch_auction_collect(
&self,
dutch_auction_id: DutchAuctionId,
) -> RpcResult<(u64, u64)>;

#[method(name = "get_block_hash")]
async fn get_block_hash(&self, height: u32) -> RpcResult<BlockHash>;
/// List all Dutch auctions
#[method(name = "dutch_auctions")]
async fn dutch_auctions(
&self,
) -> RpcResult<Vec<(DutchAuctionId, DutchAuctionState)>>;

#[method(name = "format_deposit_address")]
async fn format_deposit_address(
&self,
address: Address,
) -> RpcResult<String>;

#[method(name = "generate_mnemonic")]
async fn generate_mnemonic(&self) -> RpcResult<String>;

#[method(name = "get_amm_pool_state")]
async fn get_amm_pool_state(
&self,
asset0: AssetId,
asset1: AssetId,
) -> RpcResult<AmmPoolState>;

#[method(name = "get_amm_price")]
async fn get_amm_price(
&self,
base: AssetId,
quote: AssetId,
) -> RpcResult<Option<Fraction>>;

#[method(name = "get_block")]
async fn get_block(&self, block_hash: BlockHash) -> RpcResult<Block>;

#[method(name = "get_block_hash")]
async fn get_block_hash(&self, height: u32) -> RpcResult<BlockHash>;

#[method(name = "get_new_address")]
async fn get_new_address(&self) -> RpcResult<Address>;

#[method(name = "getblockcount")]
async fn getblockcount(&self) -> RpcResult<u32>;

#[method(name = "mine")]
async fn mine(&self, fee: Option<u64>) -> RpcResult<()>;

Expand All @@ -123,18 +132,18 @@ pub trait Rpc {
#[method(name = "my_utxos")]
async fn my_utxos(&self) -> RpcResult<Vec<FilledOutput>>;

#[method(name = "get_new_address")]
async fn get_new_address(&self) -> RpcResult<Address>;

#[method(name = "generate_mnemonic")]
async fn generate_mnemonic(&self) -> RpcResult<String>;
#[method(name = "reserve_bitasset")]
async fn reserve_bitasset(&self, plain_name: String) -> RpcResult<()>;

#[method(name = "set_seed_from_mnemonic")]
async fn set_seed_from_mnemonic(&self, mnemonic: String) -> RpcResult<()>;

#[method(name = "sidechain_wealth")]
async fn sidechain_wealth(&self) -> RpcResult<bitcoin::Amount>;

#[method(name = "stop")]
async fn stop(&self);

#[method(name = "transfer")]
async fn transfer(
&self,
Expand All @@ -143,7 +152,4 @@ pub trait Rpc {
fee: u64,
memo: Option<String>,
) -> RpcResult<()>;

#[method(name = "reserve_bitasset")]
async fn reserve_bitasset(&self, plain_name: String) -> RpcResult<()>;
}
Loading

0 comments on commit 8fa4d0e

Please sign in to comment.