Skip to content

Commit 6952eb5

Browse files
committed
Add to_json Deprecation Warnings
Closes #267 Add deprecation warnings on `Bitcoin::Protocol::Tx#to_json(_file)` as well as to `Bitcoin::Protocol::Block#to_json(_file)`. This causes the tests to display a lot of warnings and the tests and examples using these methods must also be removed / revised once they are gone for good.
1 parent 48b8897 commit 6952eb5

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

lib/bitcoin/protocol/block.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,15 +228,15 @@ def bip34_block_height(height = nil)
228228
nil
229229
end
230230

231-
# convert to json representation as seen in the block explorer.
232-
# (see also #from_json)
231+
# <b>DEPRECATED:</b> This method will removed in a future release.
233232
def to_json(options = { space: '' }, *_)
233+
warn "[DEPRECATION] Bitcoin::Protocol::Block#to_json is deprecated and will be removed in a future release."
234234
JSON.pretty_generate(to_hash(options), options)
235235
end
236236

237-
# write json representation to a file
238-
# (see also #to_json)
237+
# <b>DEPRECATED:</b> This method will removed in a future release.
239238
def to_json_file(path)
239+
warn "[DEPRECATION] Bitcoin::Protocol::Block#to_json_file is deprecated and will be removed in a future release."
240240
File.open(path, 'wb') { |f| f.print to_json; }
241241
end
242242

lib/bitcoin/protocol/tx.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -451,14 +451,15 @@ def to_hash(options = {})
451451
h
452452
end
453453

454-
# generates rawblock json as seen in the block explorer.
454+
# <b>DEPRECATED:</b> This method will removed in a future release.
455455
def to_json(options = { space: '' }, *_a)
456+
warn "[DEPRECATION] Bitcoin::Protocol::Tx#to_json is deprecated and will be removed in a future release."
456457
JSON.pretty_generate(to_hash(options), options)
457458
end
458459

459-
# write json representation to a file
460-
# (see also #to_json)
460+
# <b>DEPRECATED:</b> This method will removed in a future release.
461461
def to_json_file(path)
462+
warn "[DEPRECATION] Bitcoin::Protocol::Tx#to_json_file is deprecated and will be removed in a future release."
462463
File.open(path, 'wb') { |f| f.print to_json; }
463464
end
464465

0 commit comments

Comments
 (0)