-
Notifications
You must be signed in to change notification settings - Fork 5
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 #32 from patnorris/29-secure-send-btc-endpoint
29 secure send btc endpoint
- Loading branch information
Showing
26 changed files
with
8,627 additions
and
119 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
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"donation_canister": { | ||
"ic": "ekral-oiaaa-aaaag-acmda-cai" | ||
"ic": "ekral-oiaaa-aaaag-acmda-cai", | ||
"local": "bkyz2-fmaaa-aaaaa-qaaaq-cai" | ||
} | ||
} |
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
74 changes: 74 additions & 0 deletions
74
backend/donation_canister/src/declarations/donation_canister/donation_canister.did
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,74 @@ | ||
type Utxo = | ||
record { | ||
height: nat32; | ||
outpoint: OutPoint; | ||
value: Satoshi; | ||
}; | ||
type SendRequest = | ||
record { | ||
amount_in_satoshi: Satoshi; | ||
destination_address: text; | ||
}; | ||
type SendRecordResult = | ||
variant { | ||
Err: ApiError; | ||
Ok: SendRecord; | ||
}; | ||
type SendRecord = record {txid: text;}; | ||
type Satoshi__1 = nat64; | ||
type Satoshi = nat64; | ||
type Page = vec nat8; | ||
type OutPoint = | ||
record { | ||
txid: blob; | ||
vout: nat32; | ||
}; | ||
type Network = | ||
variant { | ||
mainnet; | ||
regtest; | ||
testnet; | ||
}; | ||
type MillisatoshiPerVByte = nat64; | ||
type GetUtxosResponse = | ||
record { | ||
next_page: opt Page; | ||
tip_block_hash: BlockHash; | ||
tip_height: nat32; | ||
utxos: vec Utxo; | ||
}; | ||
type BlockHash = vec nat8; | ||
type BitcoinAddress = text; | ||
type BasicBitcoin = | ||
service { | ||
amiController: () -> (AuthRecordResult); | ||
/// Returns the balance of the given Bitcoin address. | ||
get_balance: (BitcoinAddress) -> (Satoshi__1); | ||
/// Returns the 100 fee percentiles measured in millisatoshi/vbyte. | ||
/// Percentiles are computed from the last 10,000 transactions (if available). | ||
get_current_fee_percentiles: () -> (vec MillisatoshiPerVByte); | ||
/// Returns the P2PKH address of this canister at a specific derivation path. | ||
get_p2pkh_address: () -> (BitcoinAddress); | ||
/// Returns the UTXOs of the given Bitcoin address. | ||
get_utxos: (BitcoinAddress) -> (GetUtxosResponse); | ||
/// Sends the given amount of bitcoin from this canister to the given address. | ||
/// Only controllers of this canister allowed to call. | ||
/// - Note that the donation_tracker_canister will be a controller. | ||
/// Returns a SendRecordResult, containing the transaction ID | ||
send: (SendRequest) -> (SendRecordResult); | ||
whoami: () -> (principal); | ||
}; | ||
type AuthRecordResult = | ||
variant { | ||
Err: ApiError; | ||
Ok: AuthRecord; | ||
}; | ||
type AuthRecord = record {auth: text;}; | ||
type ApiError = | ||
variant { | ||
InvalidId; | ||
Other: text; | ||
Unauthorized; | ||
ZeroAddress; | ||
}; | ||
service : (Network) -> BasicBitcoin |
51 changes: 51 additions & 0 deletions
51
backend/donation_canister/src/declarations/donation_canister/donation_canister.did.d.ts
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,51 @@ | ||
import type { Principal } from '@dfinity/principal'; | ||
import type { ActorMethod } from '@dfinity/agent'; | ||
import type { IDL } from '@dfinity/candid'; | ||
|
||
export type ApiError = { 'InvalidId' : null } | | ||
{ 'ZeroAddress' : null } | | ||
{ 'Unauthorized' : null } | | ||
{ 'Other' : string }; | ||
export interface AuthRecord { 'auth' : string } | ||
export type AuthRecordResult = { 'Ok' : AuthRecord } | | ||
{ 'Err' : ApiError }; | ||
export interface BasicBitcoin { | ||
'amiController' : ActorMethod<[], AuthRecordResult>, | ||
'get_balance' : ActorMethod<[BitcoinAddress], Satoshi__1>, | ||
'get_current_fee_percentiles' : ActorMethod<[], BigUint64Array | bigint[]>, | ||
'get_p2pkh_address' : ActorMethod<[], BitcoinAddress>, | ||
'get_utxos' : ActorMethod<[BitcoinAddress], GetUtxosResponse>, | ||
'send' : ActorMethod<[SendRequest], SendRecordResult>, | ||
'whoami' : ActorMethod<[], Principal>, | ||
} | ||
export type BitcoinAddress = string; | ||
export type BlockHash = Uint8Array | number[]; | ||
export interface GetUtxosResponse { | ||
'next_page' : [] | [Page], | ||
'tip_height' : number, | ||
'tip_block_hash' : BlockHash, | ||
'utxos' : Array<Utxo>, | ||
} | ||
export type MillisatoshiPerVByte = bigint; | ||
export type Network = { 'mainnet' : null } | | ||
{ 'regtest' : null } | | ||
{ 'testnet' : null }; | ||
export interface OutPoint { 'txid' : Uint8Array | number[], 'vout' : number } | ||
export type Page = Uint8Array | number[]; | ||
export type Satoshi = bigint; | ||
export type Satoshi__1 = bigint; | ||
export interface SendRecord { 'txid' : string } | ||
export type SendRecordResult = { 'Ok' : SendRecord } | | ||
{ 'Err' : ApiError }; | ||
export interface SendRequest { | ||
'destination_address' : string, | ||
'amount_in_satoshi' : Satoshi, | ||
} | ||
export interface Utxo { | ||
'height' : number, | ||
'value' : Satoshi, | ||
'outpoint' : OutPoint, | ||
} | ||
export interface _SERVICE extends BasicBitcoin {} | ||
export declare const idlFactory: IDL.InterfaceFactory; | ||
export declare const init: ({ IDL }: { IDL: IDL }) => IDL.Type[]; |
Oops, something went wrong.