Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature UTXO handler #57

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

Yamaguchi
Copy link
Contributor

@Yamaguchi Yamaguchi commented Jul 5, 2020

This PR adds UTXO handler to save UTXOs and delete UTXOs from the database.

As described in README.md, SPV node start to collect UTXOs associated with wallet when utxo handler is initialized.

Note that

  • We can handle merkleblock message in order to save the position of tx in the block but this PR does not contain it.
    Block height of UTXO is useful when we need to know UTXO is confirmed deeply (e.g. 6 confirmation) or not.
  • SPV node should update the bloomfilter and send filteradd message when adding the keypair in the wallet using Bitcoin::Wallet::Base#generate_new_address or other API.

README.md Outdated Show resolved Hide resolved
def header(data)
end

def merkleblock(data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There doesn't seem to be any implementation, is this one left empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I add implementation for merkleblock and header message.
When merkleblock is called, spv nodes will store the tx position data into the leveldb.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the correctness of the merkleblock needs to be checked by restoring the markle tree.

lib/bitcoin/wallet/utxo_handler.rb Show resolved Hide resolved
@Yamaguchi Yamaguchi requested a review from azuchi July 24, 2020 18:22
spec/bitcoin/wallet/utxo_handler_spec.rb Outdated Show resolved Hide resolved
spec/bitcoin/wallet/utxo_handler_spec.rb Outdated Show resolved Hide resolved
spec/bitcoin/wallet/utxo_handler_spec.rb Outdated Show resolved Hide resolved
spec/bitcoin/wallet/utxo_handler_spec.rb Outdated Show resolved Hide resolved
def header(data)
end

def merkleblock(data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the correctness of the merkleblock needs to be checked by restoring the markle tree.

# - Delete from utxo_db for spent output.
def tx(data)
tx = data.tx
tx.outputs.each_with_index do |output, index|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you need to check if it is a Tx that exists in the merkleblock that you received earlier?

Yamaguchi and others added 3 commits September 12, 2020 19:03
Co-authored-by: shigeyuki azuchi <azuchi@chaintope.com>
Co-authored-by: shigeyuki azuchi <azuchi@chaintope.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants