-
Notifications
You must be signed in to change notification settings - Fork 256
/
Copy pathBTCBitcoinURL.h
104 lines (84 loc) · 2.77 KB
/
BTCBitcoinURL.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// CoreBitcoin by Oleg Andreev <[email protected]>, WTFPL.
#import <Foundation/Foundation.h>
#import "BTCUnitsAndLimits.h"
// TODO: support handling URL from UIApplicationDelegate.
/*!
* Class to compose and handle various Bitcoin URLs according to BIP21.
* See: https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki
*/
@class BTCAddress;
@class BTCAssetID;
@interface BTCBitcoinURL : NSObject
/*!
* Encoded address.
*/
@property(nonatomic, nullable) BTCAddress* address;
/*!
* Amount in satoshis. Default is 0.
*/
@property(nonatomic) BTCAmount amount;
/*!
* Asset ID for Open Assets URL.
*/
@property(nonatomic, nullable) BTCAssetID* assetID;
/*!
* Label. Default is nil.
*/
@property(nonatomic, nullable) NSString* label;
/*!
* Message. Default is nil.
*/
@property(nonatomic, nullable) NSString* message;
/*!
* Query parameters. Default is nil.
*/
@property(nonatomic, nonnull) NSDictionary* queryParameters;
/*!
* Payment request URL (r=...). Default is nil.
*/
@property(nonatomic, nullable) NSURL* paymentRequestURL;
/*!
* Complete URL built from the individual properties.
*/
@property(nonatomic, readonly, nonnull) NSURL* URL;
/*!
* Returns YES if it has a valid address or paymentRequestURL.
*/
@property(nonatomic, readonly) BOOL isValid;
/*!
* Returns YES if it is a pure bitcoin URL. That does not specify asset_id and not uses openassets: scheme.
*/
@property(nonatomic, readonly) BOOL isValidBitcoinURL;
/*!
* Returns YES if it is an Open Assets URL.
*/
@property(nonatomic, readonly) BOOL isValidOpenAssetsURL;
/*!
* Makes a URL in form "bitcoin:<address>?amount=1.2345&label=<label>.
* @param address Address to be rendered in base58 format.
* @param amount Amount in satoshis. Note that URI scheme dictates to render this amount as a decimal number in BTC.
* @param label Optional label.
*/
+ (nonnull NSURL*) URLWithAddress:(nonnull BTCAddress*)address amount:(BTCAmount)amount label:(nullable NSString*)label;
/*!
* Instantiates if URL is a valid bitcoin: URL.
* To be valid it should either contain a valid address, or payment request URL (r=), or both.
*/
- (nullable id) initWithURL:(nullable NSURL*)url;
/*!
* Instantiates an empty Bitcoin URL.
* Fill in address, amount, label and other fields and use `URL` property to get a composed URL.
*/
- (nonnull id) init;
/*!
* Object subscripting to access query parameters more conveniently
* @param key The key in the queryParameters
*/
- (nullable id)objectForKeyedSubscript:(nonnull id <NSCopying>)key;
/*!
* Object subscripting to set query parameter key value pairs more conveniently
* @param obj The value to be set for key in queryParameters
* @param key The key for value in the queryParameters
*/
- (void)setObject:(nullable id)obj forKeyedSubscript:(nonnull id <NSCopying>)key;
@end