Create simple contract for AccountB.
Explanation:
eosio.token::transfer
uses require_recipient(to)
which sends notification to the account/contract.
What it effectively means is that your contract will execute action with eosio::on_notify("eosio.token::transfer")
hook as inline action.
ALL Inline actions need to succeed in order to transaction be valid. So if you fail incoming transfer in your hook - the whole transfer will not succeed.
Here is a example of blocking eosio.token::transfer
from any sources
#pragma once
#include <eosio/eosio.hpp>
#include <eosio/asset.hpp>
using std::string;
CONTRACT DenyTransfer : public eosio::contract
{
public:
using contract::contract;
[[eosio::on_notify("eosio.token::transfer")]]
void on_transfer(eosio::name from, eosio::name to, eosio::asset quantity, string memo) {
eosio::check(false);
}
};