How to get bitcoin working inside a canister

seeing example and demo, I saw that user deposit btc from a btc wallet to the canister.
is this the only way to do that?
Q1: Can this be done like, " user calls a function of a canister and that function handles the deposit of the btc on the behalf of user?"


pub struct SendTransactionRequest {
    pub transaction: Vec<u8>,
    pub network: Network,

here what data is passed in the transaction field?
address of the receiver? amount to be send to the receiver?
combination of amount + receiver address ?


As far as I know the only way to get bitcoins on a canister is by making a user send bitcoins from his wallet to the Bitcoin canister address.


As described in the Internet Computer Interface Specification, bitcoin_send_transaction requires to:

specify a blob of a Bitcoin [signed] transaction

You can find out the format of a Bitcoin transaction here.
So in addition to other fields as described above, the address of the receiver and the amount to be send to the receiver are part of the Bitcoin transaction.
These two draft PRs adding more detailed examples in Rust and Motoko may give you a precise idea on how to broadcast to the Bitcoin network a Bitcoin transaction.

Don’t hesitate to let us know if you have some questions following these readings.