serai/deploy/coins/bitcoin/Dockerfile

52 lines
2.3 KiB
Text
Raw Normal View History

# Configure Environment
FROM alpine:latest as builder
ENV BITCOIN_VERSION=23.0
ENV GLIBC_VERSION=2.28-r0
ENV BITCOIN_DATA=/home/bitcoin/.bitcoin
WORKDIR /home/bitcoin
RUN apk update \
Bitcoin processor (#232) * serai Dockerfile & Makefile fixed * added new bitcoin mod & bitcoinhram * couple changes * added odd&even check for bitcoin signing * sign message updated * print_keys commented out * fixed signing process * Added new bitcoin library & added most of bitcoin processor logic * added new crate and refactored the bitcoin coin library * added signing test function * moved signature.rs * publish set to false * tests moved back to the root * added new functions to rpc * added utxo test * added new rpc methods and refactored bitcoin processor * added spendable output & fixed errors & added new logic for sighash & opened port 18443 for bitcoin docker * changed tweak keys * added tweak_keys & publish transaction and refactored bitcoin processor * added new structs and fixed problems for testing purposes * reverted dockerfile back its original * reverted block generation of bitcoin to 5 seconds * deleted unnecessary test function * added new sighash & added new dbg messages & fixed couple errors * fixed couple issue & removed unused functions * fix for signing process * crypto file for bitcoin refactored * disabled test_send & removed some of the debug logs * signing implemented & transaction weight calculation added & change address logic added * refactored tweak_keys * refactored mine_block & fixed change_address logic * implemented new traits to bitcoin processor& refactored bitcoin processor * added new line to tests file * added new line to bitcoin's wallet.rs * deleted Cargo.toml from coins folder * edited bitcoin's Cargo.toml and added LICENSE * added new line to bitcoin's Cargo.toml * added spaces * added spaces * deleted unnecessary object * added spaces * deleted patch numbers * updated sha256 parameter for message * updated tag as const * deleted unnecessary brackets and imports * updated rpc.rs to 2 space indent * deleted unnecessary brackers * deleted unnecessary brackets * changed it to explicit * updated to explicit * deleted unnecessary parsing * added ? for easy return * updated imports * updated height to number * deleted unnecessary brackets * updated clsag to sig & to_vec to as_ref * updated _sig to schnorr_signature * deleted unnecessary variable * updated Cargo.toml of processor and bitcoin * updated imports of bitcoin processor * updated MBlock to BBlock * updated MSignable to BSignable * updated imports * deleted mask from Fee * updated get_block function return * updated comparison logic for scripts * updated assert to debug_assert * updated height to number * updated txid logic * updated tweak_keys definition * updated imports * deleted new line * delete HashMap from monero * deleted old test code parts * updated test amount to a round number * changed the test code part back to its original * updated imports of rpc.rs * deleted unnecessary return assignments * deleted get_fee_per_byte * deleted create_raw_transaction * deleted fund_raw_transaction * deleted sign transaction rpc * delete verify_message rpc * deleted get_balance * deleted decode_raw_transaction rpc * deleted list_transactions rpc * changed test_send to p2wpkh * updated imports of test_send * fixed imports of test_send * updated bitcoin's mine_block function * updated bitcoin's test_send * updated bitcoin's hram and test_signing * deleted 2 rpc function (is_confirmed & get_transaction_block_number) * deleted get_raw_transaction_hex * deleted get_raw_transaction_info * deleted new_address * deleted test_mempool_accept * updated remove(0) to remove(index) * deleted ger_raw_transaction * deleted RawTx trait and converted type to Transaction * reverted raw_hex feature back * added NotEnoughFunds to CoinError * changed Sighash to all * removed lifetime of RpcParams * changed pub to pub(crate) & changed sig_hash line * changed taproot_key_spend_signature_hash to internal * added Clone to RpcError & deleted get_utxo_for * changed to_hex to as_bytes for weight calculation * updated SpendableOutput * deleted unnecessary parentheses * updated serialize of Output s id field * deleted unused crate & added lazy_static * updated RPC init function * added lazy_static for TAG_HASH & updated imported crates * changed get_block_index to get_block_number * deleted get_block_info * updated get_height to get_latest_block_number * removed GetBlockWithDetailResult and get_block_with_transactions * deleted unnecessary imports from rpc_helper * removed lock and unlock_unspent * deleted get_transactions and get_transaction and renamed get_raw_transaction to get_transaction * updated opt_into_json * changed payment_address and amount to output_script and amount for transcript * refactored error logic for rpc & deleted anyhow crate * added a dedicated file for json helper functions * refactored imports and deleted unused code * added clippy::non_snake_case * removed unused Error items * added new line to Cargo * rekmoved Block and used bitcoin::Block direcetly * removed added println and futures.len check * removed HashMap from coin mod.rs * updated Testnet to Regtest * removed unnecessary variable * updated as_str to & * removed RawTx trait * added newline * changed test transaction to p2pkh * updated test_send * updated test_send * updated test_send * reformatted bitcoin processor * moved sighash logic into signmachine * removed generate_to_address * added test_address function to bitcoin processor * updated RpcResponse to enum and added Clone trait * removed old RpcResponse * updated shared_key to internal_key * updated fee part * updated test_send block logic * added a test function for getting spendables * updated tweaking keys logic * updated calculate_weight logic * added todo for BitcoinSchnorr Algorithm * updated calculate_weight * updated calculate_weight * updated calculate_weight * added a TODO for bitcoin's signing process * removed unused code * Finish merging develop * cargo fmt * cargo machete * Handle most clippy lints on bitcoin Doesn't handle the unused transcript due to pending cryptographic considerations. * Rearrange imports and clippy tests * Misc processor lint * Update deny.toml * Remove unnecessary RPC code * updated test_send * added bitcoin ci & updated test-dependencies yml * fixed bitcoin ci * updated bitcoin ci yml * Remove mining from the bitcoin/monero docker files The tests should control block production in order to test various circumstances. The automatic mining disrupts assumptions made in testing. Since we're now using the Bitcoin docker container for testing... * Multiple fixes to the Bitcoin processor Doesn't unwrap on RPC errors. Returns the expected connection error. Fee calculation has a random - 1. This has been removed. Supports the change address being an Option, as it is. This should not have been blindly unwrapped. * Remove unnecessary RPC code * Further RPC simplifications * Simplify Bitcoin action It should not be mining. * cargo fmt * Finish RPC simplifications * Run bitcoind as a daemon * Remove the requirement on txindex Saves tens of GB. Also has attempt_send no longer return a list of outputs. That's incompatible with this and only relevant to old scheduling designs. * Remove number from Bitcoin SignableTransaction Monero requires the current block number for decoy selection. Bitcoin doesn't have a use. * Ban coinbase transactions These are burdened by maturity, so it's critically flawed to support them. This causes the test_send function to fail as its working was premised on a coinbase output. While it does make an actual output, it had insufficient funds for the test's expectations due to regtest halving every 150 blocks. In order to workaround this, the test will invalidate any existing chain, offering a fresh start. Also removes test_get_spendables and simplifies test_send. * Various simplifications Modifies SpendableOutput further to not require RPC calls at time of sign. Removes the need to have get_transaction in the RPC. * Clean prepare_send * Update the Bitcoin TransactionMachine to output a Transaction * Bitcoin TransactionMachine simplifications * Update XOnly key handling * Use a single sighash cache * Move tweak_keys * Remove unnecessary PSBT sets * Restore removed newlines * Other newlines * Replace calculate_weight's custom math with a dummy TX serialize * Move BTC TX construction code from processor to bitcoin * Rename transactions.rs to wallet.rs * Remove unused crate * Note TODO * Clean bitcoin signature test * Make unit test out of BTC FROST signing test * Final lint * Remove usage of PartiallySignedTransaction --------- Co-authored-by: Luke Parker <lukeparker5132@gmail.com>
2023-01-31 12:48:14 +00:00
&& apk --no-cache add ca-certificates gnupg bash su-exec
# Get Binary
# TODO: When bitcoin.org publishes 23.0, retrieve checksums from there.
RUN wget https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/bitcoin-${BITCOIN_VERSION}-x86_64-linux-gnu.tar.gz \
2022-12-09 03:10:12 +00:00
&& wget https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/SHA256SUMS \
&& wget https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/SHA256SUMS.asc
# Verify Binary
2022-12-09 03:10:12 +00:00
# For the PGP keys of builders and developers, refer to
# https://github.com/bitcoin/bitcoin/tree/master/contrib/builder-keys
# Serai recognizes the builder keys for 16/17 signatures
# from the 23.0 release
ENV KEYS 152812300785C96444D3334D17565732E08E5E41 0AD83877C1F0CD1EE9BD660AD7CC770B81FD22A8 590B7292695AFFA5B672CBB2E13FC145CD3F4304 948444FCE03B05BA5AB0591EC37B1C1D44C786EE 9EDAFF80E080659604F4A76B2EBB056FD847F8A7 E777299FC265DD04793070EB944D35F9AC3DB76A F4FC70F07310028424EFC20A8E4256593F177720 D1DBF2C4B96F2DEBF4C16654410108112E7EA81F
ENV KEYS2 4DAF18FE948E7A965B30F9457E296D555E7F63A7 28E72909F1717FE9607754F8A7BEB2621678D37D 74E2DEF5D77260B98BC19438099BAD163C70FBFA 71A3B16735405025D447E8F274810B012346C9A6 9D3CC86A72F8494342EA5FD10A41BDC3F4FAFF1C 287AE4CA1187C68C08B49CB2D11BD4F33F1DB499 F9A8737BF4FF5C89C903DF31DD78544CF91B1514
# Use hardcoded prints to get keys from servers. 2 Different servers used.
RUN gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys ${KEYS} \
2022-12-09 03:10:12 +00:00
&& gpg --keyserver hkp://keys.openpgp.org:80 --recv-keys ${KEYS2}
# verify all sigs and check for valid signature from laanwj -- 71A3
2022-12-09 03:10:12 +00:00
RUN gpg --verify --status-fd 1 --verify SHA256SUMS.asc SHA256SUMS | grep "^\[GNUPG:\] VALIDSIG.*71A3B16735405025D447E8F274810B012346C9A6"
RUN grep bitcoin-${BITCOIN_VERSION}-x86_64-linux-gnu.tar.gz SHA256SUMS | sha256sum -c
# Prepare Image
RUN tar xzvf bitcoin-${BITCOIN_VERSION}-x86_64-linux-gnu.tar.gz
# Prepare Image
FROM ubuntu:latest as image
WORKDIR /home/bitcoin
COPY --from=builder /home/bitcoin/* .
RUN mv bin/* /bin \
&& mv lib/* /lib \
&& mv share/* /share
COPY ./scripts /scripts
EXPOSE 8332 8333 18332 18333 18443 18444
VOLUME ["/home/bitcoin/.bitcoin"]