コード例 #1
0
ファイル: buyspage.cpp プロジェクト: ch1c4um/fantom
void BuysPage::on_escrowLockButton_clicked()
{
// get the vendor created escrow lock tx, sign it and broadcast it
// ask the user if they really want to pay
QMessageBox::StandardButton reply;
reply = QMessageBox::question(this, "Lock Escrow?", "Do you want to lock escrow for this item? This will send money to the escrow address.",
QMessageBox::Yes|QMessageBox::No);
if (reply == QMessageBox::No)
{
return;
}
QItemSelectionModel* selectionModel = ui->tableWidget->selectionModel();
QModelIndexList selected = selectionModel->selectedRows();
if(selected.count() == 0)
return;
QModelIndex index = selected.at(0);
int r = index.row();
std::string buyRequestIdHash = ui->tableWidget->item(r, 5)->text().toStdString();
uint256 buyRequestId = uint256(buyRequestIdHash);
CBuyRequest buyRequest = mapBuyRequests[buyRequestId];
bool accepted = false;
// deserialize the seller's escrow tx
BOOST_FOREACH(PAIRTYPE(const uint256, CBuyAccept)& p, mapBuyAccepts)
{
if(p.second.listingId == buyRequest.listingId && p.second.buyRequestId == buyRequestId)
{
// found seller's buy accept
CWalletTx wtxSeller;
CDataStream ssTx(p.second.raw.data(), p.second.raw.data() + p.second.raw.size(), SER_NETWORK, CLIENT_VERSION);
ssTx >> wtxSeller;
accepted = wtxSeller.AcceptToMemoryPool();
break;
}
}
コード例 #2
0
ファイル: rpcmarket.cpp プロジェクト: CryptoDJ/sling
Value marketescrowlock(const Array& params, bool fHelp)
{
    if (fHelp || params.size() == 0)
        throw runtime_error("marketescrowlock \n"
                            "Locks esrow for a buy request \n"\
                            "parameters: <requestId>");

    string requestID = params[0].get_str();
    uint256 requestHashId = uint256(requestID);
    CBuyRequest buyRequest = mapBuyRequests[requestHashId];

    bool accepted = false;
    bool res;

    // deserialize the seller's escrow tx
    BOOST_FOREACH(PAIRTYPE(const uint256, CBuyAccept)& p, mapBuyAccepts)
    {
        if(p.second.listingId == buyRequest.listingId && p.second.buyRequestId == requestHashId)
            {
                // found seller's buy accept
                CWalletTx wtxSeller;
                CDataStream ssTx(p.second.raw.data(), p.second.raw.data() + p.second.raw.size(), SER_NETWORK, CLIENT_VERSION);
                ssTx >> wtxSeller;
                accepted = wtxSeller.AcceptToMemoryPool();
                break;
            }
    }