dropzone_ruby 0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -0
  3. data/Drop Zone - An Anonymous Peer-To-Peer Local Contraband Marketplace.pdf +0 -0
  4. data/Gemfile +3 -0
  5. data/Gemfile.lock +69 -0
  6. data/README.md +62 -0
  7. data/bin/dropzone +487 -0
  8. data/dropzone-screenshot.jpg +0 -0
  9. data/dropzone_ruby.gemspec +31 -0
  10. data/lib/blockrio_ext.rb +52 -0
  11. data/lib/dropzone/buyer.rb +21 -0
  12. data/lib/dropzone/command.rb +488 -0
  13. data/lib/dropzone/communication.rb +43 -0
  14. data/lib/dropzone/connection.rb +312 -0
  15. data/lib/dropzone/invoice.rb +23 -0
  16. data/lib/dropzone/item.rb +160 -0
  17. data/lib/dropzone/listing.rb +64 -0
  18. data/lib/dropzone/message_base.rb +178 -0
  19. data/lib/dropzone/payment.rb +36 -0
  20. data/lib/dropzone/profile.rb +86 -0
  21. data/lib/dropzone/record_base.rb +34 -0
  22. data/lib/dropzone/seller.rb +21 -0
  23. data/lib/dropzone/session.rb +161 -0
  24. data/lib/dropzone/state_accumulator.rb +39 -0
  25. data/lib/dropzone/version.rb +4 -0
  26. data/lib/dropzone_ruby.rb +14 -0
  27. data/lib/veto_checks.rb +74 -0
  28. data/spec/bitcoin_spec.rb +115 -0
  29. data/spec/buyer_profile_spec.rb +279 -0
  30. data/spec/buyer_spec.rb +109 -0
  31. data/spec/command_spec.rb +353 -0
  32. data/spec/config.yml +5 -0
  33. data/spec/invoice_spec.rb +129 -0
  34. data/spec/item_spec.rb +294 -0
  35. data/spec/lib/fake_connection.rb +97 -0
  36. data/spec/listing_spec.rb +150 -0
  37. data/spec/payment_spec.rb +152 -0
  38. data/spec/seller_profile_spec.rb +290 -0
  39. data/spec/seller_spec.rb +120 -0
  40. data/spec/session_spec.rb +303 -0
  41. data/spec/sham/buyer.rb +5 -0
  42. data/spec/sham/invoice.rb +5 -0
  43. data/spec/sham/item.rb +8 -0
  44. data/spec/sham/payment.rb +13 -0
  45. data/spec/sham/seller.rb +7 -0
  46. data/spec/spec_helper.rb +49 -0
  47. metadata +267 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7e3f8aa268cff7526cede2b919230f6ea0a3de4f
4
+ data.tar.gz: 3687b6814d9f88aec34dc63c685db73cee19e127
5
+ SHA512:
6
+ metadata.gz: 1b21f9440eebd4f1eb5bea505f8765c8362f3e2c8a711deb338a7863c0d2ee89e7be720b58443aee3a52688fb0c56164e6c95dace905990df2f9b374a9590b31
7
+ data.tar.gz: 28c24e8a6c5902b084634c39659e3aa439d3a30a49567744851d3df6f50fab537871886ff59194722c4bf51a30e9c2a02141ce53dacc9f198f678e3741e91fd2
@@ -0,0 +1,4 @@
1
+ *.swp
2
+ *.swo
3
+ *.gem
4
+ doc
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,69 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ dropzone_ruby (0.1)
5
+ commander (~> 4.3)
6
+ counterparty_ruby (~> 1.2)
7
+ sequel (~> 4.21)
8
+ socksify (~> 1.7)
9
+ sqlite3 (~> 1.3)
10
+ veto (~> 1.0)
11
+
12
+ GEM
13
+ remote: https://rubygems.org/
14
+ specs:
15
+ bitcoin-ruby (0.0.7)
16
+ commander (4.3.4)
17
+ highline (~> 1.7.2)
18
+ counterparty_ruby (1.2.0)
19
+ bitcoin-ruby
20
+ ffi
21
+ rest-client
22
+ ruby-rc4
23
+ diff-lcs (1.2.5)
24
+ domain_name (0.5.24)
25
+ unf (>= 0.0.5, < 1.0.0)
26
+ ffi (1.9.10)
27
+ highline (1.7.2)
28
+ http-cookie (1.0.2)
29
+ domain_name (~> 0.5)
30
+ mime-types (2.6.1)
31
+ netrc (0.10.3)
32
+ rake (10.4.2)
33
+ rdoc (4.2.0)
34
+ rest-client (1.8.0)
35
+ http-cookie (>= 1.0.2, < 2.0)
36
+ mime-types (>= 1.16, < 3.0)
37
+ netrc (~> 0.7)
38
+ rspec (3.2.0)
39
+ rspec-core (~> 3.2.0)
40
+ rspec-expectations (~> 3.2.0)
41
+ rspec-mocks (~> 3.2.0)
42
+ rspec-core (3.2.3)
43
+ rspec-support (~> 3.2.0)
44
+ rspec-expectations (3.2.1)
45
+ diff-lcs (>= 1.2.0, < 2.0)
46
+ rspec-support (~> 3.2.0)
47
+ rspec-mocks (3.2.1)
48
+ diff-lcs (>= 1.2.0, < 2.0)
49
+ rspec-support (~> 3.2.0)
50
+ rspec-support (3.2.2)
51
+ ruby-rc4 (0.1.5)
52
+ sequel (4.21.0)
53
+ sham (1.1.0)
54
+ socksify (1.7.0)
55
+ sqlite3 (1.3.10)
56
+ unf (0.1.4)
57
+ unf_ext
58
+ unf_ext (0.0.7.1)
59
+ veto (1.0.1)
60
+
61
+ PLATFORMS
62
+ ruby
63
+
64
+ DEPENDENCIES
65
+ dropzone_ruby!
66
+ rake (~> 10.4)
67
+ rdoc (~> 4.2)
68
+ rspec (~> 3.2)
69
+ sham (~> 1.1)
@@ -0,0 +1,62 @@
1
+ Drop Zone [![Gem Version](https://badge.fury.io/rb/dropzone_ruby.svg)](http://badge.fury.io/rb/dropzone_ruby)
2
+ =================
3
+ ![Drop Zone](dropzone-screenshot.jpg)
4
+
5
+ To whom it may concern,
6
+
7
+ Markets are objects of censorship and always have been. There is a presumed
8
+ division, that renders commerce distinct from the notion of free speech. But I
9
+ will allege that the act of commerce is, itself, indistinct from speech. Where
10
+ or how one spends their value is a decision as personal and poignant as any
11
+ words ever spoken or letters ever written.
12
+
13
+ As a unfortunate consequence of freedom, bad actors will engage in repugnant
14
+ trade that impinges upon the rights and freedoms of others. It is the job of
15
+ humanity to cooperate and see to it that trade, such as this, becomes
16
+ unprofitable. Whether it is accomplished through technological achievement or
17
+ through the adjustment of social mores, or perhaps a simple appeal to the
18
+ underlying natural law, it is not the job of bad acting third parties to force
19
+ into hiding commerce that must be dealt with by means of an adjustment to the
20
+ global, social conscience.
21
+
22
+ Cooperation, in the manner I was just speaking about, has never been plausible
23
+ until the invention of The Blockchain. I will not foist upon Satoshi's humble
24
+ creation such impracticable possibilities as the achievement of world peace.
25
+ But in approaching Drop Zone, I am attempting to do nothing more than what is
26
+ possible and possibly more efficient than what exists. I wish for Drop Zone
27
+ to be nothing more than an appendage to The Blockchain. As such, it is every
28
+ bit as much Bitcoin as Bitcoin itself. Just as a fungible Bitcoin enables the
29
+ exchange of spaceless value with near impunity, Drop Zone removes the ability
30
+ of unwelcome parties from glancing over the shoulders of those in the act of an
31
+ exchange, whatever it entails. This technology disrupts the ability of buyers
32
+ to gain insight into the identities or movements of suppliers making supply
33
+ chains far less vulnerable to disruption. It is this innovation that separates
34
+ this project from all other decentralized market solutions.
35
+
36
+ Whereas Bitcoin forces us to consider the nature of money and value, Drop Zone
37
+ will do the same for commerce. At its root, Bitcoin is a message passing
38
+ system. Those messages that are passed, unlike any electronic message that's
39
+ come before it, articulate value. Commerce is, and has always been, similarly
40
+ inclined toward message passing. Whether in-person, over email, or through
41
+ large, online shopping carts, fundamentally, commerce is composed of messages
42
+ that are in service of the transaction wherein a final message of value is sent
43
+ to a recipient in exchange for a negotiated good or service. As such, Drop
44
+ Zone is a secure message passing protocol inasmuch as it is a platform for
45
+ commerce. And while the problem is far beyond the scope or capabilities of
46
+ the protocol in its most fundamental form, the observant might even see the
47
+ tenuous skeleton of a full-fledged reputation system. Such a project is, in
48
+ itself, as important and difficult as any facing this decentralized ecosystem.
49
+
50
+ I hope that Drop Zone lets us all dream of a day when no man will any longer be
51
+ made to suffer indignity for simply engaging in unpopular or stigmatized
52
+ commerce. May all commerce be created equal.
53
+
54
+ Today is a Beautiful day,
55
+
56
+ __Miracle Max__
57
+ __quia omnis qui se exaltat humiliabitur et qui se humiliat exaltabitur__
58
+
59
+ ## Errata
60
+ * The white paper expressed 8 digits of precision for the listing radius. This implementation instead uses 6 digits. If additional precision is later deemed necessary, a field can be added to the listing to accomodate enhanced precision
61
+ * The white paper expressed pkeys (addresses) as being encoded ints. These are instead encoded as variable length strings.
62
+ * The white paper expressed transaction ids as being encoded ints. These are instead encoded as variable length strings.
@@ -0,0 +1,487 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'commander/import'
5
+ require 'socksify'
6
+
7
+ $: << [File.dirname(__FILE__),'..','lib'].join('/')
8
+ require 'dropzone_ruby'
9
+ require 'dropzone/command'
10
+
11
+ # For the examples:
12
+ RANDOM_TXID = '0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098'
13
+
14
+ # Cleans up a multiline string, keeps this file readable.
15
+ def multi(string)
16
+ string.tr("\t\r\n",'').gsub(/[ ]{2,}/, ' ')
17
+ end
18
+
19
+ def command_show(type, &block)
20
+ command '%s show' % type do |c|
21
+ c.when_called DropZoneCommand, ('%s_show' % type).to_sym
22
+
23
+ c.syntax, c.summary, c.description =
24
+ 'dropzone %s show <txid> [options]' % type,
25
+ 'Show %s details' % type
26
+ multi(<<-eos) % type
27
+ Displays the information associated with the %s at the specified address.
28
+ eos
29
+ block.call c
30
+ end
31
+ end
32
+
33
+ # Defaults:
34
+ Dropzone::BitcoinConnection.cache = LocalConnectionCache.new
35
+ Bitcoin.network = :bitcoin
36
+
37
+ program :version, '0.0.1'
38
+ program :description, 'A marketplace built on The Blockchain.'
39
+
40
+ program :help, 'Author',
41
+ 'Miracle Max (17Q4MX2hmktmpuUKHFuoRmS5MfB5XPbhod / mw8Ge8HDBStKyn8u4LTkUwueheFNhuo7Ch ) '
42
+
43
+ global_option('--debug', 'Display detailed data on program activity') do
44
+ Socksify::debug = true
45
+ RestClient.log = Logger.new STDOUT
46
+ end
47
+
48
+ global_option('--socks_server SERVER:PORT',
49
+ 'Route all connections through the specified SOCKS server & port') do |server_spec|
50
+ server, port = $1, $2 if /\A([a-z\.\d]+)(?:\:([\d]+)|)\Z/i.match server_spec
51
+
52
+ raise OptionParser::InvalidArgument, "socks_server" unless server
53
+
54
+ TCPSocket::socks_server = server if server
55
+ TCPSocket::socks_port = (port) ? port : 9050
56
+ end
57
+
58
+ global_option('--force_testnet',
59
+ 'Force transactions that would normally be on mainnet, onto testnet') do
60
+ Bitcoin.network = :testnet3
61
+ end
62
+
63
+ global_option('--tip SATOSHIS',
64
+ 'Set the transaction tip amount. Defaults to 20000') do |satoshis|
65
+ satoshis_i = $1.to_i if /\A([\d]+)\Z/.match satoshis
66
+
67
+ raise OptionParser::InvalidArgument, "tip" unless satoshis_i
68
+
69
+ Dropzone::MessageBase.default_tip = satoshis_i
70
+ end
71
+
72
+ command 'balance' do |c|
73
+ c.when_called DropZoneCommand, :balance
74
+
75
+ c.syntax, c.summary, c.description =
76
+ 'dropzone balance <addr>',
77
+ 'Display the balance on the provided address, in Bitcoin',
78
+ multi(<<-eos)
79
+ Given the provided public key, display the Bitcoin balance remaining in
80
+ this account. Does not include unconfirmed transactions.
81
+ eos
82
+
83
+ c.example 'Show the balance of Miracle Max\'s Account',
84
+ 'dropzone balance 17Q4MX2hmktmpuUKHFuoRmS5MfB5XPbhod'
85
+ end
86
+
87
+ command 'pay' do |c|
88
+ c.when_called DropZoneCommand, :send_value
89
+
90
+ c.syntax, c.summary, c.description =
91
+ 'dropzone pay <private_key> <dest_addr> <amnt_btc> [options]',
92
+ 'Send value to a recipient, in Bitcoin',
93
+ multi(<<-eos)
94
+ Given the provided <private_key>, send Bitcoin in units of BTC <amnt_btc>
95
+ to the recipient specified by <dest_addr>.
96
+ eos
97
+ c.example 'Send 1.2 Bitcoin from %s to %s' % [
98
+ 'mi37WkBomHJpUghCn7Vgh3ah33h6L9Nkqw', 'mqVRfjepJTxxoDgDt892tCybhmjfKCFNyp'],
99
+ multi(<<-eos)
100
+ dropzone pay 92UvdTpmxA6cvD6YeJZSiHW8ff8DsZXL2PHZu9Mg7JY3zbaETJw
101
+ mqVRfjepJTxxoDgDt892tCybhmjfKCFNyp
102
+ 1.2
103
+ eos
104
+ end
105
+
106
+ command 'listing find' do |c|
107
+ c.when_called DropZoneCommand, :listing_find
108
+
109
+ c.syntax, c.summary, c.description =
110
+ 'dropzone listing find <block_depth>',
111
+ 'Searches through The Blockchain for listings',
112
+ multi(<<-eos)
113
+ Search through The Blockchain, up until the provided <block_depth>,
114
+ for Drop Zone listings. Note that the returned listings may not be entirely
115
+ updated, or even valid. A subsequent 'listing show' command should be
116
+ specified to validate the details of the item you're interested in.
117
+ eos
118
+
119
+ c.example 'Find listings uploaded (approximately) in the last hour',
120
+ 'dropzone listing find 6'
121
+
122
+ c.example 'Find listings uploaded Twenty Kilometers around Shijuku in the last day',
123
+ multi(<<-eos)
124
+ dropzone listing find 144
125
+ --latitude 35.689487
126
+ --longitude 139.691706
127
+ --radius 20000
128
+ eos
129
+
130
+ c.example 'Find listings between block 371813 and 371810 (inclusive)',
131
+ 'dropzone listing find 3 --start_at 371813'
132
+
133
+ c.example 'Find listings in block 371812',
134
+ 'dropzone listing find 0 --start_at 371812'
135
+
136
+ c.option '--latitude LAT ', Float,
137
+ 'The approximate latitude of your location.'
138
+ c.option '--longitude LON ', Float,
139
+ 'The approximate longitude of your location.'
140
+ c.option '--radius METERS ', Integer, multi(<<-eos)
141
+ The approximate diameter you wish to search around the provided
142
+ latitude and longitude. The expected unit of distance is in meters.
143
+ eos
144
+
145
+ c.option '--start_at BLOCKHEIGHT ', Integer, multi(<<-eos)
146
+ Start searching from the specified block height until <block_depth>
147
+ 'blocks down'. The default behavior is to start at the current blockchain
148
+ height.
149
+ eos
150
+ end
151
+
152
+ command_show(:listing) do |c|
153
+ c.example "Display a seller's listing",
154
+ 'dropzone listing show 6a9013b8684862e9ccfb527bf8f5ea5eb213e77e3970ff2cd8bbc22beb7cebfb'
155
+ end
156
+
157
+ def listing_create_update_options(cmd)
158
+ cmd.option '--description DESC', String, multi(<<-eos)
159
+ A detailed description of the item that's being listed. Hashtags are
160
+ encouraged as they will be easily searched and indexed, and take up a
161
+ small amount of space
162
+ eos
163
+ cmd.option '--price_currency ISOCODE', String, multi(<<-eos)
164
+ A three or four digit currency identifier. Common values would include
165
+ 'BTC' or 'USD', though any identifier can be specified
166
+ eos
167
+ cmd.option '--price_in_units PRICE ', Integer,
168
+ 'The price of the specified item denominated in cents, or satoshis, etc.'
169
+ cmd.option '--expiration_in NBLOCKS ', Integer, multi(<<-eos)
170
+ The expiration time of the item. "Times" are to be indicated in the number
171
+ of blocks that this listing is available for. Omitting this field indicates
172
+ no expiration. Note that clients will likely override the seller's
173
+ preference to list an item for a very long time by restricting the block
174
+ depth of users' searches.
175
+ eos
176
+ end
177
+
178
+ command 'listing update' do |c|
179
+ c.when_called DropZoneCommand, :listing_update
180
+
181
+ c.syntax, c.summary, c.description =
182
+ 'dropzone listing update <private_key> <txid> [options]',
183
+ 'Update your item listing',
184
+ multi(<<-eos)
185
+ Given the provided item transaction id <txid> on your account <private_key>,
186
+ update the specified item attributes. Note that some attributes such as
187
+ latitude, longitude, and radius cannot be updated.
188
+ eos
189
+
190
+ c.example 'Update existing item', multi(<<-eos) % RANDOM_TXID
191
+ dropzone listing update
192
+ --description "Second Description"
193
+ 92thgQGx77ihBaA56W7B1Qm8nhYHRERo1UqrgT2p6P6QTqkRhRB
194
+ %s
195
+ eos
196
+
197
+ listing_create_update_options c
198
+ end
199
+
200
+ command 'listing create' do |c|
201
+ c.when_called DropZoneCommand, :listing_create
202
+
203
+ c.syntax, c.summary, c.description =
204
+ 'dropzone listing create <private_key> [options]',
205
+ 'Create an item listing as a seller',
206
+ multi(<<-eos)
207
+ Given the provided seller address <private_key>, create an item
208
+ which is pubilicly listed as available for purchase by other users
209
+ eos
210
+
211
+ c.example 'Create an Item', multi(<<-eos)
212
+ dropzone listing create
213
+ --latitude "51.500782"
214
+ --longitude "-0.124669"
215
+ --radius 1000
216
+ --price_currency 'USD'
217
+ --price_in_units 100
218
+ --description "Test Description"
219
+ 92thgQGx77ihBaA56W7B1Qm8nhYHRERo1UqrgT2p6P6QTqkRhRB
220
+ eos
221
+
222
+ listing_create_update_options c
223
+
224
+ c.option '--latitude LAT ', Float,
225
+ "(Required) The approximate latitude your listing's location."
226
+ c.option '--longitude LON ', Float,
227
+ "(Required) The approximate longitude your listing's location."
228
+ c.option '--radius METERS ', Integer, multi(<<-eos)
229
+ (Required) The approximate diameter your item's location around the provided
230
+ latitude and longitude. The expected unit of distance is in meters.
231
+ eos
232
+ end
233
+
234
+ command 'profile seller show' do |c|
235
+ c.when_called DropZoneCommand, :profile_seller_show
236
+
237
+ c.syntax, c.summary, c.description =
238
+ 'dropzone profile seller show <addr> [options]',
239
+ "Show a seller's profile",
240
+ 'Displays the information associated with the seller at the given address.'
241
+
242
+ c.example "Look up a user's store profile",
243
+ 'dropzone profile seller show "17Q4MX2hmktmpuUKHFuoRmS5MfB5XPbhod"'
244
+ end
245
+
246
+ command 'profile seller create' do |c|
247
+ c.when_called DropZoneCommand, :profile_seller_create
248
+
249
+ c.syntax, c.summary, c.description =
250
+ 'dropzone profile seller create <private_key> [options]',
251
+ 'Open for business, and/or update your existing store',
252
+ multi(<<-eos)
253
+ A seller profile is required to precede all item
254
+ declarations on a public key (Specified in <private_key>). This
255
+ declaration is expected to contain basic information about a seller, and
256
+ offers some provisions which facilitate identity transfers. This command
257
+ will create an identity if one does not exist at the specified address,
258
+ and/or will update any identity that already exists at the specified
259
+ address.
260
+ eos
261
+
262
+ c.example 'Declare a seller profile:', multi(<<-eos)
263
+ dropzone profile seller create --alias="Miracle Max"
264
+ --description="First Seller on DropZone"
265
+ --communications_pkey="mi37WkBomHJpUghCn7Vgh3ah33h6L9Nkqw"
266
+ "92thgQGx77ihBaA56W7B1Qm8nhYHRERo1UqrgT2p6P6QTqkRhRB"
267
+ eos
268
+
269
+ c.option '--description DESC', String, 'A description of yourself'
270
+ c.option '--alias ALIAS', String,
271
+ 'A short name by which you would like to be identified'
272
+ c.option '--communications_pkey ADDR', String,
273
+ 'Specifies which testnet address you wish to receive communications inquiries at.'
274
+ c.option '--transfer_pkey ADDR', String, multi(<<-eos)
275
+ Transfer this identity to the specified address. Note that this is a
276
+ one-way operation, and that you should be sure to control the destination
277
+ key. If you wish to deactivate your store entirely, a 0 can be passed
278
+ here.
279
+ eos
280
+ end
281
+
282
+ command 'profile buyer show' do |c|
283
+ c.when_called DropZoneCommand, :profile_buyer_show
284
+
285
+ c.syntax, c.summary, c.description =
286
+ 'dropzone profile buyer show <addr> [options]',
287
+ "Show a buyer's profile",
288
+ 'Displays the information associated with the buyer at the given address.'
289
+
290
+ c.example "Look up a user's buy profile",
291
+ 'dropzone --force_testnet profile buyer show "mgDprFdTS61x1ejowYqJSmoWiqwpEiGrcy"'
292
+ end
293
+
294
+ command 'profile buyer create' do |c|
295
+ c.when_called DropZoneCommand, :profile_buyer_create
296
+
297
+ c.syntax, c.summary, c.description =
298
+ 'dropzone profile buyer create <private_key> [options]',
299
+ 'Create/Update your buyer profile (optional)',
300
+ multi(<<-eos)
301
+ A buyer profile is an optional declaration that can be
302
+ attached to an address (<private_key>) for the purpose of adding metadata
303
+ to your identity as a buyer. This command will create a profile on the
304
+ specified address, or update the existing profile on the specified address.
305
+ eos
306
+
307
+ c.example 'Declare a buyer profile:', multi(<<-eos)
308
+ dropzone profile buyer create --alias="Miracle Max"
309
+ --description="First Buyer on DropZone"
310
+ "92UvdTpmxA6cvD6YeJZSiHW8ff8DsZXL2PHZu9Mg7JY3zbaETJw"
311
+ eos
312
+ c.option '--description DESC', String, 'A description of yourself'
313
+ c.option '--alias ALIAS', String,
314
+ 'A short name by which you would like to be identified'
315
+ c.option '--transfer_pkey ADDR', String, multi(<<-eos)
316
+ Transfer this identity to the specified address. Note that this is a
317
+ one-way operation, and that you should be sure to control the destination
318
+ key. If you wish to deactivate your store entirely, a 0 can be passed
319
+ here.
320
+ eos
321
+ end
322
+
323
+ command_show(:invoice) do |c|
324
+ c.example "Display a seller's invoice",
325
+ 'dropzone invoice show %s' % RANDOM_TXID
326
+ end
327
+
328
+ command 'invoice create' do |c|
329
+ c.when_called DropZoneCommand, :invoice_create
330
+
331
+ c.syntax, c.summary, c.description =
332
+ 'dropzone invoice create <private_key> <recipient_addr> [options]',
333
+ 'Create an invoice to a potential buyer',
334
+ multi(<<-eos)
335
+ An invoice is needed to lock in currency exchange rates for the purposes
336
+ of a sale, and for the purpose of allowing the network to identify a
337
+ successful sale on your profile <private_key>. Satisfied invoices build
338
+ reputation. This command will generate an invoice to the buyer at the
339
+ specified address <recipient_addr>.
340
+ eos
341
+
342
+ c.example 'Create an invoice:', multi(<<-eos)
343
+ dropzone invoice create
344
+ --amount_due 50000000
345
+ --expiration_in 6
346
+ 92thgQGx77ihBaA56W7B1Qm8nhYHRERo1UqrgT2p6P6QTqkRhRB
347
+ mi37WkBomHJpUghCn7Vgh3ah33h6L9Nkqw
348
+ eos
349
+
350
+ c.option '--amount_due BTC', String,
351
+ 'Amount due, denominated in Bitcoin (ie "0.5")'
352
+ c.option '--expiration_in NBLOCKS ', Integer, multi(<<-eos)
353
+ The expiration time of the invoice. "Times" are to be indicated in the number
354
+ of blocks that this listing is available for. Omitting this field indicates
355
+ no expiration. Specifying an expiration is useful for locking in an exchange
356
+ rate when closing a sale.
357
+ eos
358
+ end
359
+
360
+ command_show(:review) do |c|
361
+ c.example "Display a buyer's review",
362
+ 'dropzone review show %s' % RANDOM_TXID
363
+ end
364
+
365
+ command 'review create' do |c|
366
+ c.when_called DropZoneCommand, :review_create
367
+
368
+ c.syntax, c.summary, c.description =
369
+ 'dropzone review create <private_key> <txid> [options]',
370
+ 'Leave a review on a generated invoice',
371
+ multi(<<-eos)
372
+ A review is primarily designed for the purposes of establishing
373
+ feedback and reputations amongst buyers and sellers. After an invoice
374
+ is generated, and value is sent, a review indicates to the network
375
+ the nature of the transaction, and a buyer's <privkey> experience with
376
+ the seller. Reviews are left in response to a specific invoice at the
377
+ provided
378
+ <txid>.
379
+ eos
380
+
381
+ c.example 'Review a purchase:', multi(<<-eos) % [RANDOM_TXID]
382
+ dropzone review create
383
+ --description: 'Fair exchange"
384
+ --delivery_quality 8,
385
+ --product_quality 8
386
+ --communications_quality 4
387
+ 92UvdTpmxA6cvD6YeJZSiHW8ff8DsZXL2PHZu9Mg7JY3zbaETJw
388
+ %s
389
+ eos
390
+ c.option '--description DESC', String,
391
+ 'A description of the transaction and/or a review of the product.'
392
+
393
+ c.option '--delivery_quality N', Integer,
394
+ 'The quality of the delivery itself. Between 0 (worst) to 8 (best)'
395
+
396
+ c.option '--product_quality N', Integer,
397
+ 'The quality of the product. Between 0 (worst) to 8 (best)'
398
+
399
+ c.option '--communications_quality N', Integer,
400
+ "The seller's communications skill. Between 0 (worst) to 8 (best)"
401
+ end
402
+
403
+ command 'communication list' do |c|
404
+ c.when_called DropZoneCommand, :communication_list
405
+
406
+ c.syntax, c.summary, c.description =
407
+ 'dropzone communication list <private_key>',
408
+ 'Show all the available communication channels for the given testnet address',
409
+ multi(<<-eos)
410
+ This command lists all the conversations that have been initiated and/or
411
+ authenticated on the testnet address correlated with the specified
412
+ <private_key>.
413
+ eos
414
+
415
+ c.example 'List all communication sessions for a testnet address:',
416
+ multi(<<-eos)
417
+ dropzone communication list
418
+ 92UvdTpmxA6cvD6YeJZSiHW8ff8DsZXL2PHZu9Mg7JY3zbaETJw
419
+ eos
420
+ end
421
+
422
+ command 'communication show' do |c|
423
+ c.when_called DropZoneCommand, :communication_show
424
+
425
+ c.syntax, c.summary, c.description =
426
+ 'dropzone communication show <private_key> <tx_id>',
427
+ 'Show all the available communication channels for the given testnet address',
428
+ multi(<<-eos)
429
+ Output a full conversation, start to finish, between the testnet
430
+ <private_key> starting with the initiation at <tx_id>.
431
+ eos
432
+
433
+ c.example 'Show the conversation:',
434
+ multi(<<-eos) % RANDOM_TXID
435
+ dropzone communication show
436
+ 92UvdTpmxA6cvD6YeJZSiHW8ff8DsZXL2PHZu9Mg7JY3zbaETJw
437
+ %s
438
+ eos
439
+ end
440
+
441
+ command 'communication say' do |c|
442
+ c.when_called DropZoneCommand, :communication_say
443
+
444
+ c.syntax, c.summary, c.description =
445
+ 'dropzone communication say <private_key> <tx_id> <message>',
446
+ 'Communicate to another party in a private/encrypted conversation over testnet.',
447
+ multi(<<-eos)
448
+ Append to the conversation <tx_id> at your testnet address <private> key
449
+ say the provided <message> to a receiving party.
450
+ eos
451
+
452
+ c.example 'Converse with another user over testnet:',
453
+ multi(<<-eos) % RANDOM_TXID
454
+ dropzone communication say
455
+ 92UvdTpmxA6cvD6YeJZSiHW8ff8DsZXL2PHZu9Mg7JY3zbaETJw
456
+ %s
457
+ "Thank you for your Inquiry"
458
+ eos
459
+ end
460
+
461
+ command 'communication new' do |c|
462
+ c.when_called DropZoneCommand, :communication_new
463
+
464
+ c.syntax, c.summary, c.description =
465
+ 'dropzone communication new <private_key> <addr>',
466
+ 'Start a new conversation with the person at a given testnet address',
467
+ multi(<<-eos)
468
+ Start a conversation between your tesnet <private_key> and the user at
469
+ the specified testnet address <addr>. An initiation request needs only
470
+ to be issued by one user, a recipient must reply to that request using
471
+ the "communication say" command, in order to authenticate the initiator's
472
+ request and perform key exchange. Thereafter, a channel between the two
473
+ addresses is established, and communications will remain open.
474
+
475
+ NOTE: A communications secret is generated by Drop Zone for each recipient
476
+ that a connection has been established with, and these secrets are stored
477
+ in the ~/.dropzone/dropzone.db file. When the user responds to this request
478
+ a secret is automatically generated on their computer as well.
479
+ eos
480
+
481
+ c.example 'Start a conversation:',
482
+ multi(<<-eos)
483
+ dropzone communication new
484
+ 92UvdTpmxA6cvD6YeJZSiHW8ff8DsZXL2PHZu9Mg7JY3zbaETJw
485
+ mqVRfjepJTxxoDgDt892tCybhmjfKCFNyp
486
+ eos
487
+ end