bsv-attest 0.2.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f2f577e5fd3ffdca87cab33ea4c1e8d38d3eb8451fac97eb6894169ebe75c989
4
+ data.tar.gz: 3ed83b62b4e73c35e8c8169df260281a3f22b24f333982d33fda1793d42e5742
5
+ SHA512:
6
+ metadata.gz: c994a19ba4b35abdbaca3b43c5b9a1f4125ebc54cb64b4c89922335c6fc70060e8b06e6e119d3e4bdd598d3d7b5cfc3a2cc2b6799cf37c316f96d3ad18e363d7
7
+ data.tar.gz: 64e1261fe2dd9ffd2eaf0a1ac4c659652f7b8dc920d3e8f546bc5029c4c852ecf00d91f9e769d9fecaa9baeec26dbf3dca1963c41f7ef1b5374b832db8f7f529
data/CHANGELOG.md ADDED
@@ -0,0 +1,25 @@
1
+ # Changelog — bsv-attest
2
+
3
+ All notable changes to the `bsv-attest` gem are documented here.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
6
+ and this gem adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## 0.2.0 — 2026-04-13
9
+
10
+ ### Breaking Changes
11
+ - Removed `broadcaster` from `Attest::Configuration` — attestation now uses the wallet's broadcaster via `create_action`
12
+
13
+ ### Added
14
+ - `BSV::Attest.publish` now uses `wallet.create_action` for transaction construction and broadcast (#414)
15
+ - `BSV::Attest::BroadcastError` class for create_action failures (#413)
16
+
17
+ ### Changed
18
+ - `Attest::Response` simplified to hash + txid only (#412)
19
+
20
+ ### Fixed
21
+ - Pass args as positional Hash to `create_action` for Ruby 2.7 compatibility (#414)
22
+
23
+ ## 0.1.0
24
+
25
+ Initial release of `bsv-attest`.
data/LICENSE ADDED
@@ -0,0 +1,86 @@
1
+ Open BSV License Version 5 – granted by BSV Association, Grafenauweg 6, 6300
2
+ Zug, Switzerland (CHE-427.008.338) ("Licensor"), to you as a user (henceforth
3
+ "You", "User" or "Licensee").
4
+
5
+ For the purposes of this license, the definitions below have the following
6
+ meanings:
7
+
8
+ "Bitcoin Protocol" means the protocol implementation, cryptographic rules,
9
+ network protocols, and consensus mechanisms in the Bitcoin White Paper as
10
+ described here https://protocol.bsvblockchain.org.
11
+
12
+ "Bitcoin White Paper" means the paper entitled 'Bitcoin: A Peer-to-Peer
13
+ Electronic Cash System' published by 'Satoshi Nakamoto' in October 2008.
14
+
15
+ "BSV Blockchains" means:
16
+ (a) the Bitcoin blockchain containing block height #556767 with the hash
17
+ "000000000000000001d956714215d96ffc00e0afda4cd0a96c96f8d802b1662b" and
18
+ that contains the longest honest persistent chain of blocks which has been
19
+ produced in a manner which is consistent with the rules set forth in the
20
+ Network Access Rules; and
21
+ (b) the test blockchains that contain the longest honest persistent chains of
22
+ blocks which has been produced in a manner which is consistent with the
23
+ rules set forth in the Network Access Rules.
24
+
25
+ "Network Access Rules" or "Rules" means the set of rules regulating the
26
+ relationship between BSV Association and the nodes on BSV based on the Bitcoin
27
+ Protocol rules and those set out in the Bitcoin White Paper, and available here
28
+ https://bsvblockchain.org/network-access-rules.
29
+
30
+ "Software" means the software the subject of this licence, including any/all
31
+ intellectual property rights therein and associated documentation files.
32
+
33
+ BSV Association grants permission, free of charge and on a non-exclusive and
34
+ revocable basis, to any person obtaining a copy of the Software to deal in the
35
+ Software without restriction, including without limitation the rights to use,
36
+ copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
37
+ Software, and to permit persons to whom the Software is furnished to do so,
38
+ subject to and conditioned upon the following conditions:
39
+
40
+ 1 - The text "© BSV Association," and this license shall be included in all
41
+ copies or substantial portions of the Software.
42
+ 2 - The Software, and any software that is derived from the Software or parts
43
+ thereof, must only be used on the BSV Blockchains.
44
+
45
+ For the avoidance of doubt, this license is granted subject to and conditioned
46
+ upon your compliance with these terms only. In the event of non-compliance, the
47
+ license shall extinguish and you can be enjoined from violating BSV's
48
+ intellectual property rights (incl. damages and similar related claims).
49
+
50
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
51
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES REGARDING ENTITLEMENT,
52
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
53
+ EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS THEREOF BE LIABLE FOR ANY CLAIM,
54
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
55
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
56
+ DEALINGS IN THE SOFTWARE.
57
+
58
+
59
+ Version 0.1.1 of the Bitcoin SV software, and prior versions of software upon
60
+ which it was based, were licensed under the MIT License, which is included below.
61
+
62
+ The MIT License (MIT)
63
+
64
+ Copyright (c) 2009-2010 Satoshi Nakamoto
65
+ Copyright (c) 2009-2015 Bitcoin Developers
66
+ Copyright (c) 2009-2017 The Bitcoin Core developers
67
+ Copyright (c) 2017 The Bitcoin ABC developers
68
+ Copyright (c) 2018 Bitcoin Association for BSV
69
+ Copyright (c) 2023 BSV Association
70
+
71
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
72
+ this software and associated documentation files (the "Software"), to deal in
73
+ the Software without restriction, including without limitation the rights to
74
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
75
+ the Software, and to permit persons to whom the Software is furnished to do so,
76
+ subject to the following conditions:
77
+
78
+ The above copyright notice and this permission notice shall be included in all
79
+ copies or substantial portions of the Software.
80
+
81
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
82
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
83
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
84
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
85
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
86
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BSV
4
+ module Attest
5
+ class BroadcastError < StandardError; end
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BSV
4
+ module Attest
5
+ class Configuration
6
+ attr_accessor :wallet, :provider
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BSV
4
+ module Attest
5
+ class Response
6
+ attr_reader :hash, :txid
7
+
8
+ def initialize(hash:, txid:)
9
+ @hash = hash
10
+ @txid = txid
11
+ end
12
+
13
+ def hash_hex
14
+ @hash.unpack1('H*')
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BSV
4
+ module Attest
5
+ class VerificationError < StandardError; end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BSV
4
+ module Attest
5
+ VERSION = '0.2.0'
6
+ end
7
+ end
data/lib/bsv/attest.rb ADDED
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BSV
4
+ module Attest
5
+ autoload :BroadcastError, 'bsv/attest/broadcast_error'
6
+ autoload :Configuration, 'bsv/attest/configuration'
7
+ autoload :Response, 'bsv/attest/response'
8
+ autoload :VerificationError, 'bsv/attest/verification_error'
9
+ autoload :VERSION, 'bsv/attest/version'
10
+
11
+ class << self
12
+ def configuration
13
+ @configuration ||= Configuration.new
14
+ end
15
+
16
+ def configure
17
+ yield(configuration)
18
+ end
19
+
20
+ def reset_configuration!
21
+ @configuration = Configuration.new
22
+ end
23
+
24
+ def hash(data)
25
+ BSV::Primitives::Digest.sha256(data)
26
+ end
27
+
28
+ def publish(data, wallet: nil, description: nil)
29
+ w = wallet || configuration.wallet
30
+ raise ArgumentError, 'wallet is required' unless w
31
+
32
+ digest = hash(data)
33
+ script = BSV::Script::Script.op_return(digest)
34
+
35
+ desc = description || 'Attest data hash to chain'
36
+
37
+ result = w.create_action(
38
+ {
39
+ description: desc,
40
+ outputs: [{
41
+ locking_script: script.to_hex,
42
+ satoshis: 0,
43
+ output_description: 'Attestation hash'
44
+ }],
45
+ options: { randomize_outputs: false }
46
+ }
47
+ )
48
+
49
+ raise BroadcastError, result[:broadcast_error] if result[:broadcast_error]
50
+
51
+ Response.new(hash: digest, txid: result[:txid])
52
+ end
53
+
54
+ def verify(data, txid, provider: nil)
55
+ p = provider || configuration.provider
56
+ raise ArgumentError, 'provider is required' unless p
57
+
58
+ digest = hash(data)
59
+
60
+ tx = p.fetch_transaction(txid)
61
+
62
+ tx.outputs.each do |output|
63
+ script = output.locking_script
64
+ next unless script.op_return?
65
+
66
+ # Use op_return_data which correctly re-parses the tail after F3.1's
67
+ # OP_RETURN termination fix (the raw tail is now in one chunk).
68
+ items = script.op_return_data
69
+ next if items.nil?
70
+
71
+ return true if items.include?(digest)
72
+ end
73
+
74
+ raise VerificationError, 'hash not found in transaction outputs'
75
+ end
76
+ end
77
+ end
78
+ end
data/lib/bsv-attest.rb ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bsv-sdk'
4
+ require_relative 'bsv/attest'
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bsv-attest
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Simon Bettison
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: bsv-sdk
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: 0.11.0
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: '1.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: 0.11.0
29
+ - - "<"
30
+ - !ruby/object:Gem::Version
31
+ version: '1.0'
32
+ - !ruby/object:Gem::Dependency
33
+ name: bsv-wallet
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: 0.7.0
39
+ - - "<"
40
+ - !ruby/object:Gem::Version
41
+ version: '1.0'
42
+ type: :runtime
43
+ prerelease: false
44
+ version_requirements: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: 0.7.0
49
+ - - "<"
50
+ - !ruby/object:Gem::Version
51
+ version: '1.0'
52
+ description: Hash data, publish hashes to the BSV blockchain via OP_RETURN, and verify
53
+ attestations on chain.
54
+ executables: []
55
+ extensions: []
56
+ extra_rdoc_files: []
57
+ files:
58
+ - CHANGELOG.md
59
+ - LICENSE
60
+ - lib/bsv-attest.rb
61
+ - lib/bsv/attest.rb
62
+ - lib/bsv/attest/broadcast_error.rb
63
+ - lib/bsv/attest/configuration.rb
64
+ - lib/bsv/attest/response.rb
65
+ - lib/bsv/attest/verification_error.rb
66
+ - lib/bsv/attest/version.rb
67
+ homepage: https://github.com/sgbett/bsv-ruby-sdk
68
+ licenses:
69
+ - LicenseRef-OpenBSV
70
+ metadata:
71
+ homepage_uri: https://github.com/sgbett/bsv-ruby-sdk
72
+ source_code_uri: https://github.com/sgbett/bsv-ruby-sdk
73
+ changelog_uri: https://github.com/sgbett/bsv-ruby-sdk/blob/master/gem/bsv-attest/CHANGELOG.md
74
+ rubygems_mfa_required: 'true'
75
+ rdoc_options: []
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '2.7'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubygems_version: 4.0.10
90
+ specification_version: 4
91
+ summary: Data attestation for the BSV Blockchain
92
+ test_files: []